Skip to content

Commit a64c379

Browse files
committed
Merge package:lints into the core monorepo
2 parents 7f9f597 + 2e5c71d commit a64c379

21 files changed

+2079
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
blank_issues_enabled: true
2+
contact_links:
3+
- name: Propose a new lint
4+
url: https://github.com/dart-lang/linter/issues/new?assignees=&labels=enhancement%2C+lint+request&template=lint-request.md&title=
5+
about: Request a new lint rule.
6+
- name: Report an issue with a lint
7+
url: https://github.com/dart-lang/linter/issues/new?assignees=&labels=&template=issue-report.md&title=
8+
about: Create an issue report for an existing lint.
9+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
name: Add an existing lint to the `core` or `recommended` rule set
3+
about: Propose adding an existing lint rule to the `core` or `recommended` rule set.
4+
title: ''
5+
labels: type-lint
6+
assignees: ''
7+
8+
---
9+
10+
**Describe the rule you'd like to see added and to what rule set**
11+
Include as much detail as you can.
12+
13+
**Additional context**
14+
Add any other considerations or context here.

pkgs/lints/.github/dependabot.yaml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Dependabot configuration file.
2+
version: 2
3+
4+
updates:
5+
- package-ecosystem: github-actions
6+
directory: /
7+
schedule:
8+
interval: monthly
9+
labels:
10+
- autosubmit
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# A CI configuration to auto-publish pub packages.
2+
3+
name: Publish
4+
5+
on:
6+
pull_request:
7+
branches: [ main ]
8+
push:
9+
tags: [ 'v[0-9]+.[0-9]+.[0-9]+*' ]
10+
11+
jobs:
12+
publish:
13+
if: ${{ github.repository_owner == 'dart-lang' }}
14+
uses: dart-lang/ecosystem/.github/workflows/publish.yaml@main
+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: validate
2+
3+
# Controls when the action will run.
4+
on:
5+
# Triggers the workflow on push or pull request events but only for the main branch
6+
push:
7+
branches: [ main ]
8+
pull_request:
9+
branches: [ main ]
10+
# Run weekly
11+
schedule:
12+
- cron: "0 0 * * 0"
13+
14+
jobs:
15+
build:
16+
runs-on: ubuntu-latest
17+
strategy:
18+
fail-fast: false
19+
matrix:
20+
sdk: [beta] # todo: re-add stable
21+
22+
steps:
23+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
24+
- uses: dart-lang/setup-dart@e630b99d28a3b71860378cafdc2a067c71107f94
25+
with:
26+
sdk: ${{ matrix.sdk }}
27+
28+
- run: dart pub get
29+
- run: dart format --output=none --set-exit-if-changed .
30+
- run: dart analyze --fatal-infos
31+
- run: dart tool/validate_lib.dart
32+
- run: dart tool/gen_docs.dart --verify

pkgs/lints/.gitignore

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Files and directories created by pub
2+
.dart_tool/
3+
.packages
4+
5+
# Omit commiting pubspec.lock for library packages:
6+
# https://dart.dev/guides/libraries/private-files#pubspeclock
7+
pubspec.lock
8+
9+
# Directory created by dartdoc
10+
doc/api/

pkgs/lints/CHANGELOG.md

