Skip to content

Commit 70e46c0

Browse files
authored
Require Dart 3, update lints (#669)
1 parent 89e30e5 commit 70e46c0

File tree

10 files changed

+43
-73
lines changed

10 files changed

+43
-73
lines changed

.github/workflows/dart.yml

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Created with package:mono_repo v6.5.4
1+
# Created with package:mono_repo v6.5.7
22
name: Dart CI
33
on:
44
push:
@@ -36,27 +36,27 @@ jobs:
3636
name: Checkout repository
3737
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab
3838
- name: mono_repo self validate
39-
run: dart pub global activate mono_repo 6.5.4
39+
run: dart pub global activate mono_repo 6.5.7
4040
- name: mono_repo self validate
4141
run: dart pub global run mono_repo generate --validate
4242
job_002:
43-
name: "analyze_format; linux; Dart 2.18.0; PKG: source_gen; `dart analyze`"
43+
name: "analyze_format; linux; Dart 3.0.0; PKG: source_gen; `dart analyze`"
4444
runs-on: ubuntu-latest
4545
steps:
4646
- name: Cache Pub hosted dependencies
4747
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8
4848
with:
4949
path: "~/.pub-cache/hosted"
50-
key: "os:ubuntu-latest;pub-cache-hosted;sdk:2.18.0;packages:source_gen;commands:analyze_1"
50+
key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0;packages:source_gen;commands:analyze_1"
5151
restore-keys: |
52-
os:ubuntu-latest;pub-cache-hosted;sdk:2.18.0;packages:source_gen
53-
os:ubuntu-latest;pub-cache-hosted;sdk:2.18.0
52+
os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0;packages:source_gen
53+
os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0
5454
os:ubuntu-latest;pub-cache-hosted
5555
os:ubuntu-latest
5656
- name: Setup Dart SDK
5757
uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f
5858
with:
59-
sdk: "2.18.0"
59+
sdk: "3.0.0"
6060
- id: checkout
6161
name: Checkout repository
6262
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab
@@ -143,23 +143,23 @@ jobs:
143143
if: "always() && steps.source_gen_pub_upgrade.conclusion == 'success'"
144144
working-directory: source_gen
145145
job_004:
146-
name: "unit_test; linux; Dart 2.18.0; PKG: example_usage; `dart test --run-skipped`"
146+
name: "unit_test; linux; Dart 3.0.0; PKG: example_usage; `dart test --run-skipped`"
147147
runs-on: ubuntu-latest
148148
steps:
149149
- name: Cache Pub hosted dependencies
150150
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8
151151
with:
152152
path: "~/.pub-cache/hosted"
153-
key: "os:ubuntu-latest;pub-cache-hosted;sdk:2.18.0;packages:example_usage;commands:test_0"
153+
key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0;packages:example_usage;commands:test_0"
154154
restore-keys: |
155-
os:ubuntu-latest;pub-cache-hosted;sdk:2.18.0;packages:example_usage
156-
os:ubuntu-latest;pub-cache-hosted;sdk:2.18.0
155+
os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0;packages:example_usage
156+
os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0
157157
os:ubuntu-latest;pub-cache-hosted
158158
os:ubuntu-latest
159159
- name: Setup Dart SDK
160160
uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f
161161
with:
162-
sdk: "2.18.0"
162+
sdk: "3.0.0"
163163
- id: checkout
164164
name: Checkout repository
165165
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab
@@ -177,23 +177,23 @@ jobs:
177177
- job_002
178178
- job_003
179179
job_005:
180-
name: "unit_test; linux; Dart 2.18.0; PKG: source_gen; `dart test`"
180+
name: "unit_test; linux; Dart 3.0.0; PKG: source_gen; `dart test`"
181181
runs-on: ubuntu-latest
182182
steps:
183183
- name: Cache Pub hosted dependencies
184184
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8
185185
with:
186186
path: "~/.pub-cache/hosted"
187-
key: "os:ubuntu-latest;pub-cache-hosted;sdk:2.18.0;packages:source_gen;commands:test_1"
187+
key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0;packages:source_gen;commands:test_1"
188188
restore-keys: |
189-
os:ubuntu-latest;pub-cache-hosted;sdk:2.18.0;packages:source_gen
190-
os:ubuntu-latest;pub-cache-hosted;sdk:2.18.0
189+
os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0;packages:source_gen
190+
os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0
191191
os:ubuntu-latest;pub-cache-hosted
192192
os:ubuntu-latest
193193
- name: Setup Dart SDK
194194
uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f
195195
with:
196-
sdk: "2.18.0"
196+
sdk: "3.0.0"
197197
- id: checkout
198198
name: Checkout repository
199199
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab
@@ -279,13 +279,13 @@ jobs:
279279
- job_002
280280
- job_003
281281
job_008:
282-
name: "unit_test; windows; Dart 2.18.0; PKG: source_gen; `dart test`"
282+
name: "unit_test; windows; Dart 3.0.0; PKG: source_gen; `dart test`"
283283
runs-on: windows-latest
284284
steps:
285285
- name: Setup Dart SDK
286286
uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f
287287
with:
288-
sdk: "2.18.0"
288+
sdk: "3.0.0"
289289
- id: checkout
290290
name: Checkout repository
291291
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab

_test_annotations/pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: _test_annotations
22
publish_to: none
33

44
environment:
5-
sdk: '>=2.17.0 <3.0.0'
5+
sdk: ^3.0.0
66

77
dev_dependencies:
8-
lints: ^2.0.0
8+
dart_flutter_team_lints: ^1.0.0

analysis_options.yaml

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
include: package:lints/recommended.yaml
1+
include: package:dart_flutter_team_lints/analysis_options.yaml
22

33
analyzer:
44
language:
@@ -8,11 +8,8 @@ analyzer:
88

99
linter:
1010
rules:
11-
- always_declare_return_types
1211
- avoid_bool_literals_in_conditional_expressions
13-
- avoid_catching_errors
1412
- avoid_classes_with_only_static_members
15-
- avoid_dynamic_calls
1613
- avoid_private_typedef_functions
1714
- avoid_redundant_argument_values
1815
- avoid_returning_null
@@ -22,44 +19,22 @@ linter:
2219
- avoid_void_async
2320
- cancel_subscriptions
2421
- cascade_invocations
25-
- collection_methods_unrelated_type
26-
- combinators_ordering
2722
- comment_references
28-
- dangling_library_doc_comments
29-
- directives_ordering
30-
- implicit_call_tearoffs
3123
- join_return_with_assignment
32-
- library_annotations
33-
- lines_longer_than_80_chars
3424
- literal_only_boolean_expressions
3525
- missing_whitespace_between_adjacent_strings
3626
- no_runtimeType_toString
37-
- omit_local_variable_types
38-
- only_throw_errors
3927
- package_api_docs
40-
- prefer_asserts_in_initializer_lists
4128
- prefer_const_constructors
4229
- prefer_const_declarations
4330
- prefer_expression_function_bodies
4431
- prefer_final_locals
4532
- prefer_relative_imports
46-
- prefer_single_quotes
4733
- require_trailing_commas
4834
- sort_child_properties_last
49-
- sort_pub_dependencies
5035
- test_types_in_equals
51-
- throw_in_finally
52-
- type_annotate_public_apis
53-
- unawaited_futures
5436
- unnecessary_await_in_return
55-
- unnecessary_lambdas
56-
- unnecessary_library_directive
57-
- unnecessary_parenthesis
58-
- unnecessary_statements
59-
- unreachable_from_main
6037
- unsafe_html
6138
- use_full_hex_values_for_flutter_colors
62-
- use_is_even_rather_than_modulo
6339
- use_string_buffers
64-
- use_string_in_part_of_directives
6540
- use_super_parameters

example/pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ name: source_gen_example
22
publish_to: none
33

44
environment:
5-
sdk: ">=2.17.0 <3.0.0"
5+
sdk: ^3.0.0
66

77
dependencies:
88
analyzer: '>=4.6.0 <6.0.0'
99
build: ^2.0.0
1010
source_gen: any
1111

1212
dev_dependencies:
13-
lints: ^2.0.0
13+
dart_flutter_team_lints: ^1.0.0
1414

1515
dependency_overrides:
1616
source_gen:

example_usage/pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: source_gen_example_usage
22
publish_to: none
33

44
environment:
5-
sdk: '>=2.18.0 <3.0.0'
5+
sdk: ^3.0.0
66

77
dependencies:
88
source_gen_example:
@@ -11,7 +11,7 @@ dependencies:
1111
dev_dependencies:
1212
build_runner: ^2.0.0
1313
build_verify: ^3.0.0
14-
lints: ^2.0.0
14+
dart_flutter_team_lints: ^1.0.0
1515
test: ^1.5.1
1616

1717
dependency_overrides:

source_gen/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 1.3.3-wip
2+
3+
- Require Dart 3.0
4+
15
## 1.3.2
26

37
* Make `TypeChecker.isAssignableFromType()` null safe.

source_gen/lib/src/library.dart

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,7 @@ class LibraryReader {
9898
/// * `asset`
9999
///
100100
/// May throw [ArgumentError] if it is not possible to resolve a path.
101-
Uri pathToUrl(dynamic toUrlOrString) {
102-
if (toUrlOrString == null) {
103-
throw ArgumentError.notNull('toUrlOrString');
104-
}
101+
Uri pathToUrl(Object toUrlOrString) {
105102
final to = toUrlOrString is Uri
106103
? toUrlOrString
107104
: Uri.parse(toUrlOrString as String);

source_gen/lib/src/utils.dart

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -64,18 +64,12 @@ String urlOfElement(Element element) => element.kind == ElementKind.DYNAMIC
6464
.replace(fragment: element.name)
6565
.toString();
6666

67-
Uri normalizeUrl(Uri url) {
68-
switch (url.scheme) {
69-
case 'dart':
70-
return normalizeDartUrl(url);
71-
case 'package':
72-
return packageToAssetUrl(url);
73-
case 'file':
74-
return fileToAssetUrl(url);
75-
default:
76-
return url;
77-
}
78-
}
67+
Uri normalizeUrl(Uri url) => switch (url.scheme) {
68+
'dart' => normalizeDartUrl(url),
69+
'package' => _packageToAssetUrl(url),
70+
'file' => _fileToAssetUrl(url),
71+
_ => url
72+
};
7973

8074
/// Make `dart:`-type URLs look like a user-knowable path.
8175
///
@@ -87,7 +81,7 @@ Uri normalizeDartUrl(Uri url) => url.pathSegments.isNotEmpty
8781
? url.replace(pathSegments: url.pathSegments.take(1))
8882
: url;
8983

90-
Uri fileToAssetUrl(Uri url) {
84+
Uri _fileToAssetUrl(Uri url) {
9185
if (!p.isWithin(p.url.current, url.path)) return url;
9286
return Uri(
9387
scheme: 'asset',
@@ -103,7 +97,7 @@ Uri fileToAssetUrl(Uri url) {
10397
///
10498
/// For example, this transforms `package:source_gen/source_gen.dart` into:
10599
/// `asset:source_gen/lib/source_gen.dart`.
106-
Uri packageToAssetUrl(Uri url) => url.scheme == 'package'
100+
Uri _packageToAssetUrl(Uri url) => url.scheme == 'package'
107101
? url.replace(
108102
scheme: 'asset',
109103
pathSegments: <String>[

source_gen/pubspec.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
name: source_gen
2-
version: 1.3.2
2+
version: 1.3.3-wip
33
description: >-
44
Source code generation builders and utilities for the Dart build system
55
repository: https://github.com/dart-lang/source_gen/tree/master/source_gen
66

77
environment:
8-
sdk: '>=2.18.0 <3.0.0'
8+
sdk: ^3.0.0
99

1010
dependencies:
1111
analyzer: ^5.2.0
@@ -21,6 +21,6 @@ dev_dependencies:
2121
_test_annotations:
2222
path: ../_test_annotations
2323
build_test: ^2.0.0
24-
lints: ^2.0.0
24+
dart_flutter_team_lints: ^1.0.0
2525
term_glyph: ^1.2.0
2626
test: ^1.16.0

tool/ci.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
2-
# Created with package:mono_repo v6.5.4
2+
# Created with package:mono_repo v6.5.7
33

44
# Support built in commands on windows out of the box.
55
# When it is a flutter repo (check the pubspec.yaml for "sdk: flutter")

0 commit comments

Comments
 (0)