Skip to content

Commit 217b345

Browse files
authored
move shared analysis to subdir, enable dart_flutter_team_lints (#3497)
* Adds a new `analysis` package, with the shared analysis_options.yaml file * Add an analysis_options.yaml file that imports that one to each package * Use the dart_flutter_team_lints package for lints * Fix up all the new lint violations
1 parent bde5fb9 commit 217b345

File tree

101 files changed

+463
-418
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+463
-418
lines changed

.github/workflows/dart.yml

Lines changed: 116 additions & 116 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

_test/analysis_options.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include: ../analysis/analysis_options.yaml

_test/pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ dev_dependencies:
99
build: any
1010
build_config: any
1111
build_modules: any
12-
build_web_compilers: any
1312
build_runner: any
1413
build_runner_core: any
1514
build_test: any
16-
lints: '>=1.0.0 <3.0.0'
15+
build_web_compilers: any
16+
dart_flutter_team_lints: ^1.0.0
1717
io: ^1.0.0
1818
path: ^1.8.0
1919
provides_builder:

_test/test/build_integration_test.dart

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ void main() {
9191
});
9292

9393
test(
94-
'Restores previously deleted outputs if they are not deleted in subsequent builds',
95-
() async {
94+
'Restores previously deleted outputs if they are not deleted in '
95+
'subsequent builds', () async {
9696
final dartSource =
9797
File(p.join('build', 'web', 'packages', '_test', 'app.dart'));
9898
await runBuild(trailingArgs: [
@@ -112,11 +112,12 @@ void main() {
112112

113113
var nextBuild = await runBuild();
114114
expect(
115-
nextBuild.stdout.split('\n'),
115+
(nextBuild.stdout as String).split('\n'),
116116
containsAllInOrder([
117117
contains('Generating build script'),
118118
contains(
119-
'Invalidated precompiled build script due to missing asset graph.'),
119+
'Invalidated precompiled build script due to missing asset '
120+
'graph.'),
120121
contains('Precompiling build script'),
121122
contains('Building new asset graph.'),
122123
contains('Succeeded after'),

_test_common/analysis_options.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include: ../analysis/analysis_options.yaml

_test_common/lib/descriptors.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ Future<d.FileDescriptor> pubspec(
3434
..writeln(' sdk: "$sdkEnvironment"')
3535
..writeln('dependencies:');
3636

37-
// Add all deps as `any` deps, real versions are set in dependency_overrides below.
37+
// Add all deps as `any` deps, real versions are set in dependency_overrides
38+
// below.
3839
var allPackages = [
3940
...currentIsolateDependencies,
4041
...pathDependencies.keys,

_test_common/lib/matchers.dart

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,10 +196,13 @@ class _AssetGraphMatcher extends Matcher {
196196
description.addDescriptionOf(_expected);
197197

198198
@override
199-
Description describeMismatch(
200-
item, Description mismatchDescription, Map matchState, bool verbose) {
201-
matchState.forEach((k, v) =>
202-
mismatchDescription.add('$k: got ${v[0]} but expected ${v[1]}'));
199+
Description describeMismatch(dynamic item, Description mismatchDescription,
200+
Map matchState, bool verbose) {
201+
matchState.forEach((k, v) {
202+
v = v as List;
203+
mismatchDescription.add('$k: got ${v[0]} but expected ${v[1]}');
204+
});
205+
203206
return mismatchDescription;
204207
}
205208
}

_test_common/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ dependencies:
2020
watcher: ^1.0.0
2121

2222
dev_dependencies:
23-
lints: '>=1.0.0 <3.0.0'
23+
dart_flutter_team_lints: ^1.0.0
2424

2525
dependency_overrides:
2626
build:

analysis/analysis_options.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
include: package:dart_flutter_team_lints/analysis_options.yaml
2+
analyzer:
3+
language:
4+
strict-casts: true
5+
errors:
6+
unused_import: error
7+
unused_local_variable: error
8+
dead_code: error
9+
todo: ignore
10+
deprecated_member_use_from_same_package: ignore
11+
exclude:
12+
# Prevents extra work during some e2e test runs.
13+
- "dart2js_test/**"
14+
# Common top level directories containing generated files in any package.
15+
- "build/**"
16+
- ".dart_tool/**"
17+
18+
linter:
19+
rules:
20+
# TODO: Remove this once we can use unnamed libraries.
21+
library_annotations: false
22+
# TODO: https://github.com/google/json_serializable.dart/issues/1313
23+
use_string_in_part_of_directives: false

pubspec.yaml renamed to analysis/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ publish_to: none
55
environment:
66
sdk: ">=2.12.0 <4.0.0"
77
dev_dependencies:
8-
lints: ^2.0.0
8+
dart_flutter_team_lints: any

0 commit comments

Comments
 (0)