-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
docs: better rules table (filter rules by extension, etc.) #7666
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
3c6b594
23cf04b
37d5f1f
2259ef8
bd14e9a
58f370b
23bcddb
37f13fc
d23a3f8
bde93ea
624d23a
fefe2eb
d2c35d7
868ea0b
a3457e3
ca9e428
e643ed5
3d890b4
9f26099
0b64bad
49ec745
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,18 +6,55 @@ pagination_prev: null | |
slug: / | ||
--- | ||
|
||
`@typescript-eslint/eslint-plugin` includes over 100 rules that detect best practice violations, bugs, and/or stylistic issues specifically for TypeScript code. | ||
See [Configs](/linting/configs) for how to enable recommended rules using configs. | ||
`@typescript-eslint/eslint-plugin` includes over 100 rules that detect best practice violations, bugs, and/or stylistic issues specifically for TypeScript code. All of our rules are listed below. | ||
|
||
## Supported Rules | ||
:::tip | ||
Instead of enabling rules one by one, we recommend using one of [our pre-defined configs](/linting/configs) to enable a large set of recommended rules. | ||
::: | ||
|
||
## Rules | ||
|
||
The rules are listed in alphabetical order. You can optionally filter them based on these categories: | ||
|
||
import RulesTable from "@site/src/components/RulesTable"; | ||
|
||
<RulesTable ruleset="supported-rules" /> | ||
<RulesTable /> | ||
|
||
## Filtering | ||
|
||
### Config Group (⚙️) | ||
|
||
"Config Group" refers to the [pre-defined config](/linting/configs) that includes the rule. Extending from a configuration preset allow for enabling a large set of recommended rules all at once. | ||
|
||
### Metadata | ||
|
||
- `🔧 fixable` refers to whether the rule contains an [ESLint `--fix` auto-fixer](https://eslint.org/docs/latest/use/command-line-interface#--fix). | ||
- `💡 has suggestions` refers to whether the rule contains an ESLint suggestion fixer. | ||
- Sometimes, it is not safe to automatically fix the code with an auto-fixer. But in these cases, we often have a good guess of what the correct fix should be, and we can provide it as a suggestion to the developer. | ||
- `💭 requires type information` refers to whether the rule requires [typed linting](/linting/typed-linting). | ||
- `🧱 extension rule` means that the rule is an extension of an [core ESLint rule](https://eslint.org/docs/latest/rules) (see [Extension Rules](#extension-rules)). | ||
- `📐 formatting rule` means that the rule has to do with formatting. | ||
- We [strongly recommend against using ESLint for formatting](/linting/troubleshooting/formatting). | ||
- Soon, formatting rules will be moved to the [ESLint stylistic plugin](https://eslint.style). | ||
- `💀 deprecated rule` means that the rule should no longer be used and will be removed from the plugin in a future version. | ||
|
||
## Extension Rules | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just realized https://typescript-eslint.io/rules/#extension-rules is probably the only canonical link to an explanation of extension rules out there. So we probably don't want to get rid of the heading. But I've pestered you so much on this PR 😅 I'll just add it in, and if you @Josh-Cena / @Zamiell disagree we can always revert before the release on Monday. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we really need a separate heading though? it is fairly self-explanatory what an extension rule is.
After reading this, i am not left wondering, "I have more questions about what an extension rule is, I wonder if there is a more formal definition out there in a dedicated section?" There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think folks need somewhere to hard-link to. It's similar to ESLint's issue for fixers vs suggestions: even if they're fairly straightforward for many, some folks coming in fresh have a hard time with them. I personally had a hard time both with fixers-vs-suggestions and what extension rules are. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ooh and - pretty soon I think we'll be able to trim down the metadata list down to one sentence per item!
...which just leaves the deeper explanation on extension rules. |
||
|
||
In some cases, ESLint provides a rule itself, but it doesn't support TypeScript syntax; either it crashes, or it ignores the syntax, or it falsely reports against it. | ||
In these cases, we create what we call an extension rule; a rule within our plugin that has the same functionality, but also supports TypeScript. | ||
Some core ESLint rules do not support TypeScript syntax: either they crash, ignore the syntax, or falsely report against it. | ||
In these cases, we create what we call an "extension rule": a rule within our plugin that has the same functionality, but also supports TypeScript. | ||
|
||
Extension rules generally completely replace the base rule from ESLint core. | ||
If the base rule is enabled in a config you extend from, you'll need to disable the base rule: | ||
|
||
```js | ||
module.exports = { | ||
extends: ['eslint:recommended'], | ||
rules: { | ||
// Note: you must disable the base rule as it can report incorrect errors | ||
'no-unused-vars': 'off', | ||
'@typescript-eslint/no-unused-vars': 'error', | ||
}, | ||
}; | ||
``` | ||
|
||
<RulesTable ruleset="extension-rules" /> | ||
[Search for `🧱 extension rule`s](?=extension#rules) in this page to see all extension rules. |
Uh oh!
There was an error while loading. Please reload this page.