Skip to content

Commit 0d9cc74

Browse files
authored
feat(lints): Update linter/style preferences (#402)
The main change is experimenting with replacing `omit_local_variable_types` with [`omit_obvious_local_variable_types`](https://dart.dev/tools/linter-rules/omit_obvious_local_variable_types) and [`specify_nonobvious_local_variable_types`](https://dart.dev/tools/linter-rules/specify_nonobvious_local_variable_types). This change should help improve the readability of code (especially for outside contributors) while not being as verbose as `always_specify_types`. All changes: - Update license - Bump min Dart SDK version to 3.7. - Add `annotate_redeclares` rule - Add `invalid_runtime_check_with_js_interop_types` rule - Add `missing_code_block_language_in_doc_comment` rule - Replace `omit_local_variable_types` with `omit_obvious_local_variable_types` and `specify_nonobvious_local_variable_types` rules - Add `unsafe_variance` rule - Add `use_truncating_division` rule - Remove `package_api_docs` rule (removed in Dart 3.7).
1 parent 440d027 commit 0d9cc74

File tree

4 files changed

+21
-7
lines changed

4 files changed

+21
-7
lines changed

packages/celest_lints/CHANGELOG.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
1-
## 1.1.1-wip
1+
## 1.2.0
22

3-
- chore: Update license
3+
- Update license
4+
- Bump min Dart SDK version to 3.7.
5+
- Add `annotate_redeclares` rule
6+
- Add `invalid_runtime_check_with_js_interop_types` rule
7+
- Add `missing_code_block_language_in_doc_comment` rule
8+
- Replace `omit_local_variable_types` with `omit_obvious_local_variable_types` and `specify_nonobvious_local_variable_types` rules
9+
- Add `unsafe_variance` rule
10+
- Add `use_truncating_division` rule
11+
- Remove `package_api_docs` rule (removed in Dart 3.7).
412

513
## 1.1.0
614

packages/celest_lints/lib/app.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@ linter:
1919
- eol_at_end_of_file # To provide consistency across our repos/languages.
2020
- flutter_style_todos # To ensure traceability of TODOs.
2121
- invalid_case_patterns # To prevent invalid case statements.
22+
- invalid_runtime_check_with_js_interop_types # To prevent runtime issues when compiling to JS.
2223
# - lines_longer_than_80_chars # Too restrictive as a lint, but generally a good rule to follow nonetheless.
23-
- omit_local_variable_types # To encourage conciseness and improve code readability.
24+
- omit_obvious_local_variable_types # To encourage conciseness and improve code readability.
2425
- only_throw_errors # To ensure downstream exception handling always works.
2526
- prefer_final_in_for_each # To improve code intent and avoid accidental reassignment.
2627
- prefer_final_locals # To improve code intent and avoid accidental reassignment.

packages/celest_lints/lib/library.yaml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ linter:
1212
rules:
1313
- always_declare_return_types # To ensure that functions do not implicitly return dynamic.
1414
- always_use_package_imports # To ensure consistency and prevent issues when combining with relative imports.
15+
- annotate_redeclares # To ensure redeclared methods on extension types are properly annotated.
1516
- avoid_catches_without_on_clauses # To encourage thoughtfulness when introducing catch clauses and to avoid catching Errors unless specifically required.
1617
- avoid_classes_with_only_static_members # To embrace Dart idioms and prefer top-level functions.
1718
- avoid_dynamic_calls # To prevent unintentional dynamic dispatch which can lead to preventable runtime errors.
@@ -35,14 +36,15 @@ linter:
3536
- eol_at_end_of_file # To provide consistency across our repos/languages.
3637
- flutter_style_todos # To ensure traceability of TODOs.
3738
- invalid_case_patterns # To prevent invalid case statements.
39+
- invalid_runtime_check_with_js_interop_types # To prevent runtime issues when compiling to JS.
3840
- join_return_with_assignment # To improve code readability.
3941
# - lines_longer_than_80_chars # Too restrictive as a lint, but generally a good rule to follow nonetheless.
42+
- missing_code_block_language_in_doc_comment # To ensure generated dartdoc integrity.
4043
- missing_whitespace_between_adjacent_strings # To prevent sentences which are smashedtogether.
4144
- no_runtimeType_toString # To avoid issues when compiling to Web and improve performance.
4245
- noop_primitive_operations # To prevent redundancy.
43-
- omit_local_variable_types # To encourage conciseness and improve code readability.
46+
- omit_obvious_local_variable_types # To encourage conciseness and improve code readability.
4447
- only_throw_errors # To ensure downstream exception handling always works.
45-
- package_api_docs # To ensure public APIs have proper context and explanation.
4648
- prefer_asserts_in_initializer_lists # To improve code readability.
4749
- prefer_asserts_with_message # To provide context to developers and users.
4850
- prefer_const_constructors # To allow for compile-time optimizations.
@@ -56,6 +58,7 @@ linter:
5658
- prefer_null_aware_method_calls # To improve code readability.
5759
- prefer_single_quotes # To encourage consistent styling.
5860
- public_member_api_docs # To provide users with ample context and explanation.
61+
- specify_nonobvious_local_variable_types # To improve code readability.
5962
- sort_constructors_first # To provide a consistent style for classes.
6063
- sort_unnamed_constructors_first # To provide organization and quick exploration.
6164
- sort_pub_dependencies # To simplify searching a large list.
@@ -67,6 +70,7 @@ linter:
6770
- unnecessary_breaks # To simplify switch statements.
6871
- unnecessary_lambdas # To make code more concise.
6972
- unnecessary_null_checks # To improve code readability.
73+
- unsafe_variance # To prevent runtime issues with type parameters.
7074
- use_enums # To encourage use of the enhanced-enums language feature.
7175
- use_if_null_to_convert_nulls_to_bools # To improve code readability.
7276
- use_late_for_private_fields_and_variables # To improve code readability.
@@ -77,6 +81,7 @@ linter:
7781
- use_super_parameters # To improve code readability and prevent redundancy.
7882
- use_test_throws_matchers # To improve code readability.
7983
- use_to_and_as_if_applicable # To improve code readability.
84+
- use_truncating_division # To improve code readability.
8085

8186
# Flutter-specific linter rules
8287
- avoid_unnecessary_containers # To improve code readability.

packages/celest_lints/pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
name: celest_lints
22
description: The lint rules used in developing Celest packages and plugins.
3-
version: 1.1.0
3+
version: 1.2.0
44
homepage: https://celest.dev
55
repository: https://github.com/celest-dev/celest/tree/main/packages/celest_lints
66

77
environment:
8-
sdk: ^3.5.0
8+
sdk: ^3.7.0
99
resolution: workspace
1010

1111
dependencies:

0 commit comments

Comments
 (0)