Files
sdk/pkg/linter/test/lint_code_test.dart
Paul Berry 33f4b692ae [messages] Use lower case diagnostic names in linter.
Changes the logic in `pkg/linter` to use
`DiagnosticCode.lowerCaseName` instead of `DiagnosticCode.name`, and
`DiagnosticCode.lowerCaseUniqueName` instead of
`DiagnosticCode.uniqueName`. This ensures that diagnostic codes are
matched in a case-insensitive fashion.

This paves the way for deprecating (and eventually removing) the
`DiagnosticCode.name` and `DiagnosticCode.uniqueName` getters.

Change-Id: I6a6a69645dc1b417c168a3d26ead9e76704ce0d2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/466131
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2025-12-09 07:53:23 -08:00

48 lines
1.3 KiB
Dart

// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:linter/src/lint_codes.dart';
import 'package:test/test.dart';
import 'rule_test_support.dart';
void main() {
group('lint code', () {
group('creation', () {
test('without published diagnostic docs', () {
expect(
_customCode.url,
equals('https://dart.dev/lints/${_customCode.lowerCaseName}'),
);
});
test('with published diagnostic docs', () {
expect(
_customCodeWithDocs.url,
equals(
'https://dart.dev/diagnostics/${_customCodeWithDocs.lowerCaseName}',
),
);
});
});
});
}
const LintCode _customCode = LinterLintCode(
name: 'hash_and_equals',
problemMessage: 'Override `==` if overriding `hashCode`.',
correctionMessage: 'Implement `==`.',
expectedTypes: [],
uniqueName: 'LintCode.hash_and_equals',
);
const LintCode _customCodeWithDocs = LinterLintCode(
name: 'hash_and_equals',
problemMessage: 'Override `==` if overriding `hashCode`.',
correctionMessage: 'Implement `==`.',
hasPublishedDocs: true,
expectedTypes: [],
uniqueName: 'LintCode.hash_and_equals',
);