|
1 | 1 | [](https://pub.dev/packages/lints)
|
2 | 2 | [](https://github.com/dart-lang/lints/actions?query=branch%3Amain)
|
3 | 3 |
|
4 |
| -This repo contains official Dart lint rules. |
| 4 | +# Official Dart lint rules. |
5 | 5 |
|
| 6 | +The Dart linter is a static analyzer for identifying possible problems in your |
| 7 | +Dart source code. More than a hundred [linter rules][rules] are available, |
| 8 | +checking anything from potential typing issues, coding style, and formatting. |
| 9 | + |
| 10 | +The current `package:lints` contains the official selections of lints that the |
| 11 | +Dart team encourages using. |
| 12 | + |
| 13 | +Two sets of lints are available: |
| 14 | + |
| 15 | +* ***Core lints***: Lints that help identify critical issues that are likely to |
| 16 | +lead to problems when running or consuming Dart code. All code should pass these |
| 17 | +lints. |
| 18 | + |
| 19 | +* ***Recommended lints***: Lints that help identify additional issues that may |
| 20 | +lead to problems when running or consuming Dart code, and lints that enforce |
| 21 | +writing Dart using a single, idiomatic style and format. All code is encouraged |
| 22 | +to pass these lints. The recommended lints include all the core lints. |
| 23 | + |
| 24 | +## Where these lints are used |
| 25 | + |
| 26 | +When creating new Dart project using the [`dart create`][dart create] command, |
| 27 | +the lints from `package:lints` are enabled by default. |
| 28 | + |
| 29 | +When uploading a package to the [pub.dev] package repository, packages are |
| 30 | +[awarded pub points][scoring] depending on whether they pass at least the 'core' |
| 31 | +lints (note: the recommended lints automatically include all core lints). |
| 32 | + |
| 33 | +For documentation on the individual lints, see the [linter rules][rules] page on |
| 34 | +dart.dev. |
| 35 | + |
| 36 | +## How to enable these lints |
| 37 | + |
| 38 | +For new apps created with `dart create`, the lints are enabled by default. |
| 39 | + |
| 40 | +For existing apps or packages, take these steps to enable these lints: |
| 41 | + |
| 42 | +1. Add a *dev* dependency on this package to your `pubspec.yaml` file: |
| 43 | + |
| 44 | +```yaml |
| 45 | +dev_dependencies: |
| 46 | + lints: ^1.0.0 |
| 47 | +``` |
| 48 | +
|
| 49 | +2. Create a new `analysis_options.yaml` file, next to the pubspec, that includes |
| 50 | +the lints package: |
| 51 | + |
| 52 | +```yaml |
| 53 | +include: package:lints/core.yaml |
| 54 | +``` |
| 55 | + |
| 56 | +## Customizing the pre-defined lint sets |
| 57 | + |
| 58 | +You can customize the pre-defined lint sets, both to disable one or more of the |
| 59 | +lints included, or to add additional lints. For details see [customizing static |
| 60 | +analysis]. |
| 61 | + |
| 62 | +[dart create]: https://dart.dev/tools/dart-tool |
| 63 | +[scoring]: https://pub.dev/help/scoring |
| 64 | +[customizing static analysis]: https://dart.dev/guides/language/analysis-options |
| 65 | +[rules]: https://dart.dev/tools/linter-rules |
| 66 | +[pub.dev]: https://pub.dev |
0 commit comments