File tree 2 files changed +44
-0
lines changed 2 files changed +44
-0
lines changed Original file line number Diff line number Diff line change @@ -63,6 +63,7 @@ class ConstantIdentifierNames extends LintRule {
63
63
void registerNodeProcessors (
64
64
NodeLintRegistry registry, LinterContext context) {
65
65
var visitor = _Visitor (this );
66
+ registry.addDeclaredVariablePattern (this , visitor);
66
67
registry.addEnumConstantDeclaration (this , visitor);
67
68
registry.addTopLevelVariableDeclaration (this , visitor);
68
69
registry.addVariableDeclarationList (this , visitor);
@@ -81,6 +82,11 @@ class _Visitor extends SimpleAstVisitor<void> {
81
82
}
82
83
}
83
84
85
+ @override
86
+ void visitDeclaredVariablePattern (DeclaredVariablePattern node) {
87
+ checkIdentifier (node.name);
88
+ }
89
+
84
90
@override
85
91
void visitEnumConstantDeclaration (EnumConstantDeclaration node) {
86
92
checkIdentifier (node.name);
Original file line number Diff line number Diff line change @@ -9,9 +9,47 @@ import '../rule_test_support.dart';
9
9
main () {
10
10
defineReflectiveSuite (() {
11
11
defineReflectiveTests (ConstantIdentifierNamesRecordsTest );
12
+ defineReflectiveTests (ConstantIdentifierNamesPatternsTest );
12
13
});
13
14
}
14
15
16
+ @reflectiveTest
17
+ class ConstantIdentifierNamesPatternsTest extends LintRuleTest {
18
+ @override
19
+ List <String > get experiments => ['patterns' , 'records' ];
20
+
21
+ @override
22
+ String get lintRule => 'constant_identifier_names' ;
23
+
24
+ test_destructuredConstField () async {
25
+ await assertDiagnostics (r'''
26
+ class A {
27
+ static const AA = (1, );
28
+ }
29
+ ''' , [
30
+ lint (25 , 2 ),
31
+ ]);
32
+ }
33
+
34
+ test_destructuredConstVariable () async {
35
+ await assertDiagnostics (r'''
36
+ const AA = (1, );
37
+ ''' , [
38
+ lint (6 , 2 ),
39
+ ]);
40
+ }
41
+
42
+ test_destructuredFinalVariable () async {
43
+ await assertDiagnostics (r'''
44
+ void f() {
45
+ final (AA, ) = (1, );
46
+ }
47
+ ''' , [
48
+ lint (20 , 2 ),
49
+ ]);
50
+ }
51
+ }
52
+
15
53
@reflectiveTest
16
54
class ConstantIdentifierNamesRecordsTest extends LintRuleTest {
17
55
@override
You can’t perform that action at this time.
0 commit comments