Skip to content
This repository was archived by the owner on Nov 20, 2024. It is now read-only.

Commit c61b8f8

Browse files
authored
Update docs to recommend analyzer CLI (#393). (#411)
Fixes: #393
1 parent 864b051 commit c61b8f8

File tree

1 file changed

+16
-27
lines changed

1 file changed

+16
-27
lines changed

README.md

Lines changed: 16 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -9,41 +9,28 @@ A Dart style linter.
99

1010
## Installing
1111

12-
The easiest way to install the `linter` is to [globally activate](https://www.dartlang.org/tools/pub/cmd/pub-global.html) it via `pub`:
12+
The linter is bundled with the Dart [SDK](https://www.dartlang.org/tools/sdk); if you have an updated Dart SDK already, you're done!
1313

14-
$ pub global activate linter
15-
16-
Alternatively, clone the `linter` repo like this:
14+
Alternatively, if you want to contribute to the linter or examine the source, clone the `linter` repo like this:
1715

1816
$ git clone https://github.com/dart-lang/linter.git
1917

2018
## Usage
2119

22-
Linter for Dart gives you feedback to help you keep your code in line with the published [Dart Style Guide](https://www.dartlang.org/articles/style-guide/). Currently enforced lint rules (or "lints") are catalogued [here](http://dart-lang.github.io/linter/lints/). When you run the linter all lints are enabled but don't worry, configuration, wherein you can specifically enable/disable lints, is in the [works](https://github.com/dart-lang/linter/issues/7). While initial focus is on style lints, other lints that catch common programming errors are certainly of interest. If you have ideas, please file a [feature request][tracker].
23-
24-
Running the linter via `pub` looks like this:
25-
26-
$ pub global run linter my_project
27-
28-
With example output will looking like this:
29-
30-
my_project/my_library.dart 13:8 [lint] Name non-constant identifiers using lowerCamelCase.
31-
IOSink std_err = stderr;
32-
^^^^^^^
33-
12 files analyzed, 1 issue found.
34-
35-
Supported options are
36-
37-
-h, --help Shows usage information.
38-
-s, --stats Show lint statistics.
39-
--[no-]visit-transitive-closure Visit the transitive closure of imported/exported libraries.
40-
-q, --[no-]quiet Don't show individual lint errors.
41-
-c, --config Use configuration from this file.
42-
--dart-sdk Custom path to a Dart SDK.
43-
-p, --package-root Custom package root. (Discouraged.)
20+
The linter gives you feedback to help you catch potential errors and keep your code in line with the published [Dart Style Guide](https://www.dartlang.org/articles/style-guide/). Currently enforcable lint rules (or "lints") are catalogued [here][lints] and can be configured via an [analysis options file][options_file]. The linter is run from within the `dartanalyzer` [command-line tool](https://github.com/dart-lang/sdk/tree/master/pkg/analyzer_cli#dartanalyzer) shipped with the Dart SDK. Assuming you have lints configured in an `.analysis_options` file with these contents:
4421

45-
Note that you should not need to specify an `sdk` or `package-root`. Lint configuration file format is provisional and under [active discussion](https://github.com/dart-lang/linter/issues/41). Other configuration options are on the way.
22+
```
23+
linter:
24+
rules:
25+
- annotate_overrides
26+
- hash_and_equals
27+
- prefer_is_not_empty
28+
```
29+
you could lint your package like this:
4630

31+
$ dartanalyzer --options .analysis_options .
32+
33+
and see any violations of the `annotate_overrides`, `hash_and_equals`, and `prefer_is_not_empty` rules in the console. In practice you would probably configure quite a few more rules (the full list is [here][lints]). For more on configuring analysis, see the analysis option file [docs][options_file].
4734

4835
## Contributing
4936

@@ -55,4 +42,6 @@ Feedback is, of course, greatly appreciated and contributions are welcome! Pleas
5542
Please file feature requests and bugs at the [issue tracker][tracker].
5643

5744
[tracker]: https://github.com/dart-lang/linter/issues
45+
[lints]: http://dart-lang.github.io/linter/lints/
46+
[options_file]: https://www.dartlang.org/guides/language/analysis-options#the-analysis-options-file
5847

0 commit comments

Comments
 (0)