Skip to content

Commit

Permalink
fix file_names diagnostic offset (dart-lang/linter#3020)
Browse files Browse the repository at this point in the history
* fix file_names diagnostic offset

* test fix
  • Loading branch information
pq authored Oct 11, 2021
1 parent 103b9f5 commit c3e386c
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 56 deletions.
2 changes: 1 addition & 1 deletion lib/src/rules/file_names.dart
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class _Visitor extends SimpleAstVisitor<void> {
if (declaredElement != null) {
var fileName = declaredElement.source.shortName;
if (!isValidDartFileName(fileName)) {
rule.reportLint(node);
rule.reportLintForOffset(0, 0);
}
}
}
Expand Down
47 changes: 0 additions & 47 deletions test/integration/file_names.dart

This file was deleted.

2 changes: 0 additions & 2 deletions test/integration_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import 'integration/depend_on_referenced_packages.dart'
as depend_on_referenced_packages;
import 'integration/directives_ordering.dart' as directives_ordering;
import 'integration/exhaustive_cases.dart' as exhaustive_cases;
import 'integration/file_names.dart' as file_names;
import 'integration/flutter_style_todos.dart' as flutter_style_todos;
import 'integration/lines_longer_than_80_chars.dart'
as lines_longer_than_80_chars;
Expand Down Expand Up @@ -190,7 +189,6 @@ void ruleTests() {
cancel_subscriptions.main();
depend_on_referenced_packages.main();
directives_ordering.main();
file_names.main();
flutter_style_todos.main();
lines_longer_than_80_chars.main();
only_throw_errors.main();
Expand Down
2 changes: 2 additions & 0 deletions test/rules/all.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'avoid_function_literals_in_foreach_calls.dart'
import 'avoid_init_to_null.dart' as avoid_init_to_null;
import 'avoid_shadowing_type_parameters.dart'
as avoid_shadowing_type_parameters;
import 'file_names.dart' as file_names;
import 'missing_whitespace_between_adjacent_strings.dart'
as missing_whitespace_between_adjacent_strings;
import 'non_constant_identifier_names.dart' as non_constant_identifier_names;
Expand Down Expand Up @@ -35,6 +36,7 @@ void main() {
avoid_function_literals_in_foreach_calls.main();
avoid_init_to_null.main();
avoid_shadowing_type_parameters.main();
file_names.main();
missing_whitespace_between_adjacent_strings.main();
non_constant_identifier_names.main();
null_closures.main();
Expand Down
46 changes: 46 additions & 0 deletions test/rules/file_names.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// Copyright (c) 2021, 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:test_reflective_loader/test_reflective_loader.dart';

import '../rule_test_support.dart';

main() {
defineReflectiveSuite(() {
defineReflectiveTests(FileNamesInvalidTest);
defineReflectiveTests(FileNamesNonStrictTest);
});
}

@reflectiveTest
class FileNamesInvalidTest extends LintRuleTest {
@override
String get lintRule => 'file_names';

@override
String get testFilePath => '$testPackageLibPath/a-test.dart';

test_invalidName() async {
await assertDiagnostics(r'''
class A { }
''', [
lint('file_names', 0, 0),
]);
}
}

@reflectiveTest
class FileNamesNonStrictTest extends LintRuleTest {
@override
String get lintRule => 'file_names';

@override
String get testFilePath => '$testPackageLibPath/non-strict.css.dart';

test_validName() async {
await assertNoDiagnostics(r'''
class A { }
''');
}
}
3 changes: 0 additions & 3 deletions test_data/integration/file_names/a-b.dart

This file was deleted.

3 changes: 0 additions & 3 deletions test_data/integration/file_names/non-strict.css.dart

This file was deleted.

0 comments on commit c3e386c

Please sign in to comment.