From 4a500b2d92a91873dbb729793d1ee1c36ef06ed8 Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Sun, 15 May 2022 20:08:40 -0400 Subject: [PATCH] feat(eslint-plugin): add new 'strict' config (#4706) * feat: add new 'strict' config * chore: simplified strict to always be 'warn' * chore: missing | false * test: update tests for new strictness * test: update .md file templates and docs.test.ts * chore: update configs.test.ts too * chore: update website docs * docs: add sub-list of configs to attributes * docs: unified configs readme and presets file * docs: finish trimming configs readme * fix: sidebar.base.js * fix: finish renaming presets to config * fix: configs docs id * fix: typo; not 'three' * fix: tip colons * chore: replace heavy_check_mark with lock * chore: mostly fixed up docs, probably one or two more things to do * docs: method-signature-style period, more in configs.ts * docs: method-signature-style period, more in configs.ts; fix readmes * chore: passing configs.test.ts, docs.test.ts locally --- docs/linting/CONFIGS.md | 92 ++++++ packages/eslint-plugin/README.md | 264 ++++++++--------- packages/eslint-plugin/docs/rules/README.md | 265 +++++++++--------- packages/eslint-plugin/docs/rules/TEMPLATE.md | 6 +- .../rules/adjacent-overload-signatures.md | 4 +- .../eslint-plugin/docs/rules/array-type.md | 4 +- .../docs/rules/await-thenable.md | 4 +- .../docs/rules/ban-ts-comment.md | 4 +- .../docs/rules/ban-tslint-comment.md | 17 +- .../eslint-plugin/docs/rules/ban-types.md | 4 +- .../eslint-plugin/docs/rules/brace-style.md | 4 +- .../rules/class-literal-property-style.md | 4 +- .../eslint-plugin/docs/rules/comma-dangle.md | 4 +- .../eslint-plugin/docs/rules/comma-spacing.md | 4 +- .../rules/consistent-indexed-object-style.md | 4 +- .../docs/rules/consistent-type-assertions.md | 4 +- .../docs/rules/consistent-type-definitions.md | 4 +- .../docs/rules/consistent-type-exports.md | 4 +- .../docs/rules/consistent-type-imports.md | 4 +- .../docs/rules/default-param-last.md | 4 +- .../eslint-plugin/docs/rules/dot-notation.md | 4 +- .../rules/explicit-function-return-type.md | 4 +- .../rules/explicit-member-accessibility.md | 4 +- .../rules/explicit-module-boundary-types.md | 4 +- .../docs/rules/func-call-spacing.md | 4 +- packages/eslint-plugin/docs/rules/indent.md | 4 +- .../docs/rules/init-declarations.md | 4 +- .../docs/rules/keyword-spacing.md | 4 +- .../docs/rules/lines-between-class-members.md | 4 +- .../docs/rules/member-delimiter-style.md | 4 +- .../docs/rules/member-ordering.md | 4 +- .../docs/rules/method-signature-style.md | 4 +- .../docs/rules/naming-convention.md | 4 +- .../docs/rules/no-array-constructor.md | 4 +- .../docs/rules/no-base-to-string.md | 4 +- .../rules/no-confusing-non-null-assertion.md | 17 +- .../rules/no-confusing-void-expression.md | 4 +- .../docs/rules/no-dupe-class-members.md | 4 +- .../docs/rules/no-duplicate-enum-values.md | 15 +- .../docs/rules/no-duplicate-imports.md | 4 +- .../docs/rules/no-dynamic-delete.md | 17 +- .../docs/rules/no-empty-function.md | 4 +- .../docs/rules/no-empty-interface.md | 4 +- .../docs/rules/no-explicit-any.md | 4 +- .../docs/rules/no-extra-non-null-assertion.md | 4 +- .../docs/rules/no-extra-parens.md | 4 +- .../eslint-plugin/docs/rules/no-extra-semi.md | 4 +- .../docs/rules/no-extraneous-class.md | 4 +- .../docs/rules/no-floating-promises.md | 4 +- .../docs/rules/no-for-in-array.md | 4 +- .../docs/rules/no-implicit-any-catch.md | 4 +- .../docs/rules/no-implied-eval.md | 4 +- .../docs/rules/no-inferrable-types.md | 4 +- .../docs/rules/no-invalid-this.md | 4 +- .../docs/rules/no-invalid-void-type.md | 4 +- .../eslint-plugin/docs/rules/no-loop-func.md | 4 +- .../docs/rules/no-loss-of-precision.md | 4 +- .../docs/rules/no-magic-numbers.md | 4 +- .../rules/no-meaningless-void-operator.md | 4 +- .../docs/rules/no-misused-new.md | 4 +- .../docs/rules/no-misused-promises.md | 4 +- .../eslint-plugin/docs/rules/no-namespace.md | 4 +- ...no-non-null-asserted-nullish-coalescing.md | 17 +- .../no-non-null-asserted-optional-chain.md | 4 +- .../docs/rules/no-non-null-assertion.md | 4 +- .../docs/rules/no-parameter-properties.md | 4 +- .../eslint-plugin/docs/rules/no-redeclare.md | 4 +- .../rules/no-redundant-type-constituents.md | 17 +- .../docs/rules/no-require-imports.md | 17 +- .../docs/rules/no-restricted-imports.md | 4 +- .../eslint-plugin/docs/rules/no-shadow.md | 4 +- .../eslint-plugin/docs/rules/no-this-alias.md | 4 +- .../docs/rules/no-throw-literal.md | 4 +- .../eslint-plugin/docs/rules/no-type-alias.md | 4 +- .../no-unnecessary-boolean-literal-compare.md | 4 +- .../docs/rules/no-unnecessary-condition.md | 4 +- .../docs/rules/no-unnecessary-qualifier.md | 17 +- .../rules/no-unnecessary-type-arguments.md | 17 +- .../rules/no-unnecessary-type-assertion.md | 4 +- .../rules/no-unnecessary-type-constraint.md | 4 +- .../docs/rules/no-unsafe-argument.md | 4 +- .../docs/rules/no-unsafe-assignment.md | 4 +- .../docs/rules/no-unsafe-call.md | 4 +- .../docs/rules/no-unsafe-member-access.md | 4 +- .../docs/rules/no-unsafe-return.md | 4 +- .../docs/rules/no-unused-expressions.md | 4 +- .../docs/rules/no-unused-vars.md | 4 +- .../docs/rules/no-use-before-define.md | 4 +- .../docs/rules/no-useless-constructor.md | 4 +- .../docs/rules/no-useless-empty-export.md | 17 +- .../docs/rules/no-var-requires.md | 4 +- .../non-nullable-type-assertion-style.md | 17 +- .../docs/rules/object-curly-spacing.md | 4 +- .../rules/padding-line-between-statements.md | 4 +- .../docs/rules/parameter-properties.md | 4 +- .../docs/rules/prefer-as-const.md | 4 +- .../docs/rules/prefer-enum-initializers.md | 17 +- .../eslint-plugin/docs/rules/prefer-for-of.md | 17 +- .../docs/rules/prefer-function-type.md | 17 +- .../docs/rules/prefer-includes.md | 15 +- .../docs/rules/prefer-literal-enum-member.md | 4 +- .../docs/rules/prefer-namespace-keyword.md | 4 +- .../docs/rules/prefer-nullish-coalescing.md | 4 +- .../docs/rules/prefer-optional-chain.md | 17 +- .../rules/prefer-readonly-parameter-types.md | 4 +- .../docs/rules/prefer-readonly.md | 4 +- .../rules/prefer-reduce-type-parameter.md | 15 +- .../docs/rules/prefer-regexp-exec.md | 15 +- .../docs/rules/prefer-return-this-type.md | 17 +- .../rules/prefer-string-starts-ends-with.md | 15 +- .../docs/rules/prefer-ts-expect-error.md | 17 +- .../docs/rules/promise-function-async.md | 4 +- packages/eslint-plugin/docs/rules/quotes.md | 4 +- .../docs/rules/require-array-sort-compare.md | 4 +- .../eslint-plugin/docs/rules/require-await.md | 4 +- .../docs/rules/restrict-plus-operands.md | 4 +- .../rules/restrict-template-expressions.md | 4 +- .../eslint-plugin/docs/rules/return-await.md | 4 +- packages/eslint-plugin/docs/rules/semi.md | 4 +- .../sort-type-union-intersection-members.md | 4 +- .../docs/rules/space-before-blocks.md | 4 +- .../docs/rules/space-before-function-paren.md | 4 +- .../docs/rules/space-infix-ops.md | 4 +- .../docs/rules/strict-boolean-expressions.md | 4 +- .../docs/rules/switch-exhaustiveness-check.md | 17 +- .../docs/rules/triple-slash-reference.md | 4 +- .../docs/rules/type-annotation-spacing.md | 4 +- packages/eslint-plugin/docs/rules/typedef.md | 4 +- .../docs/rules/unbound-method.md | 4 +- .../docs/rules/unified-signatures.md | 4 +- packages/eslint-plugin/src/configs/README.md | 70 +---- packages/eslint-plugin/src/configs/strict.ts | 49 ++++ packages/eslint-plugin/src/index.ts | 4 +- .../eslint-plugin/src/rules/array-type.ts | 3 +- .../src/rules/ban-tslint-comment.ts | 2 +- .../src/rules/class-literal-property-style.ts | 2 +- .../rules/consistent-indexed-object-style.ts | 3 +- .../src/rules/consistent-type-assertions.ts | 2 +- .../src/rules/consistent-type-definitions.ts | 3 +- .../eslint-plugin/src/rules/dot-notation.ts | 2 +- .../src/rules/no-base-to-string.ts | 2 +- .../rules/no-confusing-non-null-assertion.ts | 2 +- .../src/rules/no-duplicate-enum-values.ts | 2 +- .../src/rules/no-dynamic-delete.ts | 2 +- .../src/rules/no-extraneous-class.ts | 2 +- .../src/rules/no-invalid-void-type.ts | 2 +- .../src/rules/no-meaningless-void-operator.ts | 2 +- ...no-non-null-asserted-nullish-coalescing.ts | 2 +- .../src/rules/no-throw-literal.ts | 2 +- .../no-unnecessary-boolean-literal-compare.ts | 2 +- .../src/rules/no-unnecessary-condition.ts | 2 +- .../rules/no-unnecessary-type-arguments.ts | 2 +- .../src/rules/no-useless-constructor.ts | 2 +- .../non-nullable-type-assertion-style.ts | 2 +- .../eslint-plugin/src/rules/prefer-for-of.ts | 2 +- .../src/rules/prefer-function-type.ts | 2 +- .../src/rules/prefer-includes.ts | 2 +- .../src/rules/prefer-literal-enum-member.ts | 2 +- .../src/rules/prefer-nullish-coalescing.ts | 2 +- .../src/rules/prefer-optional-chain.ts | 2 +- .../src/rules/prefer-reduce-type-parameter.ts | 2 +- .../src/rules/prefer-return-this-type.ts | 2 +- .../rules/prefer-string-starts-ends-with.ts | 2 +- .../src/rules/prefer-ts-expect-error.ts | 2 +- .../src/rules/unified-signatures.ts | 2 +- packages/eslint-plugin/tests/configs.test.ts | 23 +- packages/eslint-plugin/tests/docs.test.ts | 170 ++++++----- .../eslint-plugin/tools/generate-configs.ts | 51 +++- .../tools/generate-rules-lists.ts | 15 +- packages/scope-manager/project.json | 4 +- packages/utils/src/ts-eslint/Rule.ts | 6 +- packages/website/sidebars/sidebar.base.js | 1 + 172 files changed, 1276 insertions(+), 591 deletions(-) create mode 100644 docs/linting/CONFIGS.md create mode 100644 packages/eslint-plugin/src/configs/strict.ts diff --git a/docs/linting/CONFIGS.md b/docs/linting/CONFIGS.md new file mode 100644 index 00000000000..51ef4957b34 --- /dev/null +++ b/docs/linting/CONFIGS.md @@ -0,0 +1,92 @@ +--- +id: configs +sidebar_label: Configurations +title: Configurations +--- + +## Built-In Configurations + +`@typescript-eslint/eslint-plugin` includes built-in configurations you can extend from to pull in the recommended starting rules. + +With the exception of `strict`, all configurations are considered "stable". +Rule additions and removals are treated as breaking changes and will only be done in major version bumps. + +### `eslint-recommended` + +This ruleset is meant to be used after extending `eslint:recommended`. +It disables core ESLint rules that are already checked by the TypeScript compiler. +Additionally, it enables rules that promote using the more modern constructs TypeScript allows for. + +```jsonc +{ + "extends": [ + "eslint:recommended", + "plugin:@typescript-eslint/eslint-recommended" + ] +} +``` + +This config is automatically included if you use any of the other configurations mentioned on this page. + +### `recommended` + +Recommended rules for code correctness that you can drop in without additional configuration. +These rules are those whose reports are almost always for a bad practice and/or likely bug. +`recommended` also disables rules known to conflict with this repository, or cause issues in TypeScript codebases. + +```json +{ + "extends": ["plugin:@typescript-eslint/recommended"] +} +``` + +::tip +We strongly recommend all TypeScript projects extend from this configuration. +::: + +### `recommended-requiring-type-checking` + +Additional recommended rules that require type information. +Rules in this configuration are similarly useful to those in `recommended`. + +```json +{ + "extends": [ + "plugin:@typescript-eslint/recommended", + "plugin:@typescript-eslint/recommended-requiring-type-checking" + ] +} +``` + +::tip +We recommend all TypeScript projects extend from this configuration, with the caveat that rules using type information take longer to run. +See [Linting with Type Information](/docs/linting/type-linting) for more details. +::: + +### `strict` + +Additional strict rules that can also catch bugs but are more opinionated than recommended rules. + +```json +{ + "extends": [ + "plugin:@typescript-eslint/recommended", + "plugin:@typescript-eslint/recommended-requiring-type-checking", + "plugin:@typescript-eslint/strict" + ] +} +``` + +::tip +We recommend a TypeScript project extend from this configuration only if a nontrivial percentage of its developers are highly proficient in TypeScript. +::: + +## Overriding Configurations + +These configurations are our recommended starting points, but **you don't need to use them as-is**. +ESLint allows you to configure your own rule settings on top of any extended configurations. +See [ESLint's Configuring Rules docs](https://eslint.org/docs/user-guide/configuring/rules#using-configuration-files). + +### Suggesting Configuration Changes + +If you feel strongly that a specific rule should (or should not) be one of these configurations, please feel free to [file an issue](TODO: NEW ISSUE TEMPLATE) along with a **detailed** argument explaining your reasoning. diff --git a/packages/eslint-plugin/README.md b/packages/eslint-plugin/README.md index 511f9679f11..87137b1d6e5 100644 --- a/packages/eslint-plugin/README.md +++ b/packages/eslint-plugin/README.md @@ -93,96 +93,96 @@ Pro Tip: For larger codebases you may want to consider splitting our linting int -**Key**: :white_check_mark: = recommended, :wrench: = fixable, :thought_balloon: = requires type information - -| Name | Description | :white_check_mark: | :wrench: | :thought_balloon: | -| ----------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- | ------------------ | -------- | ----------------- | -| [`@typescript-eslint/adjacent-overload-signatures`](./docs/rules/adjacent-overload-signatures.md) | Require that member overloads be consecutive | :white_check_mark: | | | -| [`@typescript-eslint/array-type`](./docs/rules/array-type.md) | Requires using either `T[]` or `Array` for arrays | | :wrench: | | -| [`@typescript-eslint/await-thenable`](./docs/rules/await-thenable.md) | Disallows awaiting a value that is not a Thenable | :white_check_mark: | | :thought_balloon: | -| [`@typescript-eslint/ban-ts-comment`](./docs/rules/ban-ts-comment.md) | Bans `@ts-` comments from being used or requires descriptions after directive | :white_check_mark: | | | -| [`@typescript-eslint/ban-tslint-comment`](./docs/rules/ban-tslint-comment.md) | Bans `// tslint:` comments from being used | | :wrench: | | -| [`@typescript-eslint/ban-types`](./docs/rules/ban-types.md) | Bans specific types from being used | :white_check_mark: | :wrench: | | -| [`@typescript-eslint/class-literal-property-style`](./docs/rules/class-literal-property-style.md) | Ensures that literals on classes are exposed in a consistent style | | :wrench: | | -| [`@typescript-eslint/consistent-indexed-object-style`](./docs/rules/consistent-indexed-object-style.md) | Enforce or disallow the use of the record type | | :wrench: | | -| [`@typescript-eslint/consistent-type-assertions`](./docs/rules/consistent-type-assertions.md) | Enforces consistent usage of type assertions | | | | -| [`@typescript-eslint/consistent-type-definitions`](./docs/rules/consistent-type-definitions.md) | Consistent with type definition either `interface` or `type` | | :wrench: | | -| [`@typescript-eslint/consistent-type-exports`](./docs/rules/consistent-type-exports.md) | Enforces consistent usage of type exports | | :wrench: | :thought_balloon: | -| [`@typescript-eslint/consistent-type-imports`](./docs/rules/consistent-type-imports.md) | Enforces consistent usage of type imports | | :wrench: | | -| [`@typescript-eslint/explicit-function-return-type`](./docs/rules/explicit-function-return-type.md) | Require explicit return types on functions and class methods | | | | -| [`@typescript-eslint/explicit-member-accessibility`](./docs/rules/explicit-member-accessibility.md) | Require explicit accessibility modifiers on class properties and methods | | :wrench: | | -| [`@typescript-eslint/explicit-module-boundary-types`](./docs/rules/explicit-module-boundary-types.md) | Require explicit return and argument types on exported functions' and classes' public class methods | | | | -| [`@typescript-eslint/member-delimiter-style`](./docs/rules/member-delimiter-style.md) | Require a specific member delimiter style for interfaces and type literals | | :wrench: | | -| [`@typescript-eslint/member-ordering`](./docs/rules/member-ordering.md) | Require a consistent member declaration order | | | | -| [`@typescript-eslint/method-signature-style`](./docs/rules/method-signature-style.md) | Enforces using a particular method signature syntax | | :wrench: | | -| [`@typescript-eslint/naming-convention`](./docs/rules/naming-convention.md) | Enforces naming conventions for everything across a codebase | | | :thought_balloon: | -| [`@typescript-eslint/no-base-to-string`](./docs/rules/no-base-to-string.md) | Requires that `.toString()` is only called on objects which provide useful information when stringified | | | :thought_balloon: | -| [`@typescript-eslint/no-confusing-non-null-assertion`](./docs/rules/no-confusing-non-null-assertion.md) | Disallow non-null assertion in locations that may be confusing | | :wrench: | | -| [`@typescript-eslint/no-confusing-void-expression`](./docs/rules/no-confusing-void-expression.md) | Requires expressions of type void to appear in statement position | | :wrench: | :thought_balloon: | -| [`@typescript-eslint/no-duplicate-enum-values`](./docs/rules/no-duplicate-enum-values.md) | Disallow duplicate enum member values | | | | -| [`@typescript-eslint/no-dynamic-delete`](./docs/rules/no-dynamic-delete.md) | Disallow the delete operator with computed key expressions | | :wrench: | | -| [`@typescript-eslint/no-empty-interface`](./docs/rules/no-empty-interface.md) | Disallow the declaration of empty interfaces | :white_check_mark: | :wrench: | | -| [`@typescript-eslint/no-explicit-any`](./docs/rules/no-explicit-any.md) | Disallow usage of the `any` type | :white_check_mark: | :wrench: | | -| [`@typescript-eslint/no-extra-non-null-assertion`](./docs/rules/no-extra-non-null-assertion.md) | Disallow extra non-null assertion | :white_check_mark: | :wrench: | | -| [`@typescript-eslint/no-extraneous-class`](./docs/rules/no-extraneous-class.md) | Forbids the use of classes as namespaces | | | | -| [`@typescript-eslint/no-floating-promises`](./docs/rules/no-floating-promises.md) | Requires Promise-like statements to be handled appropriately | :white_check_mark: | | :thought_balloon: | -| [`@typescript-eslint/no-for-in-array`](./docs/rules/no-for-in-array.md) | Disallow iterating over an array with a for-in loop | :white_check_mark: | | :thought_balloon: | -| [`@typescript-eslint/no-inferrable-types`](./docs/rules/no-inferrable-types.md) | Disallows explicit type declarations for variables or parameters initialized to a number, string, or boolean | :white_check_mark: | :wrench: | | -| [`@typescript-eslint/no-invalid-void-type`](./docs/rules/no-invalid-void-type.md) | Disallows usage of `void` type outside of generic or return types | | | | -| [`@typescript-eslint/no-meaningless-void-operator`](./docs/rules/no-meaningless-void-operator.md) | Disallow the `void` operator except when used to discard a value | | :wrench: | :thought_balloon: | -| [`@typescript-eslint/no-misused-new`](./docs/rules/no-misused-new.md) | Enforce valid definition of `new` and `constructor` | :white_check_mark: | | | -| [`@typescript-eslint/no-misused-promises`](./docs/rules/no-misused-promises.md) | Avoid using Promises in places not designed to handle them | :white_check_mark: | | :thought_balloon: | -| [`@typescript-eslint/no-namespace`](./docs/rules/no-namespace.md) | Disallow the use of custom TypeScript modules and namespaces | :white_check_mark: | | | -| [`@typescript-eslint/no-non-null-asserted-nullish-coalescing`](./docs/rules/no-non-null-asserted-nullish-coalescing.md) | Disallows using a non-null assertion in the left operand of the nullish coalescing operator | | | | -| [`@typescript-eslint/no-non-null-asserted-optional-chain`](./docs/rules/no-non-null-asserted-optional-chain.md) | Disallows using a non-null assertion after an optional chain expression | :white_check_mark: | | | -| [`@typescript-eslint/no-non-null-assertion`](./docs/rules/no-non-null-assertion.md) | Disallows non-null assertions using the `!` postfix operator | :white_check_mark: | | | -| [`@typescript-eslint/no-redundant-type-constituents`](./docs/rules/no-redundant-type-constituents.md) | Disallow members of unions and intersections that do nothing or override type information | | | :thought_balloon: | -| [`@typescript-eslint/no-require-imports`](./docs/rules/no-require-imports.md) | Disallows invocation of `require()` | | | | -| [`@typescript-eslint/no-this-alias`](./docs/rules/no-this-alias.md) | Disallow aliasing `this` | :white_check_mark: | | | -| [`@typescript-eslint/no-type-alias`](./docs/rules/no-type-alias.md) | Disallow the use of type aliases | | | | -| [`@typescript-eslint/no-unnecessary-boolean-literal-compare`](./docs/rules/no-unnecessary-boolean-literal-compare.md) | Flags unnecessary equality comparisons against boolean literals | | :wrench: | :thought_balloon: | -| [`@typescript-eslint/no-unnecessary-condition`](./docs/rules/no-unnecessary-condition.md) | Prevents conditionals where the type is always truthy or always falsy | | :wrench: | :thought_balloon: | -| [`@typescript-eslint/no-unnecessary-qualifier`](./docs/rules/no-unnecessary-qualifier.md) | Warns when a namespace qualifier is unnecessary | | :wrench: | :thought_balloon: | -| [`@typescript-eslint/no-unnecessary-type-arguments`](./docs/rules/no-unnecessary-type-arguments.md) | Enforces that type arguments will not be used if not required | | :wrench: | :thought_balloon: | -| [`@typescript-eslint/no-unnecessary-type-assertion`](./docs/rules/no-unnecessary-type-assertion.md) | Warns if a type assertion does not change the type of an expression | :white_check_mark: | :wrench: | :thought_balloon: | -| [`@typescript-eslint/no-unnecessary-type-constraint`](./docs/rules/no-unnecessary-type-constraint.md) | Disallows unnecessary constraints on generic types | :white_check_mark: | | | -| [`@typescript-eslint/no-unsafe-argument`](./docs/rules/no-unsafe-argument.md) | Disallows calling a function with an any type value | :white_check_mark: | | :thought_balloon: | -| [`@typescript-eslint/no-unsafe-assignment`](./docs/rules/no-unsafe-assignment.md) | Disallows assigning any to variables and properties | :white_check_mark: | | :thought_balloon: | -| [`@typescript-eslint/no-unsafe-call`](./docs/rules/no-unsafe-call.md) | Disallows calling an any type value | :white_check_mark: | | :thought_balloon: | -| [`@typescript-eslint/no-unsafe-member-access`](./docs/rules/no-unsafe-member-access.md) | Disallows member access on any typed variables | :white_check_mark: | | :thought_balloon: | -| [`@typescript-eslint/no-unsafe-return`](./docs/rules/no-unsafe-return.md) | Disallows returning any from a function | :white_check_mark: | | :thought_balloon: | -| [`@typescript-eslint/no-useless-empty-export`](./docs/rules/no-useless-empty-export.md) | Disallow empty exports that don't change anything in a module file | | :wrench: | | -| [`@typescript-eslint/no-var-requires`](./docs/rules/no-var-requires.md) | Disallows the use of require statements except in import statements | :white_check_mark: | | | -| [`@typescript-eslint/non-nullable-type-assertion-style`](./docs/rules/non-nullable-type-assertion-style.md) | Prefers a non-null assertion over explicit type cast when possible | | :wrench: | :thought_balloon: | -| [`@typescript-eslint/parameter-properties`](./docs/rules/parameter-properties.md) | Require or disallow the use of parameter properties in class constructors | | | | -| [`@typescript-eslint/prefer-as-const`](./docs/rules/prefer-as-const.md) | Prefer usage of `as const` over literal type | :white_check_mark: | :wrench: | | -| [`@typescript-eslint/prefer-enum-initializers`](./docs/rules/prefer-enum-initializers.md) | Prefer initializing each enums member value | | | | -| [`@typescript-eslint/prefer-for-of`](./docs/rules/prefer-for-of.md) | Prefer a ‘for-of’ loop over a standard ‘for’ loop if the index is only used to access the array being iterated | | | | -| [`@typescript-eslint/prefer-function-type`](./docs/rules/prefer-function-type.md) | Use function types instead of interfaces with call signatures | | :wrench: | | -| [`@typescript-eslint/prefer-includes`](./docs/rules/prefer-includes.md) | Enforce `includes` method over `indexOf` method | | :wrench: | :thought_balloon: | -| [`@typescript-eslint/prefer-literal-enum-member`](./docs/rules/prefer-literal-enum-member.md) | Require that all enum members be literal values to prevent unintended enum member name shadow issues | | | | -| [`@typescript-eslint/prefer-namespace-keyword`](./docs/rules/prefer-namespace-keyword.md) | Require the use of the `namespace` keyword instead of the `module` keyword to declare custom TypeScript modules | :white_check_mark: | :wrench: | | -| [`@typescript-eslint/prefer-nullish-coalescing`](./docs/rules/prefer-nullish-coalescing.md) | Enforce the usage of the nullish coalescing operator instead of logical chaining | | | :thought_balloon: | -| [`@typescript-eslint/prefer-optional-chain`](./docs/rules/prefer-optional-chain.md) | Prefer using concise optional chain expressions instead of chained logical ands | | | | -| [`@typescript-eslint/prefer-readonly`](./docs/rules/prefer-readonly.md) | Requires that private members are marked as `readonly` if they're never modified outside of the constructor | | :wrench: | :thought_balloon: | -| [`@typescript-eslint/prefer-readonly-parameter-types`](./docs/rules/prefer-readonly-parameter-types.md) | Requires that function parameters are typed as readonly to prevent accidental mutation of inputs | | | :thought_balloon: | -| [`@typescript-eslint/prefer-reduce-type-parameter`](./docs/rules/prefer-reduce-type-parameter.md) | Prefer using type parameter when calling `Array#reduce` instead of casting | | :wrench: | :thought_balloon: | -| [`@typescript-eslint/prefer-regexp-exec`](./docs/rules/prefer-regexp-exec.md) | Enforce that `RegExp#exec` is used instead of `String#match` if no global flag is provided | | :wrench: | :thought_balloon: | -| [`@typescript-eslint/prefer-return-this-type`](./docs/rules/prefer-return-this-type.md) | Enforce that `this` is used when only `this` type is returned | | :wrench: | :thought_balloon: | -| [`@typescript-eslint/prefer-string-starts-ends-with`](./docs/rules/prefer-string-starts-ends-with.md) | Enforce the use of `String#startsWith` and `String#endsWith` instead of other equivalent methods of checking substrings | | :wrench: | :thought_balloon: | -| [`@typescript-eslint/prefer-ts-expect-error`](./docs/rules/prefer-ts-expect-error.md) | Recommends using `@ts-expect-error` over `@ts-ignore` | | :wrench: | | -| [`@typescript-eslint/promise-function-async`](./docs/rules/promise-function-async.md) | Requires any function or method that returns a Promise to be marked async | | :wrench: | :thought_balloon: | -| [`@typescript-eslint/require-array-sort-compare`](./docs/rules/require-array-sort-compare.md) | Requires `Array#sort` calls to always provide a `compareFunction` | | | :thought_balloon: | -| [`@typescript-eslint/restrict-plus-operands`](./docs/rules/restrict-plus-operands.md) | When adding two variables, operands must both be of type number or of type string | :white_check_mark: | | :thought_balloon: | -| [`@typescript-eslint/restrict-template-expressions`](./docs/rules/restrict-template-expressions.md) | Enforce template literal expressions to be of string type | :white_check_mark: | | :thought_balloon: | -| [`@typescript-eslint/sort-type-union-intersection-members`](./docs/rules/sort-type-union-intersection-members.md) | Enforces that members of a type union/intersection are sorted alphabetically | | :wrench: | | -| [`@typescript-eslint/strict-boolean-expressions`](./docs/rules/strict-boolean-expressions.md) | Restricts the types allowed in boolean expressions | | :wrench: | :thought_balloon: | -| [`@typescript-eslint/switch-exhaustiveness-check`](./docs/rules/switch-exhaustiveness-check.md) | Exhaustiveness checking in switch with union type | | | :thought_balloon: | -| [`@typescript-eslint/triple-slash-reference`](./docs/rules/triple-slash-reference.md) | Sets preference level for triple slash directives versus ES6-style import declarations | :white_check_mark: | | | -| [`@typescript-eslint/type-annotation-spacing`](./docs/rules/type-annotation-spacing.md) | Require consistent spacing around type annotations | | :wrench: | | -| [`@typescript-eslint/typedef`](./docs/rules/typedef.md) | Requires type annotations to exist | | | | -| [`@typescript-eslint/unbound-method`](./docs/rules/unbound-method.md) | Enforces unbound methods are called with their expected scope | :white_check_mark: | | :thought_balloon: | -| [`@typescript-eslint/unified-signatures`](./docs/rules/unified-signatures.md) | Warns for any two overloads that could be unified into one by using a union or an optional/rest parameter | | | | +**Key**: :white_check_mark: = recommended, :lock: = strict, :wrench: = fixable, :thought_balloon: = requires type information + +| Name | Description | :white_check_mark::lock: | :wrench: | :thought_balloon: | +| ----------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- | ------------------------ | -------- | ----------------- | +| [`@typescript-eslint/adjacent-overload-signatures`](./docs/rules/adjacent-overload-signatures.md) | Require that member overloads be consecutive | :white_check_mark: | | | +| [`@typescript-eslint/array-type`](./docs/rules/array-type.md) | Requires using either `T[]` or `Array` for arrays | :lock: | :wrench: | | +| [`@typescript-eslint/await-thenable`](./docs/rules/await-thenable.md) | Disallows awaiting a value that is not a Thenable | :white_check_mark: | | :thought_balloon: | +| [`@typescript-eslint/ban-ts-comment`](./docs/rules/ban-ts-comment.md) | Bans `@ts-` comments from being used or requires descriptions after directive | :white_check_mark: | | | +| [`@typescript-eslint/ban-tslint-comment`](./docs/rules/ban-tslint-comment.md) | Bans `// tslint:` comments from being used | :lock: | :wrench: | | +| [`@typescript-eslint/ban-types`](./docs/rules/ban-types.md) | Bans specific types from being used | :white_check_mark: | :wrench: | | +| [`@typescript-eslint/class-literal-property-style`](./docs/rules/class-literal-property-style.md) | Ensures that literals on classes are exposed in a consistent style | :lock: | :wrench: | | +| [`@typescript-eslint/consistent-indexed-object-style`](./docs/rules/consistent-indexed-object-style.md) | Enforce or disallow the use of the record type | :lock: | :wrench: | | +| [`@typescript-eslint/consistent-type-assertions`](./docs/rules/consistent-type-assertions.md) | Enforces consistent usage of type assertions | :lock: | | | +| [`@typescript-eslint/consistent-type-definitions`](./docs/rules/consistent-type-definitions.md) | Consistent with type definition either `interface` or `type` | :lock: | :wrench: | | +| [`@typescript-eslint/consistent-type-exports`](./docs/rules/consistent-type-exports.md) | Enforces consistent usage of type exports | | :wrench: | :thought_balloon: | +| [`@typescript-eslint/consistent-type-imports`](./docs/rules/consistent-type-imports.md) | Enforces consistent usage of type imports | | :wrench: | | +| [`@typescript-eslint/explicit-function-return-type`](./docs/rules/explicit-function-return-type.md) | Require explicit return types on functions and class methods | | | | +| [`@typescript-eslint/explicit-member-accessibility`](./docs/rules/explicit-member-accessibility.md) | Require explicit accessibility modifiers on class properties and methods | | :wrench: | | +| [`@typescript-eslint/explicit-module-boundary-types`](./docs/rules/explicit-module-boundary-types.md) | Require explicit return and argument types on exported functions' and classes' public class methods | | | | +| [`@typescript-eslint/member-delimiter-style`](./docs/rules/member-delimiter-style.md) | Require a specific member delimiter style for interfaces and type literals | | :wrench: | | +| [`@typescript-eslint/member-ordering`](./docs/rules/member-ordering.md) | Require a consistent member declaration order | | | | +| [`@typescript-eslint/method-signature-style`](./docs/rules/method-signature-style.md) | Enforces using a particular method signature syntax | | :wrench: | | +| [`@typescript-eslint/naming-convention`](./docs/rules/naming-convention.md) | Enforces naming conventions for everything across a codebase | | | :thought_balloon: | +| [`@typescript-eslint/no-base-to-string`](./docs/rules/no-base-to-string.md) | Requires that `.toString()` is only called on objects which provide useful information when stringified | :lock: | | :thought_balloon: | +| [`@typescript-eslint/no-confusing-non-null-assertion`](./docs/rules/no-confusing-non-null-assertion.md) | Disallow non-null assertion in locations that may be confusing | :lock: | :wrench: | | +| [`@typescript-eslint/no-confusing-void-expression`](./docs/rules/no-confusing-void-expression.md) | Requires expressions of type void to appear in statement position | | :wrench: | :thought_balloon: | +| [`@typescript-eslint/no-duplicate-enum-values`](./docs/rules/no-duplicate-enum-values.md) | Disallow duplicate enum member values | :lock: | | | +| [`@typescript-eslint/no-dynamic-delete`](./docs/rules/no-dynamic-delete.md) | Disallow the delete operator with computed key expressions | :lock: | :wrench: | | +| [`@typescript-eslint/no-empty-interface`](./docs/rules/no-empty-interface.md) | Disallow the declaration of empty interfaces | :white_check_mark: | :wrench: | | +| [`@typescript-eslint/no-explicit-any`](./docs/rules/no-explicit-any.md) | Disallow usage of the `any` type | :white_check_mark: | :wrench: | | +| [`@typescript-eslint/no-extra-non-null-assertion`](./docs/rules/no-extra-non-null-assertion.md) | Disallow extra non-null assertion | :white_check_mark: | :wrench: | | +| [`@typescript-eslint/no-extraneous-class`](./docs/rules/no-extraneous-class.md) | Forbids the use of classes as namespaces | :lock: | | | +| [`@typescript-eslint/no-floating-promises`](./docs/rules/no-floating-promises.md) | Requires Promise-like statements to be handled appropriately | :white_check_mark: | | :thought_balloon: | +| [`@typescript-eslint/no-for-in-array`](./docs/rules/no-for-in-array.md) | Disallow iterating over an array with a for-in loop | :white_check_mark: | | :thought_balloon: | +| [`@typescript-eslint/no-inferrable-types`](./docs/rules/no-inferrable-types.md) | Disallows explicit type declarations for variables or parameters initialized to a number, string, or boolean | :white_check_mark: | :wrench: | | +| [`@typescript-eslint/no-invalid-void-type`](./docs/rules/no-invalid-void-type.md) | Disallows usage of `void` type outside of generic or return types | :lock: | | | +| [`@typescript-eslint/no-meaningless-void-operator`](./docs/rules/no-meaningless-void-operator.md) | Disallow the `void` operator except when used to discard a value | :lock: | :wrench: | :thought_balloon: | +| [`@typescript-eslint/no-misused-new`](./docs/rules/no-misused-new.md) | Enforce valid definition of `new` and `constructor` | :white_check_mark: | | | +| [`@typescript-eslint/no-misused-promises`](./docs/rules/no-misused-promises.md) | Avoid using Promises in places not designed to handle them | :white_check_mark: | | :thought_balloon: | +| [`@typescript-eslint/no-namespace`](./docs/rules/no-namespace.md) | Disallow the use of custom TypeScript modules and namespaces | :white_check_mark: | | | +| [`@typescript-eslint/no-non-null-asserted-nullish-coalescing`](./docs/rules/no-non-null-asserted-nullish-coalescing.md) | Disallows using a non-null assertion in the left operand of the nullish coalescing operator | :lock: | | | +| [`@typescript-eslint/no-non-null-asserted-optional-chain`](./docs/rules/no-non-null-asserted-optional-chain.md) | Disallows using a non-null assertion after an optional chain expression | :white_check_mark: | | | +| [`@typescript-eslint/no-non-null-assertion`](./docs/rules/no-non-null-assertion.md) | Disallows non-null assertions using the `!` postfix operator | :white_check_mark: | | | +| [`@typescript-eslint/no-redundant-type-constituents`](./docs/rules/no-redundant-type-constituents.md) | Disallow members of unions and intersections that do nothing or override type information | | | :thought_balloon: | +| [`@typescript-eslint/no-require-imports`](./docs/rules/no-require-imports.md) | Disallows invocation of `require()` | | | | +| [`@typescript-eslint/no-this-alias`](./docs/rules/no-this-alias.md) | Disallow aliasing `this` | :white_check_mark: | | | +| [`@typescript-eslint/no-type-alias`](./docs/rules/no-type-alias.md) | Disallow the use of type aliases | | | | +| [`@typescript-eslint/no-unnecessary-boolean-literal-compare`](./docs/rules/no-unnecessary-boolean-literal-compare.md) | Flags unnecessary equality comparisons against boolean literals | :lock: | :wrench: | :thought_balloon: | +| [`@typescript-eslint/no-unnecessary-condition`](./docs/rules/no-unnecessary-condition.md) | Prevents conditionals where the type is always truthy or always falsy | :lock: | :wrench: | :thought_balloon: | +| [`@typescript-eslint/no-unnecessary-qualifier`](./docs/rules/no-unnecessary-qualifier.md) | Warns when a namespace qualifier is unnecessary | | :wrench: | :thought_balloon: | +| [`@typescript-eslint/no-unnecessary-type-arguments`](./docs/rules/no-unnecessary-type-arguments.md) | Enforces that type arguments will not be used if not required | :lock: | :wrench: | :thought_balloon: | +| [`@typescript-eslint/no-unnecessary-type-assertion`](./docs/rules/no-unnecessary-type-assertion.md) | Warns if a type assertion does not change the type of an expression | :white_check_mark: | :wrench: | :thought_balloon: | +| [`@typescript-eslint/no-unnecessary-type-constraint`](./docs/rules/no-unnecessary-type-constraint.md) | Disallows unnecessary constraints on generic types | :white_check_mark: | | | +| [`@typescript-eslint/no-unsafe-argument`](./docs/rules/no-unsafe-argument.md) | Disallows calling a function with an any type value | :white_check_mark: | | :thought_balloon: | +| [`@typescript-eslint/no-unsafe-assignment`](./docs/rules/no-unsafe-assignment.md) | Disallows assigning any to variables and properties | :white_check_mark: | | :thought_balloon: | +| [`@typescript-eslint/no-unsafe-call`](./docs/rules/no-unsafe-call.md) | Disallows calling an any type value | :white_check_mark: | | :thought_balloon: | +| [`@typescript-eslint/no-unsafe-member-access`](./docs/rules/no-unsafe-member-access.md) | Disallows member access on any typed variables | :white_check_mark: | | :thought_balloon: | +| [`@typescript-eslint/no-unsafe-return`](./docs/rules/no-unsafe-return.md) | Disallows returning any from a function | :white_check_mark: | | :thought_balloon: | +| [`@typescript-eslint/no-useless-empty-export`](./docs/rules/no-useless-empty-export.md) | Disallow empty exports that don't change anything in a module file | | :wrench: | | +| [`@typescript-eslint/no-var-requires`](./docs/rules/no-var-requires.md) | Disallows the use of require statements except in import statements | :white_check_mark: | | | +| [`@typescript-eslint/non-nullable-type-assertion-style`](./docs/rules/non-nullable-type-assertion-style.md) | Prefers a non-null assertion over explicit type cast when possible | :lock: | :wrench: | :thought_balloon: | +| [`@typescript-eslint/parameter-properties`](./docs/rules/parameter-properties.md) | Require or disallow the use of parameter properties in class constructors | | | | +| [`@typescript-eslint/prefer-as-const`](./docs/rules/prefer-as-const.md) | Prefer usage of `as const` over literal type | :white_check_mark: | :wrench: | | +| [`@typescript-eslint/prefer-enum-initializers`](./docs/rules/prefer-enum-initializers.md) | Prefer initializing each enums member value | | | | +| [`@typescript-eslint/prefer-for-of`](./docs/rules/prefer-for-of.md) | Prefer a ‘for-of’ loop over a standard ‘for’ loop if the index is only used to access the array being iterated | :lock: | | | +| [`@typescript-eslint/prefer-function-type`](./docs/rules/prefer-function-type.md) | Use function types instead of interfaces with call signatures | :lock: | :wrench: | | +| [`@typescript-eslint/prefer-includes`](./docs/rules/prefer-includes.md) | Enforce `includes` method over `indexOf` method | :lock: | :wrench: | :thought_balloon: | +| [`@typescript-eslint/prefer-literal-enum-member`](./docs/rules/prefer-literal-enum-member.md) | Require that all enum members be literal values to prevent unintended enum member name shadow issues | :lock: | | | +| [`@typescript-eslint/prefer-namespace-keyword`](./docs/rules/prefer-namespace-keyword.md) | Require the use of the `namespace` keyword instead of the `module` keyword to declare custom TypeScript modules | :white_check_mark: | :wrench: | | +| [`@typescript-eslint/prefer-nullish-coalescing`](./docs/rules/prefer-nullish-coalescing.md) | Enforce the usage of the nullish coalescing operator instead of logical chaining | :lock: | | :thought_balloon: | +| [`@typescript-eslint/prefer-optional-chain`](./docs/rules/prefer-optional-chain.md) | Prefer using concise optional chain expressions instead of chained logical ands | :lock: | | | +| [`@typescript-eslint/prefer-readonly`](./docs/rules/prefer-readonly.md) | Requires that private members are marked as `readonly` if they're never modified outside of the constructor | | :wrench: | :thought_balloon: | +| [`@typescript-eslint/prefer-readonly-parameter-types`](./docs/rules/prefer-readonly-parameter-types.md) | Requires that function parameters are typed as readonly to prevent accidental mutation of inputs | | | :thought_balloon: | +| [`@typescript-eslint/prefer-reduce-type-parameter`](./docs/rules/prefer-reduce-type-parameter.md) | Prefer using type parameter when calling `Array#reduce` instead of casting | :lock: | :wrench: | :thought_balloon: | +| [`@typescript-eslint/prefer-regexp-exec`](./docs/rules/prefer-regexp-exec.md) | Enforce that `RegExp#exec` is used instead of `String#match` if no global flag is provided | | :wrench: | :thought_balloon: | +| [`@typescript-eslint/prefer-return-this-type`](./docs/rules/prefer-return-this-type.md) | Enforce that `this` is used when only `this` type is returned | :lock: | :wrench: | :thought_balloon: | +| [`@typescript-eslint/prefer-string-starts-ends-with`](./docs/rules/prefer-string-starts-ends-with.md) | Enforce the use of `String#startsWith` and `String#endsWith` instead of other equivalent methods of checking substrings | :lock: | :wrench: | :thought_balloon: | +| [`@typescript-eslint/prefer-ts-expect-error`](./docs/rules/prefer-ts-expect-error.md) | Recommends using `@ts-expect-error` over `@ts-ignore` | :lock: | :wrench: | | +| [`@typescript-eslint/promise-function-async`](./docs/rules/promise-function-async.md) | Requires any function or method that returns a Promise to be marked async | | :wrench: | :thought_balloon: | +| [`@typescript-eslint/require-array-sort-compare`](./docs/rules/require-array-sort-compare.md) | Requires `Array#sort` calls to always provide a `compareFunction` | | | :thought_balloon: | +| [`@typescript-eslint/restrict-plus-operands`](./docs/rules/restrict-plus-operands.md) | When adding two variables, operands must both be of type number or of type string | :white_check_mark: | | :thought_balloon: | +| [`@typescript-eslint/restrict-template-expressions`](./docs/rules/restrict-template-expressions.md) | Enforce template literal expressions to be of string type | :white_check_mark: | | :thought_balloon: | +| [`@typescript-eslint/sort-type-union-intersection-members`](./docs/rules/sort-type-union-intersection-members.md) | Enforces that members of a type union/intersection are sorted alphabetically | | :wrench: | | +| [`@typescript-eslint/strict-boolean-expressions`](./docs/rules/strict-boolean-expressions.md) | Restricts the types allowed in boolean expressions | | :wrench: | :thought_balloon: | +| [`@typescript-eslint/switch-exhaustiveness-check`](./docs/rules/switch-exhaustiveness-check.md) | Exhaustiveness checking in switch with union type | | | :thought_balloon: | +| [`@typescript-eslint/triple-slash-reference`](./docs/rules/triple-slash-reference.md) | Sets preference level for triple slash directives versus ES6-style import declarations | :white_check_mark: | | | +| [`@typescript-eslint/type-annotation-spacing`](./docs/rules/type-annotation-spacing.md) | Require consistent spacing around type annotations | | :wrench: | | +| [`@typescript-eslint/typedef`](./docs/rules/typedef.md) | Requires type annotations to exist | | | | +| [`@typescript-eslint/unbound-method`](./docs/rules/unbound-method.md) | Enforces unbound methods are called with their expected scope | :white_check_mark: | | :thought_balloon: | +| [`@typescript-eslint/unified-signatures`](./docs/rules/unified-signatures.md) | Warns for any two overloads that could be unified into one by using a union or an optional/rest parameter | :lock: | | | @@ -193,48 +193,48 @@ In these cases, we create what we call an extension rule; a rule within our plug -**Key**: :white_check_mark: = recommended, :wrench: = fixable, :thought_balloon: = requires type information - -| Name | Description | :white_check_mark: | :wrench: | :thought_balloon: | -| ------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------ | ------------------ | -------- | ----------------- | -| [`@typescript-eslint/brace-style`](./docs/rules/brace-style.md) | Enforce consistent brace style for blocks | | :wrench: | | -| [`@typescript-eslint/comma-dangle`](./docs/rules/comma-dangle.md) | Require or disallow trailing comma | | :wrench: | | -| [`@typescript-eslint/comma-spacing`](./docs/rules/comma-spacing.md) | Enforces consistent spacing before and after commas | | :wrench: | | -| [`@typescript-eslint/default-param-last`](./docs/rules/default-param-last.md) | Enforce default parameters to be last | | | | -| [`@typescript-eslint/dot-notation`](./docs/rules/dot-notation.md) | enforce dot notation whenever possible | | :wrench: | :thought_balloon: | -| [`@typescript-eslint/func-call-spacing`](./docs/rules/func-call-spacing.md) | Require or disallow spacing between function identifiers and their invocations | | :wrench: | | -| [`@typescript-eslint/indent`](./docs/rules/indent.md) | Enforce consistent indentation | | :wrench: | | -| [`@typescript-eslint/init-declarations`](./docs/rules/init-declarations.md) | require or disallow initialization in variable declarations | | | | -| [`@typescript-eslint/keyword-spacing`](./docs/rules/keyword-spacing.md) | Enforce consistent spacing before and after keywords | | :wrench: | | -| [`@typescript-eslint/lines-between-class-members`](./docs/rules/lines-between-class-members.md) | Require or disallow an empty line between class members | | :wrench: | | -| [`@typescript-eslint/no-array-constructor`](./docs/rules/no-array-constructor.md) | Disallow generic `Array` constructors | :white_check_mark: | :wrench: | | -| [`@typescript-eslint/no-dupe-class-members`](./docs/rules/no-dupe-class-members.md) | Disallow duplicate class members | | | | -| [`@typescript-eslint/no-duplicate-imports`](./docs/rules/no-duplicate-imports.md) | Disallow duplicate imports | | | | -| [`@typescript-eslint/no-empty-function`](./docs/rules/no-empty-function.md) | Disallow empty functions | :white_check_mark: | | | -| [`@typescript-eslint/no-extra-parens`](./docs/rules/no-extra-parens.md) | Disallow unnecessary parentheses | | :wrench: | | -| [`@typescript-eslint/no-extra-semi`](./docs/rules/no-extra-semi.md) | Disallow unnecessary semicolons | :white_check_mark: | :wrench: | | -| [`@typescript-eslint/no-implied-eval`](./docs/rules/no-implied-eval.md) | Disallow the use of `eval()`-like methods | :white_check_mark: | | :thought_balloon: | -| [`@typescript-eslint/no-invalid-this`](./docs/rules/no-invalid-this.md) | Disallow `this` keywords outside of classes or class-like objects | | | | -| [`@typescript-eslint/no-loop-func`](./docs/rules/no-loop-func.md) | Disallow function declarations that contain unsafe references inside loop statements | | | | -| [`@typescript-eslint/no-loss-of-precision`](./docs/rules/no-loss-of-precision.md) | Disallow literal numbers that lose precision | :white_check_mark: | | | -| [`@typescript-eslint/no-magic-numbers`](./docs/rules/no-magic-numbers.md) | Disallow magic numbers | | | | -| [`@typescript-eslint/no-redeclare`](./docs/rules/no-redeclare.md) | Disallow variable redeclaration | | | | -| [`@typescript-eslint/no-restricted-imports`](./docs/rules/no-restricted-imports.md) | Disallow specified modules when loaded by `import` | | | | -| [`@typescript-eslint/no-shadow`](./docs/rules/no-shadow.md) | Disallow variable declarations from shadowing variables declared in the outer scope | | | | -| [`@typescript-eslint/no-throw-literal`](./docs/rules/no-throw-literal.md) | Disallow throwing literals as exceptions | | | :thought_balloon: | -| [`@typescript-eslint/no-unused-expressions`](./docs/rules/no-unused-expressions.md) | Disallow unused expressions | | | | -| [`@typescript-eslint/no-unused-vars`](./docs/rules/no-unused-vars.md) | Disallow unused variables | :white_check_mark: | | | -| [`@typescript-eslint/no-use-before-define`](./docs/rules/no-use-before-define.md) | Disallow the use of variables before they are defined | | | | -| [`@typescript-eslint/no-useless-constructor`](./docs/rules/no-useless-constructor.md) | Disallow unnecessary constructors | | | | -| [`@typescript-eslint/object-curly-spacing`](./docs/rules/object-curly-spacing.md) | Enforce consistent spacing inside braces | | :wrench: | | -| [`@typescript-eslint/padding-line-between-statements`](./docs/rules/padding-line-between-statements.md) | require or disallow padding lines between statements | | :wrench: | | -| [`@typescript-eslint/quotes`](./docs/rules/quotes.md) | Enforce the consistent use of either backticks, double, or single quotes | | :wrench: | | -| [`@typescript-eslint/require-await`](./docs/rules/require-await.md) | Disallow async functions which have no `await` expression | :white_check_mark: | | :thought_balloon: | -| [`@typescript-eslint/return-await`](./docs/rules/return-await.md) | Enforces consistent returning of awaited values | | :wrench: | :thought_balloon: | -| [`@typescript-eslint/semi`](./docs/rules/semi.md) | Require or disallow semicolons instead of ASI | | :wrench: | | -| [`@typescript-eslint/space-before-blocks`](./docs/rules/space-before-blocks.md) | Enforces consistent spacing before blocks | | :wrench: | | -| [`@typescript-eslint/space-before-function-paren`](./docs/rules/space-before-function-paren.md) | Enforces consistent spacing before function parenthesis | | :wrench: | | -| [`@typescript-eslint/space-infix-ops`](./docs/rules/space-infix-ops.md) | This rule is aimed at ensuring there are spaces around infix operators. | | :wrench: | | +**Key**: :white_check_mark: = recommended, :lock: = strict, :wrench: = fixable, :thought_balloon: = requires type information + +| Name | Description | :white_check_mark::lock: | :wrench: | :thought_balloon: | +| ------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------ | ------------------------ | -------- | ----------------- | +| [`@typescript-eslint/brace-style`](./docs/rules/brace-style.md) | Enforce consistent brace style for blocks | | :wrench: | | +| [`@typescript-eslint/comma-dangle`](./docs/rules/comma-dangle.md) | Require or disallow trailing comma | | :wrench: | | +| [`@typescript-eslint/comma-spacing`](./docs/rules/comma-spacing.md) | Enforces consistent spacing before and after commas | | :wrench: | | +| [`@typescript-eslint/default-param-last`](./docs/rules/default-param-last.md) | Enforce default parameters to be last | | | | +| [`@typescript-eslint/dot-notation`](./docs/rules/dot-notation.md) | enforce dot notation whenever possible | :lock: | :wrench: | :thought_balloon: | +| [`@typescript-eslint/func-call-spacing`](./docs/rules/func-call-spacing.md) | Require or disallow spacing between function identifiers and their invocations | | :wrench: | | +| [`@typescript-eslint/indent`](./docs/rules/indent.md) | Enforce consistent indentation | | :wrench: | | +| [`@typescript-eslint/init-declarations`](./docs/rules/init-declarations.md) | require or disallow initialization in variable declarations | | | | +| [`@typescript-eslint/keyword-spacing`](./docs/rules/keyword-spacing.md) | Enforce consistent spacing before and after keywords | | :wrench: | | +| [`@typescript-eslint/lines-between-class-members`](./docs/rules/lines-between-class-members.md) | Require or disallow an empty line between class members | | :wrench: | | +| [`@typescript-eslint/no-array-constructor`](./docs/rules/no-array-constructor.md) | Disallow generic `Array` constructors | :white_check_mark: | :wrench: | | +| [`@typescript-eslint/no-dupe-class-members`](./docs/rules/no-dupe-class-members.md) | Disallow duplicate class members | | | | +| [`@typescript-eslint/no-duplicate-imports`](./docs/rules/no-duplicate-imports.md) | Disallow duplicate imports | | | | +| [`@typescript-eslint/no-empty-function`](./docs/rules/no-empty-function.md) | Disallow empty functions | :white_check_mark: | | | +| [`@typescript-eslint/no-extra-parens`](./docs/rules/no-extra-parens.md) | Disallow unnecessary parentheses | | :wrench: | | +| [`@typescript-eslint/no-extra-semi`](./docs/rules/no-extra-semi.md) | Disallow unnecessary semicolons | :white_check_mark: | :wrench: | | +| [`@typescript-eslint/no-implied-eval`](./docs/rules/no-implied-eval.md) | Disallow the use of `eval()`-like methods | :white_check_mark: | | :thought_balloon: | +| [`@typescript-eslint/no-invalid-this`](./docs/rules/no-invalid-this.md) | Disallow `this` keywords outside of classes or class-like objects | | | | +| [`@typescript-eslint/no-loop-func`](./docs/rules/no-loop-func.md) | Disallow function declarations that contain unsafe references inside loop statements | | | | +| [`@typescript-eslint/no-loss-of-precision`](./docs/rules/no-loss-of-precision.md) | Disallow literal numbers that lose precision | :white_check_mark: | | | +| [`@typescript-eslint/no-magic-numbers`](./docs/rules/no-magic-numbers.md) | Disallow magic numbers | | | | +| [`@typescript-eslint/no-redeclare`](./docs/rules/no-redeclare.md) | Disallow variable redeclaration | | | | +| [`@typescript-eslint/no-restricted-imports`](./docs/rules/no-restricted-imports.md) | Disallow specified modules when loaded by `import` | | | | +| [`@typescript-eslint/no-shadow`](./docs/rules/no-shadow.md) | Disallow variable declarations from shadowing variables declared in the outer scope | | | | +| [`@typescript-eslint/no-throw-literal`](./docs/rules/no-throw-literal.md) | Disallow throwing literals as exceptions | :lock: | | :thought_balloon: | +| [`@typescript-eslint/no-unused-expressions`](./docs/rules/no-unused-expressions.md) | Disallow unused expressions | | | | +| [`@typescript-eslint/no-unused-vars`](./docs/rules/no-unused-vars.md) | Disallow unused variables | :white_check_mark: | | | +| [`@typescript-eslint/no-use-before-define`](./docs/rules/no-use-before-define.md) | Disallow the use of variables before they are defined | | | | +| [`@typescript-eslint/no-useless-constructor`](./docs/rules/no-useless-constructor.md) | Disallow unnecessary constructors | :lock: | | | +| [`@typescript-eslint/object-curly-spacing`](./docs/rules/object-curly-spacing.md) | Enforce consistent spacing inside braces | | :wrench: | | +| [`@typescript-eslint/padding-line-between-statements`](./docs/rules/padding-line-between-statements.md) | require or disallow padding lines between statements | | :wrench: | | +| [`@typescript-eslint/quotes`](./docs/rules/quotes.md) | Enforce the consistent use of either backticks, double, or single quotes | | :wrench: | | +| [`@typescript-eslint/require-await`](./docs/rules/require-await.md) | Disallow async functions which have no `await` expression | :white_check_mark: | | :thought_balloon: | +| [`@typescript-eslint/return-await`](./docs/rules/return-await.md) | Enforces consistent returning of awaited values | | :wrench: | :thought_balloon: | +| [`@typescript-eslint/semi`](./docs/rules/semi.md) | Require or disallow semicolons instead of ASI | | :wrench: | | +| [`@typescript-eslint/space-before-blocks`](./docs/rules/space-before-blocks.md) | Enforces consistent spacing before blocks | | :wrench: | | +| [`@typescript-eslint/space-before-function-paren`](./docs/rules/space-before-function-paren.md) | Enforces consistent spacing before function parenthesis | | :wrench: | | +| [`@typescript-eslint/space-infix-ops`](./docs/rules/space-infix-ops.md) | This rule is aimed at ensuring there are spaces around infix operators. | | :wrench: | | diff --git a/packages/eslint-plugin/docs/rules/README.md b/packages/eslint-plugin/docs/rules/README.md index 944a7452a35..74d0a71ecf1 100644 --- a/packages/eslint-plugin/docs/rules/README.md +++ b/packages/eslint-plugin/docs/rules/README.md @@ -6,104 +6,104 @@ pagination_prev: null slug: / --- -`@typescript-eslint/eslint-plugin` comes with two rulesets you can extend from to pull in the recommended starting rules: - -- `'plugin:@typescript-eslint/recommended'`: recommended rules for code correctness that you can drop in without additional configuration. - See [Linting](https://typescript-eslint.io/docs/linting) for more details. -- `'plugin:@typescript-eslint/recommended-requiring-type-checking'` additional recommended rules that require type information. - See [Linting](https://typescript-eslint.io/docs/linting/type-linting) for more details. +`@typescript-eslint/eslint-plugin` includes over 100 rules that detect best practice violations, bugs, and/or stylistic issues specifically for TypeScript code. +See [Presets](/docs/linting/presets) for how to enable recommended rules using presets. ## Supported Rules -**Key**: :white_check_mark: = recommended, :wrench: = fixable, :thought_balloon: = requires type information +**Key**: :white_check_mark: = recommended, :lock: = strict, :wrench: = fixable, :thought_balloon: = requires type information -| Name | Description | :white_check_mark: | :wrench: | :thought_balloon: | -| ------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------- | ------------------ | -------- | ----------------- | -| [`@typescript-eslint/adjacent-overload-signatures`](./adjacent-overload-signatures.md) | Require that member overloads be consecutive | :white_check_mark: | | | -| [`@typescript-eslint/array-type`](./array-type.md) | Requires using either `T[]` or `Array` for arrays | | :wrench: | | -| [`@typescript-eslint/await-thenable`](./await-thenable.md) | Disallows awaiting a value that is not a Thenable | :white_check_mark: | | :thought_balloon: | -| [`@typescript-eslint/ban-ts-comment`](./ban-ts-comment.md) | Bans `@ts-` comments from being used or requires descriptions after directive | :white_check_mark: | | | -| [`@typescript-eslint/ban-tslint-comment`](./ban-tslint-comment.md) | Bans `// tslint:` comments from being used | | :wrench: | | -| [`@typescript-eslint/ban-types`](./ban-types.md) | Bans specific types from being used | :white_check_mark: | :wrench: | | -| [`@typescript-eslint/class-literal-property-style`](./class-literal-property-style.md) | Ensures that literals on classes are exposed in a consistent style | | :wrench: | | -| [`@typescript-eslint/consistent-indexed-object-style`](./consistent-indexed-object-style.md) | Enforce or disallow the use of the record type | | :wrench: | | -| [`@typescript-eslint/consistent-type-assertions`](./consistent-type-assertions.md) | Enforces consistent usage of type assertions | | | | -| [`@typescript-eslint/consistent-type-definitions`](./consistent-type-definitions.md) | Consistent with type definition either `interface` or `type` | | :wrench: | | -| [`@typescript-eslint/consistent-type-exports`](./consistent-type-exports.md) | Enforces consistent usage of type exports | | :wrench: | :thought_balloon: | -| [`@typescript-eslint/consistent-type-imports`](./consistent-type-imports.md) | Enforces consistent usage of type imports | | :wrench: | | -| [`@typescript-eslint/explicit-function-return-type`](./explicit-function-return-type.md) | Require explicit return types on functions and class methods | | | | -| [`@typescript-eslint/explicit-member-accessibility`](./explicit-member-accessibility.md) | Require explicit accessibility modifiers on class properties and methods | | :wrench: | | -| [`@typescript-eslint/explicit-module-boundary-types`](./explicit-module-boundary-types.md) | Require explicit return and argument types on exported functions' and classes' public class methods | | | | -| [`@typescript-eslint/member-delimiter-style`](./member-delimiter-style.md) | Require a specific member delimiter style for interfaces and type literals | | :wrench: | | -| [`@typescript-eslint/member-ordering`](./member-ordering.md) | Require a consistent member declaration order | | | | -| [`@typescript-eslint/method-signature-style`](./method-signature-style.md) | Enforces using a particular method signature syntax | | :wrench: | | -| [`@typescript-eslint/naming-convention`](./naming-convention.md) | Enforces naming conventions for everything across a codebase | | | :thought_balloon: | -| [`@typescript-eslint/no-base-to-string`](./no-base-to-string.md) | Requires that `.toString()` is only called on objects which provide useful information when stringified | | | :thought_balloon: | -| [`@typescript-eslint/no-confusing-non-null-assertion`](./no-confusing-non-null-assertion.md) | Disallow non-null assertion in locations that may be confusing | | :wrench: | | -| [`@typescript-eslint/no-confusing-void-expression`](./no-confusing-void-expression.md) | Requires expressions of type void to appear in statement position | | :wrench: | :thought_balloon: | -| [`@typescript-eslint/no-dynamic-delete`](./no-dynamic-delete.md) | Disallow the delete operator with computed key expressions | | :wrench: | | -| [`@typescript-eslint/no-empty-interface`](./no-empty-interface.md) | Disallow the declaration of empty interfaces | :white_check_mark: | :wrench: | | -| [`@typescript-eslint/no-explicit-any`](./no-explicit-any.md) | Disallow usage of the `any` type | :white_check_mark: | :wrench: | | -| [`@typescript-eslint/no-extra-non-null-assertion`](./no-extra-non-null-assertion.md) | Disallow extra non-null assertion | :white_check_mark: | :wrench: | | -| [`@typescript-eslint/no-extraneous-class`](./no-extraneous-class.md) | Forbids the use of classes as namespaces | | | | -| [`@typescript-eslint/no-floating-promises`](./no-floating-promises.md) | Requires Promise-like statements to be handled appropriately | :white_check_mark: | | :thought_balloon: | -| [`@typescript-eslint/no-for-in-array`](./no-for-in-array.md) | Disallow iterating over an array with a for-in loop | :white_check_mark: | | :thought_balloon: | -| [`@typescript-eslint/no-inferrable-types`](./no-inferrable-types.md) | Disallows explicit type declarations for variables or parameters initialized to a number, string, or boolean | :white_check_mark: | :wrench: | | -| [`@typescript-eslint/no-invalid-void-type`](./no-invalid-void-type.md) | Disallows usage of `void` type outside of generic or return types | | | | -| [`@typescript-eslint/no-meaningless-void-operator`](./no-meaningless-void-operator.md) | Disallow the `void` operator except when used to discard a value | | :wrench: | :thought_balloon: | -| [`@typescript-eslint/no-misused-new`](./no-misused-new.md) | Enforce valid definition of `new` and `constructor` | :white_check_mark: | | | -| [`@typescript-eslint/no-misused-promises`](./no-misused-promises.md) | Avoid using Promises in places not designed to handle them | :white_check_mark: | | :thought_balloon: | -| [`@typescript-eslint/no-namespace`](./no-namespace.md) | Disallow the use of custom TypeScript modules and namespaces | :white_check_mark: | | | -| [`@typescript-eslint/no-non-null-asserted-nullish-coalescing`](./no-non-null-asserted-nullish-coalescing.md) | Disallows using a non-null assertion in the left operand of the nullish coalescing operator | | | | -| [`@typescript-eslint/no-non-null-asserted-optional-chain`](./no-non-null-asserted-optional-chain.md) | Disallows using a non-null assertion after an optional chain expression | :white_check_mark: | | | -| [`@typescript-eslint/no-non-null-assertion`](./no-non-null-assertion.md) | Disallows non-null assertions using the `!` postfix operator | :white_check_mark: | | | -| [`@typescript-eslint/no-require-imports`](./no-require-imports.md) | Disallows invocation of `require()` | | | | -| [`@typescript-eslint/no-this-alias`](./no-this-alias.md) | Disallow aliasing `this` | :white_check_mark: | | | -| [`@typescript-eslint/no-type-alias`](./no-type-alias.md) | Disallow the use of type aliases | | | | -| [`@typescript-eslint/no-unnecessary-boolean-literal-compare`](./no-unnecessary-boolean-literal-compare.md) | Flags unnecessary equality comparisons against boolean literals | | :wrench: | :thought_balloon: | -| [`@typescript-eslint/no-unnecessary-condition`](./no-unnecessary-condition.md) | Prevents conditionals where the type is always truthy or always falsy | | :wrench: | :thought_balloon: | -| [`@typescript-eslint/no-unnecessary-qualifier`](./no-unnecessary-qualifier.md) | Warns when a namespace qualifier is unnecessary | | :wrench: | :thought_balloon: | -| [`@typescript-eslint/no-unnecessary-type-arguments`](./no-unnecessary-type-arguments.md) | Enforces that type arguments will not be used if not required | | :wrench: | :thought_balloon: | -| [`@typescript-eslint/no-unnecessary-type-assertion`](./no-unnecessary-type-assertion.md) | Warns if a type assertion does not change the type of an expression | :white_check_mark: | :wrench: | :thought_balloon: | -| [`@typescript-eslint/no-unnecessary-type-constraint`](./no-unnecessary-type-constraint.md) | Disallows unnecessary constraints on generic types | :white_check_mark: | | | -| [`@typescript-eslint/no-unsafe-argument`](./no-unsafe-argument.md) | Disallows calling a function with an any type value | :white_check_mark: | | :thought_balloon: | -| [`@typescript-eslint/no-unsafe-assignment`](./no-unsafe-assignment.md) | Disallows assigning any to variables and properties | :white_check_mark: | | :thought_balloon: | -| [`@typescript-eslint/no-unsafe-call`](./no-unsafe-call.md) | Disallows calling an any type value | :white_check_mark: | | :thought_balloon: | -| [`@typescript-eslint/no-unsafe-member-access`](./no-unsafe-member-access.md) | Disallows member access on any typed variables | :white_check_mark: | | :thought_balloon: | -| [`@typescript-eslint/no-unsafe-return`](./no-unsafe-return.md) | Disallows returning any from a function | :white_check_mark: | | :thought_balloon: | -| [`@typescript-eslint/no-var-requires`](./no-var-requires.md) | Disallows the use of require statements except in import statements | :white_check_mark: | | | -| [`@typescript-eslint/non-nullable-type-assertion-style`](./non-nullable-type-assertion-style.md) | Prefers a non-null assertion over explicit type cast when possible | | :wrench: | :thought_balloon: | -| [`@typescript-eslint/parameter-properties`](./parameter-properties.md) | Require or disallow the use of parameter properties in class constructors | | | | -| [`@typescript-eslint/prefer-as-const`](./prefer-as-const.md) | Prefer usage of `as const` over literal type | :white_check_mark: | :wrench: | | -| [`@typescript-eslint/prefer-enum-initializers`](./prefer-enum-initializers.md) | Prefer initializing each enums member value | | | | -| [`@typescript-eslint/prefer-for-of`](./prefer-for-of.md) | Prefer a ‘for-of’ loop over a standard ‘for’ loop if the index is only used to access the array being iterated | | | | -| [`@typescript-eslint/prefer-function-type`](./prefer-function-type.md) | Use function types instead of interfaces with call signatures | | :wrench: | | -| [`@typescript-eslint/prefer-includes`](./prefer-includes.md) | Enforce `includes` method over `indexOf` method | | :wrench: | :thought_balloon: | -| [`@typescript-eslint/prefer-literal-enum-member`](./prefer-literal-enum-member.md) | Require that all enum members be literal values to prevent unintended enum member name shadow issues | | | | -| [`@typescript-eslint/prefer-namespace-keyword`](./prefer-namespace-keyword.md) | Require the use of the `namespace` keyword instead of the `module` keyword to declare custom TypeScript modules | :white_check_mark: | :wrench: | | -| [`@typescript-eslint/prefer-nullish-coalescing`](./prefer-nullish-coalescing.md) | Enforce the usage of the nullish coalescing operator instead of logical chaining | | | :thought_balloon: | -| [`@typescript-eslint/prefer-optional-chain`](./prefer-optional-chain.md) | Prefer using concise optional chain expressions instead of chained logical ands | | | | -| [`@typescript-eslint/prefer-readonly`](./prefer-readonly.md) | Requires that private members are marked as `readonly` if they're never modified outside of the constructor | | :wrench: | :thought_balloon: | -| [`@typescript-eslint/prefer-readonly-parameter-types`](./prefer-readonly-parameter-types.md) | Requires that function parameters are typed as readonly to prevent accidental mutation of inputs | | | :thought_balloon: | -| [`@typescript-eslint/prefer-reduce-type-parameter`](./prefer-reduce-type-parameter.md) | Prefer using type parameter when calling `Array#reduce` instead of casting | | :wrench: | :thought_balloon: | -| [`@typescript-eslint/prefer-regexp-exec`](./prefer-regexp-exec.md) | Enforce that `RegExp#exec` is used instead of `String#match` if no global flag is provided | | :wrench: | :thought_balloon: | -| [`@typescript-eslint/prefer-return-this-type`](./prefer-return-this-type.md) | Enforce that `this` is used when only `this` type is returned | | :wrench: | :thought_balloon: | -| [`@typescript-eslint/prefer-string-starts-ends-with`](./prefer-string-starts-ends-with.md) | Enforce the use of `String#startsWith` and `String#endsWith` instead of other equivalent methods of checking substrings | | :wrench: | :thought_balloon: | -| [`@typescript-eslint/prefer-ts-expect-error`](./prefer-ts-expect-error.md) | Recommends using `@ts-expect-error` over `@ts-ignore` | | :wrench: | | -| [`@typescript-eslint/promise-function-async`](./promise-function-async.md) | Requires any function or method that returns a Promise to be marked async | | :wrench: | :thought_balloon: | -| [`@typescript-eslint/require-array-sort-compare`](./require-array-sort-compare.md) | Requires `Array#sort` calls to always provide a `compareFunction` | | | :thought_balloon: | -| [`@typescript-eslint/restrict-plus-operands`](./restrict-plus-operands.md) | When adding two variables, operands must both be of type number or of type string | :white_check_mark: | | :thought_balloon: | -| [`@typescript-eslint/restrict-template-expressions`](./restrict-template-expressions.md) | Enforce template literal expressions to be of string type | :white_check_mark: | | :thought_balloon: | -| [`@typescript-eslint/sort-type-union-intersection-members`](./sort-type-union-intersection-members.md) | Enforces that members of a type union/intersection are sorted alphabetically | | :wrench: | | -| [`@typescript-eslint/strict-boolean-expressions`](./strict-boolean-expressions.md) | Restricts the types allowed in boolean expressions | | :wrench: | :thought_balloon: | -| [`@typescript-eslint/switch-exhaustiveness-check`](./switch-exhaustiveness-check.md) | Exhaustiveness checking in switch with union type | | | :thought_balloon: | -| [`@typescript-eslint/triple-slash-reference`](./triple-slash-reference.md) | Sets preference level for triple slash directives versus ES6-style import declarations | :white_check_mark: | | | -| [`@typescript-eslint/type-annotation-spacing`](./type-annotation-spacing.md) | Require consistent spacing around type annotations | | :wrench: | | -| [`@typescript-eslint/typedef`](./typedef.md) | Requires type annotations to exist | | | | -| [`@typescript-eslint/unbound-method`](./unbound-method.md) | Enforces unbound methods are called with their expected scope | :white_check_mark: | | :thought_balloon: | -| [`@typescript-eslint/unified-signatures`](./unified-signatures.md) | Warns for any two overloads that could be unified into one by using a union or an optional/rest parameter | | | | +| Name | Description | :white_check_mark::lock: | :wrench: | :thought_balloon: | +| ------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------- | ------------------------ | -------- | ----------------- | +| [`@typescript-eslint/adjacent-overload-signatures`](./adjacent-overload-signatures.md) | Require that member overloads be consecutive | :white_check_mark: | | | +| [`@typescript-eslint/array-type`](./array-type.md) | Requires using either `T[]` or `Array` for arrays | :lock: | :wrench: | | +| [`@typescript-eslint/await-thenable`](./await-thenable.md) | Disallows awaiting a value that is not a Thenable | :white_check_mark: | | :thought_balloon: | +| [`@typescript-eslint/ban-ts-comment`](./ban-ts-comment.md) | Bans `@ts-` comments from being used or requires descriptions after directive | :white_check_mark: | | | +| [`@typescript-eslint/ban-tslint-comment`](./ban-tslint-comment.md) | Bans `// tslint:` comments from being used | :lock: | :wrench: | | +| [`@typescript-eslint/ban-types`](./ban-types.md) | Bans specific types from being used | :white_check_mark: | :wrench: | | +| [`@typescript-eslint/class-literal-property-style`](./class-literal-property-style.md) | Ensures that literals on classes are exposed in a consistent style | :lock: | :wrench: | | +| [`@typescript-eslint/consistent-indexed-object-style`](./consistent-indexed-object-style.md) | Enforce or disallow the use of the record type | :lock: | :wrench: | | +| [`@typescript-eslint/consistent-type-assertions`](./consistent-type-assertions.md) | Enforces consistent usage of type assertions | :lock: | | | +| [`@typescript-eslint/consistent-type-definitions`](./consistent-type-definitions.md) | Consistent with type definition either `interface` or `type` | :lock: | :wrench: | | +| [`@typescript-eslint/consistent-type-exports`](./consistent-type-exports.md) | Enforces consistent usage of type exports | | :wrench: | :thought_balloon: | +| [`@typescript-eslint/consistent-type-imports`](./consistent-type-imports.md) | Enforces consistent usage of type imports | | :wrench: | | +| [`@typescript-eslint/explicit-function-return-type`](./explicit-function-return-type.md) | Require explicit return types on functions and class methods | | | | +| [`@typescript-eslint/explicit-member-accessibility`](./explicit-member-accessibility.md) | Require explicit accessibility modifiers on class properties and methods | | :wrench: | | +| [`@typescript-eslint/explicit-module-boundary-types`](./explicit-module-boundary-types.md) | Require explicit return and argument types on exported functions' and classes' public class methods | | | | +| [`@typescript-eslint/member-delimiter-style`](./member-delimiter-style.md) | Require a specific member delimiter style for interfaces and type literals | | :wrench: | | +| [`@typescript-eslint/member-ordering`](./member-ordering.md) | Require a consistent member declaration order | | | | +| [`@typescript-eslint/method-signature-style`](./method-signature-style.md) | Enforces using a particular method signature syntax | | :wrench: | | +| [`@typescript-eslint/naming-convention`](./naming-convention.md) | Enforces naming conventions for everything across a codebase | | | :thought_balloon: | +| [`@typescript-eslint/no-base-to-string`](./no-base-to-string.md) | Requires that `.toString()` is only called on objects which provide useful information when stringified | :lock: | | :thought_balloon: | +| [`@typescript-eslint/no-confusing-non-null-assertion`](./no-confusing-non-null-assertion.md) | Disallow non-null assertion in locations that may be confusing | :lock: | :wrench: | | +| [`@typescript-eslint/no-confusing-void-expression`](./no-confusing-void-expression.md) | Requires expressions of type void to appear in statement position | | :wrench: | :thought_balloon: | +| [`@typescript-eslint/no-duplicate-enum-values`](./docs/rules/no-duplicate-enum-values.md) | Disallow duplicate enum member values | :lock: | | | +| [`@typescript-eslint/no-dynamic-delete`](./no-dynamic-delete.md) | Disallow the delete operator with computed key expressions | :lock: | :wrench: | | +| [`@typescript-eslint/no-empty-interface`](./no-empty-interface.md) | Disallow the declaration of empty interfaces | :white_check_mark: | :wrench: | | +| [`@typescript-eslint/no-explicit-any`](./no-explicit-any.md) | Disallow usage of the `any` type | :white_check_mark: | :wrench: | | +| [`@typescript-eslint/no-extra-non-null-assertion`](./no-extra-non-null-assertion.md) | Disallow extra non-null assertion | :white_check_mark: | :wrench: | | +| [`@typescript-eslint/no-extraneous-class`](./no-extraneous-class.md) | Forbids the use of classes as namespaces | :lock: | | | +| [`@typescript-eslint/no-floating-promises`](./no-floating-promises.md) | Requires Promise-like statements to be handled appropriately | :white_check_mark: | | :thought_balloon: | +| [`@typescript-eslint/no-for-in-array`](./no-for-in-array.md) | Disallow iterating over an array with a for-in loop | :white_check_mark: | | :thought_balloon: | +| [`@typescript-eslint/no-inferrable-types`](./no-inferrable-types.md) | Disallows explicit type declarations for variables or parameters initialized to a number, string, or boolean | :white_check_mark: | :wrench: | | +| [`@typescript-eslint/no-invalid-void-type`](./no-invalid-void-type.md) | Disallows usage of `void` type outside of generic or return types | :lock: | | | +| [`@typescript-eslint/no-meaningless-void-operator`](./no-meaningless-void-operator.md) | Disallow the `void` operator except when used to discard a value | :lock: | :wrench: | :thought_balloon: | +| [`@typescript-eslint/no-misused-new`](./no-misused-new.md) | Enforce valid definition of `new` and `constructor` | :white_check_mark: | | | +| [`@typescript-eslint/no-misused-promises`](./no-misused-promises.md) | Avoid using Promises in places not designed to handle them | :white_check_mark: | | :thought_balloon: | +| [`@typescript-eslint/no-namespace`](./no-namespace.md) | Disallow the use of custom TypeScript modules and namespaces | :white_check_mark: | | | +| [`@typescript-eslint/no-non-null-asserted-nullish-coalescing`](./no-non-null-asserted-nullish-coalescing.md) | Disallows using a non-null assertion in the left operand of the nullish coalescing operator | :lock: | | | +| [`@typescript-eslint/no-non-null-asserted-optional-chain`](./no-non-null-asserted-optional-chain.md) | Disallows using a non-null assertion after an optional chain expression | :white_check_mark: | | | +| [`@typescript-eslint/no-non-null-assertion`](./no-non-null-assertion.md) | Disallows non-null assertions using the `!` postfix operator | :white_check_mark: | | | +| [`@typescript-eslint/no-parameter-properties`](./no-parameter-properties.md) | Disallow the use of parameter properties in class constructors | | | | +| [`@typescript-eslint/no-redundant-type-constituents`](./no-redundant-type-constituents.md) | Disallow members of unions and intersections that do nothing or override type information | | | :thought_balloon: | +| [`@typescript-eslint/no-require-imports`](./no-require-imports.md) | Disallows invocation of `require()` | | | | +| [`@typescript-eslint/no-this-alias`](./no-this-alias.md) | Disallow aliasing `this` | :white_check_mark: | | | +| [`@typescript-eslint/no-type-alias`](./no-type-alias.md) | Disallow the use of type aliases | | | | +| [`@typescript-eslint/no-unnecessary-boolean-literal-compare`](./no-unnecessary-boolean-literal-compare.md) | Flags unnecessary equality comparisons against boolean literals | :lock: | :wrench: | :thought_balloon: | +| [`@typescript-eslint/no-unnecessary-condition`](./no-unnecessary-condition.md) | Prevents conditionals where the type is always truthy or always falsy | :lock: | :wrench: | :thought_balloon: | +| [`@typescript-eslint/no-unnecessary-qualifier`](./no-unnecessary-qualifier.md) | Warns when a namespace qualifier is unnecessary | | :wrench: | :thought_balloon: | +| [`@typescript-eslint/no-unnecessary-type-arguments`](./no-unnecessary-type-arguments.md) | Enforces that type arguments will not be used if not required | :lock: | :wrench: | :thought_balloon: | +| [`@typescript-eslint/no-unnecessary-type-assertion`](./no-unnecessary-type-assertion.md) | Warns if a type assertion does not change the type of an expression | :white_check_mark: | :wrench: | :thought_balloon: | +| [`@typescript-eslint/no-unnecessary-type-constraint`](./no-unnecessary-type-constraint.md) | Disallows unnecessary constraints on generic types | :white_check_mark: | | | +| [`@typescript-eslint/no-unsafe-argument`](./no-unsafe-argument.md) | Disallows calling a function with an any type value | :white_check_mark: | | :thought_balloon: | +| [`@typescript-eslint/no-unsafe-assignment`](./no-unsafe-assignment.md) | Disallows assigning any to variables and properties | :white_check_mark: | | :thought_balloon: | +| [`@typescript-eslint/no-unsafe-call`](./no-unsafe-call.md) | Disallows calling an any type value | :white_check_mark: | | :thought_balloon: | +| [`@typescript-eslint/no-unsafe-member-access`](./no-unsafe-member-access.md) | Disallows member access on any typed variables | :white_check_mark: | | :thought_balloon: | +| [`@typescript-eslint/no-unsafe-return`](./no-unsafe-return.md) | Disallows returning any from a function | :white_check_mark: | | :thought_balloon: | +| [`@typescript-eslint/no-useless-empty-export`](./no-useless-empty-export.md) | Disallow empty exports that don't change anything in a module file | | :wrench: | | +| [`@typescript-eslint/no-var-requires`](./no-var-requires.md) | Disallows the use of require statements except in import statements | :white_check_mark: | | | +| [`@typescript-eslint/non-nullable-type-assertion-style`](./non-nullable-type-assertion-style.md) | Prefers a non-null assertion over explicit type cast when possible | :lock: | :wrench: | :thought_balloon: | +| [`@typescript-eslint/parameter-properties`](./parameter-properties.md) | Require or disallow the use of parameter properties in class constructors | | | | +| [`@typescript-eslint/prefer-as-const`](./prefer-as-const.md) | Prefer usage of `as const` over literal type | :white_check_mark: | :wrench: | | +| [`@typescript-eslint/prefer-enum-initializers`](./prefer-enum-initializers.md) | Prefer initializing each enums member value | | | | +| [`@typescript-eslint/prefer-for-of`](./prefer-for-of.md) | Prefer a ‘for-of’ loop over a standard ‘for’ loop if the index is only used to access the array being iterated | :lock: | | | +| [`@typescript-eslint/prefer-function-type`](./prefer-function-type.md) | Use function types instead of interfaces with call signatures | :lock: | :wrench: | | +| [`@typescript-eslint/prefer-includes`](./prefer-includes.md) | Enforce `includes` method over `indexOf` method | :lock: | :wrench: | :thought_balloon: | +| [`@typescript-eslint/prefer-literal-enum-member`](./prefer-literal-enum-member.md) | Require that all enum members be literal values to prevent unintended enum member name shadow issues | :lock: | | | +| [`@typescript-eslint/prefer-namespace-keyword`](./prefer-namespace-keyword.md) | Require the use of the `namespace` keyword instead of the `module` keyword to declare custom TypeScript modules | :white_check_mark: | :wrench: | | +| [`@typescript-eslint/prefer-nullish-coalescing`](./prefer-nullish-coalescing.md) | Enforce the usage of the nullish coalescing operator instead of logical chaining | :lock: | | :thought_balloon: | +| [`@typescript-eslint/prefer-optional-chain`](./prefer-optional-chain.md) | Prefer using concise optional chain expressions instead of chained logical ands | :lock: | | | +| [`@typescript-eslint/prefer-readonly`](./prefer-readonly.md) | Requires that private members are marked as `readonly` if they're never modified outside of the constructor | | :wrench: | :thought_balloon: | +| [`@typescript-eslint/prefer-readonly-parameter-types`](./prefer-readonly-parameter-types.md) | Requires that function parameters are typed as readonly to prevent accidental mutation of inputs | | | :thought_balloon: | +| [`@typescript-eslint/prefer-reduce-type-parameter`](./prefer-reduce-type-parameter.md) | Prefer using type parameter when calling `Array#reduce` instead of casting | :lock: | :wrench: | :thought_balloon: | +| [`@typescript-eslint/prefer-regexp-exec`](./prefer-regexp-exec.md) | Enforce that `RegExp#exec` is used instead of `String#match` if no global flag is provided | | :wrench: | :thought_balloon: | +| [`@typescript-eslint/prefer-return-this-type`](./prefer-return-this-type.md) | Enforce that `this` is used when only `this` type is returned | :lock: | :wrench: | :thought_balloon: | +| [`@typescript-eslint/prefer-string-starts-ends-with`](./prefer-string-starts-ends-with.md) | Enforce the use of `String#startsWith` and `String#endsWith` instead of other equivalent methods of checking substrings | :lock: | :wrench: | :thought_balloon: | +| [`@typescript-eslint/prefer-ts-expect-error`](./prefer-ts-expect-error.md) | Recommends using `@ts-expect-error` over `@ts-ignore` | :lock: | :wrench: | | +| [`@typescript-eslint/promise-function-async`](./promise-function-async.md) | Requires any function or method that returns a Promise to be marked async | | :wrench: | :thought_balloon: | +| [`@typescript-eslint/require-array-sort-compare`](./require-array-sort-compare.md) | Requires `Array#sort` calls to always provide a `compareFunction` | | | :thought_balloon: | +| [`@typescript-eslint/restrict-plus-operands`](./restrict-plus-operands.md) | When adding two variables, operands must both be of type number or of type string | :white_check_mark: | | :thought_balloon: | +| [`@typescript-eslint/restrict-template-expressions`](./restrict-template-expressions.md) | Enforce template literal expressions to be of string type | :white_check_mark: | | :thought_balloon: | +| [`@typescript-eslint/sort-type-union-intersection-members`](./sort-type-union-intersection-members.md) | Enforces that members of a type union/intersection are sorted alphabetically | | :wrench: | | +| [`@typescript-eslint/strict-boolean-expressions`](./strict-boolean-expressions.md) | Restricts the types allowed in boolean expressions | | :wrench: | :thought_balloon: | +| [`@typescript-eslint/switch-exhaustiveness-check`](./switch-exhaustiveness-check.md) | Exhaustiveness checking in switch with union type | | | :thought_balloon: | +| [`@typescript-eslint/triple-slash-reference`](./triple-slash-reference.md) | Sets preference level for triple slash directives versus ES6-style import declarations | :white_check_mark: | | | +| [`@typescript-eslint/type-annotation-spacing`](./type-annotation-spacing.md) | Require consistent spacing around type annotations | | :wrench: | | +| [`@typescript-eslint/typedef`](./typedef.md) | Requires type annotations to exist | | | | +| [`@typescript-eslint/unbound-method`](./unbound-method.md) | Enforces unbound methods are called with their expected scope | :white_check_mark: | | :thought_balloon: | +| [`@typescript-eslint/unified-signatures`](./unified-signatures.md) | Warns for any two overloads that could be unified into one by using a union or an optional/rest parameter | :lock: | | | @@ -114,46 +114,47 @@ In these cases, we create what we call an extension rule; a rule within our plug -**Key**: :white_check_mark: = recommended, :wrench: = fixable, :thought_balloon: = requires type information +**Key**: :white_check_mark: = recommended, :lock: = strict, :wrench: = fixable, :thought_balloon: = requires type information -| Name | Description | :white_check_mark: | :wrench: | :thought_balloon: | -| -------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------ | ------------------ | -------- | ----------------- | -| [`@typescript-eslint/brace-style`](./brace-style.md) | Enforce consistent brace style for blocks | | :wrench: | | -| [`@typescript-eslint/comma-dangle`](./comma-dangle.md) | Require or disallow trailing comma | | :wrench: | | -| [`@typescript-eslint/comma-spacing`](./comma-spacing.md) | Enforces consistent spacing before and after commas | | :wrench: | | -| [`@typescript-eslint/default-param-last`](./default-param-last.md) | Enforce default parameters to be last | | | | -| [`@typescript-eslint/dot-notation`](./dot-notation.md) | enforce dot notation whenever possible | | :wrench: | :thought_balloon: | -| [`@typescript-eslint/func-call-spacing`](./func-call-spacing.md) | Require or disallow spacing between function identifiers and their invocations | | :wrench: | | -| [`@typescript-eslint/indent`](./indent.md) | Enforce consistent indentation | | :wrench: | | -| [`@typescript-eslint/init-declarations`](./init-declarations.md) | require or disallow initialization in variable declarations | | | | -| [`@typescript-eslint/keyword-spacing`](./keyword-spacing.md) | Enforce consistent spacing before and after keywords | | :wrench: | | -| [`@typescript-eslint/lines-between-class-members`](./lines-between-class-members.md) | Require or disallow an empty line between class members | | :wrench: | | -| [`@typescript-eslint/no-array-constructor`](./no-array-constructor.md) | Disallow generic `Array` constructors | :white_check_mark: | :wrench: | | -| [`@typescript-eslint/no-dupe-class-members`](./no-dupe-class-members.md) | Disallow duplicate class members | | | | -| [`@typescript-eslint/no-duplicate-imports`](./no-duplicate-imports.md) | Disallow duplicate imports | | | | -| [`@typescript-eslint/no-empty-function`](./no-empty-function.md) | Disallow empty functions | :white_check_mark: | | | -| [`@typescript-eslint/no-extra-parens`](./no-extra-parens.md) | Disallow unnecessary parentheses | | :wrench: | | -| [`@typescript-eslint/no-extra-semi`](./no-extra-semi.md) | Disallow unnecessary semicolons | :white_check_mark: | :wrench: | | -| [`@typescript-eslint/no-implied-eval`](./no-implied-eval.md) | Disallow the use of `eval()`-like methods | :white_check_mark: | | :thought_balloon: | -| [`@typescript-eslint/no-invalid-this`](./no-invalid-this.md) | Disallow `this` keywords outside of classes or class-like objects | | | | -| [`@typescript-eslint/no-loop-func`](./no-loop-func.md) | Disallow function declarations that contain unsafe references inside loop statements | | | | -| [`@typescript-eslint/no-loss-of-precision`](./no-loss-of-precision.md) | Disallow literal numbers that lose precision | :white_check_mark: | | | -| [`@typescript-eslint/no-magic-numbers`](./no-magic-numbers.md) | Disallow magic numbers | | | | -| [`@typescript-eslint/no-redeclare`](./no-redeclare.md) | Disallow variable redeclaration | | | | -| [`@typescript-eslint/no-restricted-imports`](./no-restricted-imports.md) | Disallow specified modules when loaded by `import` | | | | -| [`@typescript-eslint/no-shadow`](./no-shadow.md) | Disallow variable declarations from shadowing variables declared in the outer scope | | | | -| [`@typescript-eslint/no-throw-literal`](./no-throw-literal.md) | Disallow throwing literals as exceptions | | | :thought_balloon: | -| [`@typescript-eslint/no-unused-expressions`](./no-unused-expressions.md) | Disallow unused expressions | | | | -| [`@typescript-eslint/no-unused-vars`](./no-unused-vars.md) | Disallow unused variables | :white_check_mark: | | | -| [`@typescript-eslint/no-use-before-define`](./no-use-before-define.md) | Disallow the use of variables before they are defined | | | | -| [`@typescript-eslint/no-useless-constructor`](./no-useless-constructor.md) | Disallow unnecessary constructors | | | | -| [`@typescript-eslint/object-curly-spacing`](./object-curly-spacing.md) | Enforce consistent spacing inside braces | | :wrench: | | -| [`@typescript-eslint/padding-line-between-statements`](./padding-line-between-statements.md) | require or disallow padding lines between statements | | :wrench: | | -| [`@typescript-eslint/quotes`](./quotes.md) | Enforce the consistent use of either backticks, double, or single quotes | | :wrench: | | -| [`@typescript-eslint/require-await`](./require-await.md) | Disallow async functions which have no `await` expression | :white_check_mark: | | :thought_balloon: | -| [`@typescript-eslint/return-await`](./return-await.md) | Enforces consistent returning of awaited values | | :wrench: | :thought_balloon: | -| [`@typescript-eslint/semi`](./semi.md) | Require or disallow semicolons instead of ASI | | :wrench: | | -| [`@typescript-eslint/space-before-function-paren`](./space-before-function-paren.md) | Enforces consistent spacing before function parenthesis | | :wrench: | | -| [`@typescript-eslint/space-infix-ops`](./space-infix-ops.md) | This rule is aimed at ensuring there are spaces around infix operators. | | :wrench: | | +| Name | Description | :white_check_mark::lock: | :wrench: | :thought_balloon: | +| -------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------ | ------------------------ | -------- | ----------------- | +| [`@typescript-eslint/brace-style`](./brace-style.md) | Enforce consistent brace style for blocks | | :wrench: | | +| [`@typescript-eslint/comma-dangle`](./comma-dangle.md) | Require or disallow trailing comma | | :wrench: | | +| [`@typescript-eslint/comma-spacing`](./comma-spacing.md) | Enforces consistent spacing before and after commas | | :wrench: | | +| [`@typescript-eslint/default-param-last`](./default-param-last.md) | Enforce default parameters to be last | | | | +| [`@typescript-eslint/dot-notation`](./dot-notation.md) | enforce dot notation whenever possible | :lock: | :wrench: | :thought_balloon: | +| [`@typescript-eslint/func-call-spacing`](./func-call-spacing.md) | Require or disallow spacing between function identifiers and their invocations | | :wrench: | | +| [`@typescript-eslint/indent`](./indent.md) | Enforce consistent indentation | | :wrench: | | +| [`@typescript-eslint/init-declarations`](./init-declarations.md) | require or disallow initialization in variable declarations | | | | +| [`@typescript-eslint/keyword-spacing`](./keyword-spacing.md) | Enforce consistent spacing before and after keywords | | :wrench: | | +| [`@typescript-eslint/lines-between-class-members`](./lines-between-class-members.md) | Require or disallow an empty line between class members | | :wrench: | | +| [`@typescript-eslint/no-array-constructor`](./no-array-constructor.md) | Disallow generic `Array` constructors | :white_check_mark: | :wrench: | | +| [`@typescript-eslint/no-dupe-class-members`](./no-dupe-class-members.md) | Disallow duplicate class members | | | | +| [`@typescript-eslint/no-duplicate-imports`](./no-duplicate-imports.md) | Disallow duplicate imports | | | | +| [`@typescript-eslint/no-empty-function`](./no-empty-function.md) | Disallow empty functions | :white_check_mark: | | | +| [`@typescript-eslint/no-extra-parens`](./no-extra-parens.md) | Disallow unnecessary parentheses | | :wrench: | | +| [`@typescript-eslint/no-extra-semi`](./no-extra-semi.md) | Disallow unnecessary semicolons | :white_check_mark: | :wrench: | | +| [`@typescript-eslint/no-implied-eval`](./no-implied-eval.md) | Disallow the use of `eval()`-like methods | :white_check_mark: | | :thought_balloon: | +| [`@typescript-eslint/no-invalid-this`](./no-invalid-this.md) | Disallow `this` keywords outside of classes or class-like objects | | | | +| [`@typescript-eslint/no-loop-func`](./no-loop-func.md) | Disallow function declarations that contain unsafe references inside loop statements | | | | +| [`@typescript-eslint/no-loss-of-precision`](./no-loss-of-precision.md) | Disallow literal numbers that lose precision | :white_check_mark: | | | +| [`@typescript-eslint/no-magic-numbers`](./no-magic-numbers.md) | Disallow magic numbers | | | | +| [`@typescript-eslint/no-redeclare`](./no-redeclare.md) | Disallow variable redeclaration | | | | +| [`@typescript-eslint/no-restricted-imports`](./no-restricted-imports.md) | Disallow specified modules when loaded by `import` | | | | +| [`@typescript-eslint/no-shadow`](./no-shadow.md) | Disallow variable declarations from shadowing variables declared in the outer scope | | | | +| [`@typescript-eslint/no-throw-literal`](./no-throw-literal.md) | Disallow throwing literals as exceptions | :lock: | | :thought_balloon: | +| [`@typescript-eslint/no-unused-expressions`](./no-unused-expressions.md) | Disallow unused expressions | | | | +| [`@typescript-eslint/no-unused-vars`](./no-unused-vars.md) | Disallow unused variables | :white_check_mark: | | | +| [`@typescript-eslint/no-use-before-define`](./no-use-before-define.md) | Disallow the use of variables before they are defined | | | | +| [`@typescript-eslint/no-useless-constructor`](./no-useless-constructor.md) | Disallow unnecessary constructors | :lock: | | | +| [`@typescript-eslint/object-curly-spacing`](./object-curly-spacing.md) | Enforce consistent spacing inside braces | | :wrench: | | +| [`@typescript-eslint/padding-line-between-statements`](./padding-line-between-statements.md) | require or disallow padding lines between statements | | :wrench: | | +| [`@typescript-eslint/quotes`](./quotes.md) | Enforce the consistent use of either backticks, double, or single quotes | | :wrench: | | +| [`@typescript-eslint/require-await`](./require-await.md) | Disallow async functions which have no `await` expression | :white_check_mark: | | :thought_balloon: | +| [`@typescript-eslint/return-await`](./return-await.md) | Enforces consistent returning of awaited values | | :wrench: | :thought_balloon: | +| [`@typescript-eslint/semi`](./semi.md) | Require or disallow semicolons instead of ASI | | :wrench: | | +| [`@typescript-eslint/space-before-blocks`](./space-before-blocks.md) | Enforces consistent spacing before blocks | | :wrench: | | +| [`@typescript-eslint/space-before-function-paren`](./space-before-function-paren.md) | Enforces consistent spacing before function parenthesis | | :wrench: | | +| [`@typescript-eslint/space-infix-ops`](./space-infix-ops.md) | This rule is aimed at ensuring there are spaces around infix operators. | | :wrench: | | diff --git a/packages/eslint-plugin/docs/rules/TEMPLATE.md b/packages/eslint-plugin/docs/rules/TEMPLATE.md index 174fb71c6b3..c2c7136fe3e 100644 --- a/packages/eslint-plugin/docs/rules/TEMPLATE.md +++ b/packages/eslint-plugin/docs/rules/TEMPLATE.md @@ -22,6 +22,8 @@ To fill out: tell us more about this rule. ## Options +This rule is not configurable. + ```jsonc // .eslintrc.json { @@ -52,6 +54,8 @@ For example if this rule requires a feature released in a certain TS version. ## Attributes -- [ ] ✅ Recommended +- Configs: + - [ ] ✅ Recommended + - [ ] 🔒 Strict - [ ] 🔧 Fixable - [ ] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/adjacent-overload-signatures.md b/packages/eslint-plugin/docs/rules/adjacent-overload-signatures.md index 58f9d77e393..840fbcdc8d4 100644 --- a/packages/eslint-plugin/docs/rules/adjacent-overload-signatures.md +++ b/packages/eslint-plugin/docs/rules/adjacent-overload-signatures.md @@ -107,6 +107,8 @@ If you don't care about the general structure of the code, then you will not nee ## Attributes -- [x] ✅ Recommended +- Configs: + - [x] ✅ Recommended + - [x] 🔒 Strict - [ ] 🔧 Fixable - [ ] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/array-type.md b/packages/eslint-plugin/docs/rules/array-type.md index 9e5780fda39..6755f3d1975 100644 --- a/packages/eslint-plugin/docs/rules/array-type.md +++ b/packages/eslint-plugin/docs/rules/array-type.md @@ -125,6 +125,8 @@ This matrix lists all possible option combinations and their expected results fo ## Attributes -- [ ] ✅ Recommended +- Configs: + - [ ] ✅ Recommended + - [x] 🔒 Strict - [x] 🔧 Fixable - [ ] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/await-thenable.md b/packages/eslint-plugin/docs/rules/await-thenable.md index 0cb5c2a1b74..f308a202e62 100644 --- a/packages/eslint-plugin/docs/rules/await-thenable.md +++ b/packages/eslint-plugin/docs/rules/await-thenable.md @@ -53,6 +53,8 @@ This is generally not preferred, but can sometimes be useful for visual consiste ## Attributes -- [x] ✅ Recommended +- Configs: + - [x] ✅ Recommended + - [x] 🔒 Strict - [ ] 🔧 Fixable - [x] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/ban-ts-comment.md b/packages/eslint-plugin/docs/rules/ban-ts-comment.md index ee5e86113f0..8f521e919fd 100644 --- a/packages/eslint-plugin/docs/rules/ban-ts-comment.md +++ b/packages/eslint-plugin/docs/rules/ban-ts-comment.md @@ -145,6 +145,8 @@ If you want to use all of the TypeScript directives. ## Attributes -- [x] ✅ Recommended +- Configs: + - [x] ✅ Recommended + - [x] 🔒 Strict - [ ] 🔧 Fixable - [ ] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/ban-tslint-comment.md b/packages/eslint-plugin/docs/rules/ban-tslint-comment.md index 95f9ab87543..6714000aba8 100644 --- a/packages/eslint-plugin/docs/rules/ban-tslint-comment.md +++ b/packages/eslint-plugin/docs/rules/ban-tslint-comment.md @@ -30,12 +30,27 @@ someCode(); // tslint:disable-line someCode(); // This is a comment that just happens to mention tslint ``` +## Options + +```jsonc +// .eslintrc.json +{ + "rules": { + "@typescript-eslint/ban-tslint-comment": "warn" + } +} +``` + +This rule is not configurable. + ## When Not To Use It If you are still using TSLint. ## Attributes -- [ ] ✅ Recommended +- Configs: + - [ ] ✅ Recommended + - [x] 🔒 Strict - [x] 🔧 Fixable - [ ] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/ban-types.md b/packages/eslint-plugin/docs/rules/ban-types.md index 8f59dd8f60d..b83186fe747 100644 --- a/packages/eslint-plugin/docs/rules/ban-types.md +++ b/packages/eslint-plugin/docs/rules/ban-types.md @@ -195,6 +195,8 @@ const curly2: Record<'a', string> = { a: 'string' }; ## Attributes -- [x] ✅ Recommended +- Configs: + - [x] ✅ Recommended + - [x] 🔒 Strict - [x] 🔧 Fixable - [ ] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/brace-style.md b/packages/eslint-plugin/docs/rules/brace-style.md index 83316fa631f..c9a259cdb7a 100644 --- a/packages/eslint-plugin/docs/rules/brace-style.md +++ b/packages/eslint-plugin/docs/rules/brace-style.md @@ -29,6 +29,8 @@ Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/main/ ## Attributes -- [ ] ✅ Recommended +- Configs: + - [ ] ✅ Recommended + - [ ] 🔒 Strict - [x] 🔧 Fixable - [ ] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/class-literal-property-style.md b/packages/eslint-plugin/docs/rules/class-literal-property-style.md index 649a640cc73..8dab1dc263b 100644 --- a/packages/eslint-plugin/docs/rules/class-literal-property-style.md +++ b/packages/eslint-plugin/docs/rules/class-literal-property-style.md @@ -111,6 +111,8 @@ for how literal values are exposed by your classes. ## Attributes -- [ ] ✅ Recommended +- Configs: + - [ ] ✅ Recommended + - [x] 🔒 Strict - [x] 🔧 Fixable - [ ] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/comma-dangle.md b/packages/eslint-plugin/docs/rules/comma-dangle.md index 933d7a8d401..2ddd7f66ca0 100644 --- a/packages/eslint-plugin/docs/rules/comma-dangle.md +++ b/packages/eslint-plugin/docs/rules/comma-dangle.md @@ -41,6 +41,8 @@ Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/main/ ## Attributes -- [ ] ✅ Recommended +- Configs: + - [ ] ✅ Recommended + - [ ] 🔒 Strict - [x] 🔧 Fixable - [ ] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/comma-spacing.md b/packages/eslint-plugin/docs/rules/comma-spacing.md index 2cc5a68694b..e598c20fcf9 100644 --- a/packages/eslint-plugin/docs/rules/comma-spacing.md +++ b/packages/eslint-plugin/docs/rules/comma-spacing.md @@ -29,6 +29,8 @@ Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/main/ ## Attributes -- [ ] ✅ Recommended +- Configs: + - [ ] ✅ Recommended + - [ ] 🔒 Strict - [x] 🔧 Fixable - [ ] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/consistent-indexed-object-style.md b/packages/eslint-plugin/docs/rules/consistent-indexed-object-style.md index ae44a024889..6e02816695d 100644 --- a/packages/eslint-plugin/docs/rules/consistent-indexed-object-style.md +++ b/packages/eslint-plugin/docs/rules/consistent-indexed-object-style.md @@ -85,6 +85,8 @@ type Foo = { ## Attributes -- [ ] ✅ Recommended +- Configs: + - [ ] ✅ Recommended + - [x] 🔒 Strict - [x] 🔧 Fixable - [ ] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/consistent-type-assertions.md b/packages/eslint-plugin/docs/rules/consistent-type-assertions.md index cb56c5d8a24..6cf35c5c160 100644 --- a/packages/eslint-plugin/docs/rules/consistent-type-assertions.md +++ b/packages/eslint-plugin/docs/rules/consistent-type-assertions.md @@ -119,6 +119,8 @@ If you do not want to enforce consistent type assertions. ## Attributes -- [ ] ✅ Recommended +- Configs: + - [ ] ✅ Recommended + - [x] 🔒 Strict - [ ] 🔧 Fixable - [ ] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/consistent-type-definitions.md b/packages/eslint-plugin/docs/rules/consistent-type-definitions.md index 19f8d0df3d3..37f69af6c7a 100644 --- a/packages/eslint-plugin/docs/rules/consistent-type-definitions.md +++ b/packages/eslint-plugin/docs/rules/consistent-type-definitions.md @@ -87,6 +87,8 @@ If you specifically want to use an interface or type literal for stylistic reaso ## Attributes -- [ ] ✅ Recommended +- Configs: + - [ ] ✅ Recommended + - [x] 🔒 Strict - [x] 🔧 Fixable - [ ] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/consistent-type-exports.md b/packages/eslint-plugin/docs/rules/consistent-type-exports.md index 50a6fea96da..f38230dd88e 100644 --- a/packages/eslint-plugin/docs/rules/consistent-type-exports.md +++ b/packages/eslint-plugin/docs/rules/consistent-type-exports.md @@ -112,6 +112,8 @@ export { Button, type ButtonProps } from 'some-library'; ## Attributes -- [ ] ✅ Recommended +- Configs: + - [ ] ✅ Recommended + - [ ] 🔒 Strict - [x] 🔧 Fixable - [x] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/consistent-type-imports.md b/packages/eslint-plugin/docs/rules/consistent-type-imports.md index 154fe0a6252..f3d96bec5ce 100644 --- a/packages/eslint-plugin/docs/rules/consistent-type-imports.md +++ b/packages/eslint-plugin/docs/rules/consistent-type-imports.md @@ -67,6 +67,8 @@ const x: import('Bar') = 1; ## Attributes -- [ ] ✅ Recommended +- Configs: + - [ ] ✅ Recommended + - [ ] 🔒 Strict - [x] 🔧 Fixable - [ ] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/default-param-last.md b/packages/eslint-plugin/docs/rules/default-param-last.md index ec8377ecb88..830d2828c01 100644 --- a/packages/eslint-plugin/docs/rules/default-param-last.md +++ b/packages/eslint-plugin/docs/rules/default-param-last.md @@ -65,6 +65,8 @@ Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/main/ ## Attributes -- [ ] ✅ Recommended +- Configs: + - [ ] ✅ Recommended + - [ ] 🔒 Strict - [ ] 🔧 Fixable - [ ] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/dot-notation.md b/packages/eslint-plugin/docs/rules/dot-notation.md index 85a8fff08df..1256f2004fe 100644 --- a/packages/eslint-plugin/docs/rules/dot-notation.md +++ b/packages/eslint-plugin/docs/rules/dot-notation.md @@ -90,6 +90,8 @@ Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/main/ ## Attributes -- [ ] ✅ Recommended +- Configs: + - [ ] ✅ Recommended + - [x] 🔒 Strict - [x] 🔧 Fixable - [x] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/explicit-function-return-type.md b/packages/eslint-plugin/docs/rules/explicit-function-return-type.md index a542f328fb6..210871ab347 100644 --- a/packages/eslint-plugin/docs/rules/explicit-function-return-type.md +++ b/packages/eslint-plugin/docs/rules/explicit-function-return-type.md @@ -293,6 +293,8 @@ you will not need this rule. ## Attributes -- [ ] ✅ Recommended +- Configs: + - [ ] ✅ Recommended + - [ ] 🔒 Strict - [ ] 🔧 Fixable - [ ] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/explicit-member-accessibility.md b/packages/eslint-plugin/docs/rules/explicit-member-accessibility.md index e60af94265a..4d14797d02c 100644 --- a/packages/eslint-plugin/docs/rules/explicit-member-accessibility.md +++ b/packages/eslint-plugin/docs/rules/explicit-member-accessibility.md @@ -351,6 +351,8 @@ If you think defaulting to public is a good default, then you should consider us ## Attributes -- [ ] ✅ Recommended +- Configs: + - [ ] ✅ Recommended + - [ ] 🔒 Strict - [x] 🔧 Fixable - [ ] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/explicit-module-boundary-types.md b/packages/eslint-plugin/docs/rules/explicit-module-boundary-types.md index 038fb8b33ea..d968504be07 100644 --- a/packages/eslint-plugin/docs/rules/explicit-module-boundary-types.md +++ b/packages/eslint-plugin/docs/rules/explicit-module-boundary-types.md @@ -288,6 +288,8 @@ If you wish to make sure all functions have explicit return types, as opposed to ## Attributes -- [ ] ✅ Recommended +- Configs: + - [ ] ✅ Recommended + - [ ] 🔒 Strict - [ ] 🔧 Fixable - [ ] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/func-call-spacing.md b/packages/eslint-plugin/docs/rules/func-call-spacing.md index cb96cd5d7c0..f968cf45d2c 100644 --- a/packages/eslint-plugin/docs/rules/func-call-spacing.md +++ b/packages/eslint-plugin/docs/rules/func-call-spacing.md @@ -29,6 +29,8 @@ Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/main/ ## Attributes -- [ ] ✅ Recommended +- Configs: + - [ ] ✅ Recommended + - [ ] 🔒 Strict - [x] 🔧 Fixable - [ ] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/indent.md b/packages/eslint-plugin/docs/rules/indent.md index 2a8920398d3..aeee0ffcc12 100644 --- a/packages/eslint-plugin/docs/rules/indent.md +++ b/packages/eslint-plugin/docs/rules/indent.md @@ -33,6 +33,8 @@ Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/main/ ## Attributes -- [ ] ✅ Recommended +- Configs: + - [ ] ✅ Recommended + - [ ] 🔒 Strict - [x] 🔧 Fixable - [ ] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/init-declarations.md b/packages/eslint-plugin/docs/rules/init-declarations.md index 5df410a8dc5..895aa0d4dfd 100644 --- a/packages/eslint-plugin/docs/rules/init-declarations.md +++ b/packages/eslint-plugin/docs/rules/init-declarations.md @@ -29,6 +29,8 @@ Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/main/ ## Attributes -- [ ] ✅ Recommended +- Configs: + - [ ] ✅ Recommended + - [ ] 🔒 Strict - [ ] 🔧 Fixable - [ ] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/keyword-spacing.md b/packages/eslint-plugin/docs/rules/keyword-spacing.md index d2682f17abd..446cdab3e96 100644 --- a/packages/eslint-plugin/docs/rules/keyword-spacing.md +++ b/packages/eslint-plugin/docs/rules/keyword-spacing.md @@ -29,6 +29,8 @@ Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/main/ ## Attributes -- [ ] ✅ Recommended +- Configs: + - [ ] ✅ Recommended + - [ ] 🔒 Strict - [x] 🔧 Fixable - [ ] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/lines-between-class-members.md b/packages/eslint-plugin/docs/rules/lines-between-class-members.md index 8d4a8ce767d..769e5f8d268 100644 --- a/packages/eslint-plugin/docs/rules/lines-between-class-members.md +++ b/packages/eslint-plugin/docs/rules/lines-between-class-members.md @@ -80,6 +80,8 @@ Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/main/ ## Attributes -- [ ] ✅ Recommended +- Configs: + - [ ] ✅ Recommended + - [ ] 🔒 Strict - [x] 🔧 Fixable - [ ] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/member-delimiter-style.md b/packages/eslint-plugin/docs/rules/member-delimiter-style.md index 1ad60abbdee..741f34171be 100644 --- a/packages/eslint-plugin/docs/rules/member-delimiter-style.md +++ b/packages/eslint-plugin/docs/rules/member-delimiter-style.md @@ -211,6 +211,8 @@ If you don't care about enforcing a consistent member delimiter in interfaces an ## Attributes -- [ ] ✅ Recommended +- Configs: + - [ ] ✅ Recommended + - [ ] 🔒 Strict - [x] 🔧 Fixable - [ ] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/member-ordering.md b/packages/eslint-plugin/docs/rules/member-ordering.md index c9b6ecb07b1..588fd8ada36 100644 --- a/packages/eslint-plugin/docs/rules/member-ordering.md +++ b/packages/eslint-plugin/docs/rules/member-ordering.md @@ -1166,6 +1166,8 @@ If you don't care about the general order of your members, then you will not nee ## Attributes -- [ ] ✅ Recommended +- Configs: + - [ ] ✅ Recommended + - [ ] 🔒 Strict - [ ] 🔧 Fixable - [ ] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/method-signature-style.md b/packages/eslint-plugin/docs/rules/method-signature-style.md index 87a221f2757..1c3a8a0cbcd 100644 --- a/packages/eslint-plugin/docs/rules/method-signature-style.md +++ b/packages/eslint-plugin/docs/rules/method-signature-style.md @@ -107,6 +107,8 @@ If you don't want to enforce a particular style for object/interface function ty ## Attributes -- [ ] ✅ Recommended +- Configs: + - [ ] ✅ Recommended + - [ ] 🔒 Strict - [x] 🔧 Fixable - [ ] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/naming-convention.md b/packages/eslint-plugin/docs/rules/naming-convention.md index 9268e8a9d02..7fc4729b966 100644 --- a/packages/eslint-plugin/docs/rules/naming-convention.md +++ b/packages/eslint-plugin/docs/rules/naming-convention.md @@ -703,6 +703,8 @@ If you do not want to enforce naming conventions for anything. ## Attributes -- [ ] ✅ Recommended +- Configs: + - [ ] ✅ Recommended + - [ ] 🔒 Strict - [ ] 🔧 Fixable - [x] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/no-array-constructor.md b/packages/eslint-plugin/docs/rules/no-array-constructor.md index e3fbaadbf18..603ba48a5bc 100644 --- a/packages/eslint-plugin/docs/rules/no-array-constructor.md +++ b/packages/eslint-plugin/docs/rules/no-array-constructor.md @@ -52,6 +52,8 @@ Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/main/ ## Attributes -- [x] ✅ Recommended +- Configs: + - [x] ✅ Recommended + - [x] 🔒 Strict - [x] 🔧 Fixable - [ ] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/no-base-to-string.md b/packages/eslint-plugin/docs/rules/no-base-to-string.md index 5db6218bb52..fde51eccffc 100644 --- a/packages/eslint-plugin/docs/rules/no-base-to-string.md +++ b/packages/eslint-plugin/docs/rules/no-base-to-string.md @@ -92,6 +92,8 @@ If you don't mind `"[object Object]"` in your strings, then you will not need th ## Attributes -- [ ] ✅ Recommended +- Configs: + - [ ] ✅ Recommended + - [x] 🔒 Strict - [ ] 🔧 Fixable - [x] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/no-confusing-non-null-assertion.md b/packages/eslint-plugin/docs/rules/no-confusing-non-null-assertion.md index ed894aa8eb3..1f5d5b040fd 100644 --- a/packages/eslint-plugin/docs/rules/no-confusing-non-null-assertion.md +++ b/packages/eslint-plugin/docs/rules/no-confusing-non-null-assertion.md @@ -41,6 +41,19 @@ const isEqualsBar = foo.bar == 'hello'; const isEqualsNum = (1 + foo.num!) == 2; ``` +## Options + +```jsonc +// .eslintrc.json +{ + "rules": { + "@typescript-eslint/no-confusing-non-null-assertion": "warn" + } +} +``` + +This rule is not configurable. + ## When Not To Use It If you don't care about this confusion, then you will not need this rule. @@ -51,6 +64,8 @@ If you don't care about this confusion, then you will not need this rule. ## Attributes -- [ ] ✅ Recommended +- Configs: + - [ ] ✅ Recommended + - [x] 🔒 Strict - [x] 🔧 Fixable - [ ] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/no-confusing-void-expression.md b/packages/eslint-plugin/docs/rules/no-confusing-void-expression.md index c2af300e0b6..88c295ae3bb 100644 --- a/packages/eslint-plugin/docs/rules/no-confusing-void-expression.md +++ b/packages/eslint-plugin/docs/rules/no-confusing-void-expression.md @@ -154,6 +154,8 @@ Also, if you prefer concise coding style then also don't use it. ## Attributes -- [ ] ✅ Recommended +- Configs: + - [ ] ✅ Recommended + - [ ] 🔒 Strict - [x] 🔧 Fixable - [x] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/no-dupe-class-members.md b/packages/eslint-plugin/docs/rules/no-dupe-class-members.md index 7d59aec0683..e0206510e8d 100644 --- a/packages/eslint-plugin/docs/rules/no-dupe-class-members.md +++ b/packages/eslint-plugin/docs/rules/no-dupe-class-members.md @@ -29,6 +29,8 @@ Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/main/ ## Attributes -- [ ] ✅ Recommended +- Configs: + - [ ] ✅ Recommended + - [ ] 🔒 Strict - [ ] 🔧 Fixable - [ ] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/no-duplicate-enum-values.md b/packages/eslint-plugin/docs/rules/no-duplicate-enum-values.md index 2146d603980..c2fa1db4eec 100644 --- a/packages/eslint-plugin/docs/rules/no-duplicate-enum-values.md +++ b/packages/eslint-plugin/docs/rules/no-duplicate-enum-values.md @@ -42,10 +42,23 @@ enum E { } ``` +## Options + +```jsonc +// .eslintrc.json +{ + "rules": { + "@typescript-eslint/no-duplicate-enum-values": "warn" + } +} +``` + This rule is not configurable. ## Attributes -- [ ] ✅ Recommended +- Configs: + - [ ] ✅ Recommended + - [x] 🔒 Strict - [ ] 🔧 Fixable - [ ] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/no-duplicate-imports.md b/packages/eslint-plugin/docs/rules/no-duplicate-imports.md index f6d1fc5eb42..743e45e0464 100644 --- a/packages/eslint-plugin/docs/rules/no-duplicate-imports.md +++ b/packages/eslint-plugin/docs/rules/no-duplicate-imports.md @@ -29,6 +29,8 @@ Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/main/ ## Attributes -- [ ] ✅ Recommended +- Configs: + - [ ] ✅ Recommended + - [ ] 🔒 Strict - [ ] 🔧 Fixable - [ ] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/no-dynamic-delete.md b/packages/eslint-plugin/docs/rules/no-dynamic-delete.md index c5349d51983..abbee2acf02 100644 --- a/packages/eslint-plugin/docs/rules/no-dynamic-delete.md +++ b/packages/eslint-plugin/docs/rules/no-dynamic-delete.md @@ -40,6 +40,19 @@ delete container[7]; delete container['-Infinity']; ``` +## Options + +```jsonc +// .eslintrc.json +{ + "rules": { + "@typescript-eslint/no-dynamic-delete": "warn" + } +} +``` + +This rule is not configurable. + ## When Not To Use It When you know your keys are safe to delete, this rule can be unnecessary. @@ -54,6 +67,8 @@ Even repeated minor performance slowdowns likely do not significantly affect you ## Attributes -- [ ] ✅ Recommended +- Configs: + - [ ] ✅ Recommended + - [x] 🔒 Strict - [x] 🔧 Fixable - [ ] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/no-empty-function.md b/packages/eslint-plugin/docs/rules/no-empty-function.md index db450a46121..0920bf6f3c7 100644 --- a/packages/eslint-plugin/docs/rules/no-empty-function.md +++ b/packages/eslint-plugin/docs/rules/no-empty-function.md @@ -95,6 +95,8 @@ Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/main/ ## Attributes -- [x] ✅ Recommended +- Configs: + - [x] ✅ Recommended + - [x] 🔒 Strict - [ ] 🔧 Fixable - [ ] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/no-empty-interface.md b/packages/eslint-plugin/docs/rules/no-empty-interface.md index b2db028106f..508edd1993c 100644 --- a/packages/eslint-plugin/docs/rules/no-empty-interface.md +++ b/packages/eslint-plugin/docs/rules/no-empty-interface.md @@ -71,6 +71,8 @@ If you don't care about having empty/meaningless interfaces, then you will not n ## Attributes -- [x] ✅ Recommended +- Configs: + - [x] ✅ Recommended + - [x] 🔒 Strict - [x] 🔧 Fixable - [ ] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/no-explicit-any.md b/packages/eslint-plugin/docs/rules/no-explicit-any.md index 222c08c5123..aff5ae083e0 100644 --- a/packages/eslint-plugin/docs/rules/no-explicit-any.md +++ b/packages/eslint-plugin/docs/rules/no-explicit-any.md @@ -186,6 +186,8 @@ and you want to be able to specify `any`. ## Attributes -- [x] ✅ Recommended +- Configs: + - [x] ✅ Recommended + - [x] 🔒 Strict - [x] 🔧 Fixable - [ ] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/no-extra-non-null-assertion.md b/packages/eslint-plugin/docs/rules/no-extra-non-null-assertion.md index 6e19e8b0dd7..78ab63347bf 100644 --- a/packages/eslint-plugin/docs/rules/no-extra-non-null-assertion.md +++ b/packages/eslint-plugin/docs/rules/no-extra-non-null-assertion.md @@ -61,6 +61,8 @@ This rule is not configurable. ## Attributes -- [x] ✅ Recommended +- Configs: + - [x] ✅ Recommended + - [x] 🔒 Strict - [x] 🔧 Fixable - [ ] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/no-extra-parens.md b/packages/eslint-plugin/docs/rules/no-extra-parens.md index 287918a2b44..4cccccdbe79 100644 --- a/packages/eslint-plugin/docs/rules/no-extra-parens.md +++ b/packages/eslint-plugin/docs/rules/no-extra-parens.md @@ -29,6 +29,8 @@ Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/main/ ## Attributes -- [ ] ✅ Recommended +- Configs: + - [ ] ✅ Recommended + - [ ] 🔒 Strict - [x] 🔧 Fixable - [ ] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/no-extra-semi.md b/packages/eslint-plugin/docs/rules/no-extra-semi.md index 2ca8c2f14bc..6137b6ca21b 100644 --- a/packages/eslint-plugin/docs/rules/no-extra-semi.md +++ b/packages/eslint-plugin/docs/rules/no-extra-semi.md @@ -29,6 +29,8 @@ Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/main/ ## Attributes -- [x] ✅ Recommended +- Configs: + - [x] ✅ Recommended + - [x] 🔒 Strict - [x] 🔧 Fixable - [ ] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/no-extraneous-class.md b/packages/eslint-plugin/docs/rules/no-extraneous-class.md index 470da5c607d..eb229ea655a 100644 --- a/packages/eslint-plugin/docs/rules/no-extraneous-class.md +++ b/packages/eslint-plugin/docs/rules/no-extraneous-class.md @@ -87,6 +87,8 @@ team or if you use classes as namespaces. ## Attributes -- [ ] ✅ Recommended +- Configs: + - [ ] ✅ Recommended + - [x] 🔒 Strict - [ ] 🔧 Fixable - [ ] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/no-floating-promises.md b/packages/eslint-plugin/docs/rules/no-floating-promises.md index 34c855fdcd7..72ce6e2a506 100644 --- a/packages/eslint-plugin/docs/rules/no-floating-promises.md +++ b/packages/eslint-plugin/docs/rules/no-floating-promises.md @@ -122,6 +122,8 @@ If you do not use Promise-like values in your codebase, or want to allow them to ## Attributes -- [x] ✅ Recommended +- Configs: + - [x] ✅ Recommended + - [x] 🔒 Strict - [ ] 🔧 Fixable - [x] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/no-for-in-array.md b/packages/eslint-plugin/docs/rules/no-for-in-array.md index d21ab4e6081..6c4e46b8591 100644 --- a/packages/eslint-plugin/docs/rules/no-for-in-array.md +++ b/packages/eslint-plugin/docs/rules/no-for-in-array.md @@ -64,6 +64,8 @@ If you want to iterate through a loop using the indices in an array as strings, ## Attributes -- [x] ✅ Recommended +- Configs: + - [x] ✅ Recommended + - [x] 🔒 Strict - [ ] 🔧 Fixable - [x] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/no-implicit-any-catch.md b/packages/eslint-plugin/docs/rules/no-implicit-any-catch.md index d17e53209c8..3174aa28f08 100644 --- a/packages/eslint-plugin/docs/rules/no-implicit-any-catch.md +++ b/packages/eslint-plugin/docs/rules/no-implicit-any-catch.md @@ -83,6 +83,8 @@ If you are not using TypeScript 4.0 (or greater), then you will not be able to u ## Attributes -- [ ] ✅ Recommended +- Configs: + - [ ] ✅ Recommended + - [ ] 🔒 Strict - [x] 🔧 Fixable - [ ] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/no-implied-eval.md b/packages/eslint-plugin/docs/rules/no-implied-eval.md index fe0bc5a79df..5c59f35bb70 100644 --- a/packages/eslint-plugin/docs/rules/no-implied-eval.md +++ b/packages/eslint-plugin/docs/rules/no-implied-eval.md @@ -116,6 +116,8 @@ Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/main/ ## Attributes -- [x] ✅ Recommended +- Configs: + - [x] ✅ Recommended + - [x] 🔒 Strict - [ ] 🔧 Fixable - [x] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/no-inferrable-types.md b/packages/eslint-plugin/docs/rules/no-inferrable-types.md index 473676bac0e..67fd3e2f696 100644 --- a/packages/eslint-plugin/docs/rules/no-inferrable-types.md +++ b/packages/eslint-plugin/docs/rules/no-inferrable-types.md @@ -155,6 +155,8 @@ TSLint: [no-inferrable-types](https://palantir.github.io/tslint/rules/no-inferra ## Attributes -- [x] ✅ Recommended +- Configs: + - [x] ✅ Recommended + - [x] 🔒 Strict - [x] 🔧 Fixable - [ ] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/no-invalid-this.md b/packages/eslint-plugin/docs/rules/no-invalid-this.md index a8a3256b8e3..7681bb07f22 100644 --- a/packages/eslint-plugin/docs/rules/no-invalid-this.md +++ b/packages/eslint-plugin/docs/rules/no-invalid-this.md @@ -33,6 +33,8 @@ Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/main/ ## Attributes -- [ ] ✅ Recommended +- Configs: + - [ ] ✅ Recommended + - [ ] 🔒 Strict - [ ] 🔧 Fixable - [ ] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/no-invalid-void-type.md b/packages/eslint-plugin/docs/rules/no-invalid-void-type.md index 3771f572b10..44ee066b368 100644 --- a/packages/eslint-plugin/docs/rules/no-invalid-void-type.md +++ b/packages/eslint-plugin/docs/rules/no-invalid-void-type.md @@ -133,6 +133,8 @@ or in invalid places, then you don't need this rule. ## Attributes -- [ ] ✅ Recommended +- Configs: + - [ ] ✅ Recommended + - [x] 🔒 Strict - [ ] 🔧 Fixable - [ ] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/no-loop-func.md b/packages/eslint-plugin/docs/rules/no-loop-func.md index e69a0d7b0a1..5652dc62fa5 100644 --- a/packages/eslint-plugin/docs/rules/no-loop-func.md +++ b/packages/eslint-plugin/docs/rules/no-loop-func.md @@ -29,6 +29,8 @@ Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/main/ ## Attributes -- [ ] ✅ Recommended +- Configs: + - [ ] ✅ Recommended + - [ ] 🔒 Strict - [ ] 🔧 Fixable - [ ] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/no-loss-of-precision.md b/packages/eslint-plugin/docs/rules/no-loss-of-precision.md index 7165f945b07..4b1e8c6dd29 100644 --- a/packages/eslint-plugin/docs/rules/no-loss-of-precision.md +++ b/packages/eslint-plugin/docs/rules/no-loss-of-precision.md @@ -26,6 +26,8 @@ Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/main/ ## Attributes -- [x] ✅ Recommended +- Configs: + - [x] ✅ Recommended + - [x] 🔒 Strict - [ ] 🔧 Fixable - [ ] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/no-magic-numbers.md b/packages/eslint-plugin/docs/rules/no-magic-numbers.md index 936d9dd686e..ebd724b4a93 100644 --- a/packages/eslint-plugin/docs/rules/no-magic-numbers.md +++ b/packages/eslint-plugin/docs/rules/no-magic-numbers.md @@ -150,6 +150,8 @@ Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/main/ ## Attributes -- [ ] ✅ Recommended +- Configs: + - [ ] ✅ Recommended + - [ ] 🔒 Strict - [ ] 🔧 Fixable - [ ] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/no-meaningless-void-operator.md b/packages/eslint-plugin/docs/rules/no-meaningless-void-operator.md index 79e43d04ce5..58b37b0888c 100644 --- a/packages/eslint-plugin/docs/rules/no-meaningless-void-operator.md +++ b/packages/eslint-plugin/docs/rules/no-meaningless-void-operator.md @@ -57,6 +57,8 @@ This rule accepts a single object option with the following default configuratio ## Attributes -- [ ] ✅ Recommended +- Configs: + - [ ] ✅ Recommended + - [x] 🔒 Strict - [x] 🔧 Fixable - [x] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/no-misused-new.md b/packages/eslint-plugin/docs/rules/no-misused-new.md index e56ff23012a..735699c6132 100644 --- a/packages/eslint-plugin/docs/rules/no-misused-new.md +++ b/packages/eslint-plugin/docs/rules/no-misused-new.md @@ -53,6 +53,8 @@ This rule is not configurable. ## Attributes -- [x] ✅ Recommended +- Configs: + - [x] ✅ Recommended + - [x] 🔒 Strict - [ ] 🔧 Fixable - [ ] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/no-misused-promises.md b/packages/eslint-plugin/docs/rules/no-misused-promises.md index 09292aa31b7..b3d5dcbe0cb 100644 --- a/packages/eslint-plugin/docs/rules/no-misused-promises.md +++ b/packages/eslint-plugin/docs/rules/no-misused-promises.md @@ -227,6 +227,8 @@ misuses of them outside of what the TypeScript compiler will check. ## Attributes -- [x] ✅ Recommended +- Configs: + - [x] ✅ Recommended + - [x] 🔒 Strict - [ ] 🔧 Fixable - [x] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/no-namespace.md b/packages/eslint-plugin/docs/rules/no-namespace.md index bee784373ac..a6971b5b0b4 100644 --- a/packages/eslint-plugin/docs/rules/no-namespace.md +++ b/packages/eslint-plugin/docs/rules/no-namespace.md @@ -138,6 +138,8 @@ If you are using the ES2015 module syntax, then you will not need this rule. ## Attributes -- [x] ✅ Recommended +- Configs: + - [x] ✅ Recommended + - [x] 🔒 Strict - [ ] 🔧 Fixable - [ ] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/no-non-null-asserted-nullish-coalescing.md b/packages/eslint-plugin/docs/rules/no-non-null-asserted-nullish-coalescing.md index fd4b524b8cb..faec85a2e57 100644 --- a/packages/eslint-plugin/docs/rules/no-non-null-asserted-nullish-coalescing.md +++ b/packages/eslint-plugin/docs/rules/no-non-null-asserted-nullish-coalescing.md @@ -45,6 +45,19 @@ let x: string; x! ?? ''; ``` +## Options + +```jsonc +// .eslintrc.json +{ + "rules": { + "@typescript-eslint/no-non-null-asserted-nullish-coalescing": "warn" + } +} +``` + +This rule is not configurable. + ## When Not To Use It If you are not using TypeScript 3.7 (or greater), then you will not need to use this rule, as the nullish coalescing operator is not supported. @@ -56,6 +69,8 @@ If you are not using TypeScript 3.7 (or greater), then you will not need to use ## Attributes -- [ ] ✅ Recommended +- Configs: + - [ ] ✅ Recommended + - [x] 🔒 Strict - [ ] 🔧 Fixable - [ ] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/no-non-null-asserted-optional-chain.md b/packages/eslint-plugin/docs/rules/no-non-null-asserted-optional-chain.md index 196f709bab8..4772ebc9cca 100644 --- a/packages/eslint-plugin/docs/rules/no-non-null-asserted-optional-chain.md +++ b/packages/eslint-plugin/docs/rules/no-non-null-asserted-optional-chain.md @@ -68,6 +68,8 @@ If you are not using TypeScript 3.7 (or greater), then you will not need to use ## Attributes -- [x] ✅ Recommended +- Configs: + - [x] ✅ Recommended + - [x] 🔒 Strict - [ ] 🔧 Fixable - [ ] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/no-non-null-assertion.md b/packages/eslint-plugin/docs/rules/no-non-null-assertion.md index cc3f5a13814..9f84436d61c 100644 --- a/packages/eslint-plugin/docs/rules/no-non-null-assertion.md +++ b/packages/eslint-plugin/docs/rules/no-non-null-assertion.md @@ -55,6 +55,8 @@ If you don't care about strict null-checking, then you will not need this rule. ## Attributes -- [x] ✅ Recommended +- Configs: + - [x] ✅ Recommended + - [x] 🔒 Strict - [ ] 🔧 Fixable - [ ] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/no-parameter-properties.md b/packages/eslint-plugin/docs/rules/no-parameter-properties.md index e915acb1403..3f308256efb 100644 --- a/packages/eslint-plugin/docs/rules/no-parameter-properties.md +++ b/packages/eslint-plugin/docs/rules/no-parameter-properties.md @@ -402,6 +402,8 @@ If you don't care about the using parameter properties in constructors, then you ## Attributes -- [ ] ✅ Recommended +- Configs: + - [ ] ✅ Recommended + - [ ] 🔒 Strict - [ ] 🔧 Fixable - [ ] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/no-redeclare.md b/packages/eslint-plugin/docs/rules/no-redeclare.md index c8c55025577..37859e58912 100644 --- a/packages/eslint-plugin/docs/rules/no-redeclare.md +++ b/packages/eslint-plugin/docs/rules/no-redeclare.md @@ -87,6 +87,8 @@ Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/main/ ## Attributes -- [ ] ✅ Recommended +- Configs: + - [ ] ✅ Recommended + - [ ] 🔒 Strict - [ ] 🔧 Fixable - [ ] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/no-redundant-type-constituents.md b/packages/eslint-plugin/docs/rules/no-redundant-type-constituents.md index e427c671d3f..3b96bd19ad1 100644 --- a/packages/eslint-plugin/docs/rules/no-redundant-type-constituents.md +++ b/packages/eslint-plugin/docs/rules/no-redundant-type-constituents.md @@ -66,6 +66,19 @@ type IntersectionStringLiteral = 'foo'; type ReturnUnionNever = () => string | never; ``` +## Options + +```jsonc +// .eslintrc.json +{ + "rules": { + "@typescript-eslint/no-redundant-type-constituents": "warn" + } +} +``` + +This rule is not configurable. + ## Limitations This rule plays it safe and only works with bottom types, top types, and comparing literal types to primitive types. @@ -80,6 +93,8 @@ It also does not provide an auto-fixer just yet. ## Attributes -- [ ] ✅ Recommended +- Configs: + - [ ] ✅ Recommended + - [ ] 🔒 Strict - [ ] 🔧 Fixable - [x] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/no-require-imports.md b/packages/eslint-plugin/docs/rules/no-require-imports.md index 0be131f6484..8344ec726c4 100644 --- a/packages/eslint-plugin/docs/rules/no-require-imports.md +++ b/packages/eslint-plugin/docs/rules/no-require-imports.md @@ -31,6 +31,19 @@ import lib9 = lib2.anotherSubImport; import lib10 from 'lib10'; ``` +## Options + +```jsonc +// .eslintrc.json +{ + "rules": { + "@typescript-eslint/no-require-imports": "warn" + } +} +``` + +This rule is not configurable. + ## When Not To Use It If you don't care about TypeScript module syntax, then you will not need this rule. @@ -41,6 +54,8 @@ If you don't care about TypeScript module syntax, then you will not need this ru ## Attributes -- [ ] ✅ Recommended +- Configs: + - [ ] ✅ Recommended + - [ ] 🔒 Strict - [ ] 🔧 Fixable - [ ] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/no-restricted-imports.md b/packages/eslint-plugin/docs/rules/no-restricted-imports.md index ee7d341d3a4..3f20d05bb2b 100644 --- a/packages/eslint-plugin/docs/rules/no-restricted-imports.md +++ b/packages/eslint-plugin/docs/rules/no-restricted-imports.md @@ -71,6 +71,8 @@ export type { Baz } from 'import-baz'; ## Attributes -- [ ] ✅ Recommended +- Configs: + - [ ] ✅ Recommended + - [ ] 🔒 Strict - [ ] 🔧 Fixable - [ ] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/no-shadow.md b/packages/eslint-plugin/docs/rules/no-shadow.md index 11b9f62c0bd..4706fabe90e 100644 --- a/packages/eslint-plugin/docs/rules/no-shadow.md +++ b/packages/eslint-plugin/docs/rules/no-shadow.md @@ -94,6 +94,8 @@ Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/main/ ## Attributes -- [ ] ✅ Recommended +- Configs: + - [ ] ✅ Recommended + - [ ] 🔒 Strict - [ ] 🔧 Fixable - [ ] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/no-this-alias.md b/packages/eslint-plugin/docs/rules/no-this-alias.md index 9ce436eb6e5..ec76dcf97a6 100644 --- a/packages/eslint-plugin/docs/rules/no-this-alias.md +++ b/packages/eslint-plugin/docs/rules/no-this-alias.md @@ -63,6 +63,8 @@ If you need to assign `this` to variables, you shouldn’t use this rule. ## Attributes -- [x] ✅ Recommended +- Configs: + - [x] ✅ Recommended + - [x] 🔒 Strict - [ ] 🔧 Fixable - [ ] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/no-throw-literal.md b/packages/eslint-plugin/docs/rules/no-throw-literal.md index 2216a05f74c..ff5f8bb04d1 100644 --- a/packages/eslint-plugin/docs/rules/no-throw-literal.md +++ b/packages/eslint-plugin/docs/rules/no-throw-literal.md @@ -119,6 +119,8 @@ Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/main/ ## Attributes -- [ ] ✅ Recommended +- Configs: + - [ ] ✅ Recommended + - [x] 🔒 Strict - [ ] 🔧 Fixable - [x] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/no-type-alias.md b/packages/eslint-plugin/docs/rules/no-type-alias.md index 02a1cbe30d4..734c6de8d3f 100644 --- a/packages/eslint-plugin/docs/rules/no-type-alias.md +++ b/packages/eslint-plugin/docs/rules/no-type-alias.md @@ -599,6 +599,8 @@ callback, etc. that would cause the code to be unreadable or impractical. ## Attributes -- [ ] ✅ Recommended +- Configs: + - [ ] ✅ Recommended + - [ ] 🔒 Strict - [ ] 🔧 Fixable - [ ] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/no-unnecessary-boolean-literal-compare.md b/packages/eslint-plugin/docs/rules/no-unnecessary-boolean-literal-compare.md index 5ba48cc6488..a3f4316d691 100644 --- a/packages/eslint-plugin/docs/rules/no-unnecessary-boolean-literal-compare.md +++ b/packages/eslint-plugin/docs/rules/no-unnecessary-boolean-literal-compare.md @@ -153,6 +153,8 @@ if (!(someNullCondition ?? true)) { ## Attributes -- [ ] ✅ Recommended +- Configs: + - [ ] ✅ Recommended + - [x] 🔒 Strict - [x] 🔧 Fixable - [x] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/no-unnecessary-condition.md b/packages/eslint-plugin/docs/rules/no-unnecessary-condition.md index 53532b2371b..992e6d409ea 100644 --- a/packages/eslint-plugin/docs/rules/no-unnecessary-condition.md +++ b/packages/eslint-plugin/docs/rules/no-unnecessary-condition.md @@ -115,6 +115,8 @@ The main downside to using this rule is the need for type information. ## Attributes -- [ ] ✅ Recommended +- Configs: + - [ ] ✅ Recommended + - [x] 🔒 Strict - [x] 🔧 Fixable - [x] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/no-unnecessary-qualifier.md b/packages/eslint-plugin/docs/rules/no-unnecessary-qualifier.md index 55feda0a188..36fc50d7fe9 100644 --- a/packages/eslint-plugin/docs/rules/no-unnecessary-qualifier.md +++ b/packages/eslint-plugin/docs/rules/no-unnecessary-qualifier.md @@ -76,6 +76,19 @@ namespace X { } ``` +## Options + +```jsonc +// .eslintrc.json +{ + "rules": { + "@typescript-eslint/no-unnecessary-qualifier": "warn" + } +} +``` + +This rule is not configurable. + ## When Not To Use It If you don't care about having unneeded namespace or enum qualifiers, then you don't need to use this rule. @@ -86,6 +99,8 @@ If you don't care about having unneeded namespace or enum qualifiers, then you d ## Attributes -- [ ] ✅ Recommended +- Configs: + - [ ] ✅ Recommended + - [ ] 🔒 Strict - [x] 🔧 Fixable - [x] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/no-unnecessary-type-arguments.md b/packages/eslint-plugin/docs/rules/no-unnecessary-type-arguments.md index b7829c9405c..6473b871264 100644 --- a/packages/eslint-plugin/docs/rules/no-unnecessary-type-arguments.md +++ b/packages/eslint-plugin/docs/rules/no-unnecessary-type-arguments.md @@ -54,12 +54,27 @@ interface I {} class Impl implements I {} ``` +## Options + +```jsonc +// .eslintrc.json +{ + "rules": { + "@typescript-eslint/no-unnecessary-type-arguments": "warn" + } +} +``` + +This rule is not configurable. + ## Related To - TSLint: [use-default-type-parameter](https://palantir.github.io/tslint/rules/use-default-type-parameter) ## Attributes -- [ ] ✅ Recommended +- Configs: + - [ ] ✅ Recommended + - [x] 🔒 Strict - [x] 🔧 Fixable - [x] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/no-unnecessary-type-assertion.md b/packages/eslint-plugin/docs/rules/no-unnecessary-type-assertion.md index 8cf43cbe50e..66e37f70f06 100644 --- a/packages/eslint-plugin/docs/rules/no-unnecessary-type-assertion.md +++ b/packages/eslint-plugin/docs/rules/no-unnecessary-type-assertion.md @@ -80,6 +80,8 @@ If you don't care about having no-op type assertions in your code, then you can ## Attributes -- [x] ✅ Recommended +- Configs: + - [x] ✅ Recommended + - [x] 🔒 Strict - [x] 🔧 Fixable - [x] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/no-unnecessary-type-constraint.md b/packages/eslint-plugin/docs/rules/no-unnecessary-type-constraint.md index 122b6428566..e54af4015d1 100644 --- a/packages/eslint-plugin/docs/rules/no-unnecessary-type-constraint.md +++ b/packages/eslint-plugin/docs/rules/no-unnecessary-type-constraint.md @@ -75,6 +75,8 @@ If you don't care about the specific styles of your type constraints, or never u ## Attributes -- [x] ✅ Recommended +- Configs: + - [x] ✅ Recommended + - [x] 🔒 Strict - [ ] 🔧 Fixable - [ ] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/no-unsafe-argument.md b/packages/eslint-plugin/docs/rules/no-unsafe-argument.md index cd0a1e83096..2ed2f3f423a 100644 --- a/packages/eslint-plugin/docs/rules/no-unsafe-argument.md +++ b/packages/eslint-plugin/docs/rules/no-unsafe-argument.md @@ -91,6 +91,8 @@ This rule is not configurable. ## Attributes -- [x] ✅ Recommended +- Configs: + - [x] ✅ Recommended + - [x] 🔒 Strict - [ ] 🔧 Fixable - [x] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/no-unsafe-assignment.md b/packages/eslint-plugin/docs/rules/no-unsafe-assignment.md index cf2ed503207..12a934b25df 100644 --- a/packages/eslint-plugin/docs/rules/no-unsafe-assignment.md +++ b/packages/eslint-plugin/docs/rules/no-unsafe-assignment.md @@ -94,6 +94,8 @@ This rule is not configurable. ## Attributes -- [x] ✅ Recommended +- Configs: + - [x] ✅ Recommended + - [x] 🔒 Strict - [ ] 🔧 Fixable - [x] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/no-unsafe-call.md b/packages/eslint-plugin/docs/rules/no-unsafe-call.md index e6eb6fe3aaa..c883f0ff277 100644 --- a/packages/eslint-plugin/docs/rules/no-unsafe-call.md +++ b/packages/eslint-plugin/docs/rules/no-unsafe-call.md @@ -68,6 +68,8 @@ This rule is not configurable. ## Attributes -- [x] ✅ Recommended +- Configs: + - [x] ✅ Recommended + - [x] 🔒 Strict - [ ] 🔧 Fixable - [x] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/no-unsafe-member-access.md b/packages/eslint-plugin/docs/rules/no-unsafe-member-access.md index 92eacedf6c7..da4b46633e5 100644 --- a/packages/eslint-plugin/docs/rules/no-unsafe-member-access.md +++ b/packages/eslint-plugin/docs/rules/no-unsafe-member-access.md @@ -74,6 +74,8 @@ This rule is not configurable. ## Attributes -- [x] ✅ Recommended +- Configs: + - [x] ✅ Recommended + - [x] 🔒 Strict - [ ] 🔧 Fixable - [x] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/no-unsafe-return.md b/packages/eslint-plugin/docs/rules/no-unsafe-return.md index 792eb91c418..933bd5110a0 100644 --- a/packages/eslint-plugin/docs/rules/no-unsafe-return.md +++ b/packages/eslint-plugin/docs/rules/no-unsafe-return.md @@ -111,6 +111,8 @@ This rule is not configurable. ## Attributes -- [x] ✅ Recommended +- Configs: + - [x] ✅ Recommended + - [x] 🔒 Strict - [ ] 🔧 Fixable - [x] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/no-unused-expressions.md b/packages/eslint-plugin/docs/rules/no-unused-expressions.md index 4a0abf2fc43..cdd53d2a53d 100644 --- a/packages/eslint-plugin/docs/rules/no-unused-expressions.md +++ b/packages/eslint-plugin/docs/rules/no-unused-expressions.md @@ -29,6 +29,8 @@ Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/main/ ## Attributes -- [ ] ✅ Recommended +- Configs: + - [ ] ✅ Recommended + - [ ] 🔒 Strict - [ ] 🔧 Fixable - [ ] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/no-unused-vars.md b/packages/eslint-plugin/docs/rules/no-unused-vars.md index 0de95a4ac1e..c361b263b0c 100644 --- a/packages/eslint-plugin/docs/rules/no-unused-vars.md +++ b/packages/eslint-plugin/docs/rules/no-unused-vars.md @@ -29,6 +29,8 @@ Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/main/ ## Attributes -- [x] ✅ Recommended +- Configs: + - [x] ✅ Recommended + - [x] 🔒 Strict - [ ] 🔧 Fixable - [ ] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/no-use-before-define.md b/packages/eslint-plugin/docs/rules/no-use-before-define.md index d96b3099ee8..cdc1e037391 100644 --- a/packages/eslint-plugin/docs/rules/no-use-before-define.md +++ b/packages/eslint-plugin/docs/rules/no-use-before-define.md @@ -115,6 +115,8 @@ Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/main/ ## Attributes -- [ ] ✅ Recommended +- Configs: + - [ ] ✅ Recommended + - [ ] 🔒 Strict - [ ] 🔧 Fixable - [ ] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/no-useless-constructor.md b/packages/eslint-plugin/docs/rules/no-useless-constructor.md index f8a3812efc8..511a81bfc49 100644 --- a/packages/eslint-plugin/docs/rules/no-useless-constructor.md +++ b/packages/eslint-plugin/docs/rules/no-useless-constructor.md @@ -38,6 +38,8 @@ See [discussion on this rule's lack of type information](https://github.com/type ## Attributes -- [ ] ✅ Recommended +- Configs: + - [ ] ✅ Recommended + - [x] 🔒 Strict - [ ] 🔧 Fixable - [ ] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/no-useless-empty-export.md b/packages/eslint-plugin/docs/rules/no-useless-empty-export.md index 0cb24763f12..0042e30e97d 100644 --- a/packages/eslint-plugin/docs/rules/no-useless-empty-export.md +++ b/packages/eslint-plugin/docs/rules/no-useless-empty-export.md @@ -38,8 +38,23 @@ export const value = 'Hello, world!'; import 'some-other-module'; ``` +## Options + +```jsonc +// .eslintrc.json +{ + "rules": { + "@typescript-eslint/no-useless-empty-export": "warn" + } +} +``` + +This rule is not configurable. + ## Attributes -- [ ] ✅ Recommended +- Configs: + - [ ] ✅ Recommended + - [ ] 🔒 Strict - [x] 🔧 Fixable - [ ] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/no-var-requires.md b/packages/eslint-plugin/docs/rules/no-var-requires.md index 1d1a4a84eea..819dab59d83 100644 --- a/packages/eslint-plugin/docs/rules/no-var-requires.md +++ b/packages/eslint-plugin/docs/rules/no-var-requires.md @@ -49,6 +49,8 @@ If you don't care about TypeScript module syntax, then you will not need this ru ## Attributes -- [x] ✅ Recommended +- Configs: + - [x] ✅ Recommended + - [x] 🔒 Strict - [ ] 🔧 Fixable - [ ] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/non-nullable-type-assertion-style.md b/packages/eslint-plugin/docs/rules/non-nullable-type-assertion-style.md index 07d8839091f..bebf23f2813 100644 --- a/packages/eslint-plugin/docs/rules/non-nullable-type-assertion-style.md +++ b/packages/eslint-plugin/docs/rules/non-nullable-type-assertion-style.md @@ -28,12 +28,27 @@ const definitely = maybe!; const alsoDefinitely = maybe!; ``` +## Options + +```jsonc +// .eslintrc.json +{ + "rules": { + "@typescript-eslint/non-nullable-type-assertion-style": "warn" + } +} +``` + +This rule is not configurable. + ## When Not To Use It If you don't mind having unnecessarily verbose type casts, you can avoid this rule. ## Attributes -- [ ] ✅ Recommended +- Configs: + - [ ] ✅ Recommended + - [x] 🔒 Strict - [x] 🔧 Fixable - [x] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/object-curly-spacing.md b/packages/eslint-plugin/docs/rules/object-curly-spacing.md index f8f2811d7b7..c90baead9ca 100644 --- a/packages/eslint-plugin/docs/rules/object-curly-spacing.md +++ b/packages/eslint-plugin/docs/rules/object-curly-spacing.md @@ -29,6 +29,8 @@ Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/main/ ## Attributes -- [ ] ✅ Recommended +- Configs: + - [ ] ✅ Recommended + - [ ] 🔒 Strict - [x] 🔧 Fixable - [ ] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/padding-line-between-statements.md b/packages/eslint-plugin/docs/rules/padding-line-between-statements.md index 4e25f2073a6..d8c5a29ca72 100644 --- a/packages/eslint-plugin/docs/rules/padding-line-between-statements.md +++ b/packages/eslint-plugin/docs/rules/padding-line-between-statements.md @@ -57,6 +57,8 @@ Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/main/ ## Attributes -- [ ] ✅ Recommended +- Configs: + - [ ] ✅ Recommended + - [ ] 🔒 Strict - [x] 🔧 Fixable - [ ] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/parameter-properties.md b/packages/eslint-plugin/docs/rules/parameter-properties.md index 7a86a114902..773216e6cd0 100644 --- a/packages/eslint-plugin/docs/rules/parameter-properties.md +++ b/packages/eslint-plugin/docs/rules/parameter-properties.md @@ -489,6 +489,8 @@ If you don't care about the using parameter properties in constructors, then you ## Attributes -- [ ] ✅ Recommended +- Configs: + - [ ] ✅ Recommended + - [ ] 🔒 Strict - [ ] 🔧 Fixable - [ ] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/prefer-as-const.md b/packages/eslint-plugin/docs/rules/prefer-as-const.md index 47ab9787ec9..736f8734ec1 100644 --- a/packages/eslint-plugin/docs/rules/prefer-as-const.md +++ b/packages/eslint-plugin/docs/rules/prefer-as-const.md @@ -50,6 +50,8 @@ If you are using TypeScript < 3.4 ## Attributes -- [x] ✅ Recommended +- Configs: + - [x] ✅ Recommended + - [x] 🔒 Strict - [x] 🔧 Fixable - [ ] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/prefer-enum-initializers.md b/packages/eslint-plugin/docs/rules/prefer-enum-initializers.md index 357350b7642..014349bc0d9 100644 --- a/packages/eslint-plugin/docs/rules/prefer-enum-initializers.md +++ b/packages/eslint-plugin/docs/rules/prefer-enum-initializers.md @@ -71,12 +71,27 @@ enum Color { } ``` +## Options + +```jsonc +// .eslintrc.json +{ + "rules": { + "@typescript-eslint/prefer-enum-initializers": "warn" + } +} +``` + +This rule is not configurable. + ## When Not To Use It If you don't care about `enum`s having implicit values you can safely disable this rule. ## Attributes -- [ ] ✅ Recommended +- Configs: + - [ ] ✅ Recommended + - [ ] 🔒 Strict - [ ] 🔧 Fixable - [ ] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/prefer-for-of.md b/packages/eslint-plugin/docs/rules/prefer-for-of.md index f7447d82f17..78fc4543e12 100644 --- a/packages/eslint-plugin/docs/rules/prefer-for-of.md +++ b/packages/eslint-plugin/docs/rules/prefer-for-of.md @@ -38,6 +38,19 @@ for (let i = 0; i < arr.length; i++) { } ``` +## Options + +```jsonc +// .eslintrc.json +{ + "rules": { + "@typescript-eslint/prefer-for-of": "warn" + } +} +``` + +This rule is not configurable. + ## When Not To Use It If you transpile for browsers that do not support for-of loops, you may wish to use traditional for loops that produce more compact code. @@ -48,6 +61,8 @@ If you transpile for browsers that do not support for-of loops, you may wish to ## Attributes -- [ ] ✅ Recommended +- Configs: + - [ ] ✅ Recommended + - [x] 🔒 Strict - [ ] 🔧 Fixable - [ ] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/prefer-function-type.md b/packages/eslint-plugin/docs/rules/prefer-function-type.md index ffa187df83c..b64b07718bb 100644 --- a/packages/eslint-plugin/docs/rules/prefer-function-type.md +++ b/packages/eslint-plugin/docs/rules/prefer-function-type.md @@ -78,6 +78,19 @@ interface Overloaded { type Intersection = ((data: string) => number) & ((id: number) => string); ``` +## Options + +```jsonc +// .eslintrc.json +{ + "rules": { + "@typescript-eslint/prefer-function-type": "warn" + } +} +``` + +This rule is not configurable. + ## When Not To Use It If you specifically want to use an interface or type literal with a single call signature for stylistic reasons, you can disable this rule. @@ -88,6 +101,8 @@ If you specifically want to use an interface or type literal with a single call ## Attributes -- [ ] ✅ Recommended +- Configs: + - [ ] ✅ Recommended + - [x] 🔒 Strict - [x] 🔧 Fixable - [ ] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/prefer-includes.md b/packages/eslint-plugin/docs/rules/prefer-includes.md index f23889a4900..3c3bd628aa7 100644 --- a/packages/eslint-plugin/docs/rules/prefer-includes.md +++ b/packages/eslint-plugin/docs/rules/prefer-includes.md @@ -72,7 +72,16 @@ mismatchExample.indexOf(value) >= 0; ## Options -There are no options. +```jsonc +// .eslintrc.json +{ + "rules": { + "@typescript-eslint/prefer-includes": "warn" + } +} +``` + +This rule is not configurable. ## When Not To Use It @@ -80,6 +89,8 @@ If you don't want to suggest `includes`, you can safely turn this rule off. ## Attributes -- [ ] ✅ Recommended +- Configs: + - [ ] ✅ Recommended + - [x] 🔒 Strict - [x] 🔧 Fixable - [x] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/prefer-literal-enum-member.md b/packages/eslint-plugin/docs/rules/prefer-literal-enum-member.md index ff7a1ce821d..65f0d8dc1a6 100644 --- a/packages/eslint-plugin/docs/rules/prefer-literal-enum-member.md +++ b/packages/eslint-plugin/docs/rules/prefer-literal-enum-member.md @@ -99,6 +99,8 @@ If you want use anything other than simple literals as an enum value. ## Attributes -- [ ] ✅ Recommended +- Configs: + - [ ] ✅ Recommended + - [x] 🔒 Strict - [ ] 🔧 Fixable - [ ] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/prefer-namespace-keyword.md b/packages/eslint-plugin/docs/rules/prefer-namespace-keyword.md index 887c8171b36..b6ec63fd81e 100644 --- a/packages/eslint-plugin/docs/rules/prefer-namespace-keyword.md +++ b/packages/eslint-plugin/docs/rules/prefer-namespace-keyword.md @@ -38,6 +38,8 @@ This rule is not configurable. ## Attributes -- [x] ✅ Recommended +- Configs: + - [x] ✅ Recommended + - [x] 🔒 Strict - [x] 🔧 Fixable - [ ] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/prefer-nullish-coalescing.md b/packages/eslint-plugin/docs/rules/prefer-nullish-coalescing.md index dd9c02009f9..54c08e1d464 100644 --- a/packages/eslint-plugin/docs/rules/prefer-nullish-coalescing.md +++ b/packages/eslint-plugin/docs/rules/prefer-nullish-coalescing.md @@ -144,6 +144,8 @@ If you are not using TypeScript 3.7 (or greater), then you will not be able to u ## Attributes -- [ ] ✅ Recommended +- Configs: + - [ ] ✅ Recommended + - [x] 🔒 Strict - [ ] 🔧 Fixable - [x] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/prefer-optional-chain.md b/packages/eslint-plugin/docs/rules/prefer-optional-chain.md index 4d0e0871c73..df77f58a0e5 100644 --- a/packages/eslint-plugin/docs/rules/prefer-optional-chain.md +++ b/packages/eslint-plugin/docs/rules/prefer-optional-chain.md @@ -85,6 +85,19 @@ foo?.a?.b?.c?.d?.e; **Note:** there are a few edge cases where this rule will false positive. Use your best judgement when evaluating reported errors. +## Options + +```jsonc +// .eslintrc.json +{ + "rules": { + "@typescript-eslint/prefer-optional-chain": "warn" + } +} +``` + +This rule is not configurable. + ## When Not To Use It If you are not using TypeScript 3.7 (or greater), then you will not be able to use this rule, as the operator is not supported. @@ -96,6 +109,8 @@ If you are not using TypeScript 3.7 (or greater), then you will not be able to u ## Attributes -- [ ] ✅ Recommended +- Configs: + - [ ] ✅ Recommended + - [x] 🔒 Strict - [ ] 🔧 Fixable - [ ] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/prefer-readonly-parameter-types.md b/packages/eslint-plugin/docs/rules/prefer-readonly-parameter-types.md index a50fdc4fb84..48aa79dbb53 100644 --- a/packages/eslint-plugin/docs/rules/prefer-readonly-parameter-types.md +++ b/packages/eslint-plugin/docs/rules/prefer-readonly-parameter-types.md @@ -280,6 +280,8 @@ function foo(arg: MyType) {} ## Attributes -- [ ] ✅ Recommended +- Configs: + - [ ] ✅ Recommended + - [ ] 🔒 Strict - [ ] 🔧 Fixable - [x] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/prefer-readonly.md b/packages/eslint-plugin/docs/rules/prefer-readonly.md index 9698c8e9251..7d145515e12 100644 --- a/packages/eslint-plugin/docs/rules/prefer-readonly.md +++ b/packages/eslint-plugin/docs/rules/prefer-readonly.md @@ -92,6 +92,8 @@ class Container { ## Attributes -- [ ] ✅ Recommended +- Configs: + - [ ] ✅ Recommended + - [ ] 🔒 Strict - [x] 🔧 Fixable - [x] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/prefer-reduce-type-parameter.md b/packages/eslint-plugin/docs/rules/prefer-reduce-type-parameter.md index b5359343899..49ef8d4330d 100644 --- a/packages/eslint-plugin/docs/rules/prefer-reduce-type-parameter.md +++ b/packages/eslint-plugin/docs/rules/prefer-reduce-type-parameter.md @@ -53,7 +53,16 @@ Examples of code for this rule: ## Options -There are no options. +```jsonc +// .eslintrc.json +{ + "rules": { + "@typescript-eslint/prefer-reduce-type-parameter": "warn" + } +} +``` + +This rule is not configurable. ## When Not To Use It @@ -61,6 +70,8 @@ If you don't want to use typechecking in your linting, you can't use this rule. ## Attributes -- [ ] ✅ Recommended +- Configs: + - [ ] ✅ Recommended + - [x] 🔒 Strict - [x] 🔧 Fixable - [x] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/prefer-regexp-exec.md b/packages/eslint-plugin/docs/rules/prefer-regexp-exec.md index 1c820245741..d4a415752f3 100644 --- a/packages/eslint-plugin/docs/rules/prefer-regexp-exec.md +++ b/packages/eslint-plugin/docs/rules/prefer-regexp-exec.md @@ -44,20 +44,25 @@ search.exec(text); ## Options -There are no options. - -```json +```jsonc +// .eslintrc.json { - "@typescript-eslint/prefer-regexp-exec": "error" + "rules": { + "@typescript-eslint/prefer-regexp-exec": "warn" + } } ``` +This rule is not configurable. + ## When Not To Use It If you prefer consistent use of `String#match` for both, with `g` flag and without it, you can turn this rule off. ## Attributes -- [ ] ✅ Recommended +- Configs: + - [ ] ✅ Recommended + - [ ] 🔒 Strict - [x] 🔧 Fixable - [x] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/prefer-return-this-type.md b/packages/eslint-plugin/docs/rules/prefer-return-this-type.md index c60bee7ec0d..d6648458767 100644 --- a/packages/eslint-plugin/docs/rules/prefer-return-this-type.md +++ b/packages/eslint-plugin/docs/rules/prefer-return-this-type.md @@ -93,12 +93,27 @@ class Derived extends Base { } ``` +## Options + +```jsonc +// .eslintrc.json +{ + "rules": { + "@typescript-eslint/prefer-return-this-type": "warn" + } +} +``` + +This rule is not configurable. + ## When Not To Use It If you don't use method chaining or explicit return values, you can safely turn this rule off. ## Attributes -- [ ] ✅ Recommended +- Configs: + - [ ] ✅ Recommended + - [x] 🔒 Strict - [x] 🔧 Fixable - [x] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/prefer-string-starts-ends-with.md b/packages/eslint-plugin/docs/rules/prefer-string-starts-ends-with.md index 9b7cc2902ec..0ae2553c09d 100644 --- a/packages/eslint-plugin/docs/rules/prefer-string-starts-ends-with.md +++ b/packages/eslint-plugin/docs/rules/prefer-string-starts-ends-with.md @@ -47,20 +47,25 @@ foo.endsWith('bar'); ## Options -There are no options. - -```json +```jsonc +// .eslintrc.json { - "@typescript-eslint/prefer-string-starts-ends-with": "error" + "rules": { + "@typescript-eslint/prefer-string-starts-ends-with": "warn" + } } ``` +This rule is not configurable. + ## When Not To Use It If you don't mind that style, you can turn this rule off safely. ## Attributes -- [ ] ✅ Recommended +- Configs: + - [ ] ✅ Recommended + - [x] 🔒 Strict - [x] 🔧 Fixable - [x] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/prefer-ts-expect-error.md b/packages/eslint-plugin/docs/rules/prefer-ts-expect-error.md index ad9ee974530..06811604ce2 100644 --- a/packages/eslint-plugin/docs/rules/prefer-ts-expect-error.md +++ b/packages/eslint-plugin/docs/rules/prefer-ts-expect-error.md @@ -62,6 +62,19 @@ const isOptionEnabled = (key: string): boolean => { }; ``` +## Options + +```jsonc +// .eslintrc.json +{ + "rules": { + "@typescript-eslint/prefer-ts-expect-error": "warn" + } +} +``` + +This rule is not configurable. + ## When Not To Use It If you are **NOT** using TypeScript 3.9 (or greater), then you will not be able to use this rule, as the directive is not supported @@ -72,6 +85,8 @@ If you are **NOT** using TypeScript 3.9 (or greater), then you will not be able ## Attributes -- [ ] ✅ Recommended +- Configs: + - [ ] ✅ Recommended + - [x] 🔒 Strict - [x] 🔧 Fixable - [ ] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/promise-function-async.md b/packages/eslint-plugin/docs/rules/promise-function-async.md index 9791f586d57..2191277b83b 100644 --- a/packages/eslint-plugin/docs/rules/promise-function-async.md +++ b/packages/eslint-plugin/docs/rules/promise-function-async.md @@ -73,6 +73,8 @@ In addition, each of the following properties may be provided, and default to `t ## Attributes -- [ ] ✅ Recommended +- Configs: + - [ ] ✅ Recommended + - [ ] 🔒 Strict - [x] 🔧 Fixable - [x] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/quotes.md b/packages/eslint-plugin/docs/rules/quotes.md index 391c8168247..daaf3e509bc 100644 --- a/packages/eslint-plugin/docs/rules/quotes.md +++ b/packages/eslint-plugin/docs/rules/quotes.md @@ -29,6 +29,8 @@ Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/main/ ## Attributes -- [ ] ✅ Recommended +- Configs: + - [ ] ✅ Recommended + - [ ] 🔒 Strict - [x] 🔧 Fixable - [ ] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/require-array-sort-compare.md b/packages/eslint-plugin/docs/rules/require-array-sort-compare.md index 18248cca444..74d1a8dc4fb 100644 --- a/packages/eslint-plugin/docs/rules/require-array-sort-compare.md +++ b/packages/eslint-plugin/docs/rules/require-array-sort-compare.md @@ -100,6 +100,8 @@ If you understand the language specification enough, you can turn this rule off ## Attributes -- [ ] ✅ Recommended +- Configs: + - [ ] ✅ Recommended + - [ ] 🔒 Strict - [ ] 🔧 Fixable - [x] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/require-await.md b/packages/eslint-plugin/docs/rules/require-await.md index 86a5d580d87..c75a40803ce 100644 --- a/packages/eslint-plugin/docs/rules/require-await.md +++ b/packages/eslint-plugin/docs/rules/require-await.md @@ -39,6 +39,8 @@ Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/main/ ## Attributes -- [x] ✅ Recommended +- Configs: + - [x] ✅ Recommended + - [x] 🔒 Strict - [ ] 🔧 Fixable - [x] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/restrict-plus-operands.md b/packages/eslint-plugin/docs/rules/restrict-plus-operands.md index c87d3a29064..d4741186e4c 100644 --- a/packages/eslint-plugin/docs/rules/restrict-plus-operands.md +++ b/packages/eslint-plugin/docs/rules/restrict-plus-operands.md @@ -107,6 +107,8 @@ var fn = (a: any, b: number) => a + b; ## Attributes -- [x] ✅ Recommended +- Configs: + - [x] ✅ Recommended + - [x] 🔒 Strict - [ ] 🔧 Fixable - [x] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/restrict-template-expressions.md b/packages/eslint-plugin/docs/rules/restrict-template-expressions.md index e248863cfda..5593090a482 100644 --- a/packages/eslint-plugin/docs/rules/restrict-template-expressions.md +++ b/packages/eslint-plugin/docs/rules/restrict-template-expressions.md @@ -111,6 +111,8 @@ const msg1 = `arg = ${arg}`; ## Attributes -- [x] ✅ Recommended +- Configs: + - [x] ✅ Recommended + - [x] 🔒 Strict - [ ] 🔧 Fixable - [x] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/return-await.md b/packages/eslint-plugin/docs/rules/return-await.md index 09e4f2e2b28..8d4e97298da 100644 --- a/packages/eslint-plugin/docs/rules/return-await.md +++ b/packages/eslint-plugin/docs/rules/return-await.md @@ -223,6 +223,8 @@ async function validNever3() { ## Attributes -- [ ] ✅ Recommended +- Configs: + - [ ] ✅ Recommended + - [ ] 🔒 Strict - [x] 🔧 Fixable - [x] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/semi.md b/packages/eslint-plugin/docs/rules/semi.md index 46d21bfccd3..7a9e125fa2b 100644 --- a/packages/eslint-plugin/docs/rules/semi.md +++ b/packages/eslint-plugin/docs/rules/semi.md @@ -33,6 +33,8 @@ Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/main/ ## Attributes -- [ ] ✅ Recommended +- Configs: + - [ ] ✅ Recommended + - [ ] 🔒 Strict - [x] 🔧 Fixable - [ ] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/sort-type-union-intersection-members.md b/packages/eslint-plugin/docs/rules/sort-type-union-intersection-members.md index 19aa2ad18bb..49639338141 100644 --- a/packages/eslint-plugin/docs/rules/sort-type-union-intersection-members.md +++ b/packages/eslint-plugin/docs/rules/sort-type-union-intersection-members.md @@ -154,6 +154,8 @@ The ordering of groups is determined by this option. ## Attributes -- [ ] ✅ Recommended +- Configs: + - [ ] ✅ Recommended + - [ ] 🔒 Strict - [x] 🔧 Fixable - [ ] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/space-before-blocks.md b/packages/eslint-plugin/docs/rules/space-before-blocks.md index 52f8a121df6..dce543bbf21 100644 --- a/packages/eslint-plugin/docs/rules/space-before-blocks.md +++ b/packages/eslint-plugin/docs/rules/space-before-blocks.md @@ -55,6 +55,8 @@ Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/maste ## Attributes -- [ ] ✅ Recommended +- Configs: + - [ ] ✅ Recommended + - [ ] 🔒 Strict - [x] 🔧 Fixable - [ ] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/space-before-function-paren.md b/packages/eslint-plugin/docs/rules/space-before-function-paren.md index 46e352e54d8..88f6d5d4c99 100644 --- a/packages/eslint-plugin/docs/rules/space-before-function-paren.md +++ b/packages/eslint-plugin/docs/rules/space-before-function-paren.md @@ -29,6 +29,8 @@ Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/main/ ## Attributes -- [ ] ✅ Recommended +- Configs: + - [ ] ✅ Recommended + - [ ] 🔒 Strict - [x] 🔧 Fixable - [ ] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/space-infix-ops.md b/packages/eslint-plugin/docs/rules/space-infix-ops.md index c95b91a4f8c..21dd58c312d 100644 --- a/packages/eslint-plugin/docs/rules/space-infix-ops.md +++ b/packages/eslint-plugin/docs/rules/space-infix-ops.md @@ -33,6 +33,8 @@ Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/main/ ## Attributes -- [ ] ✅ Recommended +- Configs: + - [ ] ✅ Recommended + - [ ] 🔒 Strict - [x] 🔧 Fixable - [ ] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/strict-boolean-expressions.md b/packages/eslint-plugin/docs/rules/strict-boolean-expressions.md index 5b06af74c3f..f993881c8c2 100644 --- a/packages/eslint-plugin/docs/rules/strict-boolean-expressions.md +++ b/packages/eslint-plugin/docs/rules/strict-boolean-expressions.md @@ -200,6 +200,8 @@ This rule provides following fixes and suggestions for particular types in boole ## Attributes -- [ ] ✅ Recommended +- Configs: + - [ ] ✅ Recommended + - [ ] 🔒 Strict - [x] 🔧 Fixable - [x] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/switch-exhaustiveness-check.md b/packages/eslint-plugin/docs/rules/switch-exhaustiveness-check.md index 13f4123a9d0..df6fc1f72bc 100644 --- a/packages/eslint-plugin/docs/rules/switch-exhaustiveness-check.md +++ b/packages/eslint-plugin/docs/rules/switch-exhaustiveness-check.md @@ -106,12 +106,27 @@ switch (day) { } ``` +## Options + +```jsonc +// .eslintrc.json +{ + "rules": { + "@typescript-eslint/switch-exhaustiveness-check": "warn" + } +} +``` + +This rule is not configurable. + ## When Not To Use It If program doesn't have union types with many parts. Downside of this rule is the need for type information, so it's slower than regular rules. ## Attributes -- [ ] ✅ Recommended +- Configs: + - [ ] ✅ Recommended + - [ ] 🔒 Strict - [ ] 🔧 Fixable - [x] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/triple-slash-reference.md b/packages/eslint-plugin/docs/rules/triple-slash-reference.md index 23d8e12c297..2488d28ab13 100644 --- a/packages/eslint-plugin/docs/rules/triple-slash-reference.md +++ b/packages/eslint-plugin/docs/rules/triple-slash-reference.md @@ -59,6 +59,8 @@ If you want to use all flavors of triple slash reference directives. ## Attributes -- [x] ✅ Recommended +- Configs: + - [x] ✅ Recommended + - [x] 🔒 Strict - [ ] 🔧 Fixable - [ ] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/type-annotation-spacing.md b/packages/eslint-plugin/docs/rules/type-annotation-spacing.md index 46beee117e0..903e9faf819 100644 --- a/packages/eslint-plugin/docs/rules/type-annotation-spacing.md +++ b/packages/eslint-plugin/docs/rules/type-annotation-spacing.md @@ -314,6 +314,8 @@ If you don't want to enforce spacing for your type annotations, you can safely t ## Attributes -- [ ] ✅ Recommended +- Configs: + - [ ] ✅ Recommended + - [ ] 🔒 Strict - [x] 🔧 Fixable - [ ] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/typedef.md b/packages/eslint-plugin/docs/rules/typedef.md index 75e4b1ccb57..cbe3bcd3cb0 100644 --- a/packages/eslint-plugin/docs/rules/typedef.md +++ b/packages/eslint-plugin/docs/rules/typedef.md @@ -343,6 +343,8 @@ In general, if you do not consider the cost of writing unnecessary type annotati ## Attributes -- [ ] ✅ Recommended +- Configs: + - [ ] ✅ Recommended + - [ ] 🔒 Strict - [ ] 🔧 Fixable - [ ] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/unbound-method.md b/packages/eslint-plugin/docs/rules/unbound-method.md index 69f049b6c42..cef79e42601 100644 --- a/packages/eslint-plugin/docs/rules/unbound-method.md +++ b/packages/eslint-plugin/docs/rules/unbound-method.md @@ -121,6 +121,8 @@ If you're wanting to use `toBeCalled` and similar matches in `jest` tests, you c ## Attributes -- [x] ✅ Recommended +- Configs: + - [x] ✅ Recommended + - [x] 🔒 Strict - [ ] 🔧 Fixable - [x] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/unified-signatures.md b/packages/eslint-plugin/docs/rules/unified-signatures.md index 4fb7d6a7a80..b308aff9d63 100644 --- a/packages/eslint-plugin/docs/rules/unified-signatures.md +++ b/packages/eslint-plugin/docs/rules/unified-signatures.md @@ -82,6 +82,8 @@ function f(...a: string[]): void; ## Attributes -- [ ] ✅ Recommended +- Configs: + - [ ] ✅ Recommended + - [x] 🔒 Strict - [ ] 🔧 Fixable - [ ] 💭 Requires type information diff --git a/packages/eslint-plugin/src/configs/README.md b/packages/eslint-plugin/src/configs/README.md index c3ee9dbddf8..c440d3d61c5 100644 --- a/packages/eslint-plugin/src/configs/README.md +++ b/packages/eslint-plugin/src/configs/README.md @@ -1,69 +1,3 @@ -# Premade configs +# Premade Configs -These configs exist for your convenience. They contain configuration intended to save you time and effort when configuring your project by disabling rules known to conflict with this repository, or cause issues in TypeScript codebases. - -## `eslint-recommended` - -The `eslint-recommended` ruleset is meant to be used after extending `eslint:recommended`. It disables rules that are already checked by the TypeScript compiler and enables rules that promote using the more modern constructs TypeScript allows for. - -This config is automatically included if you use either the `recommended` or `recommended-requiring-type-checking` configs. - -```jsonc -{ - "extends": [ - "eslint:recommended", - "plugin:@typescript-eslint/eslint-recommended" - ] -} -``` - -We will not add new rules to the `eslint-recommended` set unless we release a major package version (i.e. it is seen as a breaking change). - -## `recommended` - -The `recommended` set is an **_opinionated_** set of rules that we think you should use because: - -1. They help you adhere to TypeScript best practices. -2. They help catch probable issue vectors in your code. - -That being said, it is not the only way to use `@typescript-eslint/eslint-plugin`, nor is it the way that will necessarily work 100% for your project/company. It has been built based off of two main things: - -1. TypeScript best practices collected and collated from places like: - - [TypeScript repo](https://github.com/Microsoft/TypeScript). - - [TypeScript documentation](https://www.typescriptlang.org/docs/home.html). - - The style used by many OSS TypeScript projects. -2. The combined state of community contributed rulesets at the time of creation. - -We will not add new rules to the `recommended` set unless we release a major package version (i.e. it is seen as a breaking change). - -### Altering the `recommended` set to suit your project - -If you disagree with a rule (or it disagrees with your codebase), consider using your local config to change the rule config so it works for your project. - -```jsonc -{ - "extends": ["plugin:@typescript-eslint/recommended"], - "rules": { - // our project thinks using IPrefixedInterfaces is a good practice - "@typescript-eslint/interface-name-prefix": ["error", "always"] - } -} -``` - -### Suggesting changes to the `recommended` set - - -If you feel _very_, **very**, ***very*** strongly that a specific rule should (or should not) be in the recommended ruleset, please feel free to file an issue along with a **detailed** argument explaining your reasoning. We expect to see you citing concrete evidence supporting why (or why not) a rule is considered best practice. **Please note that if your reasoning is along the lines of "it's what my project/company does", or "I don't like the rule", then we will likely close the request without discussion.** - -## `recommended-requiring-type-checking` - -Similar to `recommended`, the `recommended-requiring-type-checking` set is an **_opinionated_** set of rules. The difference being that all rules in this set will require type information to use. - -We will not add new rules to the `recommended-requiring-type-checking` set unless we release a major package version (i.e. it is seen as a breaking change). - -## `all` - -The `all` set simply contains every single rule in this plugin, turn on with its default configuration. -There may be some conflicts between the rules as defaults do not quite align - please file an issue if you encounter any of these. - -This set is considered unstable, as any new rules will be added with only a minor package version bump. +This page has moved to [docs/linting/CONFIGS.md](../../../../docs/linting/CONFIGS.md). diff --git a/packages/eslint-plugin/src/configs/strict.ts b/packages/eslint-plugin/src/configs/strict.ts new file mode 100644 index 00000000000..ca71a982613 --- /dev/null +++ b/packages/eslint-plugin/src/configs/strict.ts @@ -0,0 +1,49 @@ +// THIS CODE WAS AUTOMATICALLY GENERATED +// DO NOT EDIT THIS CODE BY HAND +// YOU CAN REGENERATE IT USING yarn generate:configs + +export = { + extends: [ + './configs/base', + './configs/eslint-recommended', + './configs/recommended', + './configs/recommended-requiring-type-checking', + ], + rules: { + '@typescript-eslint/array-type': 'warn', + '@typescript-eslint/ban-tslint-comment': 'warn', + '@typescript-eslint/class-literal-property-style': 'warn', + '@typescript-eslint/consistent-indexed-object-style': 'warn', + '@typescript-eslint/consistent-type-assertions': 'warn', + '@typescript-eslint/consistent-type-definitions': 'warn', + 'dot-notation': 'off', + '@typescript-eslint/dot-notation': 'warn', + '@typescript-eslint/no-base-to-string': 'warn', + '@typescript-eslint/no-confusing-non-null-assertion': 'warn', + '@typescript-eslint/no-duplicate-enum-values': 'warn', + '@typescript-eslint/no-dynamic-delete': 'warn', + '@typescript-eslint/no-extraneous-class': 'warn', + '@typescript-eslint/no-invalid-void-type': 'warn', + '@typescript-eslint/no-meaningless-void-operator': 'warn', + '@typescript-eslint/no-non-null-asserted-nullish-coalescing': 'warn', + 'no-throw-literal': 'off', + '@typescript-eslint/no-throw-literal': 'warn', + '@typescript-eslint/no-unnecessary-boolean-literal-compare': 'warn', + '@typescript-eslint/no-unnecessary-condition': 'warn', + '@typescript-eslint/no-unnecessary-type-arguments': 'warn', + 'no-useless-constructor': 'off', + '@typescript-eslint/no-useless-constructor': 'warn', + '@typescript-eslint/non-nullable-type-assertion-style': 'warn', + '@typescript-eslint/prefer-for-of': 'warn', + '@typescript-eslint/prefer-function-type': 'warn', + '@typescript-eslint/prefer-includes': 'warn', + '@typescript-eslint/prefer-literal-enum-member': 'warn', + '@typescript-eslint/prefer-nullish-coalescing': 'warn', + '@typescript-eslint/prefer-optional-chain': 'warn', + '@typescript-eslint/prefer-reduce-type-parameter': 'warn', + '@typescript-eslint/prefer-return-this-type': 'warn', + '@typescript-eslint/prefer-string-starts-ends-with': 'warn', + '@typescript-eslint/prefer-ts-expect-error': 'warn', + '@typescript-eslint/unified-signatures': 'warn', + }, +}; diff --git a/packages/eslint-plugin/src/index.ts b/packages/eslint-plugin/src/index.ts index a812b44eb7a..a0d8a6d9663 100644 --- a/packages/eslint-plugin/src/index.ts +++ b/packages/eslint-plugin/src/index.ts @@ -2,9 +2,10 @@ import rules from './rules'; import all from './configs/all'; import base from './configs/base'; +import eslintRecommended from './configs/eslint-recommended'; import recommended from './configs/recommended'; import recommendedRequiringTypeChecking from './configs/recommended-requiring-type-checking'; -import eslintRecommended from './configs/eslint-recommended'; +import strict from './configs/strict'; export = { rules, @@ -14,5 +15,6 @@ export = { recommended, 'eslint-recommended': eslintRecommended, 'recommended-requiring-type-checking': recommendedRequiringTypeChecking, + strict, }, }; diff --git a/packages/eslint-plugin/src/rules/array-type.ts b/packages/eslint-plugin/src/rules/array-type.ts index 35cfaaf1fc1..fba44197a8a 100644 --- a/packages/eslint-plugin/src/rules/array-type.ts +++ b/packages/eslint-plugin/src/rules/array-type.ts @@ -91,8 +91,7 @@ export default util.createRule({ type: 'suggestion', docs: { description: 'Requires using either `T[]` or `Array` for arrays', - // too opinionated to be recommended - recommended: false, + recommended: 'strict', }, fixable: 'code', messages: { diff --git a/packages/eslint-plugin/src/rules/ban-tslint-comment.ts b/packages/eslint-plugin/src/rules/ban-tslint-comment.ts index 99a427eead0..87e500d3c23 100644 --- a/packages/eslint-plugin/src/rules/ban-tslint-comment.ts +++ b/packages/eslint-plugin/src/rules/ban-tslint-comment.ts @@ -20,7 +20,7 @@ export default util.createRule({ type: 'suggestion', docs: { description: 'Bans `// tslint:` comments from being used', - recommended: false, + recommended: 'strict', }, messages: { commentDetected: 'tslint comment detected: "{{ text }}"', diff --git a/packages/eslint-plugin/src/rules/class-literal-property-style.ts b/packages/eslint-plugin/src/rules/class-literal-property-style.ts index 705485e0050..49c28fbd3a9 100644 --- a/packages/eslint-plugin/src/rules/class-literal-property-style.ts +++ b/packages/eslint-plugin/src/rules/class-literal-property-style.ts @@ -41,7 +41,7 @@ export default util.createRule({ docs: { description: 'Ensures that literals on classes are exposed in a consistent style', - recommended: false, + recommended: 'strict', }, fixable: 'code', messages: { diff --git a/packages/eslint-plugin/src/rules/consistent-indexed-object-style.ts b/packages/eslint-plugin/src/rules/consistent-indexed-object-style.ts index bd511d0cd0e..b68b2eae4b0 100644 --- a/packages/eslint-plugin/src/rules/consistent-indexed-object-style.ts +++ b/packages/eslint-plugin/src/rules/consistent-indexed-object-style.ts @@ -10,8 +10,7 @@ export default createRule({ type: 'suggestion', docs: { description: 'Enforce or disallow the use of the record type', - // too opinionated to be recommended - recommended: false, + recommended: 'strict', }, messages: { preferRecord: 'A record is preferred over an index signature.', diff --git a/packages/eslint-plugin/src/rules/consistent-type-assertions.ts b/packages/eslint-plugin/src/rules/consistent-type-assertions.ts index c75b93eea0e..8890007f8f0 100644 --- a/packages/eslint-plugin/src/rules/consistent-type-assertions.ts +++ b/packages/eslint-plugin/src/rules/consistent-type-assertions.ts @@ -23,7 +23,7 @@ export default util.createRule({ type: 'suggestion', docs: { description: 'Enforces consistent usage of type assertions', - recommended: false, + recommended: 'strict', }, messages: { as: "Use 'as {{cast}}' instead of '<{{cast}}>'.", diff --git a/packages/eslint-plugin/src/rules/consistent-type-definitions.ts b/packages/eslint-plugin/src/rules/consistent-type-definitions.ts index d87383bdc42..e0690e650d4 100644 --- a/packages/eslint-plugin/src/rules/consistent-type-definitions.ts +++ b/packages/eslint-plugin/src/rules/consistent-type-definitions.ts @@ -13,8 +13,7 @@ export default util.createRule({ docs: { description: 'Consistent with type definition either `interface` or `type`', - // too opinionated to be recommended - recommended: false, + recommended: 'strict', }, messages: { interfaceOverType: 'Use an `interface` instead of a `type`.', diff --git a/packages/eslint-plugin/src/rules/dot-notation.ts b/packages/eslint-plugin/src/rules/dot-notation.ts index 29db2f3fe1e..cfa8ae55a44 100644 --- a/packages/eslint-plugin/src/rules/dot-notation.ts +++ b/packages/eslint-plugin/src/rules/dot-notation.ts @@ -20,7 +20,7 @@ export default createRule({ type: 'suggestion', docs: { description: 'enforce dot notation whenever possible', - recommended: false, + recommended: 'strict', extendsBaseRule: true, requiresTypeChecking: true, }, diff --git a/packages/eslint-plugin/src/rules/no-base-to-string.ts b/packages/eslint-plugin/src/rules/no-base-to-string.ts index 09c4d8376f1..c728f0f726b 100644 --- a/packages/eslint-plugin/src/rules/no-base-to-string.ts +++ b/packages/eslint-plugin/src/rules/no-base-to-string.ts @@ -22,7 +22,7 @@ export default util.createRule({ docs: { description: 'Requires that `.toString()` is only called on objects which provide useful information when stringified', - recommended: false, + recommended: 'strict', requiresTypeChecking: true, }, messages: { diff --git a/packages/eslint-plugin/src/rules/no-confusing-non-null-assertion.ts b/packages/eslint-plugin/src/rules/no-confusing-non-null-assertion.ts index 5538781598a..c6a3234e999 100644 --- a/packages/eslint-plugin/src/rules/no-confusing-non-null-assertion.ts +++ b/packages/eslint-plugin/src/rules/no-confusing-non-null-assertion.ts @@ -13,7 +13,7 @@ export default util.createRule({ docs: { description: 'Disallow non-null assertion in locations that may be confusing', - recommended: false, + recommended: 'strict', }, fixable: 'code', hasSuggestions: true, diff --git a/packages/eslint-plugin/src/rules/no-duplicate-enum-values.ts b/packages/eslint-plugin/src/rules/no-duplicate-enum-values.ts index 3ede60b9fc3..dcd0f6be36f 100644 --- a/packages/eslint-plugin/src/rules/no-duplicate-enum-values.ts +++ b/packages/eslint-plugin/src/rules/no-duplicate-enum-values.ts @@ -7,7 +7,7 @@ export default util.createRule({ type: 'problem', docs: { description: 'Disallow duplicate enum member values', - recommended: false, + recommended: 'strict', }, hasSuggestions: true, messages: { diff --git a/packages/eslint-plugin/src/rules/no-dynamic-delete.ts b/packages/eslint-plugin/src/rules/no-dynamic-delete.ts index 8824095ab74..01ed32d7461 100644 --- a/packages/eslint-plugin/src/rules/no-dynamic-delete.ts +++ b/packages/eslint-plugin/src/rules/no-dynamic-delete.ts @@ -7,7 +7,7 @@ export default util.createRule({ meta: { docs: { description: 'Disallow the delete operator with computed key expressions', - recommended: false, + recommended: 'strict', }, fixable: 'code', messages: { diff --git a/packages/eslint-plugin/src/rules/no-extraneous-class.ts b/packages/eslint-plugin/src/rules/no-extraneous-class.ts index aa2184c9b16..b695301af32 100644 --- a/packages/eslint-plugin/src/rules/no-extraneous-class.ts +++ b/packages/eslint-plugin/src/rules/no-extraneous-class.ts @@ -17,7 +17,7 @@ export default util.createRule({ type: 'suggestion', docs: { description: 'Forbids the use of classes as namespaces', - recommended: false, + recommended: 'strict', }, schema: [ { diff --git a/packages/eslint-plugin/src/rules/no-invalid-void-type.ts b/packages/eslint-plugin/src/rules/no-invalid-void-type.ts index cd28cfa16da..cefea8cf0c3 100644 --- a/packages/eslint-plugin/src/rules/no-invalid-void-type.ts +++ b/packages/eslint-plugin/src/rules/no-invalid-void-type.ts @@ -20,7 +20,7 @@ export default util.createRule<[Options], MessageIds>({ docs: { description: 'Disallows usage of `void` type outside of generic or return types', - recommended: false, + recommended: 'strict', }, messages: { invalidVoidForGeneric: diff --git a/packages/eslint-plugin/src/rules/no-meaningless-void-operator.ts b/packages/eslint-plugin/src/rules/no-meaningless-void-operator.ts index a1dd8768130..e509b186dc8 100644 --- a/packages/eslint-plugin/src/rules/no-meaningless-void-operator.ts +++ b/packages/eslint-plugin/src/rules/no-meaningless-void-operator.ts @@ -19,7 +19,7 @@ export default util.createRule< docs: { description: 'Disallow the `void` operator except when used to discard a value', - recommended: false, + recommended: 'strict', suggestion: true, requiresTypeChecking: true, }, diff --git a/packages/eslint-plugin/src/rules/no-non-null-asserted-nullish-coalescing.ts b/packages/eslint-plugin/src/rules/no-non-null-asserted-nullish-coalescing.ts index db8b1cf860c..fada84c9a83 100644 --- a/packages/eslint-plugin/src/rules/no-non-null-asserted-nullish-coalescing.ts +++ b/packages/eslint-plugin/src/rules/no-non-null-asserted-nullish-coalescing.ts @@ -35,7 +35,7 @@ export default util.createRule({ docs: { description: 'Disallows using a non-null assertion in the left operand of the nullish coalescing operator', - recommended: false, + recommended: 'strict', }, messages: { noNonNullAssertedNullishCoalescing: diff --git a/packages/eslint-plugin/src/rules/no-throw-literal.ts b/packages/eslint-plugin/src/rules/no-throw-literal.ts index f248ef9cb8d..36522c15398 100644 --- a/packages/eslint-plugin/src/rules/no-throw-literal.ts +++ b/packages/eslint-plugin/src/rules/no-throw-literal.ts @@ -17,7 +17,7 @@ export default util.createRule({ type: 'problem', docs: { description: 'Disallow throwing literals as exceptions', - recommended: false, + recommended: 'strict', extendsBaseRule: true, requiresTypeChecking: true, }, diff --git a/packages/eslint-plugin/src/rules/no-unnecessary-boolean-literal-compare.ts b/packages/eslint-plugin/src/rules/no-unnecessary-boolean-literal-compare.ts index e3768b28aa0..1bd58206285 100644 --- a/packages/eslint-plugin/src/rules/no-unnecessary-boolean-literal-compare.ts +++ b/packages/eslint-plugin/src/rules/no-unnecessary-boolean-literal-compare.ts @@ -35,7 +35,7 @@ export default util.createRule({ docs: { description: 'Flags unnecessary equality comparisons against boolean literals', - recommended: false, + recommended: 'strict', requiresTypeChecking: true, }, fixable: 'code', diff --git a/packages/eslint-plugin/src/rules/no-unnecessary-condition.ts b/packages/eslint-plugin/src/rules/no-unnecessary-condition.ts index 4e18a9f631e..53c440442f5 100644 --- a/packages/eslint-plugin/src/rules/no-unnecessary-condition.ts +++ b/packages/eslint-plugin/src/rules/no-unnecessary-condition.ts @@ -90,7 +90,7 @@ export default createRule({ docs: { description: 'Prevents conditionals where the type is always truthy or always falsy', - recommended: false, + recommended: 'strict', requiresTypeChecking: true, }, schema: [ diff --git a/packages/eslint-plugin/src/rules/no-unnecessary-type-arguments.ts b/packages/eslint-plugin/src/rules/no-unnecessary-type-arguments.ts index 294adf554ad..892305d3191 100644 --- a/packages/eslint-plugin/src/rules/no-unnecessary-type-arguments.ts +++ b/packages/eslint-plugin/src/rules/no-unnecessary-type-arguments.ts @@ -22,7 +22,7 @@ export default util.createRule<[], MessageIds>({ docs: { description: 'Enforces that type arguments will not be used if not required', - recommended: false, + recommended: 'strict', requiresTypeChecking: true, }, fixable: 'code', diff --git a/packages/eslint-plugin/src/rules/no-useless-constructor.ts b/packages/eslint-plugin/src/rules/no-useless-constructor.ts index 0bbe2f6f64c..10e55cfbe0e 100644 --- a/packages/eslint-plugin/src/rules/no-useless-constructor.ts +++ b/packages/eslint-plugin/src/rules/no-useless-constructor.ts @@ -48,7 +48,7 @@ export default util.createRule({ type: 'problem', docs: { description: 'Disallow unnecessary constructors', - recommended: false, + recommended: 'strict', extendsBaseRule: true, }, hasSuggestions: baseRule.meta.hasSuggestions, diff --git a/packages/eslint-plugin/src/rules/non-nullable-type-assertion-style.ts b/packages/eslint-plugin/src/rules/non-nullable-type-assertion-style.ts index b0649d05745..d2973e75808 100644 --- a/packages/eslint-plugin/src/rules/non-nullable-type-assertion-style.ts +++ b/packages/eslint-plugin/src/rules/non-nullable-type-assertion-style.ts @@ -10,7 +10,7 @@ export default util.createRule({ docs: { description: 'Prefers a non-null assertion over explicit type cast when possible', - recommended: false, + recommended: 'strict', requiresTypeChecking: true, suggestion: true, }, diff --git a/packages/eslint-plugin/src/rules/prefer-for-of.ts b/packages/eslint-plugin/src/rules/prefer-for-of.ts index 3355fda2ec6..97c33878acc 100644 --- a/packages/eslint-plugin/src/rules/prefer-for-of.ts +++ b/packages/eslint-plugin/src/rules/prefer-for-of.ts @@ -8,7 +8,7 @@ export default util.createRule({ docs: { description: 'Prefer a ‘for-of’ loop over a standard ‘for’ loop if the index is only used to access the array being iterated', - recommended: false, + recommended: 'strict', }, messages: { preferForOf: diff --git a/packages/eslint-plugin/src/rules/prefer-function-type.ts b/packages/eslint-plugin/src/rules/prefer-function-type.ts index ba5865abfd7..4c4a4812069 100644 --- a/packages/eslint-plugin/src/rules/prefer-function-type.ts +++ b/packages/eslint-plugin/src/rules/prefer-function-type.ts @@ -17,7 +17,7 @@ export default util.createRule({ docs: { description: 'Use function types instead of interfaces with call signatures', - recommended: false, + recommended: 'strict', }, fixable: 'code', messages: { diff --git a/packages/eslint-plugin/src/rules/prefer-includes.ts b/packages/eslint-plugin/src/rules/prefer-includes.ts index 0e12b4ca259..0c07617b9dd 100644 --- a/packages/eslint-plugin/src/rules/prefer-includes.ts +++ b/packages/eslint-plugin/src/rules/prefer-includes.ts @@ -16,7 +16,7 @@ export default createRule({ type: 'suggestion', docs: { description: 'Enforce `includes` method over `indexOf` method', - recommended: false, + recommended: 'strict', requiresTypeChecking: true, }, fixable: 'code', diff --git a/packages/eslint-plugin/src/rules/prefer-literal-enum-member.ts b/packages/eslint-plugin/src/rules/prefer-literal-enum-member.ts index f64482a06f5..17a657d7b25 100644 --- a/packages/eslint-plugin/src/rules/prefer-literal-enum-member.ts +++ b/packages/eslint-plugin/src/rules/prefer-literal-enum-member.ts @@ -8,7 +8,7 @@ export default createRule({ docs: { description: 'Require that all enum members be literal values to prevent unintended enum member name shadow issues', - recommended: false, + recommended: 'strict', requiresTypeChecking: false, }, messages: { diff --git a/packages/eslint-plugin/src/rules/prefer-nullish-coalescing.ts b/packages/eslint-plugin/src/rules/prefer-nullish-coalescing.ts index b492287d4bb..ddb68d90c47 100644 --- a/packages/eslint-plugin/src/rules/prefer-nullish-coalescing.ts +++ b/packages/eslint-plugin/src/rules/prefer-nullish-coalescing.ts @@ -21,7 +21,7 @@ export default util.createRule({ docs: { description: 'Enforce the usage of the nullish coalescing operator instead of logical chaining', - recommended: false, + recommended: 'strict', suggestion: true, requiresTypeChecking: true, }, diff --git a/packages/eslint-plugin/src/rules/prefer-optional-chain.ts b/packages/eslint-plugin/src/rules/prefer-optional-chain.ts index b3815e09ef9..fcf3fa782aa 100644 --- a/packages/eslint-plugin/src/rules/prefer-optional-chain.ts +++ b/packages/eslint-plugin/src/rules/prefer-optional-chain.ts @@ -35,7 +35,7 @@ export default util.createRule({ docs: { description: 'Prefer using concise optional chain expressions instead of chained logical ands', - recommended: false, + recommended: 'strict', suggestion: true, }, hasSuggestions: true, diff --git a/packages/eslint-plugin/src/rules/prefer-reduce-type-parameter.ts b/packages/eslint-plugin/src/rules/prefer-reduce-type-parameter.ts index d9fe3a3071a..d034095a6f8 100644 --- a/packages/eslint-plugin/src/rules/prefer-reduce-type-parameter.ts +++ b/packages/eslint-plugin/src/rules/prefer-reduce-type-parameter.ts @@ -27,9 +27,9 @@ export default util.createRule({ meta: { type: 'problem', docs: { - recommended: false, description: 'Prefer using type parameter when calling `Array#reduce` instead of casting', + recommended: 'strict', requiresTypeChecking: true, }, messages: { diff --git a/packages/eslint-plugin/src/rules/prefer-return-this-type.ts b/packages/eslint-plugin/src/rules/prefer-return-this-type.ts index 0368300bbd6..0766d98efbd 100644 --- a/packages/eslint-plugin/src/rules/prefer-return-this-type.ts +++ b/packages/eslint-plugin/src/rules/prefer-return-this-type.ts @@ -19,7 +19,7 @@ export default createRule({ docs: { description: 'Enforce that `this` is used when only `this` type is returned', - recommended: false, + recommended: 'strict', requiresTypeChecking: true, }, messages: { diff --git a/packages/eslint-plugin/src/rules/prefer-string-starts-ends-with.ts b/packages/eslint-plugin/src/rules/prefer-string-starts-ends-with.ts index 501693efc50..8d95b9a5f2e 100644 --- a/packages/eslint-plugin/src/rules/prefer-string-starts-ends-with.ts +++ b/packages/eslint-plugin/src/rules/prefer-string-starts-ends-with.ts @@ -23,7 +23,7 @@ export default createRule({ docs: { description: 'Enforce the use of `String#startsWith` and `String#endsWith` instead of other equivalent methods of checking substrings', - recommended: false, + recommended: 'strict', requiresTypeChecking: true, }, messages: { diff --git a/packages/eslint-plugin/src/rules/prefer-ts-expect-error.ts b/packages/eslint-plugin/src/rules/prefer-ts-expect-error.ts index 17f1c465f1a..371b063d1d6 100644 --- a/packages/eslint-plugin/src/rules/prefer-ts-expect-error.ts +++ b/packages/eslint-plugin/src/rules/prefer-ts-expect-error.ts @@ -10,7 +10,7 @@ export default util.createRule<[], MessageIds>({ type: 'problem', docs: { description: 'Recommends using `@ts-expect-error` over `@ts-ignore`', - recommended: false, + recommended: 'strict', }, fixable: 'code', messages: { diff --git a/packages/eslint-plugin/src/rules/unified-signatures.ts b/packages/eslint-plugin/src/rules/unified-signatures.ts index 8a261b43c2e..2c88f48a2bd 100644 --- a/packages/eslint-plugin/src/rules/unified-signatures.ts +++ b/packages/eslint-plugin/src/rules/unified-signatures.ts @@ -66,7 +66,7 @@ export default util.createRule({ description: 'Warns for any two overloads that could be unified into one by using a union or an optional/rest parameter', // too opinionated to be recommended - recommended: false, + recommended: 'strict', }, type: 'suggestion', messages: { diff --git a/packages/eslint-plugin/tests/configs.test.ts b/packages/eslint-plugin/tests/configs.test.ts index f8fc068ad64..a7966573027 100644 --- a/packages/eslint-plugin/tests/configs.test.ts +++ b/packages/eslint-plugin/tests/configs.test.ts @@ -68,7 +68,8 @@ describe('recommended.json config', () => { const ruleConfigs = Object.entries(rules) .filter( ([, rule]) => - rule.meta.docs?.recommended !== false && + rule.meta.docs?.recommended && + rule.meta.docs.recommended !== 'strict' && rule.meta.docs?.requiresTypeChecking !== true, ) .map<[string, string]>(([name, rule]) => [ @@ -91,8 +92,9 @@ describe('recommended-requiring-type-checking.json config', () => { const ruleConfigs = Object.entries(rules) .filter( ([, rule]) => - rule.meta.docs?.recommended !== false && - rule.meta.docs?.requiresTypeChecking === true, + rule.meta.docs?.recommended && + rule.meta.docs.recommended !== 'strict' && + rule.meta.docs.requiresTypeChecking === true, ) .map<[string, string]>(([name, rule]) => [ `${RULE_NAME_PREFIX}${name}`, @@ -105,3 +107,18 @@ describe('recommended-requiring-type-checking.json config', () => { itHasBaseRulesOverriden(unfilteredConfigRules); }); + +describe('strict.json config', () => { + const unfilteredConfigRules: Record = + plugin.configs['strict'].rules; + const configRules = filterRules(unfilteredConfigRules); + const ruleConfigs = Object.entries(rules) + .filter(([, rule]) => rule.meta.docs?.recommended === 'strict') + .map<[string, string]>(([name]) => [`${RULE_NAME_PREFIX}${name}`, 'warn']); + + it('contains all recommended rules that require type checking, excluding the deprecated ones', () => { + expect(entriesToObject(ruleConfigs)).toEqual(entriesToObject(configRules)); + }); + + itHasBaseRulesOverriden(unfilteredConfigRules); +}); diff --git a/packages/eslint-plugin/tests/docs.test.ts b/packages/eslint-plugin/tests/docs.test.ts index 0a4761e809a..ca7cc5fbd8f 100644 --- a/packages/eslint-plugin/tests/docs.test.ts +++ b/packages/eslint-plugin/tests/docs.test.ts @@ -1,3 +1,4 @@ +import { TSESLint } from '@typescript-eslint/utils'; import fs from 'fs'; import { JSONSchema4 } from 'json-schema'; import path from 'path'; @@ -93,96 +94,113 @@ describe('Validating rule docs', () => { }); for (const [ruleName, rule] of rulesData) { - const filePath = path.join(docsRoot, `${ruleName}.md`); + describe(ruleName, () => { + const filePath = path.join(docsRoot, `${ruleName}.md`); - it(`First header in ${ruleName}.md must be the name of the rule`, () => { - const tokens = parseMarkdownFile(filePath); + it(`First header in ${ruleName}.md must be the name of the rule`, () => { + const tokens = parseMarkdownFile(filePath); - const header = tokens.find(tokenIsH1)!; + const header = tokens.find(tokenIsH1)!; - expect(header.text).toBe(`\`${ruleName}\``); - }); + expect(header.text).toBe(`\`${ruleName}\``); + }); - it(`Description of ${ruleName}.md must match`, () => { - // validate if description of rule is same as in docs - const tokens = parseMarkdownFile(filePath); + it(`Description of ${ruleName}.md must match`, () => { + // validate if description of rule is same as in docs + const tokens = parseMarkdownFile(filePath); - // Rule title not found. - // Rule title does not match the rule metadata. - expect(tokens[1]).toMatchObject({ - type: 'paragraph', - text: `${rule.meta.docs?.description}.`, + // Rule title not found. + // Rule title does not match the rule metadata. + expect(tokens[1]).toMatchObject({ + type: 'paragraph', + text: `${rule.meta.docs?.description}.`, + }); }); - }); - it(`Headers in ${ruleName}.md must be title-cased`, () => { - const tokens = parseMarkdownFile(filePath); + it(`Headers in ${ruleName}.md must be title-cased`, () => { + const tokens = parseMarkdownFile(filePath); - // Get all H2 headers objects as the other levels are variable by design. - const headers = tokens.filter(tokenIsH2); + // Get all H2 headers objects as the other levels are variable by design. + const headers = tokens.filter(tokenIsH2); - headers.forEach(header => - expect(header.text).toBe(titleCase(header.text)), - ); - }); + headers.forEach(header => + expect(header.text).toBe(titleCase(header.text)), + ); + }); - it(`Options in ${ruleName}.md must match the rule meta`, () => { - // TODO(#4365): We don't yet enforce formatting for all rules. - if ( - !isEmptySchema(rule.meta.schema) || - rule.meta.docs?.extendsBaseRule || - !rule.meta.docs?.recommended - ) { - return; - } + it(`Options in ${ruleName}.md must match the rule meta`, () => { + // TODO(#4365): We don't yet enforce formatting for all rules. + if ( + !isEmptySchema(rule.meta.schema) || + !rule.meta.docs?.recommended || + rule.meta.docs.extendsBaseRule + ) { + return; + } - const tokens = parseMarkdownFile(filePath); + const tokens = parseMarkdownFile(filePath); - const optionsIndex = tokens.findIndex( - token => tokenIsH2(token) && token.text === 'Options', - ); - expect(optionsIndex).toBeGreaterThan(0); + const optionsIndex = tokens.findIndex( + token => tokenIsH2(token) && token.text === 'Options', + ); + expect(optionsIndex).toBeGreaterThan(0); - const codeBlock = tokenAs(tokens[optionsIndex + 1], 'code'); - tokenAs(tokens[optionsIndex + 2], 'space'); - const descriptionBlock = tokenAs(tokens[optionsIndex + 3], 'paragraph'); + const codeBlock = tokenAs(tokens[optionsIndex + 1], 'code'); + tokenAs(tokens[optionsIndex + 2], 'space'); + const descriptionBlock = tokenAs(tokens[optionsIndex + 3], 'paragraph'); - expect(codeBlock).toMatchObject({ - lang: 'jsonc', - text: ` + expect(codeBlock).toMatchObject({ + lang: 'jsonc', + text: ` // .eslintrc.json { "rules": { - "@typescript-eslint/${ruleName}": "${rule.meta.docs?.recommended}" + "@typescript-eslint/${ruleName}": "${ + rule.meta.docs.recommended === 'strict' + ? 'warn' + : rule.meta.docs.recommended + }" } } `.trim(), - type: 'code', + type: 'code', + }); + expect(descriptionBlock).toMatchObject({ + text: 'This rule is not configurable.', + }); }); - expect(descriptionBlock).toMatchObject({ - text: 'This rule is not configurable.', - }); - }); - it(`Attributes in ${ruleName}.md must match the metadata`, () => { - const tokens = parseMarkdownFile(filePath); - - // Verify attributes header exists - const attributesHeaderIndex = tokens.findIndex( - token => tokenIs(token, 'heading') && token.text === 'Attributes', - ); - expect(attributesHeaderIndex).toBeGreaterThan(-1); - - // Verify attributes content - const attributesList = tokenAs(tokens[attributesHeaderIndex + 1], 'list'); - const recommended = attributesList.items[0]; - expect(rule.meta.docs?.recommended !== false).toBe(recommended.checked); - const fixable = attributesList.items[1]; - expect(rule.meta.fixable !== undefined).toBe(fixable.checked); - const requiresTypeChecking = attributesList.items[2]; - expect(rule.meta.docs?.requiresTypeChecking === true).toBe( - requiresTypeChecking.checked, - ); + it(`Attributes in ${ruleName}.md must match the metadata`, () => { + const tokens = parseMarkdownFile(filePath); + + // Verify attributes header exists + const attributesHeaderIndex = tokens.findIndex( + token => tokenIs(token, 'heading') && token.text === 'Attributes', + ); + expect(attributesHeaderIndex).toBeGreaterThan(-1); + + // Verify attributes content... + const attributesList = tokenAs( + tokens[attributesHeaderIndex + 1], + 'list', + ); + // ...starting with configs + const configs = attributesList.items[0]; + expect(configs.text).toMatch(/Configs:\n/); + const configsList = tokenAs(configs.tokens[1], 'list'); + const recommended = configsList.items[0]; + expect(shouldBeRecommended(rule.meta.docs)).toBe(recommended.checked); + const strict = configsList.items[1]; + expect(shouldBeStrict(rule.meta.docs)).toBe(strict.checked); + + // Verify other attributes + const fixable = attributesList.items[1]; + expect(rule.meta.fixable !== undefined).toBe(fixable.checked); + const requiresTypeChecking = attributesList.items[2]; + expect(rule.meta.docs?.requiresTypeChecking === true).toBe( + requiresTypeChecking.checked, + ); + }); }); } }); @@ -274,7 +292,11 @@ describe('Validating README.md', () => { it('Recommended column should be correct', () => { expect(ruleRow[2]).toBe( - rule.meta.docs?.recommended ? ':white_check_mark:' : '', + rule.meta.docs?.recommended === 'strict' + ? ':lock:' + : rule.meta.docs?.recommended + ? ':white_check_mark:' + : '', ); }); @@ -294,3 +316,13 @@ describe('Validating README.md', () => { }); } }); + +function shouldBeRecommended( + docs: TSESLint.RuleMetaDataDocs | undefined, +): boolean { + return docs?.recommended !== false && docs?.recommended !== 'strict'; +} + +function shouldBeStrict(docs: TSESLint.RuleMetaDataDocs | undefined): boolean { + return docs?.recommended !== false; +} diff --git a/packages/eslint-plugin/tools/generate-configs.ts b/packages/eslint-plugin/tools/generate-configs.ts index f1da74b67c7..cd7a8f9b33f 100644 --- a/packages/eslint-plugin/tools/generate-configs.ts +++ b/packages/eslint-plugin/tools/generate-configs.ts @@ -49,8 +49,14 @@ const BASE_RULES_TO_BE_OVERRIDDEN = new Map( ); const EXTENDS = ['./configs/base', './configs/eslint-recommended']; -const ruleEntries: [string, TSESLint.RuleModule][] = - Object.entries(rules).sort((a, b) => a[0].localeCompare(b[0])); +type RuleEntry = [ + string, + TSESLint.RuleModule, +]; + +const ruleEntries: RuleEntry[] = Object.entries(rules).sort((a, b) => + a[0].localeCompare(b[0]), +); /** * Helper function reduces records to key - value pairs. @@ -92,10 +98,13 @@ function reducer( const ruleName = `${RULE_NAME_PREFIX}${key}`; const recommendation = value.meta.docs?.recommended; + const usedSetting = settings.errorLevel ? settings.errorLevel : !recommendation ? DEFAULT_RULE_SETTING + : recommendation === 'strict' + ? 'warn' : recommendation; if (BASE_RULES_TO_BE_OVERRIDDEN.has(key)) { @@ -134,6 +143,19 @@ function writeConfig(config: LinterConfig, filePath: string): void { fs.writeFileSync(filePath, configStr); } +const recommendedValues = new Set([ + 'error', + 'warn', +]); + +function entryIsRecommended(entry: RuleEntry): boolean { + return recommendedValues.has(entry[1].meta.docs?.recommended); +} + +function entryIsStrict(entry: RuleEntry): boolean { + return entry[1].meta.docs?.recommended === 'strict'; +} + const baseConfig: LinterConfig = { parser: '@typescript-eslint/parser', parserOptions: { @@ -162,7 +184,7 @@ console.log( '------------------------------ recommended.ts (should not require program) ------------------------------', ); const recommendedRules = ruleEntries - .filter(entry => !!entry[1].meta.docs?.recommended) + .filter(entryIsRecommended) .reduce( (config, entry) => reducer(config, entry, { @@ -185,7 +207,7 @@ console.log( '--------------------------------- recommended-requiring-type-checking.ts ---------------------------------', ); const recommendedRulesRequiringProgram = ruleEntries - .filter(entry => !!entry[1].meta.docs?.recommended) + .filter(entryIsRecommended) .reduce( (config, entry) => reducer(config, entry, { @@ -205,3 +227,24 @@ writeConfig( '../src/configs/recommended-requiring-type-checking.ts', ), ); + +console.log(); +console.log( + '--------------------------------- strict.ts ---------------------------------', +); +const strictRules = ruleEntries.filter(entryIsStrict).reduce( + (config, entry) => + reducer(config, entry, { + filterDeprecated: false, + }), + {}, +); +const strictConfig: LinterConfig = { + extends: [ + ...EXTENDS, + './configs/recommended', + './configs/recommended-requiring-type-checking', + ], + rules: strictRules, +}; +writeConfig(strictConfig, path.resolve(__dirname, '../src/configs/strict.ts')); diff --git a/packages/eslint-plugin/tools/generate-rules-lists.ts b/packages/eslint-plugin/tools/generate-rules-lists.ts index d508f9e8330..85110db9ab3 100644 --- a/packages/eslint-plugin/tools/generate-rules-lists.ts +++ b/packages/eslint-plugin/tools/generate-rules-lists.ts @@ -6,11 +6,12 @@ import path from 'path'; import rules from '../src/rules'; import prettier from 'prettier'; +import { TSESLint } from '@typescript-eslint/utils'; interface RuleDetails { name: string; description: string; - recommended: boolean; + recommended: TSESLint.RuleRecommendation; fixable: boolean; requiresTypeChecking: boolean; extendsBaseRule: boolean; @@ -19,13 +20,14 @@ interface RuleDetails { type RuleColumn = [ string, string, - ':white_check_mark:' | '', + ':lock:' | ':white_check_mark:' | '', ':wrench:' | '', ':thought_balloon:' | '', ]; const emojiKey = { recommended: ':white_check_mark:', + strict: ':lock:', fixable: ':wrench:', requiresTypeChecking: ':thought_balloon:', } as const; @@ -33,13 +35,14 @@ const emojiKey = { const staticElements = { rulesListKey: [ `**Key**: ${emojiKey.recommended} = recommended`, + `${emojiKey.strict} = strict`, `${emojiKey.fixable} = fixable`, `${emojiKey.requiresTypeChecking} = requires type information`, ].join(', '), listHeaderRow: [ 'Name', 'Description', - emojiKey.recommended, + `${emojiKey.recommended}${emojiKey.strict}`, emojiKey.fixable, emojiKey.requiresTypeChecking, ], @@ -57,7 +60,9 @@ const createRuleLink = (ruleName: string, basePath: string): string => const buildRuleRow = (rule: RuleDetails, basePath: string): RuleColumn => [ createRuleLink(rule.name, basePath), rule.description, - returnEmojiIfTrue('recommended', rule), + rule.recommended === 'strict' + ? emojiKey.strict + : returnEmojiIfTrue('recommended', rule), returnEmojiIfTrue('fixable', rule), returnEmojiIfTrue('requiresTypeChecking', rule), ]; @@ -119,7 +124,7 @@ const rulesDetails: RuleDetails[] = Object.entries(rules) .map(([name, rule]) => ({ name, description: rule.meta.docs?.description ?? '', - recommended: !!rule.meta.docs?.recommended ?? false, + recommended: rule.meta.docs?.recommended ?? false, fixable: !!rule.meta.fixable, requiresTypeChecking: rule.meta.docs?.requiresTypeChecking ?? false, extendsBaseRule: !!rule.meta.docs?.extendsBaseRule ?? false, diff --git a/packages/scope-manager/project.json b/packages/scope-manager/project.json index f60c2fd75a9..7753d267f39 100644 --- a/packages/scope-manager/project.json +++ b/packages/scope-manager/project.json @@ -48,9 +48,7 @@ "options": { "parallel": false, "cwd": "packages/scope-manager", - "commands": [ - "rimraf -g \"./src/**/fixtures/**/snapshots\"" - ] + "commands": ["rimraf -g \"./src/**/fixtures/**/snapshots\""] } }, "lint": { diff --git a/packages/utils/src/ts-eslint/Rule.ts b/packages/utils/src/ts-eslint/Rule.ts index a4a6883146a..25d29bddf11 100644 --- a/packages/utils/src/ts-eslint/Rule.ts +++ b/packages/utils/src/ts-eslint/Rule.ts @@ -5,6 +5,8 @@ import type { Linter } from './Linter'; import type { Scope } from './Scope'; import type { SourceCode } from './SourceCode'; +export type RuleRecommendation = 'error' | 'strict' | 'warn' | false; + interface RuleMetaDataDocs { /** * Concise description of the rule @@ -12,10 +14,10 @@ interface RuleMetaDataDocs { description: string; /** * The recommendation level for the rule. - * Used by the build tools to generate the recommended config. + * Used by the build tools to generate the recommended and strict configs. * Set to false to not include it as a recommendation */ - recommended: 'error' | 'warn' | false; + recommended: 'error' | 'strict' | 'warn' | false; /** * The URL of the rule's docs */ diff --git a/packages/website/sidebars/sidebar.base.js b/packages/website/sidebars/sidebar.base.js index 5d50b266eef..8fbf27e2dc9 100644 --- a/packages/website/sidebars/sidebar.base.js +++ b/packages/website/sidebars/sidebar.base.js @@ -8,6 +8,7 @@ module.exports = { items: [ 'linting/linting', 'linting/type-linting', + 'linting/configs', 'linting/monorepo', 'linting/troubleshooting', 'linting/tslint',