diff --git a/CHANGELOG.md b/CHANGELOG.md index decf4bb..5349ea0 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,25 @@ # Changlog +## 1.8.1 + +Requires Dart `sdk: '>=2.15.0-7.0.dev <3.0.0'` + +- Enable [`always_use_package_imports`](https://dart-lang.github.io/linter/lints/always_use_package_imports.html) +- Enable [`avoid_double_and_int_checks`](https://dart-lang.github.io/linter/lints/avoid_double_and_int_checks.html) +- Enable [`use_is_even_rather_than_modulo`](https://dart-lang.github.io/linter/lints/use_is_even_rather_than_modulo.html) +- [`parameter_assignments`](https://dart-lang.github.io/linter/lints/always_use_package_imports.html) is now a warning (was hint) +- [`missing_required_param`](https://dart-lang.github.io/linter/lints/missing_required_param.html) is now a error (was warning) +- [`missing_return`](https://dart-lang.github.io/linter/lints/missing_return.html) is now an error (was warning) +- ignore any errors in auto-generated flutter file `lib/generated_plugin_registrant.dart` + +### Package + +- Enable [`library_private_types_in_public_api`](https://dart-lang.github.io/linter/lints/library_private_types_in_public_api.html) +- Enable [`lines_longer_than_80_chars`](https://dart-lang.github.io/linter/lints/lines_longer_than_80_chars.html) +- Enable [`prefer_single_quotes`](https://dart-lang.github.io/linter/lints/prefer_single_quotes.html) + +Big thanks to @rydmike for comparing all popular lint packages, identifying missing rules for this `lint` + ## 1.8.0 Requires Dart `sdk: '>=2.15.0-7.0.dev <3.0.0'` diff --git a/README.md b/README.md index 6e9075a..45fc4da 100755 --- a/README.md +++ b/README.md @@ -3,7 +3,6 @@ # Lint for Dart/Flutter -

@@ -11,70 +10,48 @@ `lint` is a hand-picked, open-source, community-driven collection of lint rules for Dart and Flutter projects. The set of rules follows the [Effective Dart: Style Guide](https://dart.dev/guides/language/effective-dart/style). -This package can be used as a replacement for [`package:pedantic`](https://github.com/dart-lang/pedantic) for those who prefer stricter rules. +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. + +`lint` tries to be strict but not annoying. ## Install -Add `lint` as dependency to your `pubspec.yaml` +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` ```yaml dev_dependencies: lint: ^1.0.0 ``` -Create a `analysis_options.yaml` file in the root of your project and import the `lint` rules: +Create a `analysis_options.yaml` file in the root of your project with the following content: ```yaml -include: package:lint/analysis_options.yaml -``` +# This file configures the analyzer to use the lint rule set from `package:lint` -If you're writing a package with a public API you should use the `package` version instead -```yaml -include: package:lint/analysis_options_package.yaml -``` +# For apps, use the default set +include: package:lint/analysis_options.yaml -## Enable/Disable rules +# Packages, that may be distributed (i.e. via pub.dev) should use the package +# version, resulting in a better pub score. +# include: package:lint/analysis_options_package.yaml -`lint` is customizable, you can add or remove rules, depending on your needs. -To do so adjust your `analysis_options.yaml`. - -```yaml -include: package:lint/analysis_options.yaml +# You might want to exclude auto-generated files from dart analysis +analyzer: + exclude: + #- '**.freezed.dart' +# You can customize the lint rules set to your own liking. A list of all rules +# can be found at https://dart-lang.github.io/linter/lints/options/options.html linter: rules: - # ------ Disable individual rules ----- # - # --- # - # Turn off what you don't like. # - # ------------------------------------- # - - # Use parameter order as in json response - always_put_required_named_parameters_first: false - # Util classes are awesome! - avoid_classes_with_only_static_members: false - - - # ------ Enable individual rules ------ # - # --- # - # These rules here are good but too # - # opinionated to enable them by default # - # ------------------------------------- # - + # avoid_classes_with_only_static_members: false + # Make constructors the first thing in every class - sort_constructors_first: true - - # The new tabs vs. spaces. Choose wisely - prefer_single_quotes: true - prefer_double_quotes: true + # sort_constructors_first: true - # Good packages document everything - public_member_api_docs: true - - # Blindly follow the Flutter code style, which prefers types everywhere - always_specify_types: true - - # Back to the 80s - lines_longer_than_80_chars: true + # Choose wisely, but you don't have to + # prefer_double_quotes: true + # prefer_single_quotes: true ``` ## Lint badge @@ -88,7 +65,13 @@ Add the badge to your `README.md` show that you honor strict lint rules [![style: lint](https://img.shields.io/badge/style-lint-4BC0F5.svg)](https://pub.dev/packages/lint) ``` -## Comparison to package:pedantic +## Comparison with other lint packages + +A detailed comparison of all linting packages for dart can be found at https://rydmike.com/blog_flutter_linting.html + +`lint` is among the strictest but not the strictest. It tires to find the right balance between useful and annoying. + +## Comparison to discontinued package:pedantic Google publicly shares their internal rules as `package:pedantic` in open-source. It represents what Google is enforcing internally throughout all Dart code. @@ -101,7 +84,6 @@ For developers outside Google, it is the norm to have separate lint rules per pr One project might enable more rules then others. `lint` enables a majority of lint rules, leaving out contradictory and very opinionated rules. - ## License diff --git a/pubspec.yaml b/pubspec.yaml index 1dff4e3..42730a1 100755 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: lint -version: 1.8.0 +version: 1.8.1 description: An opinionated, community-driven set of lint rules for Dart and Flutter projects. Like pedantic but stricter homepage: https://github.com/passsy/dart-lint