camel_case_types support for macros

Fixes: https://github.com/dart-lang/linter/issues/4882

Change-Id: I2a70fb7ccd2d55dfcc0045969a861a1b8e158033
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/352992
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
This commit is contained in:
pq 2024-02-16 19:55:37 +00:00 committed by Commit Queue
parent fe67789e43
commit 7b63c20fba
2 changed files with 25 additions and 0 deletions

View file

@ -77,6 +77,9 @@ class _Visitor extends SimpleAstVisitor<void> {
@override
void visitClassDeclaration(ClassDeclaration node) {
// Don't lint augmentation classes.
if (node.augmentKeyword != null) return;
check(node.name);
}

View file

@ -17,6 +17,20 @@ class CamelCaseTypesTest extends LintRuleTest {
@override
String get lintRule => 'camel_case_types';
test_augmentationClass_lowerCase() async {
newFile('$testPackageLibPath/a.dart', r'''
import augment 'test.dart';
class a { }
''');
await assertNoDiagnostics(r'''
library augment 'a.dart';
augment class a { }
''');
}
test_extensionType_lowerCase() async {
// No need to test all the variations. Name checking is shared with other
// declaration types.
@ -32,4 +46,12 @@ extension type fooBar(int i) {}
extension type FooBar(int i) {}
''');
}
test_macroClass_lowerCase() async {
await assertDiagnostics(r'''
macro class a { }
''', [
lint(12, 1),
]);
}
}