-
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(usage/linter): add auto fix page (#196)
- Loading branch information
Showing
2 changed files
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
--- | ||
outline: [2, 3] | ||
editLink: false | ||
--- | ||
|
||
# Automatic Fixes | ||
|
||
In some cases, Oxlint is able to automatically fix lint violations in your code. | ||
There are two categories of automatic fixes: | ||
|
||
- **Fixes**: These are changes that will not change your program's behavior. It | ||
is generally safe to run them in a pre-lint hook. | ||
- **Suggestions**: Changes that may change your program's behavior or make a | ||
change you may not want (e.g. removing `console.log`s). These should be | ||
reviewed before being committed to your codebase. | ||
|
||
```sh | ||
oxlint --fix # Safe fixes only | ||
oxlint --fix-suggestions # Safe suggestions only | ||
oxlint --fix --fix-suggestions # Safe fixes and suggestions | ||
``` | ||
|
||
You can find which rules are fixable from the [rules page](./rules.md). | ||
|
||
## Dangerous Fixes and Suggestions | ||
|
||
Some fixes and suggestions are considered dangerous. Being more aggressive in | ||
nature, **these may produce invalid code and/or change the behavior of your | ||
program**. These are disabled by default and can be enabled with the | ||
`--fix-dangerous` flag. You should review each change carefully before | ||
committing it to your codebase. | ||
|
||
:::warning | ||
If you are using git, you should stage your changes before running any of the | ||
commands below using `git add -A`. | ||
::: | ||
|
||
```sh | ||
# Safe and dangerous fixes only | ||
oxlint --fix-dangerous | ||
|
||
# Safe and dangerous suggestions only | ||
oxlint --fix-suggestions --fix-dangerous | ||
|
||
# Applies all possible fixes and suggestions | ||
oxlint --fix --fix-suggestions --fix-dangerous | ||
``` | ||
|
||
## Pending Fixes | ||
|
||
You may notice that some rules have a π§ next to their name. This indicate that | ||
they could be automatically fixed, but they are missing an auto-fixer | ||
implementation. You can help improve Oxlint by contributing an auto fixer for | ||
rules that need them. |
b0a06fb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if this doc is targeting an unreleased version, but:
b0a06fb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for noticing the erratum, it should be
--fix-dangerously
, which can be obtained from--help
. I'll correct the doc.