From a21a732a41489ffa1134cfcb3edc185d5f742b49 Mon Sep 17 00:00:00 2001 From: Rafael Amizes Date: Wed, 21 Aug 2024 18:39:56 -0300 Subject: [PATCH] refactor: stricter linting rules --- CHANGELOG.md | 3 +++ analysis_options.yaml | 22 ++++++++-------------- example/analysis_options.yaml | 18 +++++++++++++++--- example/lib/main.dart | 13 ++++++++----- example/pubspec.lock | 6 +++--- example/pubspec.yaml | 5 +++-- pubspec.lock | 6 +++--- pubspec.yaml | 4 ++-- 8 files changed, 45 insertions(+), 32 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a526912..74a2cb6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +- stricter linting rules. +- update ci-related scripts. + ## [0.5.1] - 2023-02-05 ### Changed diff --git a/analysis_options.yaml b/analysis_options.yaml index 61e2835..39a6f3b 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -1,23 +1,17 @@ include: package:lint/package.yaml + analyzer: - strong-mode: - # A value of false ensures that the type inference engine never implicitly casts - # from dynamic to a more specific type. - implicit-casts: false - # A value of false ensures that the type inference engine never chooses the - # dynamic type when it can’t determine a static type. - implicit-dynamic: false + exclude: + - '**.freezed.dart' + - '**.g.dart' linter: rules: # Make constructors the first thing in every class + sort_unnamed_constructors_first: true sort_constructors_first: true + avoid_catches_without_on_clauses: true + avoid_equals_and_hash_code_on_mutable_classes: true + cancel_subscriptions: true # Good packages document everything public_member_api_docs: true - unawaited_futures: true - # It's a good practice to expose the ability to provide a key when creating public widgets. - use_key_in_widget_constructors: true - always_declare_return_types: true - cancel_subscriptions: true - close_sinks: true - only_throw_errors: true package_api_docs: true diff --git a/example/analysis_options.yaml b/example/analysis_options.yaml index 0f150a2..39a6f3b 100644 --- a/example/analysis_options.yaml +++ b/example/analysis_options.yaml @@ -1,5 +1,17 @@ -include: package:lint/strict.yaml +include: package:lint/package.yaml + +analyzer: + exclude: + - '**.freezed.dart' + - '**.g.dart' linter: rules: - # Always await, intentionally not await - unawaited_futures: true + # Make constructors the first thing in every class + sort_unnamed_constructors_first: true + sort_constructors_first: true + avoid_catches_without_on_clauses: true + avoid_equals_and_hash_code_on_mutable_classes: true + cancel_subscriptions: true + # Good packages document everything + public_member_api_docs: true + package_api_docs: true diff --git a/example/lib/main.dart b/example/lib/main.dart index fc39787..10f8b38 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -1,10 +1,14 @@ +// ignore_for_file: public_member_api_docs + import 'package:eo_color/eo_color.dart'; import 'package:flutter/material.dart'; import 'package:flutter_brand_palettes/flutter_brand_palettes.dart'; -void main() => runApp(MyApp()); +void main() => runApp(const MyApp()); class MyApp extends StatelessWidget { + const MyApp({super.key}); + @override Widget build(BuildContext context) { return const MaterialApp( @@ -16,9 +20,8 @@ class MyApp extends StatelessWidget { } class InstagramPalettePage extends StatelessWidget { - const InstagramPalettePage({required String title, Key? key}) - : _title = title, - super(key: key); + const InstagramPalettePage({required String title, super.key}) + : _title = title; final String _title; static final _gradient = const InstagramGrad().colors; @@ -54,7 +57,7 @@ class InstagramPalettePage extends StatelessWidget { /// Gradient colored text. class GradientTitle extends StatelessWidget { /// Ctor. - const GradientTitle(this._title, this._colors); + const GradientTitle(this._title, this._colors, {super.key}); final String _title; final List _colors; diff --git a/example/pubspec.lock b/example/pubspec.lock index d65a63d..9fa9a72 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -102,10 +102,10 @@ packages: dependency: "direct dev" description: name: lint - sha256: "3e9343b1cededcfb1e8b40d0dbd3592b7a1c6c0121545663a991433390c2bc97" + sha256: d758a5211fce7fd3f5e316f804daefecdc34c7e53559716125e6da7388ae8565 url: "https://pub.dev" source: hosted - version: "2.0.1" + version: "2.3.0" matcher: dependency: transitive description: @@ -208,5 +208,5 @@ packages: source: hosted version: "14.2.4" sdks: - dart: ">=3.3.0 <4.0.0" + dart: ">=3.5.0 <4.0.0" flutter: ">=3.18.0-18.0.pre.54" diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 6462826..0906a2f 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -6,7 +6,8 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev version: 1.0.0 environment: - sdk: ">=2.12.0 <3.0.0" + sdk: ^3.5.0 + flutter: ">=1.17.0" dependencies: eo_color: ^2.2.0 @@ -19,7 +20,7 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter - lint: ^2.0.1 + lint: ^2.3.0 flutter: uses-material-design: true diff --git a/pubspec.lock b/pubspec.lock index 387cbe6..d99ebe9 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -95,10 +95,10 @@ packages: dependency: "direct dev" description: name: lint - sha256: "3e9343b1cededcfb1e8b40d0dbd3592b7a1c6c0121545663a991433390c2bc97" + sha256: d758a5211fce7fd3f5e316f804daefecdc34c7e53559716125e6da7388ae8565 url: "https://pub.dev" source: hosted - version: "2.0.1" + version: "2.3.0" matcher: dependency: transitive description: @@ -201,5 +201,5 @@ packages: source: hosted version: "14.2.4" sdks: - dart: ">=3.3.0 <4.0.0" + dart: ">=3.5.0 <4.0.0" flutter: ">=3.18.0-18.0.pre.54" diff --git a/pubspec.yaml b/pubspec.yaml index c91400a..3834900 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -5,7 +5,7 @@ homepage: https://dartoos.dev repository: https://github.com/dartoos-dev/flutter_brand_palettes environment: - sdk: ">=2.12.0 <3.0.0" + sdk: ^3.5.0 flutter: ">=1.17.0" dependencies: @@ -16,4 +16,4 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter - lint: ^2.0.1 + lint: ^2.3.0