Skip to content

Commit 9cb7e9e

Browse files
srawlinsCommit Queue
authored andcommitted
DAS: document enabling lint rule and suppressing
Change-Id: I26504b84c3a899c4f9f80d8a35f6c2c622c5613c Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/416181 Reviewed-by: Johnni Winther <[email protected]> Commit-Queue: Samuel Rawlins <[email protected]> Reviewed-by: Brian Wilkerson <[email protected]>
1 parent 630119e commit 9cb7e9e

File tree

1 file changed

+38
-2
lines changed

1 file changed

+38
-2
lines changed

pkg/analysis_server_plugin/doc/using_plugins.md

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ can be enabled for a given package, so that the plugin can report diagnostics
55
(lints and warnings) and offer quick fixes. Plugins are enabled via the
66
`analysis_options.yaml` file under the top-level `plugins` section:
77

8-
```
8+
```yaml
99
plugins:
1010
my_plugin: ^1.0.0
1111
```
@@ -26,7 +26,7 @@ as the key. The value can either be
2626

2727
For example, while developing a plugin locally, it can be enabled as:
2828

29-
```
29+
```yaml
3030
plugins:
3131
my_plugin:
3232
path: /path/to/my_plugin
@@ -37,3 +37,39 @@ Note: after any change is made to the `plugins` section of an
3737
the effects.
3838

3939
[legacy]: https://github.com/dart-lang/sdk/blob/main/pkg/analyzer_plugin/doc/tutorial/tutorial.md
40+
41+
## Enabling a lint rule
42+
43+
A plugin can report two kinds of diagnostics: warnings and lints. Any warnings
44+
that a plugin defines are enabled by default (like analyzer warnings). Any lint
45+
rules that a plugin defines are disabled by default (like analyzer lint rules),
46+
and must be explicitly enabled in analysis options. Lint rules are enabled
47+
under the `diagnostics` section for a plugin:
48+
49+
```yaml
50+
plugins:
51+
my_plugin:
52+
path: /path/to/my_plugin
53+
diagnostics:
54+
rule_1: true
55+
rule_2: true
56+
rule_3: false
57+
```
58+
59+
In the configuration above, `rule_1` and `rule_2` are enabled. Additionally,
60+
`rule_3` is disabled, which can be useful if an included analysis options file
61+
explicitly enables the rule.
62+
63+
## Suppressing diagnostics
64+
65+
A diagnostic which is reported by a plugin can be suppressed with a comment. The
66+
syntax is similar to suppressing an out-of-the-box warning or lint diagnostic
67+
(see [the docs](https://dart.dev/tools/analysis#suppressing-diagnostics-for-a-file)).
68+
To suppress a warning or lint named "some_code" in a plugin named "some_plugin,"
69+
use a comment like the following:
70+
71+
```dart
72+
// ignore: some_plugin/some_code
73+
74+
// ignore_for_file: some_plugin/some_code
75+
```

0 commit comments

Comments
 (0)