├── .github
└── FUNDING.yml
├── .gitignore
├── CHANGELOG.md
├── LICENSE
├── README.md
├── dartdoc_options.yaml
├── example
└── README.md
├── lib
├── analysis_options.yaml
├── analysis_options_package.yaml
├── casual.yaml
├── package.yaml
└── strict.yaml
└── pubspec.yaml
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | github: [passsy]
2 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .packages
2 | .pub/
3 | build/
4 | pubspec.lock
5 | /.idea/
6 | .dart_tool
7 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Changelog
2 |
3 | ## 2.8.0
4 |
5 | Requires Dart `sdk: '>=3.7.0'`
6 |
7 | - Disable [`require_trailing_commas`](https://dart.dev/tools/linter-rules/require_trailing_commas.html)
8 | - Enable [`unnecessary_underscores`](https://dart.dev/tools/linter-rules/unnecessary_underscores.html)
9 | - Enable [`strict_top_level_inference`](https://dart.dev/tools/linter-rules/strict_top_level_inference.html)
10 | - Enable [`unnecessary_async`](https://dart.dev/tools/linter-rules/unnecessary_async.html)
11 | - Remove deprecated and now removed [`package_api_docs`](https://dart.dev/tools/linter-rules/package_api_docs.html) from `package.yaml`. You can enable `public_member_api_docs` as a way stricter replacement.
12 | - Remove [`unsafe_html`](https://dart.dev/tools/linter-rules/unsafe_html.html)
13 | - Remove deprecated [`avoid_null_checks_in_equality_operators`](https://dart.dev/tools/linter-rules/avoid_null_checks_in_equality_operators.html)
14 |
15 | ## 2.7.0
16 |
17 | - Enable [`use_truncating_division`](https://dart.dev/tools/linter-rules/use_truncating_division.html)
18 | - Enable [`avoid_futureor_void`](https://dart.dev/tools/linter-rules/avoid_futureor_void.html)
19 |
20 | ## 2.6.2
21 |
22 | - Disable [`document_ignores`](https://dart.dev/tools/linter-rules/document_ignores.html) due to unnecessary verbosity
23 |
24 | ## 2.6.1
25 |
26 | Requires Dart `sdk: '>=3.5.0'`
27 |
28 | - Enable [`document_ignores`](https://dart.dev/tools/linter-rules/document_ignores.html) for strict mode
29 | - Enable [`invalid_runtime_check_with_js_interop_types`](https://dart.dev/tools/linter-rules/invalid_runtime_check_with_js_interop_types.html)
30 | - Enable [`unintended_html_in_doc_comment`](https://dart.dev/tools/linter-rules/unintended_html_in_doc_comment.html)
31 |
32 | ## 2.6.0
33 |
34 | Failed release, accidentally published Dart 3.6 rules with Dart 3.5 SDK constraints.
35 | Redacted. Use 2.6.1 instead.
36 |
37 | ## 2.5.0
38 |
39 | Requires Dart `sdk: '>=3.4.0'`
40 |
41 | - Enable [`unnecessary_library_name`](https://dart-lang.github.io/linter/lints/unnecessary_library_name.html)
42 | - Enable [`missing_code_block_language_in_doc_comment`](https://dart-lang.github.io/linter/lints/missing_code_block_language_in_doc_comment.html)
43 |
44 | ## 2.4.0
45 |
46 | Requires Dart `sdk: '>=3.3.0'`
47 |
48 | - Remove [`iterable_contains_unrelated_type`](https://dart-lang.github.io/linter/lints/iterable_contains_unrelated_type.html)
49 | - Remove [`list_remove_unrelated_type`](https://dart-lang.github.io/linter/lints/list_remove_unrelated_type.html)
50 | - Remove [`always_require_non_null_named_parameters`](https://dart-lang.github.io/linter/lints/always_require_non_null_named_parameters.html)
51 | - Remove [`avoid_returning_null`](https://dart-lang.github.io/linter/lints/avoid_returning_null.html)
52 | - Remove [`avoid_returning_null_for_future`](https://dart-lang.github.io/linter/lints/avoid_returning_null_for_future.html)
53 |
54 | ## 2.3.0
55 |
56 | Requires Dart `sdk: '>=3.2.0'`
57 |
58 | - Enable [`annotate_redeclares`](https://dart.dev/tools/linter-rules/annotate_redeclares.html)
59 |
60 | ## 2.2.0
61 |
62 | Requires Dart `sdk: '>=3.1.0'`
63 |
64 | - Disable [`unnecessary_await_in_return`](https://dart-lang.github.io/linter/lints/unnecessary_await_in_return.html) due to false positives and almost no benefit
65 | - Enable [`no_wildcard_variable_uses`](https://dart-lang.github.io/linter/lints/no_wildcard_variable_uses.html)
66 | - Enable [`no_self_assignments`](https://dart-lang.github.io/linter/lints/no_self_assignments.html)
67 |
68 | ## 2.1.2
69 |
70 | Requires Dart `sdk: '>=3.0.0'`
71 |
72 | - Remove [`prefer_equal_for_default_values`](https://dart-lang.github.io/linter/lints/prefer_equal_for_default_values.html)
73 | - Enable [`unnecessary_breaks`](https://dart-lang.github.io/linter/lints/unnecessary_breaks.html)
74 | - Enable [`invalid_case_patterns`](https://dart-lang.github.io/linter/lints/invalid_case_patterns.html)
75 | - Enable [`implicit_reopen`](https://dart-lang.github.io/linter/lints/implicit_reopen.html) for package mode
76 | - Enable [`type_literal_in_constant_pattern`](https://dart-lang.github.io/linter/lints/type_literal_in_constant_pattern.html)
77 | - Include all rules from `v2.0.20`
78 |
79 | ## 2.1.1
80 |
81 | - Disable `avoid_positional_boolean_parameters` due to new false positives in Dart 3.0
82 |
83 | ## 2.1.0
84 |
85 | Requires Dart `sdk: '>=3.0.0-0'`
86 |
87 | - Remove `implicit-casts: false`
88 | - Enable `strict-casts: true`
89 |
90 | ## 2.0.20
91 |
92 | Requires Dart `sdk: '>=2.19.0'`
93 |
94 | - Enable [`combinators_ordering`](https://dart-lang.github.io/linter/lints/combinators_ordering.html) for strict
95 | - Enable [`use_string_in_part_of_directives`](https://dart-lang.github.io/linter/lints/use_string_in_part_of_directives.html)
96 | - Enable [`unreachable_from_main`](https://dart-lang.github.io/linter/lints/unreachable_from_main.html) for strict
97 | - Enable [`dangling_library_doc_comments`](https://dart-lang.github.io/linter/lints/dangling_library_doc_comments.html) for strict
98 | - Enable [`collection_methods_unrelated_type`](https://dart-lang.github.io/linter/lints/collection_methods_unrelated_type.html)
99 | - Enable [`implicit_call_tearoffs`](https://dart-lang.github.io/linter/lints/implicit_call_tearoffs.html)
100 | - Enable [`unnecessary_library_directive`](https://dart-lang.github.io/linter/lints/unnecessary_library_directive.html)
101 | - Enable [`library_annotations`](https://dart-lang.github.io/linter/lints/library_annotations.html)
102 |
103 | ## 2.0.1
104 | - Update changelog
105 |
106 | ## 2.0.0
107 |
108 | Requires Dart `sdk: '>=2.18.0'`
109 |
110 | - New `package:lint/strict.yaml`
111 | - New `package:lint/casual.yaml`
112 | - New `package:lint/package.yaml`
113 | - Deprecate `package:lint/analysis_options.yaml` (uses `strict.yaml`)
114 | - Deprecate `package:lint/analysis_options_package.yaml` (uses `package.yaml`)
115 | - Disable [`use_decorated_box`](https://dart-lang.github.io/linter/lints/use_decorated_box.html)
116 | - Enable [`unnecessary_null_aware_operator_on_extension_on_nullable`](https://dart-lang.github.io/linter/lints/unnecessary_null_aware_assignments.html)
117 | - Enable [`unnecessary_to_list_in_spreads`](https://dart-lang.github.io/linter/lints/unnecessary_to_list_in_spreads.html)
118 |
119 | ## 1.10.0
120 |
121 | Requires Dart `sdk: '>=2.17.0'`
122 |
123 | - Removal of [`invariant_booleans`](https://dart-lang.github.io/linter/lints/invariant_booleans.html)
124 |
125 | ## 1.9.0 (Future release)
126 |
127 | Requires Dart `sdk: '>=2.16.0 <3.0.0'`
128 |
129 | - Enable [`unnecessary_late`](https://dart-lang.github.io/linter/lints/unnecessary_late.html)
130 | - Remove strict pana rules from `analysis_options_package.yaml`
131 | - `lines_longer_than_80_chars`
132 | - `prefer_single_quotes`
133 |
134 | ## 1.8.2
135 |
136 | [pana](https://github.com/dart-lang/pana) lint rules have been relaxed. No need for those two rules in the `package` version:
137 | - Remove [`lines_longer_than_80_chars`](https://dart-lang.github.io/linter/lints/lines_longer_than_80_chars.html) from `analysis_options_package.yaml`
138 | - Remove [`prefer_single_quotes`](https://dart-lang.github.io/linter/lints/prefer_single_quotes.html) from `analysis_options_package.yaml`
139 |
140 | ## 1.8.1
141 |
142 | Requires Dart `sdk: '>=2.15.0-7.0.dev <3.0.0'`
143 |
144 | - Enable [`always_use_package_imports`](https://dart-lang.github.io/linter/lints/always_use_package_imports.html)
145 | - Enable [`avoid_double_and_int_checks`](https://dart-lang.github.io/linter/lints/avoid_double_and_int_checks.html)
146 | - Enable [`use_is_even_rather_than_modulo`](https://dart-lang.github.io/linter/lints/use_is_even_rather_than_modulo.html)
147 | - [`parameter_assignments`](https://dart-lang.github.io/linter/lints/parameter_assignments.html) is now a warning (was hint)
148 | - [`missing_required_param`](https://dart-lang.github.io/linter/lints/missing_required_param.html) is now a error (was warning)
149 | - [`missing_return`](https://dart-lang.github.io/linter/lints/missing_return.html) is now an error (was warning)
150 | - ignore any errors in auto-generated flutter file `lib/generated_plugin_registrant.dart`
151 |
152 | ### Package
153 |
154 | - Enable [`library_private_types_in_public_api`](https://dart-lang.github.io/linter/lints/library_private_types_in_public_api.html)
155 | - Enable [`lines_longer_than_80_chars`](https://dart-lang.github.io/linter/lints/lines_longer_than_80_chars.html)
156 | - Enable [`prefer_single_quotes`](https://dart-lang.github.io/linter/lints/prefer_single_quotes.html)
157 |
158 | Big thanks to @rydmike for comparing all popular lint packages, identifying missing rules for this `lint`
159 |
160 | ## 1.8.0
161 |
162 | Requires Dart `sdk: '>=2.15.0-7.0.dev <3.0.0'`
163 |
164 | - Enable [`avoid_dynamic_calls`](https://dart-lang.github.io/linter/lints/avoid_dynamic_calls.html)
165 |
166 | ## 1.7.3
167 |
168 | - Removal of [`invariant_booleans`](https://dart-lang.github.io/linter/lints/invariant_booleans.html)
169 |
170 | ## 1.7.2
171 |
172 | Requires Dart `sdk: '>=2.14.0-360.0.dev <3.0.0'`
173 |
174 | - Enable [`eol_at_end_of_file`](https://dart-lang.github.io/linter/lints/eol_at_end_of_file.html)
175 |
176 | ## 1.7.1
177 |
178 | Requires Dart `sdk: '>=2.14.0-172.0.dev <3.0.0'`
179 |
180 | - Enable [`depend_on_referenced_packages`](https://dart-lang.github.io/linter/lints/depend_on_referenced_packages.html)
181 | - Enable [`noop_primitive_operations`](https://dart-lang.github.io/linter/lints/noop_primitive_operations.html)
182 | - Enable [`prefer_final_parameters`](https://dart-lang.github.io/linter/lints/prefer_final_parameters.html)
183 | - Enable [`use_test_throws_matchers`](https://dart-lang.github.io/linter/lints/use_test_throws_matchers.html)
184 |
185 | ## 1.7.0
186 |
187 | Requires Dart `sdk: '>=2.14.0-2.0.dev <3.0.0'`
188 |
189 | - Enable [`prefer_null_aware_method_calls`](https://dart-lang.github.io/linter/lints/prefer_null_aware_method_calls.html)
190 | - Enable [`require_trailing_commas`](https://dart-lang.github.io/linter/lints/require_trailing_commas.html)
191 |
192 |
193 | ## 1.6.0
194 |
195 | Requires Dart `sdk: >=2.13.0 <3.0.0`
196 |
197 | - Enable [`avoid_multiple_declarations_per_line`](https://dart-lang.github.io/linter/lints/avoid_multiple_declarations_per_line.html)
198 | - Enable [`deprecated_consistency`](https://dart-lang.github.io/linter/lints/deprecated_consistency.html)
199 | - Enable [`use_if_null_to_convert_nulls_to_bools`](https://dart-lang.github.io/linter/lints/use_if_null_to_convert_nulls_to_bools.html)
200 | - Enable [`use_build_context_synchronously`](https://dart-lang.github.io/linter/lints/use_build_context_synchronously.html)
201 | - Enable [`use_named_constants`](https://dart-lang.github.io/linter/lints/use_named_constants.html)
202 |
203 | ## 1.5.3
204 |
205 | - Remove [avoid_dynamic_calls](https://dart-lang.github.io/linter/lints/avoid_dynamic_calls.html), which is not part of the stable Dart 2.12 release
206 |
207 | ## 1.5.2
208 |
209 | Release for stable Dart `2.12.0`
210 | - Enable [avoid_dynamic_calls](https://dart-lang.github.io/linter/lints/avoid_dynamic_calls.html)
211 | - Enable [avoid_type_to_string](https://dart-lang.github.io/linter/lints/avoid_type_to_string.html)
212 | - Enable [cast_nullable_to_non_nullable](https://dart-lang.github.io/linter/lints/cast_nullable_to_non_nullable.html)
213 | - Enable [null_check_on_nullable_type_parameter](https://dart-lang.github.io/linter/lints/null_check_on_nullable_type_parameter.html)
214 | - Enable [tighten_type_of_initializing_formals](https://dart-lang.github.io/linter/lints/tighten_type_of_initializing_formals.html)
215 | - Enable [unnecessary_null_checks](https://dart-lang.github.io/linter/lints/unnecessary_null_checks.html)
216 |
217 | ## 1.5.1
218 |
219 | Min SDK is `2.12.0-0`
220 |
221 | Widen SDK contraints as long as nnbd is still in beta.
222 |
223 | ## 1.5.0
224 |
225 | Min SDK is `2.12.0`
226 |
227 | - NNBD support
228 |
229 | ## 1.4.0-dev.d210.1
230 |
231 | Release for Dart 2.10.0 with Linter v0.1.118
232 |
233 | Min SDK is `2.10.0-5.0.dev`
234 |
235 | - Enable [`use_late_for_private_fields_and_variables`](https://dart-lang.github.io/linter/lints/use_late_for_private_fields_and_variables.html)
236 | - Enable [`unnecessary_nullable_for_final_variable_declarations`](https://dart-lang.github.io/linter/lints/unnecessary_nullable_for_final_variable_declarations.html)
237 |
238 | ## 1.3.0
239 |
240 | Release for Dart 2.9.0 with Linter v0.1.117
241 |
242 | Min SDK is `2.9.0-16.0.dev`
243 |
244 | - Enable [`sized_box_for_whitespace`](https://dart-lang.github.io/linter/lints/sized_box_for_whitespace.html)
245 | - Enable [`exhaustive_cases`](https://dart-lang.github.io/linter/lints/exhaustive_cases.html)
246 |
247 | ## 1.3.0-dev.d29.1
248 |
249 | Dart SDK: >= 2.9.0-4.0.dev • (Linter v0.1.115)
250 |
251 | - Enable [`sized_box_for_whitespace`](https://dart-lang.github.io/linter/lints/sized_box_for_whitespace.html)
252 |
253 | ## 1.2.0
254 |
255 | Release for Dart 2.8.1 with Linter v0.1.114
256 |
257 | Min SDK is `2.8.0-dev.16.0`
258 |
259 | - Enable [`avoid_redundant_argument_values`](https://dart-lang.github.io/linter/lints/avoid_redundant_argument_values.html)
260 | - Enable [`missing_whitespace_between_adjacent_strings`](https://dart-lang.github.io/linter/lints/missing_whitespace_between_adjacent_strings.html)
261 | - Enable [`no_runtimeType_toString`](https://dart-lang.github.io/linter/lints/no_runtimeType_toString.html)
262 | - Enable [`unnecessary_string_interpolations`](https://dart-lang.github.io/linter/lints/unnecessary_string_interpolations.html)
263 | - Enable [`unnecessary_raw_strings`](https://dart-lang.github.io/linter/lints/unnecessary_raw_strings.html)
264 | - Enable [`unnecessary_string_escapes`](https://dart-lang.github.io/linter/lints/unnecessary_string_escapes.html)
265 | - Enable [`leading_newlines_in_multiline_strings`](https://dart-lang.github.io/linter/lints/leading_newlines_in_multiline_strings.html)
266 |
267 | - Enable [`use_key_in_widget_constructors`](https://dart-lang.github.io/linter/lints/use_key_in_widget_constructors.html) for packages
268 |
269 | ## 1.2.0-dev.d28.2
270 |
271 | Raise min sdk to `2.8.0-dev.16.0`
272 |
273 | ## 1.2.0-dev.d28.1
274 |
275 | - Dart 2.8 pre-release
276 | - Enable [`avoid_redundant_argument_values`](https://dart-lang.github.io/linter/lints/avoid_redundant_argument_values.html)
277 | - Enable [`missing_whitespace_between_adjacent_strings`](https://dart-lang.github.io/linter/lints/missing_whitespace_between_adjacent_strings.html)
278 | - Enable [`no_runtimeType_toString`](https://dart-lang.github.io/linter/lints/no_runtimeType_toString.html)
279 | - Enable [`unnecessary_string_interpolations`](https://dart-lang.github.io/linter/lints/unnecessary_string_interpolations.html)
280 | - Enable [`unnecessary_raw_strings`](https://dart-lang.github.io/linter/lints/unnecessary_raw_strings.html)
281 | - Enable [`unnecessary_string_escapes`](https://dart-lang.github.io/linter/lints/unnecessary_string_escapes.html)
282 | - Enable [`leading_newlines_in_multiline_strings`](https://dart-lang.github.io/linter/lints/leading_newlines_in_multiline_strings.html)
283 |
284 | ## 1.1.1
285 |
286 | - Fix syntactical error which breaks custom rules [#5](https://github.com/passsy/dart-lint/issues/5)
287 |
288 | ## 1.1.0
289 |
290 | Release for Dart 2.7
291 | - Enable [`prefer_is_not_operator`](https://dart-lang.github.io/linter/lints/prefer_is_not_operator.html)
292 | - Enable [`avoid_unnecessary_containers`](https://dart-lang.github.io/linter/lints/avoid_unnecessary_containers.html)
293 |
294 | ## 1.0.0
295 |
296 | Release for Dart 2.6
297 | - Enable [`camel_case_extensions`](https://dart-lang.github.io/linter/lints/camel_case_extensions.html)
298 |
299 | ## 0.3.1
300 |
301 | - Add `Example` tab to https://pub.dev/packages/lint
302 |
303 | ## 0.3.0
304 |
305 | - Disable `one_member_abstracts` [#2](https://github.com/passsy/dart-lint/issues/2)
306 | - Disable `sort_constructors_first` [#1](https://github.com/passsy/dart-lint/issues/1)
307 |
308 | New version schema:
309 |
310 | - `0.3.0+dart202`: Dart 2.2 Release `sdk: '>=2.2.0 <2.3.0'`
311 | - `0.3.0+dart203`: Dart 2.3 Release `sdk: '>=2.3.0 <2.4.0'`
312 | - `0.3.0+dart204`: Dart 2.4 Release `sdk: '>=2.4.0 <2.5.0'`
313 | - `0.3.0+dart205`: Dart 2.5 Release `sdk: '>=2.5.0 <3.0.0'`
314 |
315 | ## 0.2.3
316 |
317 | - Release for Dart 2.5 enables
318 | - `avoid_print`
319 |
320 | ## 0.2.2
321 |
322 | - Release for Dart 2.4 enables
323 | - `prefer_if_null_operators`
324 | - `sort_child_properties_last`
325 | - `unsafe_html`
326 |
327 | ## 0.2.1
328 |
329 | - Release for Dart 2.3 enables
330 | - `prefer_for_elements_to_map_fromIterable`
331 | - `prefer_if_elements_to_conditional_expressions`
332 | - `prefer_inlined_adds`
333 | - `prefer_spread_collections`
334 |
335 | ## 0.2.0
336 |
337 | - Fix `analysis_options_package.yaml` (wrong import)
338 | - Release for Dart 2.2. All incompatible rules are removed
339 |
340 | ## 0.1.1
341 | - `pubspec.yaml` `homepage` fix
342 |
343 | ## 0.1.0
344 |
345 | - app rule set `analysis_options_package.yaml`
346 | - package rule set `analysis_options_package.yaml`
347 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 |
2 | Apache License
3 | Version 2.0, January 2004
4 | http://www.apache.org/licenses/
5 |
6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7 |
8 | 1. Definitions.
9 |
10 | "License" shall mean the terms and conditions for use, reproduction,
11 | and distribution as defined by Sections 1 through 9 of this document.
12 |
13 | "Licensor" shall mean the copyright owner or entity authorized by
14 | the copyright owner that is granting the License.
15 |
16 | "Legal Entity" shall mean the union of the acting entity and all
17 | other entities that control, are controlled by, or are under common
18 | control with that entity. For the purposes of this definition,
19 | "control" means (i) the power, direct or indirect, to cause the
20 | direction or management of such entity, whether by contract or
21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
22 | outstanding shares, or (iii) beneficial ownership of such entity.
23 |
24 | "You" (or "Your") shall mean an individual or Legal Entity
25 | exercising permissions granted by this License.
26 |
27 | "Source" form shall mean the preferred form for making modifications,
28 | including but not limited to software source code, documentation
29 | source, and configuration files.
30 |
31 | "Object" form shall mean any form resulting from mechanical
32 | transformation or translation of a Source form, including but
33 | not limited to compiled object code, generated documentation,
34 | and conversions to other media types.
35 |
36 | "Work" shall mean the work of authorship, whether in Source or
37 | Object form, made available under the License, as indicated by a
38 | copyright notice that is included in or attached to the work
39 | (an example is provided in the Appendix below).
40 |
41 | "Derivative Works" shall mean any work, whether in Source or Object
42 | form, that is based on (or derived from) the Work and for which the
43 | editorial revisions, annotations, elaborations, or other modifications
44 | represent, as a whole, an original work of authorship. For the purposes
45 | of this License, Derivative Works shall not include works that remain
46 | separable from, or merely link (or bind by name) to the interfaces of,
47 | the Work and Derivative Works thereof.
48 |
49 | "Contribution" shall mean any work of authorship, including
50 | the original version of the Work and any modifications or additions
51 | to that Work or Derivative Works thereof, that is intentionally
52 | submitted to Licensor for inclusion in the Work by the copyright owner
53 | or by an individual or Legal Entity authorized to submit on behalf of
54 | the copyright owner. For the purposes of this definition, "submitted"
55 | means any form of electronic, verbal, or written communication sent
56 | to the Licensor or its representatives, including but not limited to
57 | communication on electronic mailing lists, source code control systems,
58 | and issue tracking systems that are managed by, or on behalf of, the
59 | Licensor for the purpose of discussing and improving the Work, but
60 | excluding communication that is conspicuously marked or otherwise
61 | designated in writing by the copyright owner as "Not a Contribution."
62 |
63 | "Contributor" shall mean Licensor and any individual or Legal Entity
64 | on behalf of whom a Contribution has been received by Licensor and
65 | subsequently incorporated within the Work.
66 |
67 | 2. Grant of Copyright License. Subject to the terms and conditions of
68 | this License, each Contributor hereby grants to You a perpetual,
69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70 | copyright license to reproduce, prepare Derivative Works of,
71 | publicly display, publicly perform, sublicense, and distribute the
72 | Work and such Derivative Works in Source or Object form.
73 |
74 | 3. Grant of Patent License. Subject to the terms and conditions of
75 | this License, each Contributor hereby grants to You a perpetual,
76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77 | (except as stated in this section) patent license to make, have made,
78 | use, offer to sell, sell, import, and otherwise transfer the Work,
79 | where such license applies only to those patent claims licensable
80 | by such Contributor that are necessarily infringed by their
81 | Contribution(s) alone or by combination of their Contribution(s)
82 | with the Work to which such Contribution(s) was submitted. If You
83 | institute patent litigation against any entity (including a
84 | cross-claim or counterclaim in a lawsuit) alleging that the Work
85 | or a Contribution incorporated within the Work constitutes direct
86 | or contributory patent infringement, then any patent licenses
87 | granted to You under this License for that Work shall terminate
88 | as of the date such litigation is filed.
89 |
90 | 4. Redistribution. You may reproduce and distribute copies of the
91 | Work or Derivative Works thereof in any medium, with or without
92 | modifications, and in Source or Object form, provided that You
93 | meet the following conditions:
94 |
95 | (a) You must give any other recipients of the Work or
96 | Derivative Works a copy of this License; and
97 |
98 | (b) You must cause any modified files to carry prominent notices
99 | stating that You changed the files; and
100 |
101 | (c) You must retain, in the Source form of any Derivative Works
102 | that You distribute, all copyright, patent, trademark, and
103 | attribution notices from the Source form of the Work,
104 | excluding those notices that do not pertain to any part of
105 | the Derivative Works; and
106 |
107 | (d) If the Work includes a "NOTICE" text file as part of its
108 | distribution, then any Derivative Works that You distribute must
109 | include a readable copy of the attribution notices contained
110 | within such NOTICE file, excluding those notices that do not
111 | pertain to any part of the Derivative Works, in at least one
112 | of the following places: within a NOTICE text file distributed
113 | as part of the Derivative Works; within the Source form or
114 | documentation, if provided along with the Derivative Works; or,
115 | within a display generated by the Derivative Works, if and
116 | wherever such third-party notices normally appear. The contents
117 | of the NOTICE file are for informational purposes only and
118 | do not modify the License. You may add Your own attribution
119 | notices within Derivative Works that You distribute, alongside
120 | or as an addendum to the NOTICE text from the Work, provided
121 | that such additional attribution notices cannot be construed
122 | as modifying the License.
123 |
124 | You may add Your own copyright statement to Your modifications and
125 | may provide additional or different license terms and conditions
126 | for use, reproduction, or distribution of Your modifications, or
127 | for any such Derivative Works as a whole, provided Your use,
128 | reproduction, and distribution of the Work otherwise complies with
129 | the conditions stated in this License.
130 |
131 | 5. Submission of Contributions. Unless You explicitly state otherwise,
132 | any Contribution intentionally submitted for inclusion in the Work
133 | by You to the Licensor shall be under the terms and conditions of
134 | this License, without any additional terms or conditions.
135 | Notwithstanding the above, nothing herein shall supersede or modify
136 | the terms of any separate license agreement you may have executed
137 | with Licensor regarding such Contributions.
138 |
139 | 6. Trademarks. This License does not grant permission to use the trade
140 | names, trademarks, service marks, or product names of the Licensor,
141 | except as required for reasonable and customary use in describing the
142 | origin of the Work and reproducing the content of the NOTICE file.
143 |
144 | 7. Disclaimer of Warranty. Unless required by applicable law or
145 | agreed to in writing, Licensor provides the Work (and each
146 | Contributor provides its Contributions) on an "AS IS" BASIS,
147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148 | implied, including, without limitation, any warranties or conditions
149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150 | PARTICULAR PURPOSE. You are solely responsible for determining the
151 | appropriateness of using or redistributing the Work and assume any
152 | risks associated with Your exercise of permissions under this License.
153 |
154 | 8. Limitation of Liability. In no event and under no legal theory,
155 | whether in tort (including negligence), contract, or otherwise,
156 | unless required by applicable law (such as deliberate and grossly
157 | negligent acts) or agreed to in writing, shall any Contributor be
158 | liable to You for damages, including any direct, indirect, special,
159 | incidental, or consequential damages of any character arising as a
160 | result of this License or out of the use or inability to use the
161 | Work (including but not limited to damages for loss of goodwill,
162 | work stoppage, computer failure or malfunction, or any and all
163 | other commercial damages or losses), even if such Contributor
164 | has been advised of the possibility of such damages.
165 |
166 | 9. Accepting Warranty or Additional Liability. While redistributing
167 | the Work or Derivative Works thereof, You may choose to offer,
168 | and charge a fee for, acceptance of support, warranty, indemnity,
169 | or other liability obligations and/or rights consistent with this
170 | License. However, in accepting such obligations, You may act only
171 | on Your own behalf and on Your sole responsibility, not on behalf
172 | of any other Contributor, and only if You agree to indemnify,
173 | defend, and hold each Contributor harmless for any liability
174 | incurred by, or claims asserted against, such Contributor by reason
175 | of your accepting any such warranty or additional liability.
176 |
177 | END OF TERMS AND CONDITIONS
178 |
179 | APPENDIX: How to apply the Apache License to your work.
180 |
181 | To apply the Apache License to your work, attach the following
182 | boilerplate notice, with the fields enclosed by brackets "[]"
183 | replaced with your own identifying information. (Don't include
184 | the brackets!) The text should be enclosed in the appropriate
185 | comment syntax for the file format. We also recommend that a
186 | file or class name and description of purpose be included on the
187 | same "printed page" as the copyright notice for easier
188 | identification within third-party archives.
189 |
190 | Copyright 2022 Pascal Welsch
191 |
192 | Licensed under the Apache License, Version 2.0 (the "License");
193 | you may not use this file except in compliance with the License.
194 | You may obtain a copy of the License at
195 |
196 | http://www.apache.org/licenses/LICENSE-2.0
197 |
198 | Unless required by applicable law or agreed to in writing, software
199 | distributed under the License is distributed on an "AS IS" BASIS,
200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201 | See the License for the specific language governing permissions and
202 | limitations under the License.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | [](https://pub.dartlang.org/packages/lint)
2 | [](https://pub.dev/packages/lint)
3 |
4 | # Lint for Dart/Flutter
5 |
6 |
7 |
8 |
9 |
10 | `lint` is a hand-picked, open-source, community-driven collection of lint rules for Dart and Flutter projects.
11 | The set of rules follows the [Effective Dart: Style Guide](https://dart.dev/guides/language/effective-dart/style).
12 |
13 | This package can be used as a replacement for [`package:lints`](https://pub.dev/packages/lints) or the discontinued [`package:pedantic`](https://github.com/dart-lang/pedantic) for those who prefer stricter rules.
14 |
15 | `lint` supports 3 different set of rules:
16 | - `strict`: tries to be strict but not annoying. Perfect for production app code
17 | - `casual`: great when prototyping, to be used in code samples, any non-production code
18 | - `package`: like `strict` but for dart packages, that have a public API
19 |
20 | ## Install
21 |
22 | Add `lint` as dependency to your `pubspec.yaml`. Version `^1.0.0` means you're automatically getting the latest version for `lint` when running `pub upgrade`
23 | ```yaml
24 | dev_dependencies:
25 | lint: ^2.0.0
26 | ```
27 |
28 | Create an `analysis_options.yaml` file in the root of your project with the following content:
29 |
30 | ```yaml
31 | # This file configures the analyzer to use the lint rule set from `package:lint`
32 |
33 | include: package:lint/strict.yaml # For production apps
34 | # include: package:lint/casual.yaml # For code samples, hackathons and other non-production code
35 | # include: package:lint/package.yaml # Use this for packages with public API
36 |
37 |
38 | # You might want to exclude auto-generated files from dart analysis
39 | analyzer:
40 | exclude:
41 | #- '**.freezed.dart'
42 | #- '**.g.dart'
43 |
44 | # You can customize the lint rules set to your own liking. A list of all rules
45 | # can be found at https://dart.dev/tools/linter-rules
46 | linter:
47 | rules:
48 | # Util classes are awesome!
49 | # avoid_classes_with_only_static_members: false
50 |
51 | # Make constructors the first thing in every class
52 | # sort_constructors_first: true
53 |
54 | # Choose wisely, but you don't have to
55 | # prefer_double_quotes: true
56 | # prefer_single_quotes: true
57 | ```
58 |
59 | ## Lint badge
60 |
61 | You're using lint in your open-source project?
62 | Add the badge to your `README.md` show that you honor strict lint rules
63 |
64 |
65 | [](https://pub.dev/packages/lint)
66 | ```md
67 | [](https://pub.dev/packages/lint)
68 | ```
69 |
70 | ## Comparison with other lint packages
71 |
72 | A detailed comparison of all linting packages for dart can be found at https://rydmike.com/blog_flutter_linting.html
73 |
74 | `lint` is among the strictest but not the strictest. It tires to find the right balance between useful and annoying.
75 |
76 | ## Which version to use?
77 |
78 | Generally, you can just put `lint: ^2.0.0` in your `pubspec.yaml` and pub get the latest version compatible with your Dart version.
79 |
80 | | Dart Version | Lint Version |
81 | |--------------|---------------------------------------------------------------------|
82 | | `3.7` | [`2.8.0`](https://pub.dev/packages/lint/versions/2.8.0/changelog) |
83 | | `3.6` | [`2.7.0`](https://pub.dev/packages/lint/versions/2.7.0/changelog) |
84 | | `3.5` | [`2.6.1`](https://pub.dev/packages/lint/versions/2.6.1/changelog) |
85 | | `3.4` | [`2.5.0`](https://pub.dev/packages/lint/versions/2.5.0/changelog) |
86 | | `3.3` | [`2.4.0`](https://pub.dev/packages/lint/versions/2.4.0/changelog) |
87 | | `3.2` | [`2.3.0`](https://pub.dev/packages/lint/versions/2.3.0/changelog) |
88 | | `3.1` | [`2.2.0`](https://pub.dev/packages/lint/versions/2.2.0/changelog) |
89 | | `3.0` | [`2.1.0`](https://pub.dev/packages/lint/versions/2.1.0/changelog) |
90 | | `2.18` | [`2.0.0`](https://pub.dev/packages/lint/versions/2.0.0/changelog) |
91 | | `2.17` | [`1.10.0`](https://pub.dev/packages/lint/versions/1.10.0/changelog) |
92 | | `2.16` | [`1.9.0`](https://pub.dev/packages/lint/versions/1.9.0/changelog) |
93 | | `2.15` | [`1.8.0`](https://pub.dev/packages/lint/versions/1.8.0/changelog) |
94 | | `2.14` | [`1.7.0`](https://pub.dev/packages/lint/versions/1.7.0/changelog) |
95 | | `2.13` | [`1.6.0`](https://pub.dev/packages/lint/versions/1.6.0/changelog) |
96 | | `2.12` | [`1.5.0`](https://pub.dev/packages/lint/versions/1.5.0/changelog) |
97 |
98 |
99 | ## Comparison to discontinued package:pedantic
100 |
101 | Google publicly shares their internal rules as `package:pedantic` in open-source.
102 | It represents what Google is enforcing internally throughout all Dart code.
103 | For a lint rule to be added to pedantic, Google has to change all code which doesn't follow the style.
104 |
105 | This strict practice results in only 27/150+ rules to be enabled.
106 | While some are contradictory to each other and can not enabled together, a big chunk of rules isn't enabled because it requires too much work to update all of Googles existing code.
107 |
108 | For developers outside Google, it is the norm to have separate lint rules per project.
109 | One project might enable more rules then others.
110 |
111 | `lint` enables a majority of lint rules, leaving out contradictory and very opinionated rules.
112 |
113 | ## License
114 |
115 | ```
116 | Copyright 2022 Pascal Welsch
117 |
118 | Licensed under the Apache License, Version 2.0 (the "License");
119 | you may not use this file except in compliance with the License.
120 | You may obtain a copy of the License at
121 |
122 | http://www.apache.org/licenses/LICENSE-2.0
123 |
124 | Unless required by applicable law or agreed to in writing, software
125 | distributed under the License is distributed on an "AS IS" BASIS,
126 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
127 | See the License for the specific language governing permissions and
128 | limitations under the License.
129 | ```
130 |
--------------------------------------------------------------------------------
/dartdoc_options.yaml:
--------------------------------------------------------------------------------
1 | dartdoc:
2 | ignore:
3 | # This package only contains lint rules and no Dart libraries. Therefore,
4 | # `dart doc` shows a warning (Dartdoc could not find any public libraries to
5 | # document in...). The warning may also be changed to an error in the future
6 | # (see https://github.com/dart-lang/dartdoc/issues/2907). To avoid problems,
7 | # should `dart doc` ignore that there is no Dart library.
8 | - no-documentable-libraries
--------------------------------------------------------------------------------
/example/README.md:
--------------------------------------------------------------------------------
1 | Add `lint` as dependency to your pubspec.yaml
2 |
3 | ```yaml
4 | dev_dependencies:
5 | lint: ^1.3.0
6 | ```
7 |
8 | Add a `analysis_options.yaml` to the root of you project.
9 |
10 | ```yaml
11 | include: package:lint/analysis_options.yaml
12 |
13 | # Not happy with the default? Customize the rules depending on your needs.
14 | # Here are some examples:
15 | linter:
16 | rules:
17 | # Make constructors the first thing in every class
18 | sort_constructors_first: true
19 |
20 | # The new tabs vs. spaces. Choose wisely
21 | prefer_single_quotes: true
22 | prefer_double_quotes: true
23 |
24 | # Good packages document everything
25 | public_member_api_docs: true
26 |
27 | # Blindly follow the Flutter code style, which prefers types everywhere
28 | always_specify_types: true
29 |
30 | # Back to the 80s
31 | lines_longer_than_80_chars: true
32 |
33 | # Use parameter order as in json response
34 | always_put_required_named_parameters_first: false
35 |
36 | # Util classes are awesome!
37 | avoid_classes_with_only_static_members: false
38 | ```
39 |
40 | Hit save and see the `dartanalyzer` executing the lint checks in you favorite editor.
--------------------------------------------------------------------------------
/lib/analysis_options.yaml:
--------------------------------------------------------------------------------
1 | ##
2 | # Lint rules to be used for apps without developer facing API. i.e. command line tools and Flutter applications
3 | ##
4 |
5 | # Deprecated, use `include: package:lint/strict.yaml` instead
6 | include: package:lint/strict.yaml
7 |
--------------------------------------------------------------------------------
/lib/analysis_options_package.yaml:
--------------------------------------------------------------------------------
1 | ##
2 | # Lint rules to be used for packages, which provide a dart API for developers
3 | ##
4 |
5 | # Deprecated, use `include: package:lint/package.yaml` instead
6 | include: package:lint/package.yaml
7 |
--------------------------------------------------------------------------------
/lib/casual.yaml:
--------------------------------------------------------------------------------
1 | ##
2 | # Casual lint rules that help to prevent bugs, but don't care about const, prints or formatting like commas
3 | ##
4 |
5 | analyzer:
6 | language:
7 | strict-casts: true
8 |
9 | errors:
10 | # treat missing required parameters as an error (not a hint)
11 | missing_required_param: error
12 |
13 | # treat missing returns as an error (not a hint)
14 | missing_return: error
15 |
16 | # allow having TODOs in code
17 | todo: ignore
18 |
19 | # Reassignment should be treated as warning (not a hint)
20 | parameter_assignments: warning
21 |
22 | exclude:
23 | # Generated for Flutter web apps. Since it is auto-generated, errors should be ignored
24 | - lib/generated_plugin_registrant.dart
25 |
26 | # Rules are in the same order (alphabetically) as documented at https://dart.dev/tools/linter-rules
27 | # and https://github.com/dart-lang/sdk/blob/main/pkg/linter/example/all.yaml
28 | linter:
29 | rules:
30 | # Prevents accidental return type changes which results in a breaking API change.
31 | # Enforcing return type makes API changes visible in a diff
32 | #
33 | # https://dart.dev/tools/linter-rules/always_declare_return_types
34 | - always_declare_return_types
35 |
36 | # Single line `if`s are fine as recommended in Effective Dart "DO format your code using dartfmt"
37 | #
38 | # https://dart.dev/tools/linter-rules/always_put_control_body_on_new_line
39 | # - always_put_control_body_on_new_line
40 |
41 | # Flutter widgets always put a Key as first optional parameter which breaks this rule.
42 | # Also violates other orderings like matching the class fields or alphabetically.
43 | #
44 | # https://dart.dev/tools/linter-rules/always_declare_return_types
45 | # - always_put_required_named_parameters_first
46 |
47 | # Always use package: imports.
48 | # While both, relative and package imports are fine, package imports are preferred because they allow for easy find
49 | # and replace
50 | # Conflicting with: prefer_relative_imports, avoid_relative_lib_imports
51 | #
52 | # Dart SDK: >= 2.10.0-10.0.dev • (Linter v0.1.118)
53 | # https://dart.dev/tools/linter-rules/always_use_package_imports
54 | - always_use_package_imports
55 |
56 | # Since dart 2.0 dart is a sound language, specifying types is not required anymore.
57 | # `var foo = 10;` is enough information for the compiler to make foo an int.
58 | # Violates Effective Dart "AVOID type annotating initialized local variables".
59 | # Makes code unnecessarily complex https://github.com/dart-lang/linter/issues/1620
60 | #
61 | # This convention is used in the Flutter repository
62 | #
63 | # Dart SDK: >= 2.0.0 • (Linter v0.1.4)
64 | #
65 | # https://dart.dev/tools/linter-rules/always_specify_types
66 | # - always_specify_types
67 |
68 | # Protect against unintentionally overriding superclass members
69 | #
70 | # https://dart.dev/tools/linter-rules/annotate_overrides
71 | - annotate_overrides
72 |
73 | # Annotate redeclared members. Experimental.
74 | #
75 | # Dart SDK: >= 3.2.0
76 | #
77 | # https://dart.dev/tools/linter-rules/annotate_redeclares
78 | - annotate_redeclares
79 |
80 | # All methods should define a return type. dynamic is no exception.
81 | # Violates Effective Dart "PREFER annotating with dynamic instead of letting inference fail"
82 | #
83 | # https://dart.dev/tools/linter-rules/avoid_annotating_with_dynamic
84 | # - avoid_annotating_with_dynamic
85 |
86 | # A leftover from dart1, should be deprecated
87 | #
88 | # - https://github.com/dart-lang/linter/issues/1401
89 | # https://dart.dev/tools/linter-rules/avoid_as
90 | # - avoid_as
91 |
92 | # Highlights boolean expressions which can be simplified
93 | #
94 | # https://dart.dev/tools/linter-rules/avoid_bool_literals_in_conditional_expressions
95 | - avoid_bool_literals_in_conditional_expressions
96 |
97 | # There are no strong arguments to enable this rule because it is very strict. Catching anything is useful
98 | # and common even if not always the most correct thing to do.
99 | #
100 | # https://dart.dev/tools/linter-rules/avoid_catches_without_on_clauses
101 | # - avoid_catches_without_on_clauses
102 |
103 | # Errors aren't for catching but to prevent prior to runtime
104 | #
105 | # https://dart.dev/tools/linter-rules/avoid_catching_errors
106 | # - avoid_catching_errors
107 |
108 | # Can usually be replaced with an extension
109 | #
110 | # Dart SDK: >= 2.0.0 • (Linter v0.1.31)
111 | #
112 | # https://dart.dev/tools/linter-rules/avoid_classes_with_only_static_members
113 | # - avoid_classes_with_only_static_members
114 |
115 | # Never accidentally use dynamic invocations, as it makes type error very hard to find
116 | #
117 | # Dart SDK: unreleased • (Linter v1.0)
118 | # https://dart.dev/tools/linter-rules/avoid_dynamic_calls
119 | - avoid_dynamic_calls
120 |
121 | # Since all dart code may be compiled to JS this should be considered.
122 | # Disable it manually when you're explicitly not targeting web
123 | #
124 | # https://dart.dev/tools/linter-rules/avoid_double_and_int_checks
125 | - avoid_double_and_int_checks
126 |
127 | # Prevents accidental empty else cases. See samples in documentation
128 | #
129 | # https://dart.dev/tools/linter-rules/avoid_empty_else
130 | # - avoid_empty_else
131 |
132 | # Avoid using FutureOr because the synchronous type void makes no sense since it can't be assigned to a variable
133 | #
134 | # Definitly never use it as return type of a function.
135 | #
136 | # Exception: It is ok to use it as parameter (also constructor parameter) to accept both a synchronous and asynchronous callback for flexability in API design
137 | #
138 | # ```
139 | # void executeTask(FutureOr Function() task) async { // ok
140 | # await task();
141 | # }
142 | #
143 | # void main() {
144 | # executeTask(() => print('Sync task')); // sync is allowed
145 | # executeTask(() async => await Future.delayed(Duration(seconds: 1), () => print('Async task'))); // will be awaited
146 | # }
147 | # ```
148 | #
149 | # See discusson at https://github.com/dart-lang/sdk/issues/59232
150 | #
151 | # Dart SDK: >= 3.5.0
152 | #
153 | # https://dart.dev/tools/linter-rules/avoid_futureor_void
154 | - avoid_futureor_void
155 |
156 | # It is expected that mutable objects which override hash & equals shouldn't be used as keys for hashmaps.
157 | # This one use case doesn't make all hash & equals implementations for mutable classes bad.
158 | #
159 | # https://dart.dev/tools/linter-rules/avoid_equals_and_hash_code_on_mutable_classes
160 | # - avoid_equals_and_hash_code_on_mutable_classes
161 |
162 | # Use different quotes instead of escaping
163 | # Dart SDK: >= 2.8.0-dev.11.0 • (Linter v0.1.111)
164 | # https://dart.dev/tools/linter-rules/avoid_escaping_inner_quotes
165 | # - avoid_escaping_inner_quotes
166 |
167 | # Prevents unnecessary allocation of a field
168 | #
169 | # https://dart.dev/tools/linter-rules/avoid_field_initializers_in_const_classes
170 | # - avoid_field_initializers_in_const_classes
171 |
172 | # Since lint `parameter_assignments` is enabled, the final parameter doesn't add more safety, it would be just verbose
173 | # Conflicts with prefer_final_parameters
174 | #
175 | # https://dart.dev/tools/linter-rules/avoid_final_parameters
176 | - avoid_final_parameters
177 |
178 | # Prevents allocating a lambda and allows return/break/continue control flow statements inside the loop
179 | #
180 | # Dart SDK: >= 2.0.0 • (Linter v0.1.30)
181 | #
182 | # https://dart.dev/tools/linter-rules/avoid_function_literals_in_foreach_calls
183 | - avoid_function_literals_in_foreach_calls
184 |
185 | # Don't break value types by implementing them
186 | # https://dart.dev/tools/linter-rules/avoid_implementing_value_types
187 | - avoid_implementing_value_types
188 |
189 | # Removes redundant `= null;`
190 | # https://dart.dev/tools/linter-rules/avoid_init_to_null
191 | - avoid_init_to_null
192 |
193 | # Only useful when targeting JS
194 | # Warns about too large integers when compiling to JS
195 | #
196 | # https://dart.dev/tools/linter-rules/avoid_js_rounded_ints
197 | # - avoid_js_rounded_ints
198 |
199 | # Not useful for coding golf, but in every environment where code is maintained by multiple authors.
200 | #
201 | # Dart SDK: 2.13.0 • (Linter v1.1.0)
202 | #
203 | # https://dart.dev/tools/linter-rules/avoid_multiple_declarations_per_line
204 | - avoid_multiple_declarations_per_line
205 |
206 | # Causes false-positives for callbacks and functional interfaces such as
207 | #
208 | # ```dart
209 | # final void Function(bool value)? onChanged;
210 | # ```
211 | #
212 | # https://dart.dev/tools/linter-rules/avoid_positional_boolean_parameters
213 | # - avoid_positional_boolean_parameters
214 |
215 | # Don't call print in production code
216 | #
217 | # https://dart.dev/tools/linter-rules/avoid_print
218 | # - avoid_print
219 |
220 | # Always prefer function references over typedefs.
221 | # Jumping twice in code to see the signature of a lambda sucks. This is different from the flutter analysis_options
222 | # https://dart.dev/tools/linter-rules/avoid_private_typedef_functions
223 | # - avoid_private_typedef_functions
224 |
225 | # Don't explicitly set defaults
226 | #
227 | # Dart SDK: >= 2.8.0-dev.1.0 • (Linter v0.1.107)
228 | # https://dart.dev/tools/linter-rules/avoid_redundant_argument_values
229 | - avoid_redundant_argument_values
230 |
231 | # package or relative? Let's end the discussion and use package everywhere.
232 | #
233 | # https://dart.dev/tools/linter-rules/avoid_relative_lib_imports
234 | - avoid_relative_lib_imports
235 |
236 | # It's definitely not recommended to break dartdoc but besides that there is no reason to inherit a bad named parameter
237 | # https://dart.dev/tools/linter-rules/avoid_renaming_method_parameters
238 | # - avoid_renaming_method_parameters
239 |
240 | # Setters always return void, therefore defining void is redundant
241 | #
242 | # https://dart.dev/tools/linter-rules/avoid_return_types_on_setters
243 | - avoid_return_types_on_setters
244 |
245 | # Use empty returns, don't show off with your knowledge about dart internals.
246 | # https://dart.dev/tools/linter-rules/avoid_returning_null_for_void
247 | - avoid_returning_null_for_void
248 |
249 | # Hinting you forgot about the cascade operator. But too often you did this on purpose.
250 | # There are plenty of valid reasons to return this.
251 | #
252 | # https://dart.dev/tools/linter-rules/avoid_returning_this
253 | # - avoid_returning_this
254 |
255 | # Prevents logical inconsistencies. It's good practice to define getters for all existing setters.
256 | # https://dart.dev/tools/linter-rules/avoid_setters_without_getters
257 | - avoid_setters_without_getters
258 |
259 | # Don't reuse a type parameter when on with the same name already exists in the same scope
260 | #
261 | # https://dart.dev/tools/linter-rules/avoid_shadowing_type_parameters
262 | - avoid_shadowing_type_parameters
263 |
264 | # A single cascade operator can be replaced with a normal method call
265 | #
266 | # https://dart.dev/tools/linter-rules/avoid_single_cascade_in_expression_statements
267 | - avoid_single_cascade_in_expression_statements
268 |
269 | # Might cause frame drops because of synchronous file access on mobile, especially on older phones with slow storage.
270 | # There are no known measurements sync access does *not* drop frames.
271 | #
272 | # https://dart.dev/tools/linter-rules/avoid_slow_async_io
273 | # - avoid_slow_async_io
274 |
275 | # Don't use .toString() in production code which might be minified
276 | # Dart SDK: >= 2.10.0-144.0.dev • (Linter v0.1.119)
277 | # https://dart.dev/tools/linter-rules/avoid_type_to_string
278 | - avoid_type_to_string
279 |
280 | # Don't use a parameter names which can be confused with a types (i.e. int, bool, num, ...)
281 | #
282 | # https://dart.dev/tools/linter-rules/avoid_types_as_parameter_names
283 | - avoid_types_as_parameter_names
284 |
285 | # Adding the type is not required, but sometimes improves readability. Therefore, removing it doesn't always help
286 | # https://dart.dev/tools/linter-rules/avoid_types_on_closure_parameters
287 | # - avoid_types_on_closure_parameters
288 |
289 | # Containers without parameters have no effect and can be removed
290 | # https://dart.dev/tools/linter-rules/avoid_unnecessary_containers
291 | # - avoid_unnecessary_containers
292 |
293 | # Unused parameters should be removed
294 | # https://dart.dev/tools/linter-rules/avoid_unused_constructor_parameters
295 | - avoid_unused_constructor_parameters
296 |
297 | # For async functions use `Future` as return value, not `void`
298 | # This allows usage of the await keyword and prevents operations from running in parallel.
299 | #
300 | # https://dart.dev/tools/linter-rules/avoid_void_async
301 | - avoid_void_async
302 |
303 | # Flutter mobile only: Web packages aren't available in mobile flutter apps
304 | # https://dart.dev/tools/linter-rules/avoid_web_libraries_in_flutter
305 | - avoid_web_libraries_in_flutter
306 |
307 | # Use the await keyword only for futures. There is nothing to await in synchronous code
308 | #
309 | # https://dart.dev/tools/linter-rules/await_only_futures
310 | - await_only_futures
311 |
312 | # Follow the style guide and use UpperCamelCase for extensions
313 | #
314 | # https://dart.dev/tools/linter-rules/camel_case_extensions
315 | - camel_case_extensions
316 |
317 | # Follow the style guide and use UpperCamelCase for class names and typedefs
318 | #
319 | # https://dart.dev/tools/linter-rules/camel_case_types
320 | - camel_case_types
321 |
322 | # Prevents leaks and code executing after their lifecycle.
323 | # Discussion https://github.com/passsy/dart-lint/issues/4
324 | #
325 | # https://dart.dev/tools/linter-rules/cancel_subscriptions
326 | - cancel_subscriptions
327 |
328 | # The cascade syntax is weird, and you shouldn't be forced to use it.
329 | # False positives:
330 | # https://github.com/dart-lang/linter/issues/1589
331 | #
332 | # https://dart.dev/tools/linter-rules/cascade_invocations
333 | # - cascade_invocations
334 |
335 | # Don't cast T? to T. Use ! instead
336 | # Dart SDK: >= 2.11.0-182.0.dev • (Linter v0.1.120)
337 | #
338 | # https://dart.dev/tools/linter-rules/cast_nullable_to_non_nullable
339 | - cast_nullable_to_non_nullable
340 |
341 | # False positives, not reliable enough
342 | # - https://github.com/dart-lang/linter/issues/1381
343 | #
344 | # https://dart.dev/tools/linter-rules/close_sinks
345 | # - close_sinks
346 |
347 | # It's surprising that this is not solved with a type in the sdk, but with a linter rule. This is a must-have.
348 | #
349 | # Dart SDK: 2.19.0 • (Linter v1.29.0)
350 | #
351 | # https://dart.dev/tools/linter-rules/collection_methods_unrelated_type
352 | - collection_methods_unrelated_type
353 |
354 | # False positives:
355 | # - https://github.com/dart-lang/linter/issues/1142
356 | #
357 | # https://dart.dev/tools/linter-rules/comment_references
358 | # - comment_references
359 |
360 | # Sorting doesn't catch any errors
361 | #
362 | # Linter v1.26.0
363 | # https://dart.dev/tools/linter-rules/combinators_ordering
364 | # - combinators_ordering
365 |
366 | # Checks that files in conditional imports exist
367 | #
368 | # Linter v1.16.0
369 | # https://dart.dev/tools/linter-rules/conditional_uri_does_not_exist
370 | - conditional_uri_does_not_exist
371 |
372 | # Follow standard dart naming style.
373 | #
374 | # https://dart.dev/tools/linter-rules/constant_identifier_names
375 | - constant_identifier_names
376 |
377 | # Prevents hard to debug code
378 | #
379 | # https://dart.dev/tools/linter-rules/control_flow_in_finally
380 | - control_flow_in_finally
381 |
382 | # Single line `if`s are fine, but when a new line splits the bool expression and body curly braces
383 | # are recommended. It prevents the danging else problem and easily allows the addition of more lines inside
384 | # the if-body
385 | #
386 | # Dart SDK: >= 2.0.0 • (Linter v0.1.57)
387 | #
388 | # https://dart.dev/tools/linter-rules/curly_braces_in_flow_control_structures
389 | # - curly_braces_in_flow_control_structures
390 |
391 | # The location of comments doesn't catch any error
392 | #
393 | # Dart SDK: 2.19.0 • Linter v1.29.0
394 | #
395 | # https://dart.dev/tools/linter-rules/dangling_library_doc_comments
396 | # - dangling_library_doc_comments
397 |
398 | # Requires all referenced dependencies to be declared as direct dependencies in pubspec.yaml. Transitive
399 | # dependencies might be removed by a dependency, breaking your code.
400 | #
401 | # Dart SDK: 2.14.0-172.0.dev • (Linter v1.5.0)
402 | #
403 | # https://dart.dev/tools/linter-rules/depend_on_referenced_packages
404 | - depend_on_referenced_packages
405 |
406 | # When deprecating classes, also deprecate the constructor. When deprecating fields, also deprecate the constructor
407 | # parameter. That rule is useful for apps and especially for packages
408 | #
409 | # Dart SDK: 2.13.0 • (Linter v1.0.0)
410 | #
411 | # https://dart.dev/tools/linter-rules/deprecated_consistency
412 | # - deprecated_consistency
413 |
414 | # Still experimental and pretty much work when enforced
415 | # https://dart.dev/tools/linter-rules/diagnostic_describe_all_properties
416 | # - diagnostic_describe_all_properties
417 |
418 | # Follows dart style. Fully supported by IDEs and no manual effort for a consistent style
419 | #
420 | # https://dart.dev/tools/linter-rules/directives_ordering
421 | # - directives_ordering
422 |
423 | # Similar to `unawaited_futures` but only within async function blocks
424 | # Unclear which unawaited function to use
425 | #
426 | # Dart SDK: >= 2.18.0 • (Linter v1.24.0)
427 | #
428 | # https://dart.dev/tools/linter-rules/discarded_futures
429 | # - discarded_futures
430 |
431 | # String.fromEnvironment looks up env variables at compile time. The variable is baked in by the compiler
432 | # and can't be changed by environment variables.
433 | #
434 | # For dart apps:
435 | # Better look up an environment variable at runtime with Platform.environment
436 | # or use code generation to define variables at compile time.
437 | #
438 | # For Flutter apps:
439 | # String.fromEnvironment is the recommended way to include variables defined with `flutter build --dart-define`
440 | #
441 | #
442 | # Dart SDK: >= 2.10.0-0.0.dev • (Linter v0.1.117)
443 | # https://dart.dev/tools/linter-rules/do_not_use_environment
444 | # - do_not_use_environment
445 |
446 | # The reason for the ignore is usually self-evident and an additional comment would add unnecessary verbosity.
447 | # Also, when temporarily ignoring rules for debugging or development purposes, having to add documentation creates unnecessary overhead
448 | #
449 | # Example where it is annoying:
450 | #
451 | # ```dart
452 | # } catch (e, stack) {
453 | # // ignore: avoid_print
454 | # print(stack);
455 | # }
456 | # ```
457 | #
458 | # Dart SDK: >= 3.5.0
459 | #
460 | # https://dart.dev/tools/linter-rules/document_ignores
461 | # - document_ignores
462 |
463 | # Add a comment why no further error handling is required
464 | #
465 | # https://dart.dev/tools/linter-rules/empty_catches
466 | # - empty_catches
467 |
468 | # Removed empty constructor bodies
469 | #
470 | # https://dart.dev/tools/linter-rules/empty_constructor_bodies
471 | # - empty_constructor_bodies
472 |
473 | # Don't allow empty if bodies. Works together with curly_braces_in_flow_control_structures
474 | #
475 | # https://dart.dev/tools/linter-rules/empty_statements
476 | - empty_statements
477 |
478 | # That's good habit, but not necessary. It might be useful for some parsers that split lines based on the
479 | # new line character. Common in simple bash scripts.
480 | #
481 | # Most IDEs do this automatically, therefore zero effort for devs
482 | #
483 | # Dart SDK: >=2.14.0-360.0.dev • (Linter v1.8.0)
484 | #
485 | # https://dart.dev/tools/linter-rules/eol_at_end_of_file
486 | # - eol_at_end_of_file
487 |
488 | # Enums aren't powerful enough, now enum like classes get the same linting support
489 | #
490 | # Dart SDK: >= 2.9.0-12.0.dev • (Linter v0.1.116)
491 | #
492 | # https://dart.dev/tools/linter-rules/exhaustive_cases
493 | - exhaustive_cases
494 |
495 | # Follow dart file naming schema
496 | # https://dart.dev/tools/linter-rules/file_names
497 | - file_names
498 |
499 | # Very flutter specific, not applicable for all projects
500 | #
501 | # https://dart.dev/tools/linter-rules/flutter_style_todos
502 | # - flutter_style_todos # not all todos require a ticket
503 |
504 | # hashCode and equals need to be consistent. One can't live without another.
505 | # https://dart.dev/tools/linter-rules/hash_and_equals
506 | - hash_and_equals
507 |
508 | # DON'T import implementation files from another package.
509 | # If you need access to some internal code, create an issue
510 | # https://dart.dev/tools/linter-rules/implementation_imports
511 | - implementation_imports
512 |
513 | # Less magic is better. In fear of future Dart versions, that remove the implicit call tear off, we should start migrating now.
514 | #
515 | # Dart SDK: 2.19 • (Linter v1.29.0)
516 | #
517 | # https://dart.dev/tools/linter-rules/implicit_call_tearoffs
518 | - implicit_call_tearoffs
519 |
520 | # Only relevant for package authors
521 | #
522 | # Dart SDK: 3.0.0 • (Linter v1.35.0)
523 | #
524 | # https://dart.dev/tools/linter-rules/implicit_reopen
525 | # - implicit_reopen
526 |
527 | # Helps to migrate switch cases from Dart 2 to Dart 3
528 | #
529 | # Dart SDK: 3.0.0 • (Linter v1.34.0)
530 | #
531 | # https://dart.dev/tools/linter-rules/invalid_case_patterns
532 | - invalid_case_patterns
533 |
534 | # Prevents invalid runtime checks with JS interop types
535 | #
536 | # Dart SDK: >= 3.5.0
537 | #
538 | # https://dart.dev/tools/linter-rules/invalid_runtime_check_with_js_interop_types
539 | - invalid_runtime_check_with_js_interop_types
540 |
541 | # Hint to join return and assignment.
542 | #
543 | # https://dart.dev/tools/linter-rules/join_return_with_assignment
544 | # - join_return_with_assignment
545 |
546 | # Add leading \n which which makes multiline strings easier to read
547 | # Dart SDK: >= 2.8.0-dev.16.0 • (Linter v0.1.113)
548 | # https://dart.dev/tools/linter-rules/leading_newlines_in_multiline_strings
549 | - leading_newlines_in_multiline_strings
550 |
551 | # Library annotations must be attached to the `library` keyword
552 | #
553 | # Dart SDK: 2.19 • (Linter v1.30.0)
554 | #
555 | # https://dart.dev/tools/linter-rules/library_annotations
556 | - library_annotations
557 |
558 | # Makes sure a library name is a valid dart identifier.
559 | # This comes in handy for test files combining multiple tests where the file name can be used as identifier
560 | #
561 | # ```
562 | # import src/some_test.dart as some_test;
563 | #
564 | # main() {
565 | # some_test.main();
566 | # }
567 | # ```
568 | #
569 | # https://dart.dev/tools/linter-rules/library_names
570 | - library_names
571 |
572 | # Follow dart style
573 | #
574 | # https://dart.dev/tools/linter-rules/library_prefixes
575 | - library_prefixes
576 |
577 | # Nobody wants to manually wrap lines when changing a few words. This rule is too hard to be a "general" rule
578 | #
579 | # https://dart.dev/tools/linter-rules/lines_longer_than_80_chars
580 | # - lines_longer_than_80_chars
581 |
582 | # Good for libraries to prevent unnecessary code paths.
583 | # False positives may occur for applications when boolean properties are generated by external programs
584 | # producing auto-generated source code
585 | #
586 | # Known issue: while(true) loops https://github.com/dart-lang/linter/issues/453
587 | #
588 | #
589 | # https://dart.dev/tools/linter-rules/literal_only_boolean_expressions
590 | # - literal_only_boolean_expressions
591 |
592 | # Code blocks in documentation comments should specify a language for better readability
593 | #
594 | # Dart SDK: >= 3.4.0
595 | #
596 | # https://dart.dev/tools/linter-rules/missing_code_block_language_in_doc_comment
597 | # - missing_code_block_language_in_doc_comment
598 |
599 | # Don't forget the whitespaces at the end
600 | #
601 | # Dart SDK: >= 2.8.0-dev.10.0 • (Linter v0.1.110)
602 | #
603 | # https://dart.dev/tools/linter-rules/missing_whitespace_between_adjacent_strings
604 | - missing_whitespace_between_adjacent_strings
605 |
606 | # Concat Strings obviously with `+` inside a list.
607 | #
608 | # https://dart.dev/tools/linter-rules/no_adjacent_strings_in_list
609 | - no_adjacent_strings_in_list
610 |
611 | # Second case is basically dead code which will never be reached.
612 | #
613 | # https://dart.dev/tools/linter-rules/no_duplicate_case_values
614 | - no_duplicate_case_values
615 |
616 | # private library prefixes don't exist, don't try to introduce concepts that have no effect
617 | #
618 | # Linter v1.15
619 | # https://dart.dev/tools/linter-rules/no_leading_underscores_for_library_prefixes
620 | - no_leading_underscores_for_library_prefixes
621 |
622 | # private identifier prefixes don't exist, don't try to introduce concepts that have no effect
623 | #
624 | # Linter v1.15
625 | # https://dart.dev/tools/linter-rules/no_leading_underscores_for_local_identifiers
626 | # - no_leading_underscores_for_local_identifiers
627 |
628 | # Flutter only: `createState` shouldn't pass information into the state
629 | #
630 | # https://dart.dev/tools/linter-rules/no_logic_in_create_state
631 | # - no_logic_in_create_state
632 |
633 | # calling `runtimeType` may be a performance problem
634 | # Dart SDK: >= 2.8.0-dev.10.0 • (Linter v0.1.110)
635 | # https://dart.dev/tools/linter-rules/no_runtimeType_toString
636 | - no_runtimeType_toString
637 |
638 | # Don't assign a variable to itself.
639 | #
640 | # Dart SDK: >= 3.1.0
641 | #
642 | # https://dart.dev/tools/linter-rules/no_self_assignments
643 | - no_self_assignments
644 |
645 | # Don't use wildcard parameters or variables. Code using this will break in the future.
646 | #
647 | # Dart SDK: >= 3.1.0
648 | #
649 | # https://dart.dev/tools/linter-rules/no_wildcard_variable_uses
650 | - no_wildcard_variable_uses
651 |
652 | # Follow dart style naming conventions
653 | #
654 | # https://dart.dev/tools/linter-rules/non_constant_identifier_names
655 | - non_constant_identifier_names
656 |
657 | # Don't call unnecessary conversion methods on primitives
658 | #
659 | # Dart SDK: 2.14.0-172.0.dev • (Linter v1.5.0)
660 | #
661 | # https://dart.dev/tools/linter-rules/noop_primitive_operations
662 | - noop_primitive_operations
663 |
664 | # Generic T might have a value of String or String?. Both are valid.
665 | # This lint triggers when ! is used on T? casting (String?)? to String and not (String?)? to String?
666 | # Dart SDK: >= 2.11.0-182.0.dev • (Linter v0.1.120)
667 | # https://dart.dev/tools/linter-rules/null_check_on_nullable_type_parameter
668 | - null_check_on_nullable_type_parameter
669 |
670 | # Might become irrelevant when non-nullable types land in dart. Until then use this lint check which checks for
671 | # non-null arguments for specific dart sdk methods.
672 | #
673 | # https://dart.dev/tools/linter-rules/null_closures
674 | - null_closures
675 |
676 | # Types for local variables can improve readability and shouldn't be forced to be removed.
677 | #
678 | # Dart SDK: >= 2.0.0 • (Linter v0.1.30)
679 | #
680 | # https://dart.dev/tools/linter-rules/omit_local_variable_types
681 | # - omit_local_variable_types
682 |
683 | # Experimental: Remove type annotations for local variables when they can be obviously inferred
684 | #
685 | # Dart SDK: >= 3.5.0
686 | #
687 | # https://dart.dev/tools/linter-rules/omit_obvious_local_variable_types
688 | # - omit_obvious_local_variable_types
689 |
690 | # Humans read plain code without tooling.
691 | # Types might be obvious to the compiler, but a human not a tool should decie when to add a type.
692 | #
693 | # Dart SDK: >= 3.7.0
694 | #
695 | # https://dart.dev/tools/linter-rules/omit_obvious_property_types
696 | # - omit_obvious_property_types
697 |
698 | # Defining interfaces (abstract classes), with only one method, makes sense architecture wise
699 | # Discussion: https://github.com/passsy/dart-lint/issues/2
700 | #
701 | #
702 | # https://dart.dev/tools/linter-rules/one_member_abstracts
703 | # - one_member_abstracts
704 |
705 | # Since Errors aren't intended to be caught (see avoid_catching_errors), throwing anything
706 | # doesn't cause trouble.
707 | # https://dart.dev/tools/linter-rules/only_throw_errors
708 | # - only_throw_errors
709 |
710 | # Highlights unintentionally overridden fields.
711 | #
712 | # https://dart.dev/tools/linter-rules/overridden_fields
713 | - overridden_fields
714 |
715 | # Follow dart style package naming convention
716 | #
717 | # Dart SDK: >= 2.0.0 • (Linter v0.1.31)
718 | #
719 | # https://dart.dev/tools/linter-rules/package_names
720 | - package_names
721 |
722 | # Seems very rare, especially for applications.
723 | #
724 | # https://dart.dev/tools/linter-rules/package_prefixed_library_names
725 | - package_prefixed_library_names
726 |
727 | # Most likely a mistake, if not: bad practice
728 | #
729 | # https://dart.dev/tools/linter-rules/parameter_assignments
730 | - parameter_assignments
731 |
732 | # Is contradictory to `no_adjacent_strings_in_list`
733 | #
734 | # https://dart.dev/tools/linter-rules/prefer_adjacent_string_concatenation
735 | # - prefer_adjacent_string_concatenation
736 |
737 | # Makes it easier to migrate to const constructors and to have final fields
738 | #
739 | # https://dart.dev/tools/linter-rules/prefer_asserts_in_initializer_lists
740 | # - prefer_asserts_in_initializer_lists
741 |
742 | # Assertions blocks don't require a message because they throw simple to understand errors
743 | #
744 | # https://dart.dev/tools/linter-rules/prefer_asserts_with_message
745 | # - prefer_asserts_with_message
746 |
747 | # Collection literals are shorter. They exist, use them.
748 | #
749 | # https://dart.dev/tools/linter-rules/prefer_collection_literals
750 | - prefer_collection_literals
751 |
752 | # Use the ??= operator when possible
753 | #
754 | # https://dart.dev/tools/linter-rules/prefer_conditional_assignment
755 | # - prefer_conditional_assignment
756 |
757 | # Always use const when possible, make runtime faster
758 | #
759 | # https://dart.dev/tools/linter-rules/prefer_const_constructors
760 | # - prefer_const_constructors
761 |
762 | # Add a const constructor when possible
763 | #
764 | # https://dart.dev/tools/linter-rules/prefer_const_constructors_in_immutables
765 | # - prefer_const_constructors_in_immutables
766 |
767 | # final is good, const is better
768 | # https://dart.dev/tools/linter-rules/prefer_const_declarations
769 | # - prefer_const_declarations
770 |
771 | # Always use const when possible, make runtime faster
772 | #
773 | # https://dart.dev/tools/linter-rules/prefer_const_literals_to_create_immutables
774 | # - prefer_const_literals_to_create_immutables
775 |
776 | # Dart has named constructors. Static methods in other languages (java) are a workaround which don't have
777 | # named constructors.
778 | #
779 | # https://dart.dev/tools/linter-rules/prefer_constructors_over_static_methods
780 | # - prefer_constructors_over_static_methods
781 |
782 | # Contains may be faster and is easier to read
783 | #
784 | # https://dart.dev/tools/linter-rules/prefer_contains
785 | - prefer_contains
786 |
787 | # Use whatever makes you happy. lint doesn't define a style
788 | # Conflicts with prefer_single_quotes
789 | #
790 | # https://dart.dev/tools/linter-rules/prefer_double_quotes
791 | # - prefer_double_quotes
792 |
793 | # Single line methods + implementation makes it hard to write comments for that line.
794 | # Dense code isn't necessarily better code.
795 | #
796 | # https://dart.dev/tools/linter-rules/prefer_expression_function_bodies
797 | # - prefer_expression_function_bodies
798 |
799 | # Avoid accidental reassignments and allows the compiler to do optimizations.
800 | #
801 | # https://dart.dev/tools/linter-rules/prefer_final_fields
802 | - prefer_final_fields
803 |
804 | # Helps avoid accidental reassignments and allows the compiler to do optimizations.
805 | #
806 | # https://dart.dev/tools/linter-rules/prefer_final_in_for_each
807 | - prefer_final_in_for_each
808 |
809 | # Helps avoid accidental reassignments and allows the compiler to do optimizations.
810 | #
811 | # https://dart.dev/tools/linter-rules/prefer_final_locals
812 | - prefer_final_locals
813 |
814 | # While prefer_final_fields and prefer_final_locals is enabled, this lint would add a lot of clutter to methods,
815 | # especially lambdas.
816 | # parameter_assignments is already enabled, catching this error
817 | # Conflicts with avoid_final_parameters
818 | #
819 | # Dart SDK: 2.14.0-172.0.dev • (Linter v1.5.0)
820 | #
821 | # https://dart.dev/tools/linter-rules/prefer_final_parameters
822 | # - prefer_final_parameters
823 |
824 | # Saves a lot of code
825 | #
826 | # https://dart.dev/tools/linter-rules/prefer_for_elements_to_map_fromIterable
827 | - prefer_for_elements_to_map_fromIterable
828 |
829 | # Dense code isn't necessarily better code
830 | #
831 | # https://dart.dev/tools/linter-rules/prefer_foreach
832 | # - prefer_foreach
833 |
834 | # As Dart allows local function declarations, it is a good practice to use them in the place of function literals.
835 | # https://dart.dev/tools/linter-rules/prefer_function_declarations_over_variables
836 | - prefer_function_declarations_over_variables
837 |
838 | # For consistency
839 | #
840 | # https://dart.dev/tools/linter-rules/prefer_generic_function_type_aliases
841 | - prefer_generic_function_type_aliases
842 |
843 | # Allows potential usage of const
844 | # https://dart.dev/tools/linter-rules/prefer_if_elements_to_conditional_expressions
845 | - prefer_if_elements_to_conditional_expressions
846 |
847 | # Dart has a special operator for this, use it
848 | #
849 | # https://dart.dev/tools/linter-rules/prefer_if_null_operators
850 | - prefer_if_null_operators
851 |
852 | # Terser code
853 | # https://dart.dev/tools/linter-rules/prefer_initializing_formals
854 | # - prefer_initializing_formals
855 |
856 | # Easier move towards const, and way easier to read
857 | #
858 | # https://dart.dev/tools/linter-rules/prefer_inlined_adds
859 | # - prefer_inlined_adds
860 |
861 | # There is no argument which makes int literals better than double literals for doubles.
862 | #
863 | # https://dart.dev/tools/linter-rules/prefer_int_literals
864 | # - prefer_int_literals
865 |
866 | # Interpolate, use less "", '' and +
867 | # https://dart.dev/tools/linter-rules/prefer_interpolation_to_compose_strings
868 | - prefer_interpolation_to_compose_strings
869 |
870 | # Iterables do not necessary know their length
871 | #
872 | # https://dart.dev/tools/linter-rules/prefer_is_empty
873 | - prefer_is_empty
874 |
875 | # Easier to read
876 | #
877 | # Dart SDK: >= 2.0.0 • (Linter v0.1.5)
878 | #
879 | # https://dart.dev/tools/linter-rules/prefer_is_not_empty
880 | - prefer_is_not_empty
881 |
882 | # Use the `foo is! Foo` instead of `!(foo is Foo)`
883 | # https://dart.dev/tools/linter-rules/prefer_is_not_operator
884 | - prefer_is_not_operator
885 |
886 | # Easier to read
887 | #
888 | # https://dart.dev/tools/linter-rules/prefer_iterable_whereType
889 | - prefer_iterable_whereType
890 |
891 | # Users of a 3rd party mixins can't change 3rd party code to use the mixin syntax.
892 | # This makes the rule useless
893 | # https://dart.dev/tools/linter-rules/prefer_mixin
894 | # - prefer_mixin
895 |
896 | # It's shorter and should be preferred. Especially helpful for devs new to dart.
897 | #
898 | # Dart SDK: 2.14.0-2.0.dev • (Linter v1.3.0)
899 | #
900 | # https://dart.dev/tools/linter-rules/prefer_null_aware_method_calls
901 | - prefer_null_aware_method_calls
902 |
903 | # Makes expressions with null checks easier to read.
904 | # https://github.com/flutter/flutter/pull/32711#issuecomment-492930932
905 | - prefer_null_aware_operators
906 |
907 | # Conflicting with `avoid_relative_lib_imports` which is enforced
908 | # https://dart.dev/tools/linter-rules/prefer_relative_imports
909 | # - prefer_relative_imports
910 |
911 | # Use whatever makes you happy. lint doesn't define a style
912 | # Conflicts with prefer_double_quotes
913 | #
914 | # https://dart.dev/tools/linter-rules/prefer_single_quotes
915 | # - prefer_single_quotes
916 |
917 | # Allows potential usage of const
918 | #
919 | # https://dart.dev/tools/linter-rules/prefer_spread_collections
920 | - prefer_spread_collections
921 |
922 | # Define types
923 | #
924 | # https://dart.dev/tools/linter-rules/prefer_typing_uninitialized_variables
925 | - prefer_typing_uninitialized_variables
926 |
927 | # Null is not a type, use void
928 | # https://dart.dev/tools/linter-rules/prefer_void_to_null
929 | - prefer_void_to_null
930 |
931 | # Document the replacement API
932 | # https://dart.dev/tools/linter-rules/provide_deprecation_message
933 | - provide_deprecation_message
934 |
935 | # Definitely not a rule for standard dart code. Maybe relevant for packages
936 | # https://dart.dev/tools/linter-rules/public_member_api_docs
937 | # - public_member_api_docs
938 |
939 | # Hints accidental recursions
940 | #
941 | # https://dart.dev/tools/linter-rules/recursive_getters
942 | - recursive_getters
943 |
944 | # Dartfmt formats differently when adding trailing commas. This lint makes sure there is zero doubt in how code
945 | # should be formatted.
946 | #
947 | # Removed for Dart 3.7 because dart now formats differently, compared to this rule (removes some commas)
948 | #
949 | # This rule is debatable, though.
950 | # A non-representative [vote](https://twitter.com/passsy/status/1427220769050972162) shows a strong tendency towards
951 | # enabling this rule. Especially because the code example does only include the debatable formatting changes. There
952 | # are more, especially in Flutter build methods which make the code clearly better.
953 | #
954 | # Dart SDK: 2.14.0-2.0.dev • (Linter v1.3.0)
955 | #
956 | # https://dart.dev/tools/linter-rules/require_trailing_commas
957 | # - require_trailing_commas
958 |
959 | # Use https in pubspec.yaml
960 | #
961 | # Linter v1.15
962 | # https://dart.dev/tools/linter-rules/secure_pubspec_urls
963 | - secure_pubspec_urls
964 |
965 | # Flutter only, prefer SizedBox over Container which offers a const constructors
966 | # Dart SDK: >= 2.9.0-4.0.dev • (Linter v0.1.115)
967 | # https://dart.dev/tools/linter-rules/sized_box_for_whitespace
968 | # - sized_box_for_whitespace
969 |
970 | # Use the SizeBox.expand or SizeBox.shrink constructor instead of setting both width and height
971 | # to `0` or `double.infinity`
972 | #
973 | # Linter v1.15
974 | # https://dart.dev/tools/linter-rules/sized_box_shrink_expand
975 | - sized_box_shrink_expand
976 |
977 | # Follow dart style use triple slashes
978 | #
979 | # https://dart.dev/tools/linter-rules/slash_for_doc_comments
980 | - slash_for_doc_comments
981 |
982 | # Flutter only, always put child last
983 | #
984 | # https://dart.dev/tools/linter-rules/sort_child_properties_last
985 | # - sort_child_properties_last
986 |
987 | # Working, results in consistent code. But too opinionated
988 | # Discussion: https://github.com/passsy/dart-lint/issues/1
989 | #
990 | #
991 | # https://dart.dev/tools/linter-rules/sort_constructors_first
992 | # - sort_constructors_first
993 |
994 | # Any sorting is better than no sorting
995 | # https://dart.dev/tools/linter-rules/sort_pub_dependencies
996 | # - sort_pub_dependencies
997 |
998 | # Default constructor comes first.
999 | #
1000 | # https://dart.dev/tools/linter-rules/sort_unnamed_constructors_first
1001 | # - sort_unnamed_constructors_first
1002 |
1003 | # Never forget a return or variable type!
1004 | #
1005 | # Dart SDK: >= 3.7.0
1006 | #
1007 | # https://dart.dev/tools/linter-rules/strict_top_level_inference
1008 | - strict_top_level_inference
1009 |
1010 | # This rule is too opinionated and doesn't have a clear benefit
1011 | # The complexity of what "obvious" means is too high
1012 | #
1013 | # Dart SDK: >= 3.5.0
1014 | #
1015 | # https://dart.dev/tools/linter-rules/specify_nonobvious_local_variable_types
1016 | # - specify_nonobvious_local_variable_types
1017 |
1018 | # Useful, but often too agressive
1019 | #
1020 | # ```dart
1021 | # final _formKey = GlobalKey(); // warning
1022 | # final GlobalKey _formKey = GlobalKey(); // ok
1023 | #
1024 | # final animationCurve = Curves.easeOut; // warning
1025 | # final Curve animationCurve = Curves.easeOut; // ok
1026 | # ```
1027 | #
1028 | # Dart SDK: >= 3.7.0
1029 | #
1030 | # https://dart.dev/tools/linter-rules/specify_nonobvious_property_types
1031 | # - specify_nonobvious_property_types
1032 |
1033 | # First test, then cast
1034 | #
1035 | # https://dart.dev/tools/linter-rules/test_types_in_equals
1036 | - test_types_in_equals
1037 |
1038 | # Hard to debug and bad style
1039 | #
1040 | # https://dart.dev/tools/linter-rules/throw_in_finally
1041 | - throw_in_finally
1042 |
1043 | # Help the compiler at compile time with non-null asserts rather than crashing at runtime
1044 | #
1045 | # Dart SDK: >= 2.11.0-182.0.dev • (Linter v0.1.120)
1046 | # https://dart.dev/tools/linter-rules/tighten_type_of_initializing_formals
1047 | - tighten_type_of_initializing_formals
1048 |
1049 | # Type annotations make the compiler intelligent, use them
1050 | # https://dart.dev/tools/linter-rules/type_annotate_public_apis
1051 | - type_annotate_public_apis
1052 |
1053 | # Don't add types for already typed constructor parameters.
1054 | #
1055 | # https://dart.dev/tools/linter-rules/type_init_formals
1056 | # - type_init_formals
1057 |
1058 | # Catches type matches that look correct but actually don't match
1059 | #
1060 | # Dart SDK: Dart 3.0.0 • (Linter v1.35.0)
1061 | #
1062 | # https://dart.dev/tools/linter-rules/type_literal_in_constant_pattern
1063 | - type_literal_in_constant_pattern
1064 |
1065 | # Unclear which unawaited function to use
1066 | #
1067 | # https://dart.dev/tools/linter-rules/unawaited_futures
1068 | # - unawaited_futures
1069 |
1070 | # No await? No async!
1071 | #
1072 | # Dart SDK: >= 3.7.0
1073 | #
1074 | # https://dart.dev/tools/linter-rules/unnecessary_async
1075 | - unnecessary_async
1076 |
1077 | # Replace `return await future;` with `return future;`
1078 | #
1079 | # This check causes false positives in try-catch blocks, where removing await would not catch the exception anymore
1080 | # https://github.com/dart-lang/linter/issues/2357
1081 | # https://github.com/dart-lang/linter/issues/2250
1082 | #
1083 | # https://dart.dev/tools/linter-rules/unnecessary_await_in_return
1084 | # - unnecessary_await_in_return
1085 |
1086 | # Remove unnecessary braces
1087 | #
1088 | # https://dart.dev/tools/linter-rules/unnecessary_brace_in_string_interps
1089 | # - unnecessary_brace_in_string_interps
1090 |
1091 | # switch case works now finally without `break;`
1092 | #
1093 | # Dart SDK: 3.0.0 • (Linter v1.33.0)
1094 | #
1095 | # https://dart.dev/tools/linter-rules/unnecessary_breaks
1096 | - unnecessary_breaks
1097 |
1098 | # Yes, const everywhere. But not in an already const scope
1099 | #
1100 | # https://dart.dev/tools/linter-rules/unnecessary_const
1101 | # - unnecessary_const
1102 |
1103 | # Disabled because `final` prevents accidental reassignment
1104 | # https://dart.dev/tools/linter-rules/unnecessary_final
1105 | # - unnecessary_final
1106 |
1107 | # Getter/setters can be added later on in a non API breaking manner
1108 | #
1109 | # https://dart.dev/tools/linter-rules/unnecessary_getters_setters
1110 | # - unnecessary_getters_setters
1111 |
1112 | # Flutter setState is a good example where a lambda should always be used.
1113 | # https://github.com/dart-lang/linter/issues/498
1114 | #
1115 | # Some generic code sometimes requires lambdas, otherwise the generic type isn't forwarded correctly.
1116 | #
1117 | # https://dart.dev/tools/linter-rules/unnecessary_lambdas
1118 | # - unnecessary_lambdas
1119 |
1120 | # Top-level and static variables with initializers are already evaluated lazily as if they are marked late
1121 | #
1122 | # Linter v1.17
1123 | # https://dart.dev/tools/linter-rules/unnecessary_late
1124 | - unnecessary_late
1125 |
1126 | # New library syntax, time to migrate
1127 | #
1128 | # Dart SDK: 2.19.0 • (Linter v1.29.0)
1129 | #
1130 | # https://dart.dev/tools/linter-rules/unnecessary_library_directive
1131 | - unnecessary_library_directive
1132 |
1133 | # Don't use unnecessary library names
1134 | #
1135 | # Dart SDK: >= 3.4.0
1136 | #
1137 | # https://dart.dev/tools/linter-rules/unnecessary_library_name
1138 | # - unnecessary_library_name
1139 |
1140 | # Remove the optional `new` keyword
1141 | #
1142 | # https://dart.dev/tools/linter-rules/unnecessary_new
1143 | - unnecessary_new
1144 |
1145 | # Don't assign `null` when value is already `null`.
1146 | #
1147 | # https://dart.dev/tools/linter-rules/unnecessary_null_aware_assignments
1148 | - unnecessary_null_aware_assignments
1149 |
1150 | # Unnecessary `?.` when the extension is on type `T?`
1151 | #
1152 | # Dart SDK: >= 2.18.0 • (Linter v1.24.0)
1153 | #
1154 | # https://dart.dev/tools/linter-rules/unnecessary_null_aware_operator_on_extension_on_nullable
1155 | - unnecessary_null_aware_operator_on_extension_on_nullable
1156 |
1157 | # Remove ! when already non-nullable
1158 | # Dart SDK: >= 2.10.0-144.0.dev • (Linter v0.1.119)
1159 | # https://dart.dev/tools/linter-rules/unnecessary_null_checks
1160 | - unnecessary_null_checks
1161 |
1162 | # Don't assign `null` when value is already `null`.
1163 | #
1164 | # https://dart.dev/tools/linter-rules/unnecessary_null_in_if_null_operators
1165 | - unnecessary_null_in_if_null_operators
1166 |
1167 | # If a variable doesn't change and is initialized, no need to define it as nullable (NNBD)
1168 | # Dart SDK: >= 2.10.0-10.0.dev • (Linter v0.1.118)
1169 | # https://dart.dev/tools/linter-rules/unnecessary_nullable_for_final_variable_declarations
1170 | - unnecessary_nullable_for_final_variable_declarations
1171 |
1172 | # Remove overrides which simply call super
1173 | # https://dart.dev/tools/linter-rules/unnecessary_overrides
1174 | - unnecessary_overrides
1175 |
1176 | # Remove clutter where possible
1177 | # https://dart.dev/tools/linter-rules/unnecessary_parenthesis
1178 | - unnecessary_parenthesis
1179 |
1180 | # Use raw string only when needed
1181 | # Dart SDK: >= 2.8.0-dev.11.0 • (Linter v0.1.111)
1182 | # https://dart.dev/tools/linter-rules/unnecessary_raw_strings
1183 | - unnecessary_raw_strings
1184 |
1185 | # Avoid magic overloads of + operators
1186 | # https://dart.dev/tools/linter-rules/unnecessary_statements
1187 | - unnecessary_statements
1188 |
1189 | # Remove unnecessary escape characters
1190 | # Dart SDK: >= 2.8.0-dev.11.0 • (Linter v0.1.111)
1191 | # https://dart.dev/tools/linter-rules/unnecessary_string_escapes
1192 | - unnecessary_string_escapes
1193 |
1194 | # Completely unnecessary code, simplify to save a few CPU cycles
1195 | #
1196 | # Dart SDK: >= 2.8.0-dev.10.0 • (Linter v0.1.110)
1197 | #
1198 | # https://dart.dev/tools/linter-rules/unnecessary_string_interpolations
1199 | - unnecessary_string_interpolations
1200 |
1201 | # The variable is clear, remove clutter
1202 | #
1203 | # https://dart.dev/tools/linter-rules/unnecessary_this
1204 | - unnecessary_this
1205 |
1206 | # toList() is not required when an Iterable is expected
1207 | #
1208 | # Dart SDK: >= 2.18.0 • (Linter v1.24.0)
1209 | #
1210 | # https://dart.dev/tools/linter-rules/unnecessary_to_list_in_spreads
1211 | - unnecessary_to_list_in_spreads
1212 |
1213 | # Due to the wildcard variables language feature in Dart 3.7, multiple parameters can now be called _
1214 | #
1215 | # Dart SDK: >= 3.7.0
1216 | #
1217 | # https://dart.dev/tools/linter-rules/unnecessary_underscores
1218 | - unnecessary_underscores
1219 |
1220 | # Prevents unintended HTML in doc comments which could cause rendering issues
1221 | #
1222 | # Dart SDK: >= 3.5.0
1223 | #
1224 | # https://dart.dev/tools/linter-rules/unintended_html_in_doc_comment
1225 | - unintended_html_in_doc_comment
1226 |
1227 | # It's just unused code, nothing to worry about
1228 | #
1229 | # Linter v1.28.0
1230 | # https://dart.dev/tools/linter-rules/unreachable_from_main
1231 | # - unreachable_from_main
1232 |
1233 | # Highlights potential bugs where unrelated types are compared with another. (always *not* equal).
1234 | #
1235 | # https://dart.dev/tools/linter-rules/unrelated_type_equality_checks
1236 | - unrelated_type_equality_checks
1237 |
1238 | # In most cases, using T is just fine, unless T is a base class.
1239 | # The workaround is quite complex and not worth applying, unless runtime errors appear.
1240 | #
1241 | # Dart SDK: >= 3.7.0
1242 | #
1243 | # https://dart.dev/tools/linter-rules/unsafe_variance
1244 | # - unsafe_variance
1245 |
1246 | # Very useful in preventing Flutter BuildContext bugs in async callbacks
1247 | #
1248 | # Dart SDK: 2.13.0 • (Linter v1.1.0)
1249 | #
1250 | # https://dart.dev/tools/linter-rules/use_build_context_synchronously
1251 | - use_build_context_synchronously
1252 |
1253 | # Replace Container with ColoredBox to be able to use the const constructor
1254 | #
1255 | # Linter v1.19.1
1256 | # https://dart.dev/tools/linter-rules/use_colored_box
1257 | # - use_colored_box
1258 |
1259 | # DecoratedBox is not a replacement for Container https://github.com/dart-lang/linter/issues/3286
1260 | #
1261 | # Linter v1.15
1262 | # https://dart.dev/tools/linter-rules/use_decorated_box
1263 | # - use_decorated_box
1264 |
1265 | # Use the [Enhanced Enum Classes](https://github.com/dart-lang/language/blob/master/accepted/future-releases/enhanced-enums/feature-specification.md) feature instead of classes with static members.
1266 | #
1267 | # This check is very precise, it's rather unlikely to have false positives.
1268 | #
1269 | # Linter v1.19.1
1270 | # https://dart.dev/tools/linter-rules/use_enums
1271 | - use_enums
1272 |
1273 | # Always use hex syntax Color(0x00000001), never Color(1)
1274 | #
1275 | # https://dart.dev/tools/linter-rules/use_full_hex_values_for_flutter_colors
1276 | - use_full_hex_values_for_flutter_colors
1277 |
1278 | # Always use generic function type syntax, don't mix styles
1279 | #
1280 | # https://dart.dev/tools/linter-rules/use_function_type_syntax_for_parameters
1281 | - use_function_type_syntax_for_parameters
1282 |
1283 | # Don't use the modulo operator for isEven/isOdd checks
1284 | #
1285 | # Linter v0.1.116
1286 | # https://dart.dev/tools/linter-rules/use_is_even_rather_than_modulo
1287 | # - use_is_even_rather_than_modulo
1288 |
1289 | # Write `if (nullableBool ?? false)` instead of `if (nullableBool == true)`
1290 | # Not enabled, because `nullableBool == true` is very explicit, whereas `nullableBool ?? false` requires
1291 | # cognitive effort to process
1292 | #
1293 | # Dart SDK: 2.13.0 • (Linter v1.0.0)
1294 | #
1295 | # https://dart.dev/tools/linter-rules/use_if_null_to_convert_nulls_to_bools
1296 | # - use_if_null_to_convert_nulls_to_bools
1297 |
1298 | # Replace const values with predefined constants
1299 | # `const Duration(seconds: 0)` -> `Duration.zero`
1300 | #
1301 | # Dart SDK: 2.13.0 • (Linter v1.0.0)
1302 | #
1303 | # https://dart.dev/tools/linter-rules/use_named_constants
1304 | - use_named_constants
1305 |
1306 | # Adding a key without using it isn't helpful in applications, only for the Flutter SDK
1307 | # https://github.com/dart-lang/linter/issues/3384
1308 | #
1309 | # Dart SDK: >= 2.8.0-dev.1.0 • (Linter v0.1.108)
1310 | # https://dart.dev/tools/linter-rules/use_key_in_widget_constructors
1311 | # - use_key_in_widget_constructors
1312 |
1313 | # Some might argue `late` is a code smell, this lint is very opinionated. It triggers only for private fields and
1314 | # therefore might actually clean up some code.
1315 | # There is no performance impact either way https://github.com/dart-lang/linter/pull/2189#discussion_r457945301
1316 | #
1317 | # Dart SDK: >= 2.10.0-10.0.dev • (Linter v0.1.118)
1318 | #
1319 | # https://dart.dev/tools/linter-rules/use_late_for_private_fields_and_variables
1320 | # - use_late_for_private_fields_and_variables
1321 |
1322 | # Use rethrow to preserve the original stacktrace.
1323 | # https://dart.dev/guides/language/effective-dart/usage#do-use-rethrow-to-rethrow-a-caught-exception
1324 | #
1325 | # Dart SDK: >= 2.0.0 • (Linter v0.1.31)
1326 | #
1327 | # https://dart.dev/tools/linter-rules/use_rethrow_when_possible
1328 | - use_rethrow_when_possible
1329 |
1330 | # Use the setter syntax
1331 | #
1332 | # https://dart.dev/tools/linter-rules/use_setters_to_change_properties
1333 | - use_setters_to_change_properties
1334 |
1335 | # In most cases, using a string buffer is preferred for composing strings due to its improved performance.
1336 | # https://dart.dev/tools/linter-rules/use_string_buffers
1337 | - use_string_buffers
1338 |
1339 | # Library names are a legacy feature and discouraged https://dart.dev/guides/language/effective-dart/style#dont-explicitly-name-libraries
1340 | #
1341 | # Linter v1.27.0
1342 | # https://dart.dev/tools/linter-rules/use_string_in_part_of_directives
1343 | - use_string_in_part_of_directives
1344 |
1345 | # More concise and easier to read constructors.
1346 | #
1347 | # Especially helps not to repeat default parameters, which will not update when they change in the super constructor.
1348 | #
1349 | # Linter v1.20
1350 | # https://dart.dev/tools/linter-rules/use_super_parameters
1351 | - use_super_parameters
1352 |
1353 | # Don't use try-catch with fail(), instead catch the error with the `throwsA` matcher. The big advantage:
1354 | # When another error is thrown, the assertion fails whereas catching a specific error would miss the catch block
1355 | #
1356 | # Dart SDK: 2.14.0-172.0.dev • (Linter v1.5.0)
1357 | #
1358 | # https://dart.dev/tools/linter-rules/use_test_throws_matchers
1359 | - use_test_throws_matchers
1360 |
1361 | # Use the truncating division operator (~/) for integer division
1362 | #
1363 | # Dart SDK: >= 3.5.0
1364 | #
1365 | # https://dart.dev/tools/linter-rules/use_truncating_division
1366 | # - use_truncating_division
1367 |
1368 | # Naming is hard, strict rules don't help
1369 | #
1370 | # https://dart.dev/tools/linter-rules/use_to_and_as_if_applicable
1371 | # - use_to_and_as_if_applicable
1372 |
1373 | # Catches invalid regular expressions.
1374 | #
1375 | # https://dart.dev/tools/linter-rules/valid_regexps
1376 | - valid_regexps
1377 |
1378 | # Don't assign anything to void
1379 | # https://dart.dev/tools/linter-rules/void_checks
1380 | - void_checks
1381 |
--------------------------------------------------------------------------------
/lib/package.yaml:
--------------------------------------------------------------------------------
1 | ##
2 | # Lint rules to be used for packages, which provide a dart API for developers
3 | ##
4 |
5 | include: package:lint/analysis_options.yaml
6 |
7 | # Lint rules and documentation, see https://dart.dev/tools/linter-rules
8 | linter:
9 | rules:
10 |
11 | # Make sure reopening is intentional with @reopen
12 | #
13 | # Dart SDK: 3.0.0 • (Linter v1.35.0)
14 | #
15 | # https://dart.dev/tools/linter-rules/implicit_reopen
16 | - implicit_reopen
17 |
18 | # Make sure the public API is complete
19 | #
20 | # Linter v1.3
21 | # https://dart.dev/tools/linter-rules/library_private_types_in_public_api
22 | - library_private_types_in_public_api
23 |
24 | # Good for libraries to prevent unnecessary code paths.
25 | # Dart SDK: >= 2.0.0 • (Linter v0.1.25)
26 | # https://dart.dev/tools/linter-rules/literal_only_boolean_expressions
27 | - literal_only_boolean_expressions
28 |
29 | # Too strict. Implementing all exported public APIs (`package_api_docs`) is enough.
30 | # Dart SDK: >= 2.0.0 • (Linter v0.1.11)
31 | # https://dart.dev/tools/linter-rules/public_member_api_docs
32 | # - public_member_api_docs
33 |
34 | # Adding a key without using it isn't helpful in applications, only for the Flutter SDK
35 | # Dart SDK: >= 2.8.0-dev.1.0 • (Linter v0.1.108)
36 | # https://dart.dev/tools/linter-rules/use_key_in_widget_constructors
37 | - use_key_in_widget_constructors
38 |
--------------------------------------------------------------------------------
/lib/strict.yaml:
--------------------------------------------------------------------------------
1 | ##
2 | # A strict set of lint rules
3 | #
4 | # strict should be used apps without developer facing API. i.e. Flutter applications or CLIs.
5 | # For packages, use `include: package:lint/package.yaml` instead.
6 | ##
7 |
8 | analyzer:
9 | language:
10 | strict-casts: true
11 |
12 | errors:
13 | # treat missing required parameters as an error (not a hint)
14 | missing_required_param: error
15 |
16 | # treat missing returns as an error (not a hint)
17 | missing_return: error
18 |
19 | # allow having TODOs in code
20 | todo: ignore
21 |
22 | # Reassignment should be treated as warning (not a hint)
23 | parameter_assignments: warning
24 |
25 | exclude:
26 | # Generated for Flutter web apps. Since it is auto-generated, errors should be ignored
27 | - lib/generated_plugin_registrant.dart
28 |
29 | # Rules are in the same order (alphabetically) as documented at https://dart.dev/tools/linter-rules
30 | # and https://github.com/dart-lang/linter/blob/master/example/all.yaml
31 | linter:
32 | rules:
33 | # Prevents accidental return type changes which results in a breaking API change.
34 | # Enforcing return type makes API changes visible in a diff
35 | #
36 | # https://dart.dev/tools/linter-rules/always_declare_return_types
37 | - always_declare_return_types
38 |
39 | # Single line `if`s are fine as recommended in Effective Dart "DO format your code using dartfmt"
40 | #
41 | # https://dart.dev/tools/linter-rules/always_put_control_body_on_new_line
42 | # - always_put_control_body_on_new_line
43 |
44 | # Flutter widgets always put a Key as first optional parameter which breaks this rule.
45 | # Also violates other orderings like matching the class fields or alphabetically.
46 | #
47 | # https://dart.dev/tools/linter-rules/always_declare_return_types
48 | # - always_put_required_named_parameters_first
49 |
50 | # Always use package: imports.
51 | # While both, relative and package imports are fine, package imports are preferred because they allow for easy find
52 | # and replace
53 | # Conflicting with: prefer_relative_imports, avoid_relative_lib_imports
54 | #
55 | # Dart SDK: >= 2.10.0-10.0.dev • (Linter v0.1.118)
56 | # https://dart.dev/tools/linter-rules/always_use_package_imports
57 | - always_use_package_imports
58 |
59 | # Since dart 2.0 dart is a sound language, specifying types is not required anymore.
60 | # `var foo = 10;` is enough information for the compiler to make foo an int.
61 | # Violates Effective Dart "AVOID type annotating initialized local variables".
62 | # Makes code unnecessarily complex https://github.com/dart-lang/linter/issues/1620
63 | #
64 | # This convention is used in the Flutter repository
65 | #
66 | # Dart SDK: >= 2.0.0 • (Linter v0.1.4)
67 | #
68 | # https://dart.dev/tools/linter-rules/always_specify_types
69 | # - always_specify_types
70 |
71 | # Protect against unintentionally overriding superclass members
72 | #
73 | # https://dart.dev/tools/linter-rules/annotate_overrides
74 | - annotate_overrides
75 |
76 | # Annotate redeclared members. Experimental.
77 | #
78 | # Dart SDK: >= 3.2.0
79 | #
80 | # https://dart.dev/tools/linter-rules/annotate_redeclares
81 | - annotate_redeclares
82 |
83 | # All methods should define a return type. dynamic is no exception.
84 | # Violates Effective Dart "PREFER annotating with dynamic instead of letting inference fail"
85 | #
86 | # https://dart.dev/tools/linter-rules/avoid_annotating_with_dynamic
87 | # - avoid_annotating_with_dynamic
88 |
89 | # A leftover from dart1, should be deprecated
90 | #
91 | # - https://github.com/dart-lang/linter/issues/1401
92 | # https://dart.dev/tools/linter-rules/avoid_as
93 | # - avoid_as
94 |
95 | # Highlights boolean expressions which can be simplified
96 | #
97 | # https://dart.dev/tools/linter-rules/avoid_bool_literals_in_conditional_expressions
98 | - avoid_bool_literals_in_conditional_expressions
99 |
100 | # There are no strong arguments to enable this rule because it is very strict. Catching anything is useful
101 | # and common even if not always the most correct thing to do.
102 | #
103 | # https://dart.dev/tools/linter-rules/avoid_catches_without_on_clauses
104 | # - avoid_catches_without_on_clauses
105 |
106 | # Errors aren't for catching but to prevent prior to runtime
107 | #
108 | # https://dart.dev/tools/linter-rules/avoid_catching_errors
109 | - avoid_catching_errors
110 |
111 | # Can usually be replaced with an extension
112 | #
113 | # Dart SDK: >= 2.0.0 • (Linter v0.1.31)
114 | #
115 | # https://dart.dev/tools/linter-rules/avoid_classes_with_only_static_members
116 | - avoid_classes_with_only_static_members
117 |
118 | # Never accidentally use dynamic invocations, as it makes type error very hard to find
119 | #
120 | # Dart SDK: unreleased • (Linter v1.0)
121 | # https://dart.dev/tools/linter-rules/avoid_dynamic_calls
122 | - avoid_dynamic_calls
123 |
124 | # Since all dart code may be compiled to JS this should be considered.
125 | # Disable it manually when you're explicitly not targeting web
126 | #
127 | # https://dart.dev/tools/linter-rules/avoid_double_and_int_checks
128 | - avoid_double_and_int_checks
129 |
130 | # Prevents accidental empty else cases. See samples in documentation
131 | #
132 | # https://dart.dev/tools/linter-rules/avoid_empty_else
133 | - avoid_empty_else
134 |
135 | # Avoid using FutureOr because the synchronous type void makes no sense since it can't be assigned to a variable
136 | #
137 | # Definitly never use it as return type of a function.
138 | #
139 | # Exception: It is ok to use it as parameter (also constructor parameter) to accept both a synchronous and asynchronous callback for flexability in API design
140 | #
141 | # ```
142 | # void executeTask(FutureOr Function() task) async { // ok
143 | # await task();
144 | # }
145 | #
146 | # void main() {
147 | # executeTask(() => print('Sync task')); // sync is allowed
148 | # executeTask(() async => await Future.delayed(Duration(seconds: 1), () => print('Async task'))); // will be awaited
149 | # }
150 | # ```
151 | #
152 | # See discusson at https://github.com/dart-lang/sdk/issues/59232
153 | #
154 | # Dart SDK: >= 3.5.0
155 | #
156 | # https://dart.dev/tools/linter-rules/avoid_futureor_void
157 | - avoid_futureor_void
158 |
159 | # It is expected that mutable objects which override hash & equals shouldn't be used as keys for hashmaps.
160 | # This one use case doesn't make all hash & equals implementations for mutable classes bad.
161 | #
162 | # https://dart.dev/tools/linter-rules/avoid_equals_and_hash_code_on_mutable_classes
163 | # - avoid_equals_and_hash_code_on_mutable_classes
164 |
165 | # Use different quotes instead of escaping
166 | # Dart SDK: >= 2.8.0-dev.11.0 • (Linter v0.1.111)
167 | # https://dart.dev/tools/linter-rules/avoid_escaping_inner_quotes
168 | - avoid_escaping_inner_quotes
169 |
170 | # Prevents unnecessary allocation of a field
171 | #
172 | # https://dart.dev/tools/linter-rules/avoid_field_initializers_in_const_classes
173 | - avoid_field_initializers_in_const_classes
174 |
175 | # Since lint `parameter_assignments` is enabled, the final parameter doesn't add more safety, it would be just verbose
176 | # Conflicts with prefer_final_parameters
177 | #
178 | # https://dart.dev/tools/linter-rules/avoid_final_parameters
179 | - avoid_final_parameters
180 |
181 | # Prevents allocating a lambda and allows return/break/continue control flow statements inside the loop
182 | #
183 | # Dart SDK: >= 2.0.0 • (Linter v0.1.30)
184 | #
185 | # https://dart.dev/tools/linter-rules/avoid_function_literals_in_foreach_calls
186 | - avoid_function_literals_in_foreach_calls
187 |
188 | # Don't break value types by implementing them
189 | # https://dart.dev/tools/linter-rules/avoid_implementing_value_types
190 | - avoid_implementing_value_types
191 |
192 | # Removes redundant `= null;`
193 | # https://dart.dev/tools/linter-rules/avoid_init_to_null
194 | - avoid_init_to_null
195 |
196 | # Only useful when targeting JS
197 | # Warns about too large integers when compiling to JS
198 | #
199 | # https://dart.dev/tools/linter-rules/avoid_js_rounded_ints
200 | # - avoid_js_rounded_ints
201 |
202 | # Not useful for coding golf, but in every environment where code is maintained by multiple authors.
203 | #
204 | # Dart SDK: 2.13.0 • (Linter v1.1.0)
205 | #
206 | # https://dart.dev/tools/linter-rules/avoid_multiple_declarations_per_line
207 | - avoid_multiple_declarations_per_line
208 |
209 | # Causes false-positives for callbacks and functional interfaces such as
210 | #
211 | # ```dart
212 | # final void Function(bool value)? onChanged;
213 | # ```
214 | #
215 | # https://dart.dev/tools/linter-rules/avoid_positional_boolean_parameters
216 | # - avoid_positional_boolean_parameters
217 |
218 | # Don't call print in production code
219 | #
220 | # https://dart.dev/tools/linter-rules/avoid_print
221 | - avoid_print
222 |
223 | # Always prefer function references over typedefs.
224 | # Jumping twice in code to see the signature of a lambda sucks. This is different from the flutter analysis_options
225 | # https://dart.dev/tools/linter-rules/avoid_private_typedef_functions
226 | - avoid_private_typedef_functions
227 |
228 | # Don't explicitly set defaults
229 | #
230 | # Dart SDK: >= 2.8.0-dev.1.0 • (Linter v0.1.107)
231 | # https://dart.dev/tools/linter-rules/avoid_redundant_argument_values
232 | - avoid_redundant_argument_values
233 |
234 | # package or relative? Let's end the discussion and use package everywhere.
235 | #
236 | # https://dart.dev/tools/linter-rules/avoid_relative_lib_imports
237 | - avoid_relative_lib_imports
238 |
239 | # It's definitely not recommended to break dartdoc but besides that there is no reason to inherit a bad named parameter
240 | # https://dart.dev/tools/linter-rules/avoid_renaming_method_parameters
241 | # - avoid_renaming_method_parameters
242 |
243 | # Setters always return void, therefore defining void is redundant
244 | #
245 | # https://dart.dev/tools/linter-rules/avoid_return_types_on_setters
246 | - avoid_return_types_on_setters
247 |
248 | # Use empty returns, don't show off with your knowledge about dart internals.
249 | # https://dart.dev/tools/linter-rules/avoid_returning_null_for_void
250 | - avoid_returning_null_for_void
251 |
252 | # Hinting you forgot about the cascade operator. But too often you did this on purpose.
253 | # There are plenty of valid reasons to return this.
254 | #
255 | # https://dart.dev/tools/linter-rules/avoid_returning_this
256 | # - avoid_returning_this
257 |
258 | # Prevents logical inconsistencies. It's good practice to define getters for all existing setters.
259 | # https://dart.dev/tools/linter-rules/avoid_setters_without_getters
260 | - avoid_setters_without_getters
261 |
262 | # Don't reuse a type parameter when on with the same name already exists in the same scope
263 | #
264 | # https://dart.dev/tools/linter-rules/avoid_shadowing_type_parameters
265 | - avoid_shadowing_type_parameters
266 |
267 | # A single cascade operator can be replaced with a normal method call
268 | #
269 | # https://dart.dev/tools/linter-rules/avoid_single_cascade_in_expression_statements
270 | - avoid_single_cascade_in_expression_statements
271 |
272 | # Might cause frame drops because of synchronous file access on mobile, especially on older phones with slow storage.
273 | # There are no known measurements sync access does *not* drop frames.
274 | #
275 | # https://dart.dev/tools/linter-rules/avoid_slow_async_io
276 | # - avoid_slow_async_io
277 |
278 | # Don't use .toString() in production code which might be minified
279 | # Dart SDK: >= 2.10.0-144.0.dev • (Linter v0.1.119)
280 | # https://dart.dev/tools/linter-rules/avoid_type_to_string
281 | - avoid_type_to_string
282 |
283 | # Don't use a parameter names which can be confused with a types (i.e. int, bool, num, ...)
284 | #
285 | # https://dart.dev/tools/linter-rules/avoid_types_as_parameter_names
286 | - avoid_types_as_parameter_names
287 |
288 | # Adding the type is not required, but sometimes improves readability. Therefore, removing it doesn't always help
289 | # https://dart.dev/tools/linter-rules/avoid_types_on_closure_parameters
290 | # - avoid_types_on_closure_parameters
291 |
292 | # Containers without parameters have no effect and can be removed
293 | # https://dart.dev/tools/linter-rules/avoid_unnecessary_containers
294 | - avoid_unnecessary_containers
295 |
296 | # Unused parameters should be removed
297 | # https://dart.dev/tools/linter-rules/avoid_unused_constructor_parameters
298 | - avoid_unused_constructor_parameters
299 |
300 | # For async functions use `Future` as return value, not `void`
301 | # This allows usage of the await keyword and prevents operations from running in parallel.
302 | #
303 | # https://dart.dev/tools/linter-rules/avoid_void_async
304 | - avoid_void_async
305 |
306 | # Flutter mobile only: Web packages aren't available in mobile flutter apps
307 | # https://dart.dev/tools/linter-rules/avoid_web_libraries_in_flutter
308 | - avoid_web_libraries_in_flutter
309 |
310 | # Use the await keyword only for futures. There is nothing to await in synchronous code
311 | #
312 | # https://dart.dev/tools/linter-rules/await_only_futures
313 | - await_only_futures
314 |
315 | # Follow the style guide and use UpperCamelCase for extensions
316 | #
317 | # https://dart.dev/tools/linter-rules/camel_case_extensions
318 | - camel_case_extensions
319 |
320 | # Follow the style guide and use UpperCamelCase for class names and typedefs
321 | #
322 | # https://dart.dev/tools/linter-rules/camel_case_types
323 | - camel_case_types
324 |
325 | # Prevents leaks and code executing after their lifecycle.
326 | # Discussion https://github.com/passsy/dart-lint/issues/4
327 | #
328 | # https://dart.dev/tools/linter-rules/cancel_subscriptions
329 | - cancel_subscriptions
330 |
331 | # The cascade syntax is weird, and you shouldn't be forced to use it.
332 | # False positives:
333 | # https://github.com/dart-lang/linter/issues/1589
334 | #
335 | # https://dart.dev/tools/linter-rules/cascade_invocations
336 | # - cascade_invocations
337 |
338 | # Don't cast T? to T. Use ! instead
339 | # Dart SDK: >= 2.11.0-182.0.dev • (Linter v0.1.120)
340 | #
341 | # https://dart.dev/tools/linter-rules/cast_nullable_to_non_nullable
342 | - cast_nullable_to_non_nullable
343 |
344 | # False positives, not reliable enough
345 | # - https://github.com/dart-lang/linter/issues/1381
346 | #
347 | # https://dart.dev/tools/linter-rules/close_sinks
348 | # - close_sinks
349 |
350 | # It's surprising that this is not solved with a type in the sdk, but with a linter rule. This is a must-have.
351 | #
352 | # Dart SDK: 2.19.0 • (Linter v1.29.0)
353 | #
354 | # https://dart.dev/tools/linter-rules/collection_methods_unrelated_type
355 | - collection_methods_unrelated_type
356 |
357 | # False positives:
358 | # - https://github.com/dart-lang/linter/issues/1142
359 | #
360 | # https://dart.dev/tools/linter-rules/comment_references
361 | # - comment_references
362 |
363 | # We sort imports, we should also sort show and hide
364 | #
365 | # Linter v1.26.0
366 | # https://dart.dev/tools/linter-rules/combinators_ordering
367 | - combinators_ordering
368 |
369 | # Checks that files in conditional imports exist
370 | #
371 | # Linter v1.16.0
372 | # https://dart.dev/tools/linter-rules/conditional_uri_does_not_exist
373 | - conditional_uri_does_not_exist
374 |
375 | # Follow standard dart naming style.
376 | #
377 | # https://dart.dev/tools/linter-rules/constant_identifier_names
378 | - constant_identifier_names
379 |
380 | # Prevents hard to debug code
381 | #
382 | # https://dart.dev/tools/linter-rules/control_flow_in_finally
383 | - control_flow_in_finally
384 |
385 | # Single line `if`s are fine, but when a new line splits the bool expression and body curly braces
386 | # are recommended. It prevents the dangling else problem and easily allows the addition of more lines inside
387 | # the if-body
388 | #
389 | # Dart SDK: >= 2.0.0 • (Linter v0.1.57)
390 | #
391 | # https://dart.dev/tools/linter-rules/curly_braces_in_flow_control_structures
392 | - curly_braces_in_flow_control_structures
393 |
394 | # Directly attach comments to the `library;` keyword. No new lines in between.
395 | #
396 | # Dart SDK: 2.19.0 • Linter v1.29.0
397 | #
398 | # https://dart.dev/tools/linter-rules/dangling_library_doc_comments
399 | - dangling_library_doc_comments
400 |
401 | # Requires all referenced dependencies to be declared as direct dependencies in pubspec.yaml. Transitive
402 | # dependencies might be removed by a dependency, breaking your code.
403 | #
404 | # Dart SDK: 2.14.0-172.0.dev • (Linter v1.5.0)
405 | #
406 | # https://dart.dev/tools/linter-rules/depend_on_referenced_packages
407 | - depend_on_referenced_packages
408 |
409 | # When deprecating classes, also deprecate the constructor. When deprecating fields, also deprecate the constructor
410 | # parameter. That rule is useful for apps and especially for packages
411 | #
412 | # Dart SDK: 2.13.0 • (Linter v1.0.0)
413 | #
414 | # https://dart.dev/tools/linter-rules/deprecated_consistency
415 | - deprecated_consistency
416 |
417 | # Still experimental and pretty much work when enforced
418 | # https://dart.dev/tools/linter-rules/diagnostic_describe_all_properties
419 | # - diagnostic_describe_all_properties
420 |
421 | # Follows dart style. Fully supported by IDEs and no manual effort for a consistent style
422 | #
423 | # https://dart.dev/tools/linter-rules/directives_ordering
424 | - directives_ordering
425 |
426 | # Similar to `unawaited_futures` but only within async function blocks
427 | # Unclear which unawaited function to use
428 | #
429 | # Dart SDK: >= 2.18.0 • (Linter v1.24.0)
430 | #
431 | # https://dart.dev/tools/linter-rules/discarded_futures
432 | # - discarded_futures
433 |
434 | # String.fromEnvironment looks up env variables at compile time. The variable is baked in by the compiler
435 | # and can't be changed by environment variables.
436 | #
437 | # For dart apps:
438 | # Better look up an environment variable at runtime with Platform.environment
439 | # or use code generation to define variables at compile time.
440 | #
441 | # For Flutter apps:
442 | # String.fromEnvironment is the recommended way to include variables defined with `flutter build --dart-define`
443 | #
444 | #
445 | # Dart SDK: >= 2.10.0-0.0.dev • (Linter v0.1.117)
446 | # https://dart.dev/tools/linter-rules/do_not_use_environment
447 | # - do_not_use_environment
448 |
449 | # The reason for the ignore is usually self-evident and an additional comment would add unnecessary verbosity.
450 | # Also, when temporarily ignoring rules for debugging or development purposes, having to add documentation creates unnecessary overhead
451 | #
452 | # Example where it is annoying:
453 | #
454 | # ```dart
455 | # } catch (e, stack) {
456 | # // ignore: avoid_print
457 | # print(stack);
458 | # }
459 | # ```
460 | #
461 | # Dart SDK: >= 3.5.0
462 | #
463 | # https://dart.dev/tools/linter-rules/document_ignores
464 | # - document_ignores
465 |
466 | # Add a comment why no further error handling is required
467 | #
468 | # https://dart.dev/tools/linter-rules/empty_catches
469 | - empty_catches
470 |
471 | # Removes empty constructor bodies
472 | #
473 | # https://dart.dev/tools/linter-rules/empty_constructor_bodies
474 | - empty_constructor_bodies
475 |
476 | # Don't allow empty if bodies. Works together with curly_braces_in_flow_control_structures
477 | #
478 | # https://dart.dev/tools/linter-rules/empty_statements
479 | - empty_statements
480 |
481 | # That's good habit, but not necessary. It might be useful for some parsers that split lines based on the
482 | # new line character. Common in simple bash scripts.
483 | #
484 | # Most IDEs do this automatically, therefore zero effort for devs
485 | #
486 | # Dart SDK: >=2.14.0-360.0.dev • (Linter v1.8.0)
487 | #
488 | # https://dart.dev/tools/linter-rules/eol_at_end_of_file
489 | - eol_at_end_of_file
490 |
491 | # Enums aren't powerful enough, now enum like classes get the same linting support
492 | #
493 | # Dart SDK: >= 2.9.0-12.0.dev • (Linter v0.1.116)
494 | #
495 | # https://dart.dev/tools/linter-rules/exhaustive_cases
496 | - exhaustive_cases
497 |
498 | # Follow dart file naming schema
499 | # https://dart.dev/tools/linter-rules/file_names
500 | - file_names
501 |
502 | # Very flutter specific, not applicable for all projects
503 | #
504 | # https://dart.dev/tools/linter-rules/flutter_style_todos
505 | # - flutter_style_todos # not all todos require a ticket
506 |
507 | # hashCode and equals need to be consistent. One can't live without another.
508 | # https://dart.dev/tools/linter-rules/hash_and_equals
509 | - hash_and_equals
510 |
511 | # DON'T import implementation files from another package.
512 | # If you need access to some internal code, create an issue
513 | # https://dart.dev/tools/linter-rules/implementation_imports
514 | - implementation_imports
515 |
516 | # Less magic is better. In fear of future Dart versions, that remove the implicit call tear off, we should start migrating now.
517 | #
518 | # Dart SDK: 2.19 • (Linter v1.29.0)
519 | #
520 | # https://dart.dev/tools/linter-rules/implicit_call_tearoffs
521 | - implicit_call_tearoffs
522 |
523 | # Only relevant for package authors
524 | #
525 | # Dart SDK: 3.0.0 • (Linter v1.35.0)
526 | #
527 | # https://dart.dev/tools/linter-rules/implicit_reopen
528 | # - implicit_reopen
529 |
530 | # Helps to migrate switch cases from Dart 2 to Dart 3
531 | #
532 | # Dart SDK: 3.0.0 • (Linter v1.34.0)
533 | #
534 | # https://dart.dev/tools/linter-rules/invalid_case_patterns
535 | - invalid_case_patterns
536 |
537 | # Prevents invalid runtime checks with JS interop types
538 | #
539 | # Dart SDK: >= 3.5.0
540 | #
541 | # https://dart.dev/tools/linter-rules/invalid_runtime_check_with_js_interop_types
542 | - invalid_runtime_check_with_js_interop_types
543 |
544 | # Hint to join return and assignment.
545 | #
546 | # https://dart.dev/tools/linter-rules/join_return_with_assignment
547 | - join_return_with_assignment
548 |
549 | # Add leading \n which which makes multiline strings easier to read
550 | # Dart SDK: >= 2.8.0-dev.16.0 • (Linter v0.1.113)
551 | # https://dart.dev/tools/linter-rules/leading_newlines_in_multiline_strings
552 | - leading_newlines_in_multiline_strings
553 |
554 | # Library annotations must be attached to the `library` keyword
555 | #
556 | # Dart SDK: 2.19 • (Linter v1.30.0)
557 | #
558 | # https://dart.dev/tools/linter-rules/library_annotations
559 | - library_annotations
560 |
561 | # Makes sure a library name is a valid dart identifier.
562 | # This comes in handy for test files combining multiple tests where the file name can be used as identifier
563 | #
564 | # ```
565 | # import src/some_test.dart as some_test;
566 | #
567 | # main() {
568 | # some_test.main();
569 | # }
570 | # ```
571 | #
572 | # https://dart.dev/tools/linter-rules/library_names
573 | - library_names
574 |
575 | # Follow dart style
576 | #
577 | # https://dart.dev/tools/linter-rules/library_prefixes
578 | - library_prefixes
579 |
580 | # Nobody wants to manually wrap lines when changing a few words. This rule is too hard to be a "general" rule
581 | #
582 | # https://dart.dev/tools/linter-rules/lines_longer_than_80_chars
583 | # - lines_longer_than_80_chars
584 |
585 | # Good for libraries to prevent unnecessary code paths.
586 | # False positives may occur for applications when boolean properties are generated by external programs
587 | # producing auto-generated source code
588 | #
589 | # Known issue: while(true) loops https://github.com/dart-lang/linter/issues/453
590 | #
591 | #
592 | # https://dart.dev/tools/linter-rules/literal_only_boolean_expressions
593 | # - literal_only_boolean_expressions
594 |
595 | # Code blocks in documentation comments should specify a language for better readability
596 | #
597 | # Dart SDK: >= 3.4.0
598 | #
599 | # https://dart.dev/tools/linter-rules/missing_code_block_language_in_doc_comment
600 | - missing_code_block_language_in_doc_comment
601 |
602 | # Don't forget the whitespaces at the end
603 | #
604 | # Dart SDK: >= 2.8.0-dev.10.0 • (Linter v0.1.110)
605 | #
606 | # https://dart.dev/tools/linter-rules/missing_whitespace_between_adjacent_strings
607 | - missing_whitespace_between_adjacent_strings
608 |
609 | # Concat Strings obviously with `+` inside a list.
610 | #
611 | # https://dart.dev/tools/linter-rules/no_adjacent_strings_in_list
612 | - no_adjacent_strings_in_list
613 |
614 | # Second case is basically dead code which will never be reached.
615 | #
616 | # https://dart.dev/tools/linter-rules/no_duplicate_case_values
617 | - no_duplicate_case_values
618 |
619 | # private library prefixes don't exist, don't try to introduce concepts that have no effect
620 | #
621 | # Linter v1.15
622 | # https://dart.dev/tools/linter-rules/no_leading_underscores_for_library_prefixes
623 | - no_leading_underscores_for_library_prefixes
624 |
625 | # private identifier prefixes don't exist, don't try to introduce concepts that have no effect
626 | #
627 | # Linter v1.15
628 | # https://dart.dev/tools/linter-rules/no_leading_underscores_for_local_identifiers
629 | - no_leading_underscores_for_local_identifiers
630 |
631 | # Flutter only: `createState` shouldn't pass information into the state
632 | #
633 | # https://dart.dev/tools/linter-rules/no_logic_in_create_state
634 | - no_logic_in_create_state
635 |
636 | # calling `runtimeType` may be a performance problem
637 | # Dart SDK: >= 2.8.0-dev.10.0 • (Linter v0.1.110)
638 | # https://dart.dev/tools/linter-rules/no_runtimeType_toString
639 | - no_runtimeType_toString
640 |
641 | # Don't assign a variable to itself.
642 | #
643 | # Dart SDK: >= 3.1.0
644 | #
645 | # https://dart.dev/tools/linter-rules/no_self_assignments
646 | - no_self_assignments
647 |
648 | # Don't use wildcard parameters or variables. Code using this will break in the future.
649 | #
650 | # Dart SDK: >= 3.1.0
651 | #
652 | # https://dart.dev/tools/linter-rules/no_wildcard_variable_uses
653 | - no_wildcard_variable_uses
654 |
655 | # Follow dart style naming conventions
656 | #
657 | # https://dart.dev/tools/linter-rules/non_constant_identifier_names
658 | - non_constant_identifier_names
659 |
660 | # Don't call unnecessary conversion methods on primitives
661 | #
662 | # Dart SDK: 2.14.0-172.0.dev • (Linter v1.5.0)
663 | #
664 | # https://dart.dev/tools/linter-rules/noop_primitive_operations
665 | - noop_primitive_operations
666 |
667 | # Generic T might have a value of String or String?. Both are valid.
668 | # This lint triggers when ! is used on T? casting (String?)? to String and not (String?)? to String?
669 | # Dart SDK: >= 2.11.0-182.0.dev • (Linter v0.1.120)
670 | # https://dart.dev/tools/linter-rules/null_check_on_nullable_type_parameter
671 | - null_check_on_nullable_type_parameter
672 |
673 | # Might become irrelevant when non-nullable types land in dart. Until then use this lint check which checks for
674 | # non-null arguments for specific dart sdk methods.
675 | #
676 | # https://dart.dev/tools/linter-rules/null_closures
677 | - null_closures
678 |
679 | # Types for local variables can improve readability and shouldn't be forced to be removed.
680 | #
681 | # Dart SDK: >= 2.0.0 • (Linter v0.1.30)
682 | #
683 | # https://dart.dev/tools/linter-rules/omit_local_variable_types
684 | # - omit_local_variable_types
685 |
686 | # It recommends replacing `int` with `var`. That's not useful
687 | #
688 | # Dart SDK: >= 3.5.0
689 | #
690 | # https://dart.dev/tools/linter-rules/omit_obvious_local_variable_types
691 | # - omit_obvious_local_variable_types
692 |
693 | # Humans read plain code without tooling.
694 | # Types might be obvious to the compiler, but a human not a tool should decie when to add a type.
695 | #
696 | # Dart SDK: >= 3.7.0
697 | #
698 | # https://dart.dev/tools/linter-rules/omit_obvious_property_types
699 | # - omit_obvious_property_types
700 |
701 | # Defining interfaces (abstract classes), with only one method, makes sense architecture wise
702 | # Discussion: https://github.com/passsy/dart-lint/issues/2
703 | #
704 | #
705 | # https://dart.dev/tools/linter-rules/one_member_abstracts
706 | # - one_member_abstracts
707 |
708 | # Since Errors aren't intended to be caught (see avoid_catching_errors), throwing anything
709 | # doesn't cause trouble.
710 | # https://dart.dev/tools/linter-rules/only_throw_errors
711 | # - only_throw_errors
712 |
713 | # Highlights unintentionally overridden fields.
714 | #
715 | # https://dart.dev/tools/linter-rules/overridden_fields
716 | - overridden_fields
717 |
718 | # Follow dart style package naming convention
719 | #
720 | # Dart SDK: >= 2.0.0 • (Linter v0.1.31)
721 | #
722 | # https://dart.dev/tools/linter-rules/package_names
723 | - package_names
724 |
725 | # Seems very rare, especially for applications.
726 | #
727 | # https://dart.dev/tools/linter-rules/package_prefixed_library_names
728 | - package_prefixed_library_names
729 |
730 | # Most likely a mistake, if not: bad practice
731 | #
732 | # https://dart.dev/tools/linter-rules/parameter_assignments
733 | - parameter_assignments
734 |
735 | # Is contradictory to `no_adjacent_strings_in_list`
736 | #
737 | # https://dart.dev/tools/linter-rules/prefer_adjacent_string_concatenation
738 | # - prefer_adjacent_string_concatenation
739 |
740 | # Makes it easier to migrate to const constructors and to have final fields
741 | #
742 | # https://dart.dev/tools/linter-rules/prefer_asserts_in_initializer_lists
743 | - prefer_asserts_in_initializer_lists
744 |
745 | # Assertions blocks don't require a message because they throw simple to understand errors
746 | #
747 | # https://dart.dev/tools/linter-rules/prefer_asserts_with_message
748 | # - prefer_asserts_with_message
749 |
750 | # Collection literals are shorter. They exist, use them.
751 | #
752 | # https://dart.dev/tools/linter-rules/prefer_collection_literals
753 | - prefer_collection_literals
754 |
755 | # Use the ??= operator when possible
756 | #
757 | # https://dart.dev/tools/linter-rules/prefer_conditional_assignment
758 | - prefer_conditional_assignment
759 |
760 | # Always use const when possible, make runtime faster
761 | #
762 | # https://dart.dev/tools/linter-rules/prefer_const_constructors
763 | - prefer_const_constructors
764 |
765 | # Add a const constructor when possible
766 | #
767 | # https://dart.dev/tools/linter-rules/prefer_const_constructors_in_immutables
768 | - prefer_const_constructors_in_immutables
769 |
770 | # final is good, const is better
771 | # https://dart.dev/tools/linter-rules/prefer_const_declarations
772 | - prefer_const_declarations
773 |
774 | # Always use const when possible, make runtime faster
775 | #
776 | # https://dart.dev/tools/linter-rules/prefer_const_literals_to_create_immutables
777 | - prefer_const_literals_to_create_immutables
778 |
779 | # Dart has named constructors. Static methods in other languages (java) are a workaround which don't have
780 | # named constructors.
781 | #
782 | # https://dart.dev/tools/linter-rules/prefer_constructors_over_static_methods
783 | - prefer_constructors_over_static_methods
784 |
785 | # Contains may be faster and is easier to read
786 | #
787 | # https://dart.dev/tools/linter-rules/prefer_contains
788 | - prefer_contains
789 |
790 | # Use whatever makes you happy. lint doesn't define a style
791 | # Conflicts with prefer_single_quotes
792 | #
793 | # https://dart.dev/tools/linter-rules/prefer_double_quotes
794 | # - prefer_double_quotes
795 |
796 | # Single line methods + implementation makes it hard to write comments for that line.
797 | # Dense code isn't necessarily better code.
798 | #
799 | # https://dart.dev/tools/linter-rules/prefer_expression_function_bodies
800 | # - prefer_expression_function_bodies
801 |
802 | # Avoid accidental reassignments and allows the compiler to do optimizations.
803 | #
804 | # https://dart.dev/tools/linter-rules/prefer_final_fields
805 | - prefer_final_fields
806 |
807 | # Helps avoid accidental reassignments and allows the compiler to do optimizations.
808 | #
809 | # https://dart.dev/tools/linter-rules/prefer_final_in_for_each
810 | - prefer_final_in_for_each
811 |
812 | # Helps avoid accidental reassignments and allows the compiler to do optimizations.
813 | #
814 | # https://dart.dev/tools/linter-rules/prefer_final_locals
815 | - prefer_final_locals
816 |
817 | # While prefer_final_fields and prefer_final_locals is enabled, this lint would add a lot of clutter to methods,
818 | # especially lambdas.
819 | # parameter_assignments is already enabled, catching this error
820 | # Conflicts with avoid_final_parameters
821 | #
822 | # Dart SDK: 2.14.0-172.0.dev • (Linter v1.5.0)
823 | #
824 | # https://dart.dev/tools/linter-rules/prefer_final_parameters
825 | # - prefer_final_parameters
826 |
827 | # Saves a lot of code
828 | #
829 | # https://dart.dev/tools/linter-rules/prefer_for_elements_to_map_fromIterable
830 | - prefer_for_elements_to_map_fromIterable
831 |
832 | # Dense code isn't necessarily better code
833 | #
834 | # https://dart.dev/tools/linter-rules/prefer_foreach
835 | # - prefer_foreach
836 |
837 | # As Dart allows local function declarations, it is a good practice to use them in the place of function literals.
838 | # https://dart.dev/tools/linter-rules/prefer_function_declarations_over_variables
839 | - prefer_function_declarations_over_variables
840 |
841 | # For consistency
842 | #
843 | # https://dart.dev/tools/linter-rules/prefer_generic_function_type_aliases
844 | - prefer_generic_function_type_aliases
845 |
846 | # Allows potential usage of const
847 | # https://dart.dev/tools/linter-rules/prefer_if_elements_to_conditional_expressions
848 | - prefer_if_elements_to_conditional_expressions
849 |
850 | # Dart has a special operator for this, use it
851 | #
852 | # https://dart.dev/tools/linter-rules/prefer_if_null_operators
853 | - prefer_if_null_operators
854 |
855 | # Terser code
856 | # https://dart.dev/tools/linter-rules/prefer_initializing_formals
857 | - prefer_initializing_formals
858 |
859 | # Easier move towards const, and way easier to read
860 | #
861 | # https://dart.dev/tools/linter-rules/prefer_inlined_adds
862 | - prefer_inlined_adds
863 |
864 | # There is no argument which makes int literals better than double literals for doubles.
865 | #
866 | # https://dart.dev/tools/linter-rules/prefer_int_literals
867 | # - prefer_int_literals
868 |
869 | # Interpolate, use less "", '' and +
870 | # https://dart.dev/tools/linter-rules/prefer_interpolation_to_compose_strings
871 | - prefer_interpolation_to_compose_strings
872 |
873 | # Iterables do not necessary know their length
874 | #
875 | # https://dart.dev/tools/linter-rules/prefer_is_empty
876 | - prefer_is_empty
877 |
878 | # Easier to read
879 | #
880 | # Dart SDK: >= 2.0.0 • (Linter v0.1.5)
881 | #
882 | # https://dart.dev/tools/linter-rules/prefer_is_not_empty
883 | - prefer_is_not_empty
884 |
885 | # Use the `foo is! Foo` instead of `!(foo is Foo)`
886 | # https://dart.dev/tools/linter-rules/prefer_is_not_operator
887 | - prefer_is_not_operator
888 |
889 | # Easier to read
890 | #
891 | # https://dart.dev/tools/linter-rules/prefer_iterable_whereType
892 | - prefer_iterable_whereType
893 |
894 | # Users of a 3rd party mixins can't change 3rd party code to use the mixin syntax.
895 | # This makes the rule useless
896 | # https://dart.dev/tools/linter-rules/prefer_mixin
897 | # - prefer_mixin
898 |
899 | # It's shorter and should be preferred. Especially helpful for devs new to dart.
900 | #
901 | # Dart SDK: 2.14.0-2.0.dev • (Linter v1.3.0)
902 | #
903 | # https://dart.dev/tools/linter-rules/prefer_null_aware_method_calls
904 | - prefer_null_aware_method_calls
905 |
906 | # Makes expressions with null checks easier to read.
907 | # https://github.com/flutter/flutter/pull/32711#issuecomment-492930932
908 | - prefer_null_aware_operators
909 |
910 | # Conflicting with `avoid_relative_lib_imports` which is enforced
911 | # https://dart.dev/tools/linter-rules/prefer_relative_imports
912 | # - prefer_relative_imports
913 |
914 | # Use whatever makes you happy. lint doesn't define a style
915 | # Conflicts with prefer_double_quotes
916 | #
917 | # https://dart.dev/tools/linter-rules/prefer_single_quotes
918 | # - prefer_single_quotes
919 |
920 | # Allows potential usage of const
921 | #
922 | # https://dart.dev/tools/linter-rules/prefer_spread_collections
923 | - prefer_spread_collections
924 |
925 | # Define types
926 | #
927 | # https://dart.dev/tools/linter-rules/prefer_typing_uninitialized_variables
928 | - prefer_typing_uninitialized_variables
929 |
930 | # Null is not a type, use void
931 | # https://dart.dev/tools/linter-rules/prefer_void_to_null
932 | - prefer_void_to_null
933 |
934 | # Document the replacement API
935 | # https://dart.dev/tools/linter-rules/provide_deprecation_message
936 | - provide_deprecation_message
937 |
938 | # Definitely not a rule for standard dart code. Maybe relevant for packages
939 | # https://dart.dev/tools/linter-rules/public_member_api_docs
940 | # - public_member_api_docs
941 |
942 | # Hints accidental recursions
943 | #
944 | # https://dart.dev/tools/linter-rules/recursive_getters
945 | - recursive_getters
946 |
947 | # Dartfmt formats differently when adding trailing commas. This lint makes sure there is zero doubt in how code
948 | # should be formatted.
949 | #
950 | # Removed for Dart 3.7 because dart now formats differently, compared to this rule (removes some commas)
951 | #
952 | # This rule is debatable, though.
953 | # A non-representative [vote](https://twitter.com/passsy/status/1427220769050972162) shows a strong tendency towards
954 | # enabling this rule. Especially because the code example does only include the debatable formatting changes. There
955 | # are more, especially in Flutter build methods which make the code clearly better.
956 | #
957 | # Dart SDK: 2.14.0-2.0.dev • (Linter v1.3.0)
958 | #
959 | # https://dart.dev/tools/linter-rules/require_trailing_commas
960 | # - require_trailing_commas
961 |
962 | # Use https in pubspec.yaml
963 | #
964 | # Linter v1.15
965 | # https://dart.dev/tools/linter-rules/secure_pubspec_urls
966 | - secure_pubspec_urls
967 |
968 | # Flutter only, prefer SizedBox over Container which offers a const constructors
969 | # Dart SDK: >= 2.9.0-4.0.dev • (Linter v0.1.115)
970 | # https://dart.dev/tools/linter-rules/sized_box_for_whitespace
971 | - sized_box_for_whitespace
972 |
973 | # Use the SizeBox.expand or SizeBox.shrink constructor instead of setting both width and height
974 | # to `0` or `double.infinity`
975 | #
976 | # Linter v1.15
977 | # https://dart.dev/tools/linter-rules/sized_box_shrink_expand
978 | - sized_box_shrink_expand
979 |
980 | # Follow dart style use triple slashes
981 | #
982 | # https://dart.dev/tools/linter-rules/slash_for_doc_comments
983 | - slash_for_doc_comments
984 |
985 | # Flutter only, always put child last
986 | #
987 | # https://dart.dev/tools/linter-rules/sort_child_properties_last
988 | - sort_child_properties_last
989 |
990 | # Working, results in consistent code. But too opinionated
991 | # Discussion: https://github.com/passsy/dart-lint/issues/1
992 | #
993 | #
994 | # https://dart.dev/tools/linter-rules/sort_constructors_first
995 | # - sort_constructors_first
996 |
997 | # Any sorting is better than no sorting
998 | # https://dart.dev/tools/linter-rules/sort_pub_dependencies
999 | - sort_pub_dependencies
1000 |
1001 | # Default constructor comes first.
1002 | #
1003 | # https://dart.dev/tools/linter-rules/sort_unnamed_constructors_first
1004 | - sort_unnamed_constructors_first
1005 |
1006 | # Never forget a return or variable type!
1007 | #
1008 | # Dart SDK: >= 3.7.0
1009 | #
1010 | # https://dart.dev/tools/linter-rules/strict_top_level_inference
1011 | - strict_top_level_inference
1012 |
1013 | # This rule is too opinionated and doesn't have a clear benefit
1014 | # The complexity of what "obvious" means is too high
1015 | #
1016 | # Dart SDK: >= 3.5.0
1017 | #
1018 | # https://dart.dev/tools/linter-rules/specify_nonobvious_local_variable_types
1019 | # - specify_nonobvious_local_variable_types
1020 |
1021 | # Useful, but often too agressive
1022 | #
1023 | # ```dart
1024 | # final _formKey = GlobalKey(); // warning
1025 | # final GlobalKey _formKey = GlobalKey(); // ok
1026 | #
1027 | # final animationCurve = Curves.easeOut; // warning
1028 | # final Curve animationCurve = Curves.easeOut; // ok
1029 | # ```
1030 | #
1031 | # Dart SDK: >= 3.7.0
1032 | #
1033 | # https://dart.dev/tools/linter-rules/specify_nonobvious_property_types
1034 | # - specify_nonobvious_property_types
1035 |
1036 | # First test, then cast
1037 | #
1038 | # https://dart.dev/tools/linter-rules/test_types_in_equals
1039 | - test_types_in_equals
1040 |
1041 | # Hard to debug and bad style
1042 | #
1043 | # https://dart.dev/tools/linter-rules/throw_in_finally
1044 | - throw_in_finally
1045 |
1046 | # Help the compiler at compile time with non-null asserts rather than crashing at runtime
1047 | #
1048 | # Dart SDK: >= 2.11.0-182.0.dev • (Linter v0.1.120)
1049 | # https://dart.dev/tools/linter-rules/tighten_type_of_initializing_formals
1050 | - tighten_type_of_initializing_formals
1051 |
1052 | # Type annotations make the compiler intelligent, use them
1053 | # https://dart.dev/tools/linter-rules/type_annotate_public_apis
1054 | - type_annotate_public_apis
1055 |
1056 | # Don't add types for already typed constructor parameters.
1057 | #
1058 | # https://dart.dev/tools/linter-rules/type_init_formals
1059 | - type_init_formals
1060 |
1061 | # Catches type matches that look correct but actually don't match
1062 | #
1063 | # Dart SDK: Dart 3.0.0 • (Linter v1.35.0)
1064 | #
1065 | # https://dart.dev/tools/linter-rules/type_literal_in_constant_pattern
1066 | - type_literal_in_constant_pattern
1067 |
1068 | # Unclear which unawaited function to use
1069 | #
1070 | # https://dart.dev/tools/linter-rules/unawaited_futures
1071 | # - unawaited_futures
1072 |
1073 | # No await? No async!
1074 | #
1075 | # Dart SDK: >= 3.7.0
1076 | #
1077 | # https://dart.dev/tools/linter-rules/unnecessary_async
1078 | - unnecessary_async
1079 |
1080 | # Replace `return await future;` with `return future;`
1081 | #
1082 | # This check causes false positives in try-catch blocks, where removing await would not catch the exception anymore
1083 | # https://github.com/dart-lang/linter/issues/2357
1084 | # https://github.com/dart-lang/linter/issues/2250
1085 | #
1086 | # https://dart.dev/tools/linter-rules/unnecessary_await_in_return
1087 | # - unnecessary_await_in_return
1088 |
1089 | # Remove unnecessary braces
1090 | #
1091 | # https://dart.dev/tools/linter-rules/unnecessary_brace_in_string_interps
1092 | - unnecessary_brace_in_string_interps
1093 |
1094 | # switch case works now finally without `break;`
1095 | #
1096 | # Dart SDK: 3.0.0 • (Linter v1.33.0)
1097 | #
1098 | # https://dart.dev/tools/linter-rules/unnecessary_breaks
1099 | - unnecessary_breaks
1100 |
1101 | # Yes, const everywhere. But not in an already const scope
1102 | #
1103 | # https://dart.dev/tools/linter-rules/unnecessary_const
1104 | - unnecessary_const
1105 |
1106 | # Disabled because `final` prevents accidental reassignment
1107 | # https://dart.dev/tools/linter-rules/unnecessary_final
1108 | # - unnecessary_final
1109 |
1110 | # Getter/setters can be added later on in a non API breaking manner
1111 | #
1112 | # https://dart.dev/tools/linter-rules/unnecessary_getters_setters
1113 | - unnecessary_getters_setters
1114 |
1115 | # Flutter setState is a good example where a lambda should always be used.
1116 | # https://github.com/dart-lang/linter/issues/498
1117 | #
1118 | # Some generic code sometimes requires lambdas, otherwise the generic type isn't forwarded correctly.
1119 | #
1120 | # https://dart.dev/tools/linter-rules/unnecessary_lambdas
1121 | # - unnecessary_lambdas
1122 |
1123 | # Top-level and static variables with initializers are already evaluated lazily as if they are marked late
1124 | #
1125 | # Linter v1.17
1126 | # https://dart.dev/tools/linter-rules/unnecessary_late
1127 | - unnecessary_late
1128 |
1129 | # Don't use unnecessary library names
1130 | #
1131 | # Dart SDK: >= 3.4.0
1132 | #
1133 | # https://dart.dev/tools/linter-rules/unnecessary_library_name
1134 | - unnecessary_library_name
1135 |
1136 | # New library syntax, time to migrate
1137 | #
1138 | # Dart SDK: 2.19.0 • (Linter v1.29.0)
1139 | #
1140 | # https://dart.dev/tools/linter-rules/unnecessary_library_directive
1141 | - unnecessary_library_directive
1142 |
1143 | # Remove the optional `new` keyword
1144 | #
1145 | # https://dart.dev/tools/linter-rules/unnecessary_new
1146 | - unnecessary_new
1147 |
1148 | # Don't assign `null` when value is already `null`.
1149 | #
1150 | # https://dart.dev/tools/linter-rules/unnecessary_null_aware_assignments
1151 | - unnecessary_null_aware_assignments
1152 |
1153 | # Unnecessary `?.` when the extension is on type `T?`
1154 | #
1155 | # Dart SDK: >= 2.18.0 • (Linter v1.24.0)
1156 | #
1157 | # https://dart.dev/tools/linter-rules/unnecessary_null_aware_operator_on_extension_on_nullable
1158 | - unnecessary_null_aware_operator_on_extension_on_nullable
1159 |
1160 | # Remove ! when already non-nullable
1161 | # Dart SDK: >= 2.10.0-144.0.dev • (Linter v0.1.119)
1162 | # https://dart.dev/tools/linter-rules/unnecessary_null_checks
1163 | - unnecessary_null_checks
1164 |
1165 | # Don't assign `null` when value is already `null`.
1166 | #
1167 | # https://dart.dev/tools/linter-rules/unnecessary_null_in_if_null_operators
1168 | - unnecessary_null_in_if_null_operators
1169 |
1170 | # If a variable doesn't change and is initialized, no need to define it as nullable (NNBD)
1171 | # Dart SDK: >= 2.10.0-10.0.dev • (Linter v0.1.118)
1172 | # https://dart.dev/tools/linter-rules/unnecessary_nullable_for_final_variable_declarations
1173 | - unnecessary_nullable_for_final_variable_declarations
1174 |
1175 | # Remove overrides which simply call super
1176 | # https://dart.dev/tools/linter-rules/unnecessary_overrides
1177 | - unnecessary_overrides
1178 |
1179 | # Remove clutter where possible
1180 | # https://dart.dev/tools/linter-rules/unnecessary_parenthesis
1181 | - unnecessary_parenthesis
1182 |
1183 | # Use raw string only when needed
1184 | # Dart SDK: >= 2.8.0-dev.11.0 • (Linter v0.1.111)
1185 | # https://dart.dev/tools/linter-rules/unnecessary_raw_strings
1186 | - unnecessary_raw_strings
1187 |
1188 | # Avoid magic overloads of + operators
1189 | # https://dart.dev/tools/linter-rules/unnecessary_statements
1190 | - unnecessary_statements
1191 |
1192 | # Remove unnecessary escape characters
1193 | # Dart SDK: >= 2.8.0-dev.11.0 • (Linter v0.1.111)
1194 | # https://dart.dev/tools/linter-rules/unnecessary_string_escapes
1195 | - unnecessary_string_escapes
1196 |
1197 | # Completely unnecessary code, simplify to save a few CPU cycles
1198 | #
1199 | # Dart SDK: >= 2.8.0-dev.10.0 • (Linter v0.1.110)
1200 | #
1201 | # https://dart.dev/tools/linter-rules/unnecessary_string_interpolations
1202 | - unnecessary_string_interpolations
1203 |
1204 | # The variable is clear, remove clutter
1205 | #
1206 | # https://dart.dev/tools/linter-rules/unnecessary_this
1207 | - unnecessary_this
1208 |
1209 | # toList() is not required when an Iterable is expected
1210 | #
1211 | # Dart SDK: >= 2.18.0 • (Linter v1.24.0)
1212 | #
1213 | # https://dart.dev/tools/linter-rules/unnecessary_to_list_in_spreads
1214 | - unnecessary_to_list_in_spreads
1215 |
1216 | # Due to the wildcard variables language feature in Dart 3.7, multiple parameters can now be called _
1217 | #
1218 | # Dart SDK: >= 3.7.0
1219 | #
1220 | # https://dart.dev/tools/linter-rules/unnecessary_underscores
1221 | - unnecessary_underscores
1222 |
1223 | # Prevents unintended HTML in doc comments which could cause rendering issues
1224 | #
1225 | # Dart SDK: >= 3.5.0
1226 | #
1227 | # https://dart.dev/tools/linter-rules/unintended_html_in_doc_comment
1228 | - unintended_html_in_doc_comment
1229 |
1230 | # Highlights unreachable/unused code in libraries containing a main function / @pragma('vm:entry-point')
1231 | #
1232 | # Linter v1.28.0
1233 | # https://dart.dev/tools/linter-rules/unreachable_from_main
1234 | - unreachable_from_main
1235 |
1236 | # Highlights potential bugs where unrelated types are compared with another. (always *not* equal).
1237 | #
1238 | # https://dart.dev/tools/linter-rules/unrelated_type_equality_checks
1239 | - unrelated_type_equality_checks
1240 |
1241 | # In most cases, using T is just fine, unless T is a base class.
1242 | # The workaround is quite complex and not worth applying, unless runtime errors appear.
1243 | #
1244 | # Dart SDK: >= 3.7.0
1245 | #
1246 | # https://dart.dev/tools/linter-rules/unsafe_variance
1247 | # - unsafe_variance
1248 |
1249 | # Very useful in preventing Flutter BuildContext bugs in async callbacks
1250 | #
1251 | # Dart SDK: 2.13.0 • (Linter v1.1.0)
1252 | #
1253 | # https://dart.dev/tools/linter-rules/use_build_context_synchronously
1254 | - use_build_context_synchronously
1255 |
1256 | # Replace Container with ColoredBox to be able to use the const constructor
1257 | #
1258 | # Linter v1.19.1
1259 | # https://dart.dev/tools/linter-rules/use_colored_box
1260 | - use_colored_box
1261 |
1262 | # DecoratedBox is not a replacement for Container https://github.com/dart-lang/linter/issues/3286
1263 | #
1264 | # Linter v1.15
1265 | # https://dart.dev/tools/linter-rules/use_decorated_box
1266 | # - use_decorated_box
1267 |
1268 | # Use the [Enhanced Enum Classes](https://github.com/dart-lang/language/blob/master/accepted/future-releases/enhanced-enums/feature-specification.md) feature instead of classes with static members.
1269 | #
1270 | # This check is very precise, it's rather unlikely to have false positives.
1271 | #
1272 | # Linter v1.19.1
1273 | # https://dart.dev/tools/linter-rules/use_enums
1274 | - use_enums
1275 |
1276 | # Always use hex syntax Color(0x00000001), never Color(1)
1277 | #
1278 | # https://dart.dev/tools/linter-rules/use_full_hex_values_for_flutter_colors
1279 | - use_full_hex_values_for_flutter_colors
1280 |
1281 | # Always use generic function type syntax, don't mix styles
1282 | #
1283 | # https://dart.dev/tools/linter-rules/use_function_type_syntax_for_parameters
1284 | - use_function_type_syntax_for_parameters
1285 |
1286 | # Don't use the modulo operator for isEven/isOdd checks
1287 | #
1288 | # Linter v0.1.116
1289 | # https://dart.dev/tools/linter-rules/use_is_even_rather_than_modulo
1290 | - use_is_even_rather_than_modulo
1291 |
1292 | # Write `if (nullableBool ?? false)` instead of `if (nullableBool == true)`
1293 | # Not enabled, because `nullableBool == true` is very explicit, whereas `nullableBool ?? false` requires
1294 | # cognitive effort to process
1295 | #
1296 | # Dart SDK: 2.13.0 • (Linter v1.0.0)
1297 | #
1298 | # https://dart.dev/tools/linter-rules/use_if_null_to_convert_nulls_to_bools
1299 | # - use_if_null_to_convert_nulls_to_bools
1300 |
1301 | # Replace const values with predefined constants
1302 | # `const Duration(seconds: 0)` -> `Duration.zero`
1303 | #
1304 | # Dart SDK: 2.13.0 • (Linter v1.0.0)
1305 | #
1306 | # https://dart.dev/tools/linter-rules/use_named_constants
1307 | - use_named_constants
1308 |
1309 | # Adding a key without using it isn't helpful in applications, only for the Flutter SDK
1310 | # https://github.com/dart-lang/linter/issues/3384
1311 | #
1312 | # Dart SDK: >= 2.8.0-dev.1.0 • (Linter v0.1.108)
1313 | # https://dart.dev/tools/linter-rules/use_key_in_widget_constructors
1314 | # - use_key_in_widget_constructors
1315 |
1316 | # Some might argue `late` is a code smell, this lint is very opinionated. It triggers only for private fields and
1317 | # therefore might actually clean up some code.
1318 | # There is no performance impact either way https://github.com/dart-lang/linter/pull/2189#discussion_r457945301
1319 | #
1320 | # Dart SDK: >= 2.10.0-10.0.dev • (Linter v0.1.118)
1321 | #
1322 | # https://dart.dev/tools/linter-rules/use_late_for_private_fields_and_variables
1323 | - use_late_for_private_fields_and_variables
1324 |
1325 | # Use rethrow to preserve the original stacktrace.
1326 | # https://dart.dev/guides/language/effective-dart/usage#do-use-rethrow-to-rethrow-a-caught-exception
1327 | #
1328 | # Dart SDK: >= 2.0.0 • (Linter v0.1.31)
1329 | #
1330 | # https://dart.dev/tools/linter-rules/use_rethrow_when_possible
1331 | - use_rethrow_when_possible
1332 |
1333 | # Use the setter syntax
1334 | #
1335 | # https://dart.dev/tools/linter-rules/use_setters_to_change_properties
1336 | - use_setters_to_change_properties
1337 |
1338 | # In most cases, using a string buffer is preferred for composing strings due to its improved performance.
1339 | # https://dart.dev/tools/linter-rules/use_string_buffers
1340 | - use_string_buffers
1341 |
1342 | # Library names are a legacy feature and discouraged https://dart.dev/guides/language/effective-dart/style#dont-explicitly-name-libraries
1343 | #
1344 | # Linter v1.27.0
1345 | # https://dart.dev/tools/linter-rules/use_string_in_part_of_directives
1346 | - use_string_in_part_of_directives
1347 |
1348 | # More concise and easier to read constructors.
1349 | #
1350 | # Especially helps not to repeat default parameters, which will not update when they change in the super constructor.
1351 | #
1352 | # Linter v1.20
1353 | # https://dart.dev/tools/linter-rules/use_super_parameters
1354 | - use_super_parameters
1355 |
1356 | # Don't use try-catch with fail(), instead catch the error with the `throwsA` matcher. The big advantage:
1357 | # When another error is thrown, the assertion fails whereas catching a specific error would miss the catch block
1358 | #
1359 | # Dart SDK: 2.14.0-172.0.dev • (Linter v1.5.0)
1360 | #
1361 | # https://dart.dev/tools/linter-rules/use_test_throws_matchers
1362 | - use_test_throws_matchers
1363 |
1364 | # Use the truncating division operator (~/) for integer division
1365 | #
1366 | # Dart SDK: >= 3.5.0
1367 | #
1368 | # https://dart.dev/tools/linter-rules/use_truncating_division
1369 | - use_truncating_division
1370 |
1371 | # Naming is hard, strict rules don't help
1372 | #
1373 | # https://dart.dev/tools/linter-rules/use_to_and_as_if_applicable
1374 | # - use_to_and_as_if_applicable
1375 |
1376 | # Catches invalid regular expressions.
1377 | #
1378 | # https://dart.dev/tools/linter-rules/valid_regexps
1379 | - valid_regexps
1380 |
1381 | # Don't assign anything to void
1382 | # https://dart.dev/tools/linter-rules/void_checks
1383 | - void_checks
1384 |
--------------------------------------------------------------------------------
/pubspec.yaml:
--------------------------------------------------------------------------------
1 | name: lint
2 | version: 2.8.0
3 | description: An opinionated, community-driven set of lint rules for Dart and Flutter projects. Like pedantic but stricter
4 | repository: https://github.com/passsy/dart-lint
5 | issue_tracker: https://github.com/passsy/dart-lint/issues
6 | topics:
7 | - lint
8 |
9 | environment:
10 | sdk: ">=3.7.0 <4.0.0"
11 |
--------------------------------------------------------------------------------