Viewing version 6.1.0. Open the latest package page.

lints

6.1.0

Official Dart lint rules. Defines the 'core' and 'recommended' set of lints suggested by the Dart team.

Download archive

Readme

Dart CI pub package package publisher

Official Dart lint rules

The Dart linter is a static analyzer for identifying possible problems in your Dart source code. More than a hundred linter rules are available, checking anything from potential typing issues, coding style, and formatting. This package - package:lints - contains the lint settings recommended by the Dart team.

Lint sets

This package includes two sets of lints:

  • Core lints: Lints that help identify critical issues that are likely to lead to problems when running or consuming Dart code. All code should pass these lints.

  • Recommended lints: Lints that help identify additional issues that may lead to problems when running or consuming Dart code, and lints that enforce writing Dart using a single, idiomatic style and format. All code is encouraged to pass these lints. The recommended lints include all the core lints.

Additionally, a third lint set - package:flutter_lints - extends the recommended set with additional recommended Flutter-specific lints.

The Dart team will likely not provide recommendations past the core and recommended sets (e.g., a strict rule set). However, there are many such rule sets in the ecosystem (available at pub.dev).

Rule set authors: consider adding the lints topic to your pubspec to allow easier discovery (e.g., pub.dev/packages?q=topic:lints). For more information about topics, visit dart.dev/tools/pub/pubspec#topics.

Where these lints are used

When creating a new Dart project using the dart create command, the recommended set of lints from package:lints is enabled by default.

When uploading a package to the pub.dev package repository, packages are awarded pub points based on how many of the 'core' lints pass.

Enabling the lints

For new apps created with dart create the recommended set of lints are enabled by default.

For existing apps or packages, you can enable these lints via:

  1. In a terminal, located at the root of your package, run this command:

    dart pub add dev:lints
    
  2. Create a new analysis_options.yaml file, next to the pubspec, that includes the lints package:

    include: package:lints/recommended.yaml
    

    or:

    include: package:lints/core.yaml
    

Upgrading to the latest lints

To upgrade to the latest version of the lint set, run:

dart pub add dev:lints

Customizing the predefined lint sets

For details on customizing static analysis above and beyond the predefined lint sets, check out Customizing static analysis.

Evolving the lint sets

The Dart language changes and the ecosystem continues to develop new best practices, so the lint sets must be periodically updated to reflect the best way we know to write Dart code. The process we use is:

  1. Anyone can file an issue to discuss a potential change to a lint set (i.e., adding or removing a lint from one or both sets; if you're proposing an entirely new lint, the place to suggest that is at the sdk repo). Feedback is welcome from any Dart user.

  2. Periodically, a group of Dart and Flutter team members meet to review the suggestions and decide what to adopt.

  3. The lists are updated and a new version of the package is published.

Lint set contents

See rules.md for a list of rules that make up the core and recommended rule sets.

Changelog

6.1.0

6.0.0

5.1.1

  • Updated the SDK lower bound to 3.6.
  • Move to dart-lang/core monorepo.

5.1.0

5.0.0

4.0.0

3.0.0

  • core:
    • added collection_methods_unrelated_type
    • added dangling_library_doc_comments
    • added implicit_call_tearoffs
    • added secure_pubspec_urls
    • added type_literal_in_constant_pattern
    • added use_string_in_part_of_directives
    • removed iterable_contains_unrelated_type
    • removed list_remove_unrelated_type
  • recommended:
    • added unnecessary_to_list_in_spreads
    • added use_super_parameters
    • removed prefer_equal_for_default_values
    • removed prefer_void_to_null
  • Add info about which lints have quick fixes to the package's readme.
  • Move the list of lint rules from the readme to a separate rules.md file.

2.1.1

  • Added the analysis and lints topics to the pubspec file.
  • Update the package's readme to include the list of lint rules that package:lints/core.yaml and package:lints/recommended.yaml include.

2.1.0

  • Updated the SDK lower-bound to 3.0.
  • Removed always_require_non_null_named_parameters from recommended.yaml as it is only relevant in Dart pre 2.12 and with Dart 3.0, libraries can no longer be opted back that far.

2.0.1

  • Updated documentation for the lib/core.yaml and lib/recommended.yaml analysis configurations.

2.0.0

  • Added the following lints to core.yaml:
    • depend_on_referenced_packages
    • null_check_on_nullable_type_parameter
  • Added the following lints to recommended.yaml:
    • library_private_types_in_public_api
    • no_leading_underscores_for_library_prefixes
    • no_leading_underscores_for_local_identifiers
    • prefer_interpolation_to_compose_strings
    • unnecessary_constructor_name
    • unnecessary_late
    • unnecessary_null_aware_assignments
    • unnecessary_nullable_for_final_variable_declarations
  • Bumped the minimum required Dart SDK version to 2.17

1.0.1

  • Documentation updates

1.0.0

  • Initial stable version

Installing

export PUB_HOSTED_URL=https://pub.mirror.p-hatan.ir
flutter pub add 'lints:6.1.0'
pubspec.yaml
name: lints
version: 6.1.0
description: >
  Official Dart lint rules. Defines the 'core' and 'recommended' set of lints
  suggested by the Dart team.
repository: https://github.com/dart-lang/core/tree/main/pkgs/lints
issue_tracker: https://github.com/dart-lang/core/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Alints

topics:
  - analysis
  - lints

environment:
  sdk: ^3.8.0

# NOTE: Code is not allowed in this package - do not add dependencies.
# dependencies:

dev_dependencies:
  http: ^1.0.0
  path: ^1.8.0
  yaml: ^3.1.0

Version history

VersionPublishedArchiveSHA-256
0.1.0On demandDownload7ed8ba71…c7c423
1.0.0-dev.0On demandDownloade5049a1b…5b74a0
1.0.0On demandDownloade98ebba4…53b1f0
1.0.1On demandDownloada2c3d198…fd369c
2.0.0On demandDownload5cfd6509…f396e3
2.0.1On demandDownload5e4a9cd0…5ba593
2.1.0On demandDownload6b0206b0…dbe015
2.1.1On demandDownload0a217c6c…f1b452
3.0.0-betaOn demandDownloadd577a4e0…ed7ffb
3.0.0-beta.2On demandDownload5e5a8fdb…bc0dca
3.0.0On demandDownloadcbf8d4b8…5c4290
4.0.0On demandDownload976c774d…828235
5.0.0On demandDownload3315600f…e3b413
5.1.0On demandDownload4a16b3f0…e1a4c3
5.1.1On demandDownloadc35bb795…74a9d7
6.0.0On demandDownloada5e2b223…fce9a0
6.1.0Cached · Upstream SHA-256 matchedDownload12f842a4…6a87df

Dependencies

No direct dependencies declared.