mirror of https://github.com/astral-sh/ruff
Add "--select E402" to example snippet in `CONTRIBUTING.md` (#6108)
## Summary In Ruff only a subset of rules are enabled by default. This change change aims to clarify that when adding a new rule, you must explicitly use the `--select name_of_rule` command to ensure the rule gets executed. This was talked about on Discord a while back. ## Test Plan Checked docs via mkdocs
This commit is contained in:
parent
64a186272f
commit
788643f718
|
|
@ -224,9 +224,12 @@ Once you've completed the code for the rule itself, you can define tests with th
|
|||
For example, if you're adding a new rule named `E402`, you would run:
|
||||
|
||||
```shell
|
||||
cargo run -p ruff_cli -- check crates/ruff/resources/test/fixtures/pycodestyle/E402.py --no-cache
|
||||
cargo run -p ruff_cli -- check crates/ruff/resources/test/fixtures/pycodestyle/E402.py --no-cache --select E402
|
||||
```
|
||||
|
||||
**Note:** Only a subset of rules are enabled by default. When testing a new rule, ensure that
|
||||
you activate it by adding `--select ${rule_code}` to the command.
|
||||
|
||||
1. Add the test to the relevant `crates/ruff/src/rules/[linter]/mod.rs` file. If you're contributing
|
||||
a rule to a pre-existing set, you should be able to find a similar example to pattern-match
|
||||
against. If you're adding a new linter, you'll need to create a new `mod.rs` file (see,
|
||||
|
|
|
|||
Loading…
Reference in New Issue