Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork2.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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
3c6b59423cf04b37d5f1f2259ef8bd14e9a58f370b23bcddb37f13fcd23a3f8bde93ea624d23afefe2ebd2c35d7868ea0ba3457e3ca9e428e643ed53d890b49f260990b64bad49ec745File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
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. All of our rules are listed below. | ||
| :::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 /> | ||
| ## 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. | ||
Zamiell marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| ## Extension Rules | ||
Member 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 realizedhttps://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. ContributorAuthor 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?" Member 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-suggestionsand what extension rules are. Member 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. | ||
| 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', | ||
| }, | ||
| }; | ||
| ``` | ||
| [Search for `🧱 extension rule`s](?=extension#rules) in this page to see all extension rules. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,3 @@ | ||
| constplugin=require('@typescript-eslint/eslint-plugin'); | ||
| construles=Object.entries(plugin.rules).map(([name,rule])=>{ | ||
| @@ -10,43 +7,6 @@ const rules = Object.entries(plugin.rules).map(([name, rule]) => { | ||
| }; | ||
| }); | ||
| functioncreateCategory(label,rules,additionalItems=[]){ | ||
| return{ | ||
| items:[ | ||
| @@ -68,17 +28,8 @@ module.exports = { | ||
| someSidebar:[ | ||
| 'README', | ||
| { | ||
| ...createCategory('Rules',rules), | ||
| collapsed:false, | ||
| }, | ||
Zamiell marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| ], | ||
| }; | ||
Uh oh!
There was an error while loading.Please reload this page.