Skip to content
This repository was archived by the owner on Jul 16, 2023. It is now read-only.

Commit ae0af1c

Browse files
author
Konoshenko Vlad
authored
fix: prefer-match-file-name (#437)
* [Rule change] prefer-match-file-name: ignore characters after the first dot * Formated code
1 parent fdebc9a commit ae0af1c

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

lib/src/analyzers/lint_analyzer/rules/rules_list/prefer_match_file_name/prefer_match_file_name.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ class PreferMatchFileName extends CommonRule {
3434
className.replaceAll(_onlySymbolsRegex, '').toLowerCase();
3535

3636
return classNameFormatted ==
37-
basenameWithoutExtension(path)
37+
basename(path)
38+
.split('.')
39+
.first
3840
.replaceAll(_onlySymbolsRegex, '')
3941
.toLowerCase();
4042
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
class SomeWidget extends StatelessWidget {
2+
@override
3+
Widget build(BuildContext context) {
4+
//...
5+
}
6+
}

test/analyzers/lint_analyzer/rules/rules_list/prefer_match_file_name/prefer_match_file_name_test.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const _withIssue = '$_examplePath/example_with_issue.dart';
1212
const _emptyFile = '$_examplePath/empty_file.dart';
1313
const _privateClass = '$_examplePath/private_class.dart';
1414
const _multiClass = '$_examplePath/multiple_classes_example.dart';
15+
const _codegenFile = '$_examplePath/some_widget.codegen.dart';
1516

1617
void main() {
1718
group('PreferMatchFileName', () {
@@ -75,5 +76,12 @@ void main() {
7576

7677
RuleTestHelper.verifyNoIssues(issues);
7778
});
79+
80+
test('reports no issues for codegen file', () async {
81+
final unit = await RuleTestHelper.resolveFromFile(_codegenFile);
82+
final issues = PreferMatchFileName().check(unit);
83+
84+
RuleTestHelper.verifyNoIssues(issues);
85+
});
7886
});
7987
}

0 commit comments

Comments
 (0)