+96
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
## 5.1.1
2+
3+
- Updated the SDK lower bound to 3.6.
4+
5+
## 5.1.0
6+
7+
- `core`:
8+
- added [unintended_html_in_doc_comment] (https://github.com/dart-lang/lints/issues/192)
9+
- Updated the SDK lower bound to 3.6 (dev).
10+
11+
[unintended_html_in_doc_comment]: https://dart.dev/lints/unintended_html_in_doc_comment
12+
13+
## 5.0.0
14+
15+
- `recommended`:
16+
- added [invalid_runtime_check_with_js_interop_types] (https://github.com/dart-lang/lints/issues/188)
17+
- added [unnecessary_library_name] (https://github.com/dart-lang/lints/issues/181)
18+
- removed [avoid_null_checks_in_equality_operators] (https://github.com/dart-lang/lints/issues/200)
19+
- Updated the SDK lower-bound to 3.5.
20+
21+
[invalid_runtime_check_with_js_interop_types]: https://dart.dev/tools/linter-rules/invalid_runtime_check_with_js_interop_types
22+
[unnecessary_library_name]: https://dart.dev/lints/unnecessary_library_name
23+
[avoid_null_checks_in_equality_operators]: https://dart.dev/tools/linter-rules/avoid_null_checks_in_equality_operators
24+
25+
## 4.0.0
26+
27+
- `core`:
28+
- added `library_annotations` (https://github.com/dart-lang/lints/issues/177)
29+
- added `no_wildcard_variable_uses` (https://github.com/dart-lang/lints/issues/139)
30+
- removed `package_prefixed_library_names` (https://github.com/dart-lang/lints/issues/172)
31+
- `recommended`:
32+
- removed `library_names` (https://github.com/dart-lang/lints/issues/181)
33+
- Updated the SDK lower-bound to 3.1.
34+
- Add a section on upgrading to the latest lint set to the readme.
35+
36+
## 3.0.0
37+
38+
- `core`:
39+
- added `collection_methods_unrelated_type`
40+
- added `dangling_library_doc_comments`
41+
- added `implicit_call_tearoffs`
42+
- added `secure_pubspec_urls`
43+
- added `type_literal_in_constant_pattern`
44+
- added `use_string_in_part_of_directives`
45+
- removed `iterable_contains_unrelated_type`
46+
- removed `list_remove_unrelated_type`
47+
- `recommended`:
48+
- added `unnecessary_to_list_in_spreads`
49+
- added `use_super_parameters`
50+
- removed `prefer_equal_for_default_values`
51+
- removed `prefer_void_to_null`
52+
- Add info about which lints have quick fixes to the package's readme.
53+
- Move the list of lint rules from the readme to a separate
54+
[rules.md](https://github.com/dart-lang/lints/blob/main/rules.md) file.
55+
56+
## 2.1.1
57+
58+
- Added the `analysis` and `lints` topics to the pubspec file.
59+
- Update the package's readme to include the list of lint rules that
60+
`package:lints/core.yaml` and `package:lints/recommended.yaml` include.
61+
62+
## 2.1.0
63+
64+
- Updated the SDK lower-bound to 3.0.
65+
- Removed `always_require_non_null_named_parameters` from `recommended.yaml`
66+
as it is only relevant in Dart pre 2.12 and with Dart 3.0, libraries can
67+
no longer be opted back that far.
68+
69+
## 2.0.1
70+
71+
- Updated documentation for the `lib/core.yaml` and `lib/recommended.yaml`
72+
analysis configurations.
73+
74+
## 2.0.0
75+
76+
- Added the following lints to core.yaml:
77+
- `depend_on_referenced_packages`
78+
- `null_check_on_nullable_type_parameter`
79+
- Added the following lints to recommended.yaml:
80+
- `library_private_types_in_public_api`
81+
- `no_leading_underscores_for_library_prefixes`
82+
- `no_leading_underscores_for_local_identifiers`
83+
- `prefer_interpolation_to_compose_strings`
84+
- `unnecessary_constructor_name`
85+
- `unnecessary_late`
86+
- `unnecessary_null_aware_assignments`
87+
- `unnecessary_nullable_for_final_variable_declarations`
88+
- Bumped the minimum required Dart SDK version to 2.17
89+
90+
## 1.0.1
91+
92+
- Documentation updates
93+
94+
## 1.0.0
95+
96+
- Initial stable version

pkgs/lints/LICENSE

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
Copyright 2021, the Dart project authors.
2+
3+
Redistribution and use in source and binary forms, with or without
4+
modification, are permitted provided that the following conditions are
5+
met:
6+
7+
* Redistributions of source code must retain the above copyright
8+
notice, this list of conditions and the following disclaimer.
9+
* Redistributions in binary form must reproduce the above
10+
copyright notice, this list of conditions and the following
11+
disclaimer in the documentation and/or other materials provided
12+
with the distribution.
13+
* Neither the name of Google LLC nor the names of its
14+
contributors may be used to endorse or promote products derived
15+
from this software without specific prior written permission.
16+
17+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21+
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

pkgs/lints/README.md

+115
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
[![Build Status](https://github.com/dart-lang/lints/workflows/validate/badge.svg)](https://github.com/dart-lang/lints/actions?query=branch%3Amain)
2+
[![pub package](https://img.shields.io/pub/v/lints.svg)](https://pub.dev/packages/lints)
3+
[![package publisher](https://img.shields.io/pub/publisher/lints.svg)](https://pub.dev/packages/lints/publisher)
4+
5+
# Official Dart lint rules
6+
7+
The Dart linter is a static analyzer for identifying possible problems in your
8+
Dart source code. More than a hundred [linter rules][rules] are available,
9+
checking anything from potential typing issues, coding style, and formatting.
10+
This package - `package:lints` - contains the lint settings recommended by the
11+
Dart team.
12+
13+
## Lint sets
14+
15+
This package includes two sets of lints:
16+
17+
* **Core lints**: Lints that help identify critical issues that are likely to
18+
lead to problems when running or consuming Dart code. All code should pass these
19+
lints.
20+
21+
* **Recommended lints**: Lints that help identify additional issues that may
22+
lead to problems when running or consuming Dart code, and lints that enforce
23+
writing Dart using a single, idiomatic style and format. All code is encouraged
24+
to pass these lints. The recommended lints include all the core lints.
25+
26+
Additionally, a third lint set -
27+
[`package:flutter_lints`](https://pub.dev/packages/flutter_lints) - extends the
28+
recommended set with additional recommended Flutter-specific lints.
29+
30+
The Dart team will likely not provide recommendations past the `core` and
31+
`recommended` sets (e.g., a `strict` rule set). However, there are many such rule
32+
sets in the ecosystem (available at [pub.dev](https://pub.dev/)).
33+
34+
Rule set authors: consider adding the `lints` topic to your pubspec to allow
35+
easier discovery (e.g.,
36+
[pub.dev/packages?q=topic:lints](https://pub.dev/packages?q=topic%3Alints)).
37+
For more information about topics, visit
38+
[dart.dev/tools/pub/pubspec#topics](https://dart.dev/tools/pub/pubspec#topics).
39+
40+
## Where these lints are used
41+
42+
When creating a new Dart project using the [`dart create`][dart create] command,
43+
the `recommended` set of lints from `package:lints` is enabled by default.
44+
45+
When uploading a package to the [pub.dev] package repository, packages are
46+
[awarded pub points][scoring] based on how many of the 'core' lints pass.
47+
48+
## Enabling the lints
49+
50+
For new apps created with `dart create` the `recommended` set of lints are
51+
enabled by default.
52+
53+
For existing apps or packages, you can enable these lints via:
54+
55+
1. In a terminal, located at the root of your package, run this command:
56+
57+
```terminal
58+
dart pub add dev:lints
59+
```
60+
61+
2. Create a new `analysis_options.yaml` file, next to the pubspec, that
62+
includes the lints package:
63+
64+
```yaml
65+
include: package:lints/recommended.yaml
66+
```
67+
68+
or:
69+
70+
```yaml
71+
include: package:lints/core.yaml
72+
```
73+
74+
## Upgrading to the latest lints
75+
76+
To upgrade to the latest version of the lint set, run:
77+
78+
```
79+
dart pub add dev:lints
80+
```
81+
82+
## Customizing the predefined lint sets
83+
84+
For details on customizing static analysis above and beyond the predefined
85+
lint sets, check out [Customizing static analysis].
86+
87+
## Evolving the lint sets
88+
89+
The Dart language changes and the ecosystem continues to develop new best
90+
practices, so the lint sets must be periodically updated to reflect the best way
91+
we know to write Dart code. The process we use is:
92+
93+
1. Anyone can file an [issue] to discuss a potential change to a lint set
94+
(i.e., adding or removing a lint from one or both sets; if you're proposing
95+
an entirely new lint, the place to suggest that is at the [linter repo]).
96+
Feedback is welcome from any Dart user.
97+
98+
2. Periodically, a group of Dart and Flutter team members meet to review the
99+
suggestions and decide what to adopt.
100+
101+
3. The lists are updated and a new version of the package is published.
102+
103+
## Lint set contents
104+
105+
See [rules.md](https://github.com/dart-lang/lints/blob/main/rules.md) for a list
106+
of rules that make up the core and recommended rule sets.
107+
108+
[dart create]: https://dart.dev/tools/dart-create
109+
[scoring]: https://pub.dev/help/scoring
110+
[customizing static analysis]: https://dart.dev/tools/analysis
111+
[rules]: https://dart.dev/tools/linter-rules
112+
[pub.dev]: https://pub.dev
113+
[issue]: https://github.com/dart-lang/lints/issues
114+
[linter repo]: https://github.com/dart-lang/linter
115+
[`package:flutter_lints`]: https://pub.dev/packages/flutter_lints

pkgs/lints/example/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
An example project that uses Dart recommended lints.
+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# This file configures the static analysis results for your project (errors,
2+
# warnings, and lints).
3+
#
4+
# This enables the 'recommended' set of lints from `package:lints`.
5+
# This set helps identify many issues that may lead to problems when running
6+
# or consuming Dart code, and enforces writing Dart using a single, idiomatic
7+
# style and format.
8+
#
9+
# If you want a smaller set of lints you can change this to specify
10+
# 'package:lints/core.yaml'. These are just the most critical lints
11+
# (the recommended set includes the core lints).
12+
# The core lints are also what is used by pub.dev for scoring packages.
13+
14+
include: package:lints/recommended.yaml
15+
16+
# Uncomment the following section to specify additional rules.
17+
18+
# linter:
19+
# rules:
20+
# - camel_case_types
21+
22+
# analyzer:
23+
# exclude:
24+
# - path/to/excluded/files/**
25+
26+
# For more information about the core and recommended set of lints, see
27+
# https://dart.dev/go/core-lints
28+
29+
# For additional information about configuring this file, see
30+
# https://dart.dev/guides/language/analysis-options

pkgs/lints/example/pubspec.yaml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
name: example
2+
description: An example project that uses Dart recommended lints.
3+
version: 0.1.0
4+
publish_to: none
5+
6+
environment:
7+
sdk: ^3.0.0
8+
9+
dev_dependencies:
10+
lints: ^2.1.0

0 commit comments

Comments
 (0)