From c2716fcab01e03c4db8d184b4a02ef7fbb276793 Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Sat, 25 Jun 2022 15:36:06 -0400 Subject: [PATCH 1/6] chore(website): generate rule docs h1 and description automatically --- packages/eslint-plugin/docs/rules/TEMPLATE.md | 4 -- .../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 | 4 -- .../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-generic-constructors.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 | 2 - .../rules/no-confusing-non-null-assertion.md | 4 -- .../rules/no-confusing-void-expression.md | 4 -- .../docs/rules/no-dupe-class-members.md | 4 -- .../docs/rules/no-duplicate-enum-values.md | 4 -- .../docs/rules/no-duplicate-imports.md | 4 -- .../docs/rules/no-dynamic-delete.md | 4 -- .../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 | 4 -- .../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 | 4 -- .../docs/rules/no-require-imports.md | 4 -- .../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 | 4 -- .../rules/no-unnecessary-type-arguments.md | 4 -- .../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 | 4 -- .../docs/rules/no-var-requires.md | 4 -- .../non-nullable-type-assertion-style.md | 4 -- .../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 | 4 -- .../eslint-plugin/docs/rules/prefer-for-of.md | 4 -- .../docs/rules/prefer-function-type.md | 4 -- .../docs/rules/prefer-includes.md | 4 -- .../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 | 4 -- .../rules/prefer-readonly-parameter-types.md | 4 -- .../docs/rules/prefer-readonly.md | 4 -- .../rules/prefer-reduce-type-parameter.md | 4 -- .../docs/rules/prefer-regexp-exec.md | 4 -- .../docs/rules/prefer-return-this-type.md | 4 -- .../rules/prefer-string-starts-ends-with.md | 5 -- .../docs/rules/prefer-ts-expect-error.md | 4 -- .../docs/rules/promise-function-async.md | 4 -- packages/eslint-plugin/docs/rules/quotes.md | 4 -- .../docs/rules/require-array-sort-compare.md | 5 -- .../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 | 4 -- .../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 | 7 --- .../docs/rules/unified-signatures.md | 4 -- packages/website/docusaurusConfig.ts | 4 +- .../plugins/add-rule-attributes-list.ts | 38 ------------- .../website/plugins/generated-rule-docs.ts | 55 +++++++++++++++++++ 131 files changed, 57 insertions(+), 555 deletions(-) delete mode 100644 packages/website/plugins/add-rule-attributes-list.ts create mode 100644 packages/website/plugins/generated-rule-docs.ts diff --git a/packages/eslint-plugin/docs/rules/TEMPLATE.md b/packages/eslint-plugin/docs/rules/TEMPLATE.md index 7528ad501a31..0da7b3adedec 100644 --- a/packages/eslint-plugin/docs/rules/TEMPLATE.md +++ b/packages/eslint-plugin/docs/rules/TEMPLATE.md @@ -1,7 +1,3 @@ -# `your-rule-name` - -Your rule description here. - ## Rule Details To fill out: tell us more about this rule. diff --git a/packages/eslint-plugin/docs/rules/adjacent-overload-signatures.md b/packages/eslint-plugin/docs/rules/adjacent-overload-signatures.md index a30dfe06142e..87c0705bb18f 100644 --- a/packages/eslint-plugin/docs/rules/adjacent-overload-signatures.md +++ b/packages/eslint-plugin/docs/rules/adjacent-overload-signatures.md @@ -1,7 +1,3 @@ -# `adjacent-overload-signatures` - -Requires that member overloads be consecutive. - Grouping overloaded members together can improve readability of the code. ## Rule Details diff --git a/packages/eslint-plugin/docs/rules/array-type.md b/packages/eslint-plugin/docs/rules/array-type.md index 1e0ea89327dc..b56a7e4a93f8 100644 --- a/packages/eslint-plugin/docs/rules/array-type.md +++ b/packages/eslint-plugin/docs/rules/array-type.md @@ -1,7 +1,3 @@ -# `array-type` - -Requires using either `T[]` or `Array` for arrays. - Using the same style for array definitions across your codebase makes it easier for your developers to read and understand the types. ## Rule Details diff --git a/packages/eslint-plugin/docs/rules/await-thenable.md b/packages/eslint-plugin/docs/rules/await-thenable.md index 4a2398719275..d6de2c65f6ec 100644 --- a/packages/eslint-plugin/docs/rules/await-thenable.md +++ b/packages/eslint-plugin/docs/rules/await-thenable.md @@ -1,7 +1,3 @@ -# `await-thenable` - -Disallows awaiting a value that is not a Thenable. - This rule disallows awaiting a value that is not a "Thenable" (an object which has `then` method, such as a Promise). While it is valid JavaScript to await a non-`Promise`-like value (it will resolve immediately), this pattern is often a programmer error, such as forgetting to add parenthesis to call a function that returns a Promise. diff --git a/packages/eslint-plugin/docs/rules/ban-ts-comment.md b/packages/eslint-plugin/docs/rules/ban-ts-comment.md index 8ee73654e994..559acc21c2ec 100644 --- a/packages/eslint-plugin/docs/rules/ban-ts-comment.md +++ b/packages/eslint-plugin/docs/rules/ban-ts-comment.md @@ -1,7 +1,3 @@ -# `ban-ts-comment` - -Disallows `@ts-` comments or requires descriptions after directive. - TypeScript provides several directive comments that can be used to alter how it processes files. Using these to suppress TypeScript Compiler Errors reduces the effectiveness of TypeScript overall. diff --git a/packages/eslint-plugin/docs/rules/ban-tslint-comment.md b/packages/eslint-plugin/docs/rules/ban-tslint-comment.md index b89e9929167a..aff145cc300f 100644 --- a/packages/eslint-plugin/docs/rules/ban-tslint-comment.md +++ b/packages/eslint-plugin/docs/rules/ban-tslint-comment.md @@ -1,7 +1,3 @@ -# `ban-tslint-comment` - -Disallows `// tslint:` comments. - Useful when migrating from TSLint to ESLint. Once TSLint has been removed, this rule helps locate TSLint annotations (e.g. `// tslint:disable`). ## Rule Details diff --git a/packages/eslint-plugin/docs/rules/ban-types.md b/packages/eslint-plugin/docs/rules/ban-types.md index b5dc1b0e33cd..f8f5a8d87c4d 100644 --- a/packages/eslint-plugin/docs/rules/ban-types.md +++ b/packages/eslint-plugin/docs/rules/ban-types.md @@ -1,7 +1,3 @@ -# `ban-types` - -Disallows certain types. - Some builtin types have aliases, some types are considered dangerous or harmful. It's often a good idea to ban certain types to help with consistency and safety. diff --git a/packages/eslint-plugin/docs/rules/brace-style.md b/packages/eslint-plugin/docs/rules/brace-style.md index a21884184608..641bf15cb0dc 100644 --- a/packages/eslint-plugin/docs/rules/brace-style.md +++ b/packages/eslint-plugin/docs/rules/brace-style.md @@ -1,7 +1,3 @@ -# `brace-style` - -Enforces consistent brace style for blocks. - ## Rule Details This rule extends the base [`eslint/brace-style`](https://eslint.org/docs/rules/brace-style) rule. 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 afbdc96fc187..f1e997a58dd4 100644 --- a/packages/eslint-plugin/docs/rules/class-literal-property-style.md +++ b/packages/eslint-plugin/docs/rules/class-literal-property-style.md @@ -1,7 +1,3 @@ -# `class-literal-property-style` - -Enforces that literals on classes are exposed in a consistent style. - When writing TypeScript applications, it's typically safe to store literal values on classes using fields with the `readonly` modifier to prevent them from being reassigned. When writing TypeScript libraries that could be used by JavaScript users however, it's typically safer to expose these literals using `getter`s, since the `readonly` modifier is enforced at compile type. diff --git a/packages/eslint-plugin/docs/rules/comma-dangle.md b/packages/eslint-plugin/docs/rules/comma-dangle.md index f18992fff775..8acebcdb9f82 100644 --- a/packages/eslint-plugin/docs/rules/comma-dangle.md +++ b/packages/eslint-plugin/docs/rules/comma-dangle.md @@ -1,7 +1,3 @@ -# `comma-dangle` - -Requires or disallows trailing commas. - ## Rule Details This rule extends the base [`eslint/comma-dangle`](https://eslint.org/docs/rules/comma-dangle) rule. diff --git a/packages/eslint-plugin/docs/rules/comma-spacing.md b/packages/eslint-plugin/docs/rules/comma-spacing.md index 7fa6056759dc..507923299d48 100644 --- a/packages/eslint-plugin/docs/rules/comma-spacing.md +++ b/packages/eslint-plugin/docs/rules/comma-spacing.md @@ -1,7 +1,3 @@ -# `comma-spacing` - -Enforces consistent spacing before and after commas. - ## Rule Details This rule extends the base [`eslint/comma-spacing`](https://eslint.org/docs/rules/comma-spacing) rule. diff --git a/packages/eslint-plugin/docs/rules/consistent-generic-constructors.md b/packages/eslint-plugin/docs/rules/consistent-generic-constructors.md index db717dbcbd3d..21737c3b2087 100644 --- a/packages/eslint-plugin/docs/rules/consistent-generic-constructors.md +++ b/packages/eslint-plugin/docs/rules/consistent-generic-constructors.md @@ -1,7 +1,3 @@ -# `consistent-generic-constructors` - -Enforces specifying generic type arguments on type annotation or constructor name of a constructor call. - When constructing a generic class, you can specify the type arguments on either the left-hand side (as a type annotation) or the right-hand side (as part of the constructor call): ```ts 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 f61a4f68fdde..350065a5a0a5 100644 --- a/packages/eslint-plugin/docs/rules/consistent-indexed-object-style.md +++ b/packages/eslint-plugin/docs/rules/consistent-indexed-object-style.md @@ -1,7 +1,3 @@ -# `consistent-indexed-object-style` - -Requires or disallows the `Record` type. - TypeScript supports defining object show keys can be flexible using an index signature. TypeScript also has a builtin type named `Record` to create an empty object defining only an index signature. For example, the following types are equal: ```ts diff --git a/packages/eslint-plugin/docs/rules/consistent-type-assertions.md b/packages/eslint-plugin/docs/rules/consistent-type-assertions.md index 7e1d4d0487c8..361feb26c38c 100644 --- a/packages/eslint-plugin/docs/rules/consistent-type-assertions.md +++ b/packages/eslint-plugin/docs/rules/consistent-type-assertions.md @@ -1,7 +1,3 @@ -# `consistent-type-assertions` - -Enforces consistent usage of type assertions. - ## Rule Details This rule aims to standardize the use of type assertion style across the codebase. diff --git a/packages/eslint-plugin/docs/rules/consistent-type-definitions.md b/packages/eslint-plugin/docs/rules/consistent-type-definitions.md index 1df12bcde43f..60e539e5ef12 100644 --- a/packages/eslint-plugin/docs/rules/consistent-type-definitions.md +++ b/packages/eslint-plugin/docs/rules/consistent-type-definitions.md @@ -1,7 +1,3 @@ -# `consistent-type-definitions` - -Enforces type definitions to consistently use either `interface` or `type`. - There are two ways to define a type. ```ts diff --git a/packages/eslint-plugin/docs/rules/consistent-type-exports.md b/packages/eslint-plugin/docs/rules/consistent-type-exports.md index bd10a616261c..f668a1d97614 100644 --- a/packages/eslint-plugin/docs/rules/consistent-type-exports.md +++ b/packages/eslint-plugin/docs/rules/consistent-type-exports.md @@ -1,7 +1,3 @@ -# `consistent-type-exports` - -Enforces consistent usage of type exports. - TypeScript 3.8 added support for type-only exports. Type-only exports allow you to specify that 1 or more named exports are exported as type-only. This allows diff --git a/packages/eslint-plugin/docs/rules/consistent-type-imports.md b/packages/eslint-plugin/docs/rules/consistent-type-imports.md index 47022b04ec57..c2722d348e49 100644 --- a/packages/eslint-plugin/docs/rules/consistent-type-imports.md +++ b/packages/eslint-plugin/docs/rules/consistent-type-imports.md @@ -1,7 +1,3 @@ -# `consistent-type-imports` - -Enforces consistent usage of type imports. - TypeScript 3.8 added support for type-only imports. Type-only imports allow you to specify that an import can only be used in a type location, allowing certain optimizations within compilers. diff --git a/packages/eslint-plugin/docs/rules/default-param-last.md b/packages/eslint-plugin/docs/rules/default-param-last.md index 5db33411d1d5..f1134510a827 100644 --- a/packages/eslint-plugin/docs/rules/default-param-last.md +++ b/packages/eslint-plugin/docs/rules/default-param-last.md @@ -1,7 +1,3 @@ -# `default-param-last` - -Enforces default parameters to be last. - ## Rule Details This rule extends the base [`eslint/default-param-last`](https://eslint.org/docs/rules/default-param-last) rule. diff --git a/packages/eslint-plugin/docs/rules/dot-notation.md b/packages/eslint-plugin/docs/rules/dot-notation.md index 414170416846..fa137cb6d940 100644 --- a/packages/eslint-plugin/docs/rules/dot-notation.md +++ b/packages/eslint-plugin/docs/rules/dot-notation.md @@ -1,7 +1,3 @@ -# `dot-notation` - -Enforces dot notation whenever possible. - ## Rule Details This rule extends the base [`eslint/dot-notation`](https://eslint.org/docs/rules/dot-notation) rule. 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 9e3ff78a3665..6e2a343cadc0 100644 --- a/packages/eslint-plugin/docs/rules/explicit-function-return-type.md +++ b/packages/eslint-plugin/docs/rules/explicit-function-return-type.md @@ -1,7 +1,3 @@ -# `explicit-function-return-type` - -Requires explicit return types on functions and class methods. - Explicit types for function return values makes it clear to any calling code what type is returned. This ensures that the return value is assigned to a variable of the correct type; or in the case where there is no return value, that the calling code doesn't try to use the undefined value when it diff --git a/packages/eslint-plugin/docs/rules/explicit-member-accessibility.md b/packages/eslint-plugin/docs/rules/explicit-member-accessibility.md index 4b41a1327eda..a9b6c94b3f72 100644 --- a/packages/eslint-plugin/docs/rules/explicit-member-accessibility.md +++ b/packages/eslint-plugin/docs/rules/explicit-member-accessibility.md @@ -1,7 +1,3 @@ -# `explicit-member-accessibility` - -Requires explicit accessibility modifiers on class properties and methods. - Leaving off accessibility modifier and making everything public can make your interface hard to use by others. If you make all internal pieces private or protected, your interface will 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 b25350b60b97..d47241e9c3b9 100644 --- a/packages/eslint-plugin/docs/rules/explicit-module-boundary-types.md +++ b/packages/eslint-plugin/docs/rules/explicit-module-boundary-types.md @@ -1,7 +1,3 @@ -# `explicit-module-boundary-types` - -Requires explicit return and argument types on exported functions' and classes' public class methods. - Explicit types for function return values and arguments makes it clear to any calling code what is the module boundary's input and output. ## Rule Details diff --git a/packages/eslint-plugin/docs/rules/func-call-spacing.md b/packages/eslint-plugin/docs/rules/func-call-spacing.md index 88b73e2eda25..94c2ebcf4d41 100644 --- a/packages/eslint-plugin/docs/rules/func-call-spacing.md +++ b/packages/eslint-plugin/docs/rules/func-call-spacing.md @@ -1,7 +1,3 @@ -# `func-call-spacing` - -Requires or disallows spacing between function identifiers and their invocations. - ## Rule Details This rule extends the base [`eslint/func-call-spacing`](https://eslint.org/docs/rules/func-call-spacing) rule. diff --git a/packages/eslint-plugin/docs/rules/indent.md b/packages/eslint-plugin/docs/rules/indent.md index 5d732a305bf4..6c12e5b84b1d 100644 --- a/packages/eslint-plugin/docs/rules/indent.md +++ b/packages/eslint-plugin/docs/rules/indent.md @@ -1,7 +1,3 @@ -# `indent` - -Enforces consistent indentation. - ## Warning PLEASE READ THIS ISSUE BEFORE USING THIS RULE [#1824](https://github.com/typescript-eslint/typescript-eslint/issues/1824) diff --git a/packages/eslint-plugin/docs/rules/init-declarations.md b/packages/eslint-plugin/docs/rules/init-declarations.md index 6a4ce4786512..e730b3ec1ce2 100644 --- a/packages/eslint-plugin/docs/rules/init-declarations.md +++ b/packages/eslint-plugin/docs/rules/init-declarations.md @@ -1,7 +1,3 @@ -# `init-declarations` - -Requires or disallows initialization in variable declarations. - ## Rule Details This rule extends the base [`eslint/init-declarations`](https://eslint.org/docs/rules/init-declarations) rule. diff --git a/packages/eslint-plugin/docs/rules/keyword-spacing.md b/packages/eslint-plugin/docs/rules/keyword-spacing.md index 4b9b386b940f..8ae810a56e05 100644 --- a/packages/eslint-plugin/docs/rules/keyword-spacing.md +++ b/packages/eslint-plugin/docs/rules/keyword-spacing.md @@ -1,7 +1,3 @@ -# `keyword-spacing` - -Enforces consistent spacing before and after keywords. - ## Rule Details This rule extends the base [`eslint/keyword-spacing`](https://eslint.org/docs/rules/keyword-spacing) rule. 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 8a68abe9cda1..1a73d9b1a791 100644 --- a/packages/eslint-plugin/docs/rules/lines-between-class-members.md +++ b/packages/eslint-plugin/docs/rules/lines-between-class-members.md @@ -1,7 +1,3 @@ -# `lines-between-class-members` - -Requires or disallows an empty line between class members. - This rule improves readability by enforcing lines between class members. It will not check empty lines before the first member and after the last member. This rule require or disallow an empty line between class members. ## Rule Details diff --git a/packages/eslint-plugin/docs/rules/member-delimiter-style.md b/packages/eslint-plugin/docs/rules/member-delimiter-style.md index 858d3777d069..36b3a20195e9 100644 --- a/packages/eslint-plugin/docs/rules/member-delimiter-style.md +++ b/packages/eslint-plugin/docs/rules/member-delimiter-style.md @@ -1,7 +1,3 @@ -# `member-delimiter-style` - -Requires a specific member delimiter style for interfaces and type literals. - Enforces a consistent member delimiter style in interfaces and type literals. There are three member delimiter styles primarily used in TypeScript: - Semicolon style (default, preferred in TypeScript). diff --git a/packages/eslint-plugin/docs/rules/member-ordering.md b/packages/eslint-plugin/docs/rules/member-ordering.md index aacc062008f9..d482ef0c5beb 100644 --- a/packages/eslint-plugin/docs/rules/member-ordering.md +++ b/packages/eslint-plugin/docs/rules/member-ordering.md @@ -1,7 +1,3 @@ -# `member-ordering` - -Requires a consistent member declaration order. - A consistent ordering of fields, methods and constructors can make interfaces, type literals, classes and class expressions easier to read, navigate, and edit. ## Rule Details diff --git a/packages/eslint-plugin/docs/rules/method-signature-style.md b/packages/eslint-plugin/docs/rules/method-signature-style.md index 53a6d3e17a02..1e5094ca5d45 100644 --- a/packages/eslint-plugin/docs/rules/method-signature-style.md +++ b/packages/eslint-plugin/docs/rules/method-signature-style.md @@ -1,7 +1,3 @@ -# `method-signature-style` - -Enforces using a particular method signature syntax. - There are two ways to define an object/interface function property. ```ts diff --git a/packages/eslint-plugin/docs/rules/naming-convention.md b/packages/eslint-plugin/docs/rules/naming-convention.md index 9032119ca40d..7ad9177be0a5 100644 --- a/packages/eslint-plugin/docs/rules/naming-convention.md +++ b/packages/eslint-plugin/docs/rules/naming-convention.md @@ -1,7 +1,3 @@ -# `naming-convention` - -Enforces naming conventions for everything across a codebase. - Enforcing naming conventions helps keep the codebase consistent, and reduces overhead when thinking about how to name a variable. Additionally, a well-designed style guide can help communicate intent, such as by enforcing all private properties begin with an `_`, and all global-level constants are written in `UPPER_CASE`. diff --git a/packages/eslint-plugin/docs/rules/no-array-constructor.md b/packages/eslint-plugin/docs/rules/no-array-constructor.md index 01fd843caf16..534208b844b3 100644 --- a/packages/eslint-plugin/docs/rules/no-array-constructor.md +++ b/packages/eslint-plugin/docs/rules/no-array-constructor.md @@ -1,7 +1,3 @@ -# `no-array-constructor` - -Disallows generic `Array` constructors. - ## Rule Details This rule extends the base [`eslint/no-array-constructor`](https://eslint.org/docs/rules/no-array-constructor) rule. 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 1e5cd41c94aa..e5fcffc6bdbe 100644 --- a/packages/eslint-plugin/docs/rules/no-base-to-string.md +++ b/packages/eslint-plugin/docs/rules/no-base-to-string.md @@ -1,5 +1,3 @@ -# `no-base-to-string` - Requires `.toString()` to only be called on objects which provide useful information when stringified. JavaScript will call `toString()` on an object when it is converted to a string, such as when `+` adding to a string or in `${}` template literals. 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 77d11f68d211..9c077af2d8d6 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 @@ -1,7 +1,3 @@ -# `no-confusing-non-null-assertion` - -Disallows non-null assertion in locations that may be confusing. - ## Rule Details Using a non-null assertion (`!`) next to an assign or equals check (`=` or `==` or `===`) creates code that is confusing as it looks similar to a not equals check (`!=` `!==`). 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 8589e65d4c19..a1a6d744f6b4 100644 --- a/packages/eslint-plugin/docs/rules/no-confusing-void-expression.md +++ b/packages/eslint-plugin/docs/rules/no-confusing-void-expression.md @@ -1,7 +1,3 @@ -# `no-confusing-void-expression` - -Requires expressions of type void to appear in statement position. - Returning the results of an expression whose type is void can be misleading. Attempting to do so is likely a symptom of expecting a different return type from a function. Even if used correctly, it can be misleading for other developers, 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 e31b8548c660..2d9e92431538 100644 --- a/packages/eslint-plugin/docs/rules/no-dupe-class-members.md +++ b/packages/eslint-plugin/docs/rules/no-dupe-class-members.md @@ -1,7 +1,3 @@ -# `no-dupe-class-members` - -Disallows duplicate class members. - ## Rule Details This rule extends the base [`eslint/no-dupe-class-members`](https://eslint.org/docs/rules/no-dupe-class-members) rule. 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 6b69d540c55f..ea723158974c 100644 --- a/packages/eslint-plugin/docs/rules/no-duplicate-enum-values.md +++ b/packages/eslint-plugin/docs/rules/no-duplicate-enum-values.md @@ -1,7 +1,3 @@ -# `no-duplicate-enum-values` - -Disallows duplicate enum member values. - Although TypeScript supports duplicate enum member values, people usually expect members to have unique values within the same enum. Duplicate values can lead to bugs that are hard to track down. ## Rule Details diff --git a/packages/eslint-plugin/docs/rules/no-duplicate-imports.md b/packages/eslint-plugin/docs/rules/no-duplicate-imports.md index 90ab3da41235..67b53b8fe8ed 100644 --- a/packages/eslint-plugin/docs/rules/no-duplicate-imports.md +++ b/packages/eslint-plugin/docs/rules/no-duplicate-imports.md @@ -1,7 +1,3 @@ -# `no-duplicate-imports` - -Disallows duplicate imports. - ## DEPRECATED This rule has been deprecated in favour of the [`import/no-duplicates`](https://github.com/import-js/eslint-plugin-import/blob/HEAD/docs/rules/no-duplicates.md) rule. diff --git a/packages/eslint-plugin/docs/rules/no-dynamic-delete.md b/packages/eslint-plugin/docs/rules/no-dynamic-delete.md index e0c590a9de97..7d9a9f7005e2 100644 --- a/packages/eslint-plugin/docs/rules/no-dynamic-delete.md +++ b/packages/eslint-plugin/docs/rules/no-dynamic-delete.md @@ -1,7 +1,3 @@ -# `no-dynamic-delete` - -Disallows using the `delete` operator on computed key expressions. - Deleting dynamically computed keys can be dangerous and in some cases not well optimized. ## Rule Details diff --git a/packages/eslint-plugin/docs/rules/no-empty-function.md b/packages/eslint-plugin/docs/rules/no-empty-function.md index e23cc10bdd43..60801436bc49 100644 --- a/packages/eslint-plugin/docs/rules/no-empty-function.md +++ b/packages/eslint-plugin/docs/rules/no-empty-function.md @@ -1,7 +1,3 @@ -# `no-empty-function` - -Disallows empty functions. - ## Rule Details This rule extends the base [`eslint/no-empty-function`](https://eslint.org/docs/rules/no-empty-function) rule. diff --git a/packages/eslint-plugin/docs/rules/no-empty-interface.md b/packages/eslint-plugin/docs/rules/no-empty-interface.md index c9e36a528b1c..409acea106cd 100644 --- a/packages/eslint-plugin/docs/rules/no-empty-interface.md +++ b/packages/eslint-plugin/docs/rules/no-empty-interface.md @@ -1,7 +1,3 @@ -# `no-empty-interface` - -Disallows the declaration of empty interfaces. - An empty interface is equivalent to its supertype. If the interface does not implement a supertype, then the interface is equivalent to an empty object (`{}`). In both cases it can be omitted. diff --git a/packages/eslint-plugin/docs/rules/no-explicit-any.md b/packages/eslint-plugin/docs/rules/no-explicit-any.md index ebf043104986..cf2cefb78568 100644 --- a/packages/eslint-plugin/docs/rules/no-explicit-any.md +++ b/packages/eslint-plugin/docs/rules/no-explicit-any.md @@ -1,7 +1,3 @@ -# `no-explicit-any` - -Disallows the `any` type. - Using the `any` type defeats the purpose of using TypeScript. When `any` is used, all compiler type checks around that value are ignored. 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 43cfacf756ff..e038a5f00212 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 @@ -1,7 +1,3 @@ -# `no-extra-non-null-assertion` - -Disallows extra non-null assertion. - ## Rule Details Examples of code for this rule: diff --git a/packages/eslint-plugin/docs/rules/no-extra-parens.md b/packages/eslint-plugin/docs/rules/no-extra-parens.md index f123b70d1417..5eace5e8eded 100644 --- a/packages/eslint-plugin/docs/rules/no-extra-parens.md +++ b/packages/eslint-plugin/docs/rules/no-extra-parens.md @@ -1,7 +1,3 @@ -# `no-extra-parens` - -Disallows unnecessary parentheses. - ## Rule Details This rule extends the base [`eslint/no-extra-parens`](https://eslint.org/docs/rules/no-extra-parens) rule. diff --git a/packages/eslint-plugin/docs/rules/no-extra-semi.md b/packages/eslint-plugin/docs/rules/no-extra-semi.md index b0649081b5c3..b8fa04c6db70 100644 --- a/packages/eslint-plugin/docs/rules/no-extra-semi.md +++ b/packages/eslint-plugin/docs/rules/no-extra-semi.md @@ -1,7 +1,3 @@ -# `no-extra-semi` - -Disallows unnecessary semicolons. - ## Rule Details This rule extends the base [`eslint/no-extra-semi`](https://eslint.org/docs/rules/no-extra-semi) rule. diff --git a/packages/eslint-plugin/docs/rules/no-extraneous-class.md b/packages/eslint-plugin/docs/rules/no-extraneous-class.md index e1697254ef91..0a9b698868a9 100644 --- a/packages/eslint-plugin/docs/rules/no-extraneous-class.md +++ b/packages/eslint-plugin/docs/rules/no-extraneous-class.md @@ -1,7 +1,3 @@ -# `no-extraneous-class` - -Disallows classes used as namespaces. - This rule warns when a class has no non-static members, such as for a class used exclusively as a static namespace. ## Rule Details diff --git a/packages/eslint-plugin/docs/rules/no-floating-promises.md b/packages/eslint-plugin/docs/rules/no-floating-promises.md index 1df8ea23c72b..0feb4cfe72ce 100644 --- a/packages/eslint-plugin/docs/rules/no-floating-promises.md +++ b/packages/eslint-plugin/docs/rules/no-floating-promises.md @@ -1,7 +1,3 @@ -# `no-floating-promises` - -Requires Promise-like statements to be handled appropriately. - A "floating" Promise is one that is created without any code set up to handle any errors it might throw. Floating Promises can cause several issues, such as improperly sequenced operations, ignored Promise rejections, and more. 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 bcc51aa1660a..b054549984b2 100644 --- a/packages/eslint-plugin/docs/rules/no-for-in-array.md +++ b/packages/eslint-plugin/docs/rules/no-for-in-array.md @@ -1,7 +1,3 @@ -# `no-for-in-array` - -Disallows iterating over an array with a for-in loop. - This rule prohibits iterating over an array with a for-in loop. ## Rule Details 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 40530896835c..9b03128039e1 100644 --- a/packages/eslint-plugin/docs/rules/no-implicit-any-catch.md +++ b/packages/eslint-plugin/docs/rules/no-implicit-any-catch.md @@ -1,7 +1,3 @@ -# `no-implicit-any-catch` - -Disallows usage of the implicit `any` type in catch clauses. - TypeScript 4.0 added support for adding an explicit `any` or `unknown` type annotation on a catch clause variable. By default, TypeScript will type a catch clause variable as `any`, so explicitly annotating it as `unknown` can add a lot of safety to your codebase. diff --git a/packages/eslint-plugin/docs/rules/no-implied-eval.md b/packages/eslint-plugin/docs/rules/no-implied-eval.md index d39a6f70609f..2ef6560950fa 100644 --- a/packages/eslint-plugin/docs/rules/no-implied-eval.md +++ b/packages/eslint-plugin/docs/rules/no-implied-eval.md @@ -1,7 +1,3 @@ -# `no-implied-eval` - -Disallows the use of `eval()`-like methods. - It's considered a good practice to avoid using `eval()`. There are security and performance implications involved with doing so, which is why many linters recommend disallowing `eval()`. However, there are some other ways to pass a string and have it interpreted as JavaScript code that have similar concerns. The first is using `setTimeout()`, `setInterval()`, `setImmediate` or `execScript()` (Internet Explorer only), all of which can accept a string of code as their first argument diff --git a/packages/eslint-plugin/docs/rules/no-inferrable-types.md b/packages/eslint-plugin/docs/rules/no-inferrable-types.md index 137d6c558bef..cfcd4f6281f1 100644 --- a/packages/eslint-plugin/docs/rules/no-inferrable-types.md +++ b/packages/eslint-plugin/docs/rules/no-inferrable-types.md @@ -1,7 +1,3 @@ -# `no-inferrable-types` - -Disallows explicit type declarations for variables or parameters initialized to a number, string, or boolean. - Explicit types where they can be easily inferred may add unnecessary verbosity. ## Rule Details diff --git a/packages/eslint-plugin/docs/rules/no-invalid-this.md b/packages/eslint-plugin/docs/rules/no-invalid-this.md index 5061e60559d1..37c468db8400 100644 --- a/packages/eslint-plugin/docs/rules/no-invalid-this.md +++ b/packages/eslint-plugin/docs/rules/no-invalid-this.md @@ -1,7 +1,3 @@ -# `no-invalid-this` - -Disallows `this` keywords outside of classes or class-like objects. - ## Rule Details This rule extends the base [`eslint/no-invalid-this`](https://eslint.org/docs/rules/no-invalid-this) rule. 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 928fc6152970..bf94bd58b39b 100644 --- a/packages/eslint-plugin/docs/rules/no-invalid-void-type.md +++ b/packages/eslint-plugin/docs/rules/no-invalid-void-type.md @@ -1,7 +1,3 @@ -# `no-invalid-void-type` - -Disallows `void` type outside of generic or return types. - Disallows usage of `void` type outside of return types or generic type arguments. If `void` is used as return type, it shouldn’t be a part of intersection/union type with most other types. diff --git a/packages/eslint-plugin/docs/rules/no-loop-func.md b/packages/eslint-plugin/docs/rules/no-loop-func.md index 890bd80ecc06..d40d8a1aa8d2 100644 --- a/packages/eslint-plugin/docs/rules/no-loop-func.md +++ b/packages/eslint-plugin/docs/rules/no-loop-func.md @@ -1,7 +1,3 @@ -# `no-loop-func` - -Disallows function declarations that contain unsafe references inside loop statements. - ## Rule Details This rule extends the base [`eslint/no-loop-func`](https://eslint.org/docs/rules/no-loop-func) rule. 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 a27701afdfba..e4906b87b320 100644 --- a/packages/eslint-plugin/docs/rules/no-loss-of-precision.md +++ b/packages/eslint-plugin/docs/rules/no-loss-of-precision.md @@ -1,7 +1,3 @@ -# `no-loss-of-precision` - -Disallows literal numbers that lose precision. - ## Rule Details This rule extends the base [`eslint/no-loss-of-precision`](https://eslint.org/docs/rules/no-loss-of-precision) rule. diff --git a/packages/eslint-plugin/docs/rules/no-magic-numbers.md b/packages/eslint-plugin/docs/rules/no-magic-numbers.md index e5edc2e280d0..c367e370ee33 100644 --- a/packages/eslint-plugin/docs/rules/no-magic-numbers.md +++ b/packages/eslint-plugin/docs/rules/no-magic-numbers.md @@ -1,7 +1,3 @@ -# `no-magic-numbers` - -Disallows magic numbers. - ## Rule Details This rule extends the base [`eslint/no-magic-numbers`](https://eslint.org/docs/rules/no-magic-numbers) rule. 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 fa348f30808d..6a664ef6862b 100644 --- a/packages/eslint-plugin/docs/rules/no-meaningless-void-operator.md +++ b/packages/eslint-plugin/docs/rules/no-meaningless-void-operator.md @@ -1,7 +1,3 @@ -# `no-meaningless-void-operator` - -Disallows the `void` operator except when used to discard a value. - Disallows the `void` operator when its argument is already of type `void` or `undefined`. ## Rule Details diff --git a/packages/eslint-plugin/docs/rules/no-misused-new.md b/packages/eslint-plugin/docs/rules/no-misused-new.md index 10d0470f67bf..250b02d49893 100644 --- a/packages/eslint-plugin/docs/rules/no-misused-new.md +++ b/packages/eslint-plugin/docs/rules/no-misused-new.md @@ -1,7 +1,3 @@ -# `no-misused-new` - -Enforces valid definition of `new` and `constructor`. - Warns on apparent attempts to define constructors for interfaces or `new` for classes. ## Rule Details diff --git a/packages/eslint-plugin/docs/rules/no-misused-promises.md b/packages/eslint-plugin/docs/rules/no-misused-promises.md index f3e67234c6fe..4e5bdcb32e68 100644 --- a/packages/eslint-plugin/docs/rules/no-misused-promises.md +++ b/packages/eslint-plugin/docs/rules/no-misused-promises.md @@ -1,7 +1,3 @@ -# `no-misused-promises` - -Disallows Promises in places not designed to handle them. - This rule forbids providing Promises to logical locations such as if statements in places where the TypeScript compiler allows them but they are not handled properly. These situations can often arise due to a missing `await` keyword or just a misunderstanding of the way async functions are handled/awaited. diff --git a/packages/eslint-plugin/docs/rules/no-namespace.md b/packages/eslint-plugin/docs/rules/no-namespace.md index e1e83fd1c7e5..ec0fe6af3805 100644 --- a/packages/eslint-plugin/docs/rules/no-namespace.md +++ b/packages/eslint-plugin/docs/rules/no-namespace.md @@ -1,7 +1,3 @@ -# `no-namespace` - -Disallows custom TypeScript modules and namespaces. - Custom TypeScript modules (`module foo {}`) and namespaces (`namespace foo {}`) are considered outdated ways to organize TypeScript code. ES2015 module syntax is now preferred (`import`/`export`). 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 29eac71f2f4e..659658349e8e 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 @@ -1,7 +1,3 @@ -# `no-non-null-asserted-nullish-coalescing` - -Disallows non-null assertions in the left operand of a nullish coalescing operator. - ## Rule Details The nullish coalescing operator is designed to provide a default value when dealing with `null` or `undefined`. 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 0913824ef8b7..8dcb92b0e6bc 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 @@ -1,7 +1,3 @@ -# `no-non-null-asserted-optional-chain` - -Disallows non-null assertions after an optional chain expression. - ## Rule Details Optional chain expressions are designed to return `undefined` if the optional property is nullish. 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 a28c07112a58..42059d843645 100644 --- a/packages/eslint-plugin/docs/rules/no-non-null-assertion.md +++ b/packages/eslint-plugin/docs/rules/no-non-null-assertion.md @@ -1,7 +1,3 @@ -# `no-non-null-assertion` - -Disallows non-null assertions using the `!` postfix operator. - ## Rule Details Using non-null assertions cancels the benefits of the strict null-checking mode. diff --git a/packages/eslint-plugin/docs/rules/no-parameter-properties.md b/packages/eslint-plugin/docs/rules/no-parameter-properties.md index 3ff367fb2e2b..7b5f772df1ca 100644 --- a/packages/eslint-plugin/docs/rules/no-parameter-properties.md +++ b/packages/eslint-plugin/docs/rules/no-parameter-properties.md @@ -1,7 +1,3 @@ -# `no-parameter-properties` - -Disallows the use of parameter properties in class constructors. - Parameter properties can be confusing to those new to TypeScript as they are less explicit than other ways of declaring and initializing class members. diff --git a/packages/eslint-plugin/docs/rules/no-redeclare.md b/packages/eslint-plugin/docs/rules/no-redeclare.md index 6ddb0d6d7302..b69f50f3f981 100644 --- a/packages/eslint-plugin/docs/rules/no-redeclare.md +++ b/packages/eslint-plugin/docs/rules/no-redeclare.md @@ -1,7 +1,3 @@ -# `no-redeclare` - -Disallows variable redeclaration. - ## Rule Details This rule extends the base [`eslint/no-redeclare`](https://eslint.org/docs/rules/no-redeclare) rule. 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 fc393d5c0d44..39b85e38f82a 100644 --- a/packages/eslint-plugin/docs/rules/no-redundant-type-constituents.md +++ b/packages/eslint-plugin/docs/rules/no-redundant-type-constituents.md @@ -1,7 +1,3 @@ -# `no-redundant-type-constituents` - -Disallows members of unions and intersections that do nothing or override type information. - ## Rule Details Some types can override some other types ("constituents") in a union or intersection and/or be overridden by some other types. diff --git a/packages/eslint-plugin/docs/rules/no-require-imports.md b/packages/eslint-plugin/docs/rules/no-require-imports.md index 9e45c8bd4339..c7d697b2225f 100644 --- a/packages/eslint-plugin/docs/rules/no-require-imports.md +++ b/packages/eslint-plugin/docs/rules/no-require-imports.md @@ -1,7 +1,3 @@ -# `no-require-imports` - -Disallows invocation of `require()`. - Prefer the newer ES6-style imports over `require()`. ## Rule Details diff --git a/packages/eslint-plugin/docs/rules/no-restricted-imports.md b/packages/eslint-plugin/docs/rules/no-restricted-imports.md index 2e741490d098..5e13b4541f57 100644 --- a/packages/eslint-plugin/docs/rules/no-restricted-imports.md +++ b/packages/eslint-plugin/docs/rules/no-restricted-imports.md @@ -1,7 +1,3 @@ -# `no-restricted-imports` - -Disallows specified modules when loaded by `import`. - ## Rule Details This rule extends the base [`eslint/no-restricted-imports`](https://eslint.org/docs/rules/no-restricted-imports) rule. diff --git a/packages/eslint-plugin/docs/rules/no-shadow.md b/packages/eslint-plugin/docs/rules/no-shadow.md index 4ed7f199c2ca..fea79d118d0a 100644 --- a/packages/eslint-plugin/docs/rules/no-shadow.md +++ b/packages/eslint-plugin/docs/rules/no-shadow.md @@ -1,7 +1,3 @@ -# `no-shadow` - -Disallows variable declarations from shadowing variables declared in the outer scope. - ## Rule Details This rule extends the base [`eslint/no-shadow`](https://eslint.org/docs/rules/no-shadow) rule. diff --git a/packages/eslint-plugin/docs/rules/no-this-alias.md b/packages/eslint-plugin/docs/rules/no-this-alias.md index 8485ef88c071..0faf7881262e 100644 --- a/packages/eslint-plugin/docs/rules/no-this-alias.md +++ b/packages/eslint-plugin/docs/rules/no-this-alias.md @@ -1,7 +1,3 @@ -# `no-this-alias` - -Disallows aliasing `this`. - This rule prohibits assigning variables to `this`. ## Rule Details diff --git a/packages/eslint-plugin/docs/rules/no-throw-literal.md b/packages/eslint-plugin/docs/rules/no-throw-literal.md index 4bb8bbcc58c9..249f8e1f97f9 100644 --- a/packages/eslint-plugin/docs/rules/no-throw-literal.md +++ b/packages/eslint-plugin/docs/rules/no-throw-literal.md @@ -1,7 +1,3 @@ -# `no-throw-literal` - -Disallows throwing literals as exceptions. - It is considered good practice to only `throw` the `Error` object itself or an object using the `Error` object as base objects for user-defined exceptions. The fundamental benefit of `Error` objects is that they automatically keep track of where they were built and originated. diff --git a/packages/eslint-plugin/docs/rules/no-type-alias.md b/packages/eslint-plugin/docs/rules/no-type-alias.md index 3a02c4b9760d..aca6603d9b63 100644 --- a/packages/eslint-plugin/docs/rules/no-type-alias.md +++ b/packages/eslint-plugin/docs/rules/no-type-alias.md @@ -1,7 +1,3 @@ -# `no-type-alias` - -Disallows type aliases. - In TypeScript, type aliases serve three purposes: - Aliasing other types so that we can refer to them using a simpler name. 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 73f5ac0c06a8..a7b927298ac8 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 @@ -1,7 +1,3 @@ -# `no-unnecessary-boolean-literal-compare` - -Disallows unnecessary equality comparisons against boolean literals. - Comparing boolean values to boolean literals is unnecessary, those comparisons result in the same booleans. Using the boolean values directly, or via a unary negation (`!value`), is more concise and clearer. ## Rule Details diff --git a/packages/eslint-plugin/docs/rules/no-unnecessary-condition.md b/packages/eslint-plugin/docs/rules/no-unnecessary-condition.md index 3c03a5655217..b65a67840945 100644 --- a/packages/eslint-plugin/docs/rules/no-unnecessary-condition.md +++ b/packages/eslint-plugin/docs/rules/no-unnecessary-condition.md @@ -1,7 +1,3 @@ -# `no-unnecessary-condition` - -Disallows conditionals where the type is always truthy or always falsy. - Any expression being used as a condition must be able to evaluate as truthy or falsy in order to be considered "necessary". Conversely, any expression that always evaluates to truthy or always evaluates to falsy, as determined by the type of the expression, is considered unnecessary and will be flagged by this rule. The following expressions are checked: diff --git a/packages/eslint-plugin/docs/rules/no-unnecessary-qualifier.md b/packages/eslint-plugin/docs/rules/no-unnecessary-qualifier.md index db73814ee788..29d77d188157 100644 --- a/packages/eslint-plugin/docs/rules/no-unnecessary-qualifier.md +++ b/packages/eslint-plugin/docs/rules/no-unnecessary-qualifier.md @@ -1,7 +1,3 @@ -# `no-unnecessary-qualifier` - -Disallows unnecessary namespace qualifiers. - ## Rule Details This rule aims to let users know when a namespace or enum qualifier is unnecessary, 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 26e5c5a01cbb..871026d39f41 100644 --- a/packages/eslint-plugin/docs/rules/no-unnecessary-type-arguments.md +++ b/packages/eslint-plugin/docs/rules/no-unnecessary-type-arguments.md @@ -1,7 +1,3 @@ -# `no-unnecessary-type-arguments` - -Disallows type arguments that are equal to the default. - Warns if an explicitly specified type argument is the default for that type parameter. ## Rule Details 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 e801c73f0ca5..fe1c25a2889d 100644 --- a/packages/eslint-plugin/docs/rules/no-unnecessary-type-assertion.md +++ b/packages/eslint-plugin/docs/rules/no-unnecessary-type-assertion.md @@ -1,7 +1,3 @@ -# `no-unnecessary-type-assertion` - -Disallows type assertions that do not change the type of an expression. - This rule prohibits using a type assertion that does not change the type of an expression. ## Rule Details 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 b2fb9c6b2b95..530243a90651 100644 --- a/packages/eslint-plugin/docs/rules/no-unnecessary-type-constraint.md +++ b/packages/eslint-plugin/docs/rules/no-unnecessary-type-constraint.md @@ -1,7 +1,3 @@ -# `no-unnecessary-type-constraint` - -Disallows unnecessary constraints on generic types. - ## Rule Details Type parameters (``) may be "constrained" with an `extends` keyword ([docs](https://www.typescriptlang.org/docs/handbook/generics.html#generic-constraints)). diff --git a/packages/eslint-plugin/docs/rules/no-unsafe-argument.md b/packages/eslint-plugin/docs/rules/no-unsafe-argument.md index 30d7e441e661..a49da4419448 100644 --- a/packages/eslint-plugin/docs/rules/no-unsafe-argument.md +++ b/packages/eslint-plugin/docs/rules/no-unsafe-argument.md @@ -1,7 +1,3 @@ -# `no-unsafe-argument` - -Disallows calling a function with a value with type `any`. - Despite your best intentions, the `any` type can sometimes leak into your codebase. Call a function with `any` typed argument are not checked at all by TypeScript, so it creates a potential safety hole, and source of bugs in your codebase. diff --git a/packages/eslint-plugin/docs/rules/no-unsafe-assignment.md b/packages/eslint-plugin/docs/rules/no-unsafe-assignment.md index 98bb047e7863..c793fae3d819 100644 --- a/packages/eslint-plugin/docs/rules/no-unsafe-assignment.md +++ b/packages/eslint-plugin/docs/rules/no-unsafe-assignment.md @@ -1,7 +1,3 @@ -# `no-unsafe-assignment` - -Disallows assigning a value with type `any` to variables and properties. - Despite your best intentions, the `any` type can sometimes leak into your codebase. Assigning an `any` typed value to a variable can be hard to pick up on, particularly if it leaks in from an external library. Operations on the variable will not be checked at all by TypeScript, so it creates a potential safety hole, and source of bugs in your codebase. diff --git a/packages/eslint-plugin/docs/rules/no-unsafe-call.md b/packages/eslint-plugin/docs/rules/no-unsafe-call.md index 68c5ba8b81c5..1505882e8b26 100644 --- a/packages/eslint-plugin/docs/rules/no-unsafe-call.md +++ b/packages/eslint-plugin/docs/rules/no-unsafe-call.md @@ -1,7 +1,3 @@ -# `no-unsafe-call` - -Disallows calling a value with type `any`. - Despite your best intentions, the `any` type can sometimes leak into your codebase. The arguments to, and return value of calling an `any` typed variable are not checked at all by TypeScript, so it creates a potential safety hole, and source of bugs in your codebase. 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 a79a8c648c5c..cad9d4418746 100644 --- a/packages/eslint-plugin/docs/rules/no-unsafe-member-access.md +++ b/packages/eslint-plugin/docs/rules/no-unsafe-member-access.md @@ -1,7 +1,3 @@ -# `no-unsafe-member-access` - -Disallows member access on a value with type `any`. - Despite your best intentions, the `any` type can sometimes leak into your codebase. Member access on `any` typed variables is not checked at all by TypeScript, so it creates a potential safety hole, and source of bugs in your codebase. diff --git a/packages/eslint-plugin/docs/rules/no-unsafe-return.md b/packages/eslint-plugin/docs/rules/no-unsafe-return.md index a3401b3b94ee..5c62e9e9f616 100644 --- a/packages/eslint-plugin/docs/rules/no-unsafe-return.md +++ b/packages/eslint-plugin/docs/rules/no-unsafe-return.md @@ -1,7 +1,3 @@ -# `no-unsafe-return` - -Disallows returning a value with type `any` from a function. - Despite your best intentions, the `any` type can sometimes leak into your codebase. Returned `any` typed values are not checked at all by TypeScript, so it creates a potential safety hole, and source of bugs in your codebase. diff --git a/packages/eslint-plugin/docs/rules/no-unused-expressions.md b/packages/eslint-plugin/docs/rules/no-unused-expressions.md index f89aa6349e7d..a5b8b84a6561 100644 --- a/packages/eslint-plugin/docs/rules/no-unused-expressions.md +++ b/packages/eslint-plugin/docs/rules/no-unused-expressions.md @@ -1,7 +1,3 @@ -# `no-unused-expressions` - -Disallows unused expressions. - ## Rule Details This rule extends the base [`eslint/no-unused-expressions`](https://eslint.org/docs/rules/no-unused-expressions) rule. diff --git a/packages/eslint-plugin/docs/rules/no-unused-vars.md b/packages/eslint-plugin/docs/rules/no-unused-vars.md index 7b46ad3f59cf..ffd067aab1d4 100644 --- a/packages/eslint-plugin/docs/rules/no-unused-vars.md +++ b/packages/eslint-plugin/docs/rules/no-unused-vars.md @@ -1,7 +1,3 @@ -# `no-unused-vars` - -Disallows unused variables. - ## Rule Details This rule extends the base [`eslint/no-unused-vars`](https://eslint.org/docs/rules/no-unused-vars) rule. 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 ec29f33c821d..6eac9eb60eaa 100644 --- a/packages/eslint-plugin/docs/rules/no-use-before-define.md +++ b/packages/eslint-plugin/docs/rules/no-use-before-define.md @@ -1,7 +1,3 @@ -# `no-use-before-define` - -Disallows the use of variables before they are defined. - ## Rule Details This rule extends the base [`eslint/no-use-before-define`](https://eslint.org/docs/rules/no-use-before-define) rule. diff --git a/packages/eslint-plugin/docs/rules/no-useless-constructor.md b/packages/eslint-plugin/docs/rules/no-useless-constructor.md index 221a0aaad202..14fb6bf345e7 100644 --- a/packages/eslint-plugin/docs/rules/no-useless-constructor.md +++ b/packages/eslint-plugin/docs/rules/no-useless-constructor.md @@ -1,7 +1,3 @@ -# `no-useless-constructor` - -Disallows unnecessary constructors. - ## Rule Details This rule extends the base [`eslint/no-useless-constructor`](https://eslint.org/docs/rules/no-useless-constructor) rule. 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 94d8dc8a08c8..27783498fc40 100644 --- a/packages/eslint-plugin/docs/rules/no-useless-empty-export.md +++ b/packages/eslint-plugin/docs/rules/no-useless-empty-export.md @@ -1,7 +1,3 @@ -# `no-useless-empty-export` - -Disallows empty exports that don't change anything in a module file. - ## Rule Details An empty `export {}` statement is sometimes useful in TypeScript code to turn a file that would otherwise be a script file into a module file. diff --git a/packages/eslint-plugin/docs/rules/no-var-requires.md b/packages/eslint-plugin/docs/rules/no-var-requires.md index 1ec377b2ba13..18bd664f8da0 100644 --- a/packages/eslint-plugin/docs/rules/no-var-requires.md +++ b/packages/eslint-plugin/docs/rules/no-var-requires.md @@ -1,7 +1,3 @@ -# `no-var-requires` - -Disallows `require` statements except in import statements. - In other words, the use of forms such as `var foo = require("foo")` are banned. Instead use ES6 style imports or `import foo = require("foo")` imports. ## Rule Details 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 ffb0d7b4e704..749d5f9f909b 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 @@ -1,7 +1,3 @@ -# `non-nullable-type-assertion-style` - -Enforces non-null assertions over explicit type casts. - This rule detects when an `as` cast is doing the same job as a `!` would, and suggests fixing the code to be an `!`. ## Rule Details diff --git a/packages/eslint-plugin/docs/rules/object-curly-spacing.md b/packages/eslint-plugin/docs/rules/object-curly-spacing.md index 4789df3e14e4..e9e805ab9796 100644 --- a/packages/eslint-plugin/docs/rules/object-curly-spacing.md +++ b/packages/eslint-plugin/docs/rules/object-curly-spacing.md @@ -1,7 +1,3 @@ -# `object-curly-spacing` - -Enforces consistent spacing inside braces. - ## Rule Details This rule extends the base [`eslint/object-curly-spacing`](https://eslint.org/docs/rules/object-curly-spacing) rule. 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 82f98043d4b7..0668e3c05b78 100644 --- a/packages/eslint-plugin/docs/rules/padding-line-between-statements.md +++ b/packages/eslint-plugin/docs/rules/padding-line-between-statements.md @@ -1,7 +1,3 @@ -# `padding-line-between-statements` - -Requires or disallows padding lines between statements. - ## Rule Details This rule extends the base [`eslint/padding-line-between-statements`](https://eslint.org/docs/rules/padding-line-between-statements) rule. diff --git a/packages/eslint-plugin/docs/rules/parameter-properties.md b/packages/eslint-plugin/docs/rules/parameter-properties.md index e4ff9a4ea8a1..d01a87596936 100644 --- a/packages/eslint-plugin/docs/rules/parameter-properties.md +++ b/packages/eslint-plugin/docs/rules/parameter-properties.md @@ -1,7 +1,3 @@ -# `parameter-properties` - -Requires or disallows parameter properties in class constructors. - Parameter properties can be confusing to those new to TypeScript as they are less explicit than other ways of declaring and initializing class members. diff --git a/packages/eslint-plugin/docs/rules/prefer-as-const.md b/packages/eslint-plugin/docs/rules/prefer-as-const.md index 76d3dede5472..871c04a04d05 100644 --- a/packages/eslint-plugin/docs/rules/prefer-as-const.md +++ b/packages/eslint-plugin/docs/rules/prefer-as-const.md @@ -1,7 +1,3 @@ -# `prefer-as-const` - -Enforces the use of `as const` over literal type. - This rule recommends usage of `const` assertion when type primitive value is equal to type. ## Rule Details diff --git a/packages/eslint-plugin/docs/rules/prefer-enum-initializers.md b/packages/eslint-plugin/docs/rules/prefer-enum-initializers.md index fb3a24494d46..93dfe2fb6719 100644 --- a/packages/eslint-plugin/docs/rules/prefer-enum-initializers.md +++ b/packages/eslint-plugin/docs/rules/prefer-enum-initializers.md @@ -1,7 +1,3 @@ -# `prefer-enum-initializers` - -Requires each enum member value to be explicitly initialized. - This rule recommends having each `enum`s member value explicitly initialized. `enum`s are a practical way to organize semantically related constant values. However, by implicitly defining values, `enum`s can lead to unexpected bugs if it's modified without paying attention to the order of its items. diff --git a/packages/eslint-plugin/docs/rules/prefer-for-of.md b/packages/eslint-plugin/docs/rules/prefer-for-of.md index f4a4f207e78d..06162217c783 100644 --- a/packages/eslint-plugin/docs/rules/prefer-for-of.md +++ b/packages/eslint-plugin/docs/rules/prefer-for-of.md @@ -1,7 +1,3 @@ -# `prefer-for-of` - -Enforces the use of `for-of` loop over the standard `for` loop where possible. - This rule recommends a for-of loop when the loop index is only used to read from an array that is being iterated. ## Rule Details diff --git a/packages/eslint-plugin/docs/rules/prefer-function-type.md b/packages/eslint-plugin/docs/rules/prefer-function-type.md index 22b579798fc5..7b8ec069f6d3 100644 --- a/packages/eslint-plugin/docs/rules/prefer-function-type.md +++ b/packages/eslint-plugin/docs/rules/prefer-function-type.md @@ -1,7 +1,3 @@ -# `prefer-function-type` - -Enforces using function types instead of interfaces with call signatures. - ## Rule Details This rule suggests using a function type instead of an interface or object type literal with a single call signature. diff --git a/packages/eslint-plugin/docs/rules/prefer-includes.md b/packages/eslint-plugin/docs/rules/prefer-includes.md index 448d6bef4a31..5309a204dbc4 100644 --- a/packages/eslint-plugin/docs/rules/prefer-includes.md +++ b/packages/eslint-plugin/docs/rules/prefer-includes.md @@ -1,7 +1,3 @@ -# `prefer-includes` - -Enforces `includes` method over `indexOf` method. - Until ES5, we were using `String#indexOf` method to check whether a string contains an arbitrary substring or not. Until ES2015, we were using `Array#indexOf` method to check whether an array contains an arbitrary value or not. 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 4f4db49cb625..52bb1674e936 100644 --- a/packages/eslint-plugin/docs/rules/prefer-literal-enum-member.md +++ b/packages/eslint-plugin/docs/rules/prefer-literal-enum-member.md @@ -1,7 +1,3 @@ -# `prefer-literal-enum-member` - -Requires all enum members to be literal values. - TypeScript allows the value of an enum member to be many different kinds of valid JavaScript expressions. However, because enums create their own scope whereby each enum member becomes a variable in that scope, unexpected values could be used at runtime. Example: ```ts diff --git a/packages/eslint-plugin/docs/rules/prefer-namespace-keyword.md b/packages/eslint-plugin/docs/rules/prefer-namespace-keyword.md index 01bd2377a0fa..d2fe7e7a7781 100644 --- a/packages/eslint-plugin/docs/rules/prefer-namespace-keyword.md +++ b/packages/eslint-plugin/docs/rules/prefer-namespace-keyword.md @@ -1,7 +1,3 @@ -# `prefer-namespace-keyword` - -Requires using `namespace` keyword over `module` keyword to declare custom TypeScript modules. - In an effort to prevent further confusion between custom TypeScript modules and the new ES2015 modules, starting with TypeScript `v1.5` the keyword `namespace` is now the preferred way to declare custom TypeScript modules. diff --git a/packages/eslint-plugin/docs/rules/prefer-nullish-coalescing.md b/packages/eslint-plugin/docs/rules/prefer-nullish-coalescing.md index 9b1dfe988209..e8355f918650 100644 --- a/packages/eslint-plugin/docs/rules/prefer-nullish-coalescing.md +++ b/packages/eslint-plugin/docs/rules/prefer-nullish-coalescing.md @@ -1,7 +1,3 @@ -# `prefer-nullish-coalescing` - -Enforces using the nullish coalescing operator instead of logical chaining. - TypeScript 3.7 added support for the nullish coalescing operator. This operator allows you to safely cascade a value when dealing with `null` or `undefined`. diff --git a/packages/eslint-plugin/docs/rules/prefer-optional-chain.md b/packages/eslint-plugin/docs/rules/prefer-optional-chain.md index c2b196a04a47..a38008a888e6 100644 --- a/packages/eslint-plugin/docs/rules/prefer-optional-chain.md +++ b/packages/eslint-plugin/docs/rules/prefer-optional-chain.md @@ -1,7 +1,3 @@ -# `prefer-optional-chain` - -Enforces using concise optional chain expressions instead of chained logical ands. - TypeScript 3.7 added support for the optional chain operator. This operator allows you to safely access properties and methods on objects when they are potentially `null` or `undefined`. 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 5ac98d6f043f..8486a1281326 100644 --- a/packages/eslint-plugin/docs/rules/prefer-readonly-parameter-types.md +++ b/packages/eslint-plugin/docs/rules/prefer-readonly-parameter-types.md @@ -1,7 +1,3 @@ -# `prefer-readonly-parameter-types` - -Requires function parameters to be typed as `readonly` to prevent accidental mutation of inputs. - Mutating function arguments can lead to confusing, hard to debug behavior. Whilst it's easy to implicitly remember to not modify function arguments, explicitly typing arguments as readonly provides clear contract to consumers. This contract makes it easier for a consumer to reason about if a function has side-effects. diff --git a/packages/eslint-plugin/docs/rules/prefer-readonly.md b/packages/eslint-plugin/docs/rules/prefer-readonly.md index bfc297ae8fc3..1688ecd43b9d 100644 --- a/packages/eslint-plugin/docs/rules/prefer-readonly.md +++ b/packages/eslint-plugin/docs/rules/prefer-readonly.md @@ -1,7 +1,3 @@ -# `prefer-readonly` - -Requires private members to be marked as `readonly` if they're never modified outside of the constructor. - This rule enforces that private members are marked as `readonly` if they're never modified outside of the constructor. ## Rule Details 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 16a1046a24da..5bf7ef200952 100644 --- a/packages/eslint-plugin/docs/rules/prefer-reduce-type-parameter.md +++ b/packages/eslint-plugin/docs/rules/prefer-reduce-type-parameter.md @@ -1,7 +1,3 @@ -# `prefer-reduce-type-parameter` - -Enforces using type parameter when calling `Array#reduce` instead of casting. - It's common to call `Array#reduce` with a generic type, such as an array or object, as the initial value. Since these values are empty, their types are not usable: diff --git a/packages/eslint-plugin/docs/rules/prefer-regexp-exec.md b/packages/eslint-plugin/docs/rules/prefer-regexp-exec.md index 7c7756646b91..135ede506c20 100644 --- a/packages/eslint-plugin/docs/rules/prefer-regexp-exec.md +++ b/packages/eslint-plugin/docs/rules/prefer-regexp-exec.md @@ -1,7 +1,3 @@ -# `prefer-regexp-exec` - -Enforces `RegExp#exec` over `String#match` if no global flag is provided. - As `String#match` is defined to be the same as `RegExp#exec` when the regular expression does not include the `g` flag, prefer a consistent usage. ## Rule Details 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 2ec748340126..a49c961af7a0 100644 --- a/packages/eslint-plugin/docs/rules/prefer-return-this-type.md +++ b/packages/eslint-plugin/docs/rules/prefer-return-this-type.md @@ -1,7 +1,3 @@ -# `prefer-return-this-type` - -Enforces that `this` is used when only `this` type is returned. - [Method chaining](https://en.wikipedia.org/wiki/Method_chaining) is a common pattern in OOP languages and TypeScript provides a special [polymorphic this type](https://www.typescriptlang.org/docs/handbook/2/classes.html#this-types). If any type other than `this` is specified as the return type of these chaining methods, TypeScript will fail to cast it when invoking in subclass. 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 c103769e1ef1..e576d1958da8 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 @@ -1,9 +1,4 @@ -# `prefer-string-starts-ends-with` - -Enforces using `String#startsWith` and `String#endsWith` over other equivalent methods of checking substrings. - There are multiple ways to verify if a string starts or ends with a specific string, such as `foo.indexOf('bar') === 0`. - Since ES2015 has added `String#startsWith` and `String#endsWith`, this rule reports other ways to be consistent. ## Rule Details 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 bf96eb8fa9a6..f46f9d95f888 100644 --- a/packages/eslint-plugin/docs/rules/prefer-ts-expect-error.md +++ b/packages/eslint-plugin/docs/rules/prefer-ts-expect-error.md @@ -1,7 +1,3 @@ -# `prefer-ts-expect-error` - -Enforces using `@ts-expect-error` over `@ts-ignore`. - TypeScript allows you to suppress all errors on a line by placing a single-line comment or a comment block line starting with `@ts-ignore` immediately before the erroring line. While powerful, there is no way to know if a `@ts-ignore` is actually suppressing an error without manually investigating what happens when the `@ts-ignore` is removed. diff --git a/packages/eslint-plugin/docs/rules/promise-function-async.md b/packages/eslint-plugin/docs/rules/promise-function-async.md index 7316e02f1b32..fa800fd6c081 100644 --- a/packages/eslint-plugin/docs/rules/promise-function-async.md +++ b/packages/eslint-plugin/docs/rules/promise-function-async.md @@ -1,7 +1,3 @@ -# `promise-function-async` - -Requires any function or method that returns a Promise to be marked async. - Ensures that each function is only capable of: - returning a rejected promise, or diff --git a/packages/eslint-plugin/docs/rules/quotes.md b/packages/eslint-plugin/docs/rules/quotes.md index 1e3f6d32363d..608db1fc8e1e 100644 --- a/packages/eslint-plugin/docs/rules/quotes.md +++ b/packages/eslint-plugin/docs/rules/quotes.md @@ -1,7 +1,3 @@ -# `quotes` - -Enforces the consistent use of either backticks, double, or single quotes. - ## Rule Details This rule extends the base [`eslint/quotes`](https://eslint.org/docs/rules/quotes) rule. 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 23694f06d6ae..49b54d8582b9 100644 --- a/packages/eslint-plugin/docs/rules/require-array-sort-compare.md +++ b/packages/eslint-plugin/docs/rules/require-array-sort-compare.md @@ -1,9 +1,4 @@ -# `require-array-sort-compare` - -Requires `Array#sort` calls to always provide a `compareFunction`. - This rule prevents invoking the `Array#sort()` method without providing a `compare` argument. - When called without a compare function, `Array#sort()` converts all non-undefined array elements into strings and then compares said strings based off their UTF-16 code units. The result is that elements are sorted alphabetically, regardless of their type. diff --git a/packages/eslint-plugin/docs/rules/require-await.md b/packages/eslint-plugin/docs/rules/require-await.md index f4ac8cf56766..2b460a6f1ab8 100644 --- a/packages/eslint-plugin/docs/rules/require-await.md +++ b/packages/eslint-plugin/docs/rules/require-await.md @@ -1,7 +1,3 @@ -# `require-await` - -Disallows async functions which have no `await` expression. - ## Rule Details This rule extends the base [`eslint/require-await`](https://eslint.org/docs/rules/require-await) rule. diff --git a/packages/eslint-plugin/docs/rules/restrict-plus-operands.md b/packages/eslint-plugin/docs/rules/restrict-plus-operands.md index a8b4a83f288f..ace09e656a61 100644 --- a/packages/eslint-plugin/docs/rules/restrict-plus-operands.md +++ b/packages/eslint-plugin/docs/rules/restrict-plus-operands.md @@ -1,7 +1,3 @@ -# `restrict-plus-operands` - -Requires both operands of addition to have type `number` or `string`. - ## Rule Details Examples of code for this rule: diff --git a/packages/eslint-plugin/docs/rules/restrict-template-expressions.md b/packages/eslint-plugin/docs/rules/restrict-template-expressions.md index 59c507f167e2..a06c717b2b70 100644 --- a/packages/eslint-plugin/docs/rules/restrict-template-expressions.md +++ b/packages/eslint-plugin/docs/rules/restrict-template-expressions.md @@ -1,7 +1,3 @@ -# `restrict-template-expressions` - -Enforces template literal expressions to be of `string` type. - ## Rule Details Examples of code for this rule: diff --git a/packages/eslint-plugin/docs/rules/return-await.md b/packages/eslint-plugin/docs/rules/return-await.md index 20e99158dffa..6162ddcef7e6 100644 --- a/packages/eslint-plugin/docs/rules/return-await.md +++ b/packages/eslint-plugin/docs/rules/return-await.md @@ -1,7 +1,3 @@ -# `return-await` - -Enforces consistent returning of awaited values. - Returning an awaited promise can make sense for better stack trace information as well as for consistent error handling (returned promises will not be caught in an async function try/catch). ## Rule Details diff --git a/packages/eslint-plugin/docs/rules/semi.md b/packages/eslint-plugin/docs/rules/semi.md index 307637c7168e..0c81c67779f9 100644 --- a/packages/eslint-plugin/docs/rules/semi.md +++ b/packages/eslint-plugin/docs/rules/semi.md @@ -1,7 +1,3 @@ -# `semi` - -Requires or disallows semicolons instead of ASI. - This rule enforces consistent use of semicolons after statements. ## Rule Details 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 a7444659ee34..1b6390d244b0 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 @@ -1,7 +1,3 @@ -# `sort-type-union-intersection-members` - -Enforces members of a type union/intersection to be sorted alphabetically. - Sorting union (`|`) and intersection (`&`) types can help: - keep your codebase standardized diff --git a/packages/eslint-plugin/docs/rules/space-before-blocks.md b/packages/eslint-plugin/docs/rules/space-before-blocks.md index 5ff10537795f..183e84d8b6a7 100644 --- a/packages/eslint-plugin/docs/rules/space-before-blocks.md +++ b/packages/eslint-plugin/docs/rules/space-before-blocks.md @@ -1,7 +1,3 @@ -# `space-before-blocks` - -Enforces consistent spacing before blocks. - ## Rule Details This rule extends the base [`eslint/space-before-blocks`](https://eslint.org/docs/rules/space-before-blocks) rule. 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 4664dd4c6a51..936b6bd6bfc1 100644 --- a/packages/eslint-plugin/docs/rules/space-before-function-paren.md +++ b/packages/eslint-plugin/docs/rules/space-before-function-paren.md @@ -1,7 +1,3 @@ -# `space-before-function-paren` - -Enforces consistent spacing before function parenthesis. - ## Rule Details This rule extends the base [`eslint/space-before-function-paren`](https://eslint.org/docs/rules/space-before-function-paren) rule. diff --git a/packages/eslint-plugin/docs/rules/space-infix-ops.md b/packages/eslint-plugin/docs/rules/space-infix-ops.md index afcb5de8e788..e9c477ba99b2 100644 --- a/packages/eslint-plugin/docs/rules/space-infix-ops.md +++ b/packages/eslint-plugin/docs/rules/space-infix-ops.md @@ -1,7 +1,3 @@ -# `space-infix-ops` - -Requires spacing around infix operators. - This rule extends the base [`eslint/space-infix-ops`](https://eslint.org/docs/rules/space-infix-ops) rule. It also add support for enum members diff --git a/packages/eslint-plugin/docs/rules/strict-boolean-expressions.md b/packages/eslint-plugin/docs/rules/strict-boolean-expressions.md index 16ceb26aa8fe..73df9337ae33 100644 --- a/packages/eslint-plugin/docs/rules/strict-boolean-expressions.md +++ b/packages/eslint-plugin/docs/rules/strict-boolean-expressions.md @@ -1,7 +1,3 @@ -# `strict-boolean-expressions` - -Disallows certain types in boolean expressions. - Forbids usage of non-boolean types in expressions where a boolean is expected. `boolean` and `never` types are always allowed. Additional types which are considered safe in a boolean context can be configured via options. diff --git a/packages/eslint-plugin/docs/rules/switch-exhaustiveness-check.md b/packages/eslint-plugin/docs/rules/switch-exhaustiveness-check.md index 7e6126830d4c..7b71610f9383 100644 --- a/packages/eslint-plugin/docs/rules/switch-exhaustiveness-check.md +++ b/packages/eslint-plugin/docs/rules/switch-exhaustiveness-check.md @@ -1,7 +1,3 @@ -# `switch-exhaustiveness-check` - -Requires switch-case statements to be exhaustive with union type. - Union type may have a lot of parts. It's easy to forget to consider all cases in switch. This rule reminds which parts are missing. If domain of the problem requires to have only a partial switch, developer may _explicitly_ add a default clause. ## Rule Details diff --git a/packages/eslint-plugin/docs/rules/triple-slash-reference.md b/packages/eslint-plugin/docs/rules/triple-slash-reference.md index 97f4fb77dab4..2d15174c38b8 100644 --- a/packages/eslint-plugin/docs/rules/triple-slash-reference.md +++ b/packages/eslint-plugin/docs/rules/triple-slash-reference.md @@ -1,7 +1,3 @@ -# `triple-slash-reference` - -Disallows certain triple slash directives in favor of ES6-style import declarations. - Use of triple-slash reference type directives is discouraged in favor of the newer `import` style. This rule allows you to ban use of `/// `, `/// `, or `/// ` directives. ## Rule Details diff --git a/packages/eslint-plugin/docs/rules/type-annotation-spacing.md b/packages/eslint-plugin/docs/rules/type-annotation-spacing.md index 475ad29ca4d1..711b4c6e194f 100644 --- a/packages/eslint-plugin/docs/rules/type-annotation-spacing.md +++ b/packages/eslint-plugin/docs/rules/type-annotation-spacing.md @@ -1,7 +1,3 @@ -# `type-annotation-spacing` - -Requires consistent spacing around type annotations. - Spacing around type annotations improves readability of the code. Although the most commonly used style guideline for type annotations in TypeScript prescribes adding a space after the colon, but not before it, it is subjective to the preferences of a project. For example: diff --git a/packages/eslint-plugin/docs/rules/typedef.md b/packages/eslint-plugin/docs/rules/typedef.md index 5356cdd7a2d7..85e5d7a1155a 100644 --- a/packages/eslint-plugin/docs/rules/typedef.md +++ b/packages/eslint-plugin/docs/rules/typedef.md @@ -1,7 +1,3 @@ -# `typedef` - -Requires type annotations in certain places. - TypeScript cannot always infer types for all places in code. Some locations require type annotations for their types to be inferred. diff --git a/packages/eslint-plugin/docs/rules/unbound-method.md b/packages/eslint-plugin/docs/rules/unbound-method.md index 9f71738f5a91..f5dbc8971945 100644 --- a/packages/eslint-plugin/docs/rules/unbound-method.md +++ b/packages/eslint-plugin/docs/rules/unbound-method.md @@ -1,11 +1,4 @@ -# `unbound-method` - -Enforces unbound methods are called with their expected scope. - -Warns when a method is used outside of a method call. - Class functions don't preserve the class scope when passed as standalone variables. - If your function does not access `this`, [you can annotate it with `this: void`](https://www.typescriptlang.org/docs/handbook/2/functions.html#declaring-this-in-a-function), or consider using an arrow function instead. If you're working with `jest`, you can use [`eslint-plugin-jest`'s version of this rule](https://github.com/jest-community/eslint-plugin-jest/blob/main/docs/rules/unbound-method.md) to lint your test files, which knows when it's ok to pass an unbound method to `expect` calls. diff --git a/packages/eslint-plugin/docs/rules/unified-signatures.md b/packages/eslint-plugin/docs/rules/unified-signatures.md index 7cb47574a145..ccb24d9447ad 100644 --- a/packages/eslint-plugin/docs/rules/unified-signatures.md +++ b/packages/eslint-plugin/docs/rules/unified-signatures.md @@ -1,7 +1,3 @@ -# `unified-signatures` - -Disallows two overloads that could be unified into one with a union or an optional/rest parameter. - ## Rule Details This rule aims to keep the source code as maintainable as possible by reducing the amount of overloads. diff --git a/packages/website/docusaurusConfig.ts b/packages/website/docusaurusConfig.ts index c91f2d3e7aca..a1b7749347eb 100644 --- a/packages/website/docusaurusConfig.ts +++ b/packages/website/docusaurusConfig.ts @@ -8,7 +8,7 @@ import type { Config } from '@docusaurus/types'; import { rulesMeta } from './rulesMeta'; import npm2yarnPlugin from '@docusaurus/remark-plugin-npm2yarn'; import tabsPlugin from 'remark-docusaurus-tabs'; -import { addRuleAttributesList } from './plugins/add-rule-attributes-list'; +import { generatedRuleDocs } from './plugins/generated-rule-docs'; const remarkPlugins: MDXPlugin[] = [[npm2yarnPlugin, { sync: true }]]; @@ -24,7 +24,7 @@ const presetClassicOptions: PresetClassicOptions = { routeBasePath: 'rules', editUrl: `${githubUrl}/edit/main/packages/website/`, beforeDefaultRemarkPlugins, - remarkPlugins: [...remarkPlugins, [addRuleAttributesList, {}]], + remarkPlugins: [...remarkPlugins, [generatedRuleDocs, {}]], exclude: ['TEMPLATE.md'], breadcrumbs: false, }, diff --git a/packages/website/plugins/add-rule-attributes-list.ts b/packages/website/plugins/add-rule-attributes-list.ts deleted file mode 100644 index febbfc355576..000000000000 --- a/packages/website/plugins/add-rule-attributes-list.ts +++ /dev/null @@ -1,38 +0,0 @@ -import type * as unist from 'unist'; -import type * as mdast from 'mdast'; -import type { Plugin } from 'unified'; - -import * as eslintPlugin from '@typescript-eslint/eslint-plugin'; - -const addRuleAttributesList: Plugin = () => { - return (root, file) => { - if (file.stem == null) { - return; - } - - const rule = eslintPlugin.rules[file.stem]; - if (rule == null) { - return; - } - - const parent = root as unist.Parent; - const h2Idx = parent.children.findIndex( - child => child.type === 'heading' && (child as mdast.Heading).depth === 2, - ); - // The actual content will be injected on client side. - const attrNode = { - type: 'jsx', - value: ``, - }; - if (h2Idx != null) { - // insert it just before the first h2 in the doc - // this should be just after the rule's description - parent.children.splice(h2Idx, 0, attrNode); - } else { - // failing that, add it to the end - parent.children.push(attrNode); - } - }; -}; - -export { addRuleAttributesList }; diff --git a/packages/website/plugins/generated-rule-docs.ts b/packages/website/plugins/generated-rule-docs.ts new file mode 100644 index 000000000000..e7c398a94185 --- /dev/null +++ b/packages/website/plugins/generated-rule-docs.ts @@ -0,0 +1,55 @@ +import type * as unist from 'unist'; +import type * as mdast from 'mdast'; +import type { Plugin } from 'unified'; + +import * as eslintPlugin from '@typescript-eslint/eslint-plugin'; + +const generatedRuleDocs: Plugin = () => { + return (root, file) => { + if (file.stem == null) { + return; + } + + const docs = eslintPlugin.rules[file.stem]?.meta.docs; + if (!docs) { + return; + } + + const parent = root as unist.Parent; + + // 1. Add a description of the rule at the top of the file + parent.children.unshift({ + children: [ + { + children: [ + { + type: 'text', + value: `${docs.description}.`, + }, + ], + type: 'paragraph', + }, + ], + type: 'blockquote', + } as mdast.Blockquote); + + // 2. Add a rule attributes list... + const h2Idx = + // ...or the first h2, if it exists... + parent.children.findIndex( + child => + child.type === 'heading' && (child as mdast.Heading).depth === 2, + ) ?? + // ...or at the very end, if not. + parent.children.length; + + // The actual content will be injected on client side. + const attrNode = { + type: 'jsx', + value: ``, + }; + parent.children.splice(h2Idx, 0, attrNode); + }; +}; + +export { generatedRuleDocs }; From c77dda413f168eedc83d5239519191dd0526e38c Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Sat, 25 Jun 2022 16:11:18 -0400 Subject: [PATCH 2/6] Fix docs tests too --- packages/eslint-plugin/tests/docs.test.ts | 27 ----------------------- 1 file changed, 27 deletions(-) diff --git a/packages/eslint-plugin/tests/docs.test.ts b/packages/eslint-plugin/tests/docs.test.ts index 13262e4ce73c..e6f067077463 100644 --- a/packages/eslint-plugin/tests/docs.test.ts +++ b/packages/eslint-plugin/tests/docs.test.ts @@ -41,10 +41,6 @@ function tokenIs( return token.type === type; } -function tokenIsH1(token: marked.Token): token is marked.Tokens.Heading { - return tokenIs(token, 'heading') && token.depth === 1; -} - function tokenIsH2(token: marked.Token): token is marked.Tokens.Heading { return tokenIs(token, 'heading') && token.depth === 2; } @@ -71,29 +67,6 @@ describe('Validating rule docs', () => { 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); - - const header = tokens.find(tokenIsH1)!; - - 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); - - // Rule title not found. - // Rule title does not match the rule metadata. - expect(tokens[1]).toMatchObject({ - type: 'paragraph', - text: `${rule.meta.docs?.description.replace( - /(? { const tokens = parseMarkdownFile(filePath); From 79f0387f63639b3d3ba74ca12c0f93518fca5c4b Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Sun, 26 Jun 2022 17:18:01 -0400 Subject: [PATCH 3/6] Add move notice to the top of each rule docs file --- .../docs/rules/adjacent-overload-signatures.md | 4 ++++ packages/eslint-plugin/docs/rules/array-type.md | 4 ++++ .../eslint-plugin/docs/rules/await-thenable.md | 4 ++++ .../eslint-plugin/docs/rules/ban-ts-comment.md | 4 ++++ .../eslint-plugin/docs/rules/ban-tslint-comment.md | 4 ++++ packages/eslint-plugin/docs/rules/ban-types.md | 4 ++++ packages/eslint-plugin/docs/rules/brace-style.md | 4 ++++ .../docs/rules/class-literal-property-style.md | 4 ++++ packages/eslint-plugin/docs/rules/comma-dangle.md | 4 ++++ packages/eslint-plugin/docs/rules/comma-spacing.md | 4 ++++ .../docs/rules/consistent-generic-constructors.md | 4 ++++ .../docs/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 ++++ .../eslint-plugin/docs/rules/default-param-last.md | 4 ++++ packages/eslint-plugin/docs/rules/dot-notation.md | 4 ++++ .../docs/rules/explicit-function-return-type.md | 4 ++++ .../docs/rules/explicit-member-accessibility.md | 4 ++++ .../docs/rules/explicit-module-boundary-types.md | 4 ++++ .../eslint-plugin/docs/rules/func-call-spacing.md | 4 ++++ packages/eslint-plugin/docs/rules/indent.md | 4 ++++ .../eslint-plugin/docs/rules/init-declarations.md | 4 ++++ .../eslint-plugin/docs/rules/keyword-spacing.md | 4 ++++ .../docs/rules/lines-between-class-members.md | 4 ++++ .../docs/rules/member-delimiter-style.md | 4 ++++ .../eslint-plugin/docs/rules/member-ordering.md | 4 ++++ .../docs/rules/method-signature-style.md | 4 ++++ .../eslint-plugin/docs/rules/naming-convention.md | 4 ++++ .../docs/rules/no-array-constructor.md | 4 ++++ .../eslint-plugin/docs/rules/no-base-to-string.md | 4 ++++ .../docs/rules/no-confusing-non-null-assertion.md | 4 ++++ .../docs/rules/no-confusing-void-expression.md | 4 ++++ .../docs/rules/no-dupe-class-members.md | 4 ++++ .../docs/rules/no-duplicate-enum-values.md | 4 ++++ .../docs/rules/no-duplicate-imports.md | 4 ++++ .../eslint-plugin/docs/rules/no-dynamic-delete.md | 4 ++++ .../eslint-plugin/docs/rules/no-empty-function.md | 4 ++++ .../eslint-plugin/docs/rules/no-empty-interface.md | 4 ++++ .../eslint-plugin/docs/rules/no-explicit-any.md | 4 ++++ .../docs/rules/no-extra-non-null-assertion.md | 4 ++++ .../eslint-plugin/docs/rules/no-extra-parens.md | 4 ++++ packages/eslint-plugin/docs/rules/no-extra-semi.md | 4 ++++ .../docs/rules/no-extraneous-class.md | 4 ++++ .../docs/rules/no-floating-promises.md | 4 ++++ .../eslint-plugin/docs/rules/no-for-in-array.md | 4 ++++ .../docs/rules/no-implicit-any-catch.md | 4 ++++ .../eslint-plugin/docs/rules/no-implied-eval.md | 4 ++++ .../docs/rules/no-inferrable-types.md | 4 ++++ .../eslint-plugin/docs/rules/no-invalid-this.md | 4 ++++ .../docs/rules/no-invalid-void-type.md | 4 ++++ packages/eslint-plugin/docs/rules/no-loop-func.md | 4 ++++ .../docs/rules/no-loss-of-precision.md | 4 ++++ .../eslint-plugin/docs/rules/no-magic-numbers.md | 4 ++++ .../docs/rules/no-meaningless-void-operator.md | 4 ++++ .../eslint-plugin/docs/rules/no-misused-new.md | 4 ++++ .../docs/rules/no-misused-promises.md | 4 ++++ packages/eslint-plugin/docs/rules/no-namespace.md | 4 ++++ .../no-non-null-asserted-nullish-coalescing.md | 4 ++++ .../rules/no-non-null-asserted-optional-chain.md | 4 ++++ .../docs/rules/no-non-null-assertion.md | 4 ++++ .../docs/rules/no-parameter-properties.md | 4 ++++ packages/eslint-plugin/docs/rules/no-redeclare.md | 4 ++++ .../docs/rules/no-redundant-type-constituents.md | 4 ++++ .../eslint-plugin/docs/rules/no-require-imports.md | 4 ++++ .../docs/rules/no-restricted-imports.md | 4 ++++ packages/eslint-plugin/docs/rules/no-shadow.md | 4 ++++ packages/eslint-plugin/docs/rules/no-this-alias.md | 4 ++++ .../eslint-plugin/docs/rules/no-throw-literal.md | 4 ++++ packages/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 | 4 ++++ .../docs/rules/no-unnecessary-type-arguments.md | 4 ++++ .../docs/rules/no-unnecessary-type-assertion.md | 4 ++++ .../docs/rules/no-unnecessary-type-constraint.md | 4 ++++ .../eslint-plugin/docs/rules/no-unsafe-argument.md | 4 ++++ .../docs/rules/no-unsafe-assignment.md | 4 ++++ .../eslint-plugin/docs/rules/no-unsafe-call.md | 4 ++++ .../docs/rules/no-unsafe-member-access.md | 4 ++++ .../eslint-plugin/docs/rules/no-unsafe-return.md | 4 ++++ .../docs/rules/no-unused-expressions.md | 4 ++++ .../eslint-plugin/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 | 4 ++++ .../eslint-plugin/docs/rules/no-var-requires.md | 4 ++++ .../rules/non-nullable-type-assertion-style.md | 4 ++++ .../docs/rules/object-curly-spacing.md | 4 ++++ .../docs/rules/padding-line-between-statements.md | 4 ++++ .../docs/rules/parameter-properties.md | 4 ++++ .../eslint-plugin/docs/rules/prefer-as-const.md | 4 ++++ .../docs/rules/prefer-enum-initializers.md | 4 ++++ packages/eslint-plugin/docs/rules/prefer-for-of.md | 4 ++++ .../docs/rules/prefer-function-type.md | 4 ++++ .../eslint-plugin/docs/rules/prefer-includes.md | 4 ++++ .../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 | 4 ++++ .../docs/rules/prefer-readonly-parameter-types.md | 4 ++++ .../eslint-plugin/docs/rules/prefer-readonly.md | 4 ++++ .../docs/rules/prefer-reduce-type-parameter.md | 4 ++++ .../eslint-plugin/docs/rules/prefer-regexp-exec.md | 4 ++++ .../docs/rules/prefer-return-this-type.md | 4 ++++ .../docs/rules/prefer-string-starts-ends-with.md | 4 ++++ .../docs/rules/prefer-ts-expect-error.md | 4 ++++ .../docs/rules/promise-function-async.md | 4 ++++ packages/eslint-plugin/docs/rules/quotes.md | 4 ++++ .../docs/rules/require-array-sort-compare.md | 4 ++++ packages/eslint-plugin/docs/rules/require-await.md | 4 ++++ .../docs/rules/restrict-plus-operands.md | 4 ++++ .../docs/rules/restrict-template-expressions.md | 4 ++++ packages/eslint-plugin/docs/rules/return-await.md | 4 ++++ packages/eslint-plugin/docs/rules/semi.md | 4 ++++ .../rules/sort-type-union-intersection-members.md | 4 ++++ .../docs/rules/space-before-blocks.md | 4 ++++ .../docs/rules/space-before-function-paren.md | 4 ++++ .../eslint-plugin/docs/rules/space-infix-ops.md | 4 ++++ .../docs/rules/strict-boolean-expressions.md | 4 ++++ .../docs/rules/switch-exhaustiveness-check.md | 4 ++++ .../docs/rules/triple-slash-reference.md | 4 ++++ .../docs/rules/type-annotation-spacing.md | 4 ++++ packages/eslint-plugin/docs/rules/typedef.md | 4 ++++ .../eslint-plugin/docs/rules/unbound-method.md | 4 ++++ .../eslint-plugin/docs/rules/unified-signatures.md | 4 ++++ packages/eslint-plugin/tests/docs.test.ts | 14 ++++++++++++++ 128 files changed, 522 insertions(+) diff --git a/packages/eslint-plugin/docs/rules/adjacent-overload-signatures.md b/packages/eslint-plugin/docs/rules/adjacent-overload-signatures.md index 87c0705bb18f..57677bd4ac1f 100644 --- a/packages/eslint-plugin/docs/rules/adjacent-overload-signatures.md +++ b/packages/eslint-plugin/docs/rules/adjacent-overload-signatures.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/adjacent-overload-signatures** for documentation. + Grouping overloaded members together can improve readability of the code. ## Rule Details diff --git a/packages/eslint-plugin/docs/rules/array-type.md b/packages/eslint-plugin/docs/rules/array-type.md index b56a7e4a93f8..9a9ac0985bc3 100644 --- a/packages/eslint-plugin/docs/rules/array-type.md +++ b/packages/eslint-plugin/docs/rules/array-type.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/array-type** for documentation. + Using the same style for array definitions across your codebase makes it easier for your developers to read and understand the types. ## Rule Details diff --git a/packages/eslint-plugin/docs/rules/await-thenable.md b/packages/eslint-plugin/docs/rules/await-thenable.md index d6de2c65f6ec..d0d3d5f7d521 100644 --- a/packages/eslint-plugin/docs/rules/await-thenable.md +++ b/packages/eslint-plugin/docs/rules/await-thenable.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/await-thenable** for documentation. + This rule disallows awaiting a value that is not a "Thenable" (an object which has `then` method, such as a Promise). While it is valid JavaScript to await a non-`Promise`-like value (it will resolve immediately), this pattern is often a programmer error, such as forgetting to add parenthesis to call a function that returns a Promise. diff --git a/packages/eslint-plugin/docs/rules/ban-ts-comment.md b/packages/eslint-plugin/docs/rules/ban-ts-comment.md index 559acc21c2ec..4e5941215c2a 100644 --- a/packages/eslint-plugin/docs/rules/ban-ts-comment.md +++ b/packages/eslint-plugin/docs/rules/ban-ts-comment.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/ban-ts-comment** for documentation. + TypeScript provides several directive comments that can be used to alter how it processes files. Using these to suppress TypeScript Compiler Errors reduces the effectiveness of TypeScript overall. diff --git a/packages/eslint-plugin/docs/rules/ban-tslint-comment.md b/packages/eslint-plugin/docs/rules/ban-tslint-comment.md index aff145cc300f..3e5789bc005b 100644 --- a/packages/eslint-plugin/docs/rules/ban-tslint-comment.md +++ b/packages/eslint-plugin/docs/rules/ban-tslint-comment.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/ban-tslint-comment** for documentation. + Useful when migrating from TSLint to ESLint. Once TSLint has been removed, this rule helps locate TSLint annotations (e.g. `// tslint:disable`). ## Rule Details diff --git a/packages/eslint-plugin/docs/rules/ban-types.md b/packages/eslint-plugin/docs/rules/ban-types.md index f8f5a8d87c4d..256b12372fe7 100644 --- a/packages/eslint-plugin/docs/rules/ban-types.md +++ b/packages/eslint-plugin/docs/rules/ban-types.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/ban-types** for documentation. + Some builtin types have aliases, some types are considered dangerous or harmful. It's often a good idea to ban certain types to help with consistency and safety. diff --git a/packages/eslint-plugin/docs/rules/brace-style.md b/packages/eslint-plugin/docs/rules/brace-style.md index 641bf15cb0dc..923a841fcbde 100644 --- a/packages/eslint-plugin/docs/rules/brace-style.md +++ b/packages/eslint-plugin/docs/rules/brace-style.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/brace-style** for documentation. + ## Rule Details This rule extends the base [`eslint/brace-style`](https://eslint.org/docs/rules/brace-style) rule. 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 f1e997a58dd4..5b577e16136f 100644 --- a/packages/eslint-plugin/docs/rules/class-literal-property-style.md +++ b/packages/eslint-plugin/docs/rules/class-literal-property-style.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/class-literal-property-style** for documentation. + When writing TypeScript applications, it's typically safe to store literal values on classes using fields with the `readonly` modifier to prevent them from being reassigned. When writing TypeScript libraries that could be used by JavaScript users however, it's typically safer to expose these literals using `getter`s, since the `readonly` modifier is enforced at compile type. diff --git a/packages/eslint-plugin/docs/rules/comma-dangle.md b/packages/eslint-plugin/docs/rules/comma-dangle.md index 8acebcdb9f82..8d97190b8e1b 100644 --- a/packages/eslint-plugin/docs/rules/comma-dangle.md +++ b/packages/eslint-plugin/docs/rules/comma-dangle.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/comma-dangle** for documentation. + ## Rule Details This rule extends the base [`eslint/comma-dangle`](https://eslint.org/docs/rules/comma-dangle) rule. diff --git a/packages/eslint-plugin/docs/rules/comma-spacing.md b/packages/eslint-plugin/docs/rules/comma-spacing.md index 507923299d48..28ea99602d90 100644 --- a/packages/eslint-plugin/docs/rules/comma-spacing.md +++ b/packages/eslint-plugin/docs/rules/comma-spacing.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/comma-spacing** for documentation. + ## Rule Details This rule extends the base [`eslint/comma-spacing`](https://eslint.org/docs/rules/comma-spacing) rule. diff --git a/packages/eslint-plugin/docs/rules/consistent-generic-constructors.md b/packages/eslint-plugin/docs/rules/consistent-generic-constructors.md index 21737c3b2087..e62ba44bbb91 100644 --- a/packages/eslint-plugin/docs/rules/consistent-generic-constructors.md +++ b/packages/eslint-plugin/docs/rules/consistent-generic-constructors.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/consistent-generic-constructors** for documentation. + When constructing a generic class, you can specify the type arguments on either the left-hand side (as a type annotation) or the right-hand side (as part of the constructor call): ```ts 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 350065a5a0a5..56c22fec4db7 100644 --- a/packages/eslint-plugin/docs/rules/consistent-indexed-object-style.md +++ b/packages/eslint-plugin/docs/rules/consistent-indexed-object-style.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/consistent-indexed-object-style** for documentation. + TypeScript supports defining object show keys can be flexible using an index signature. TypeScript also has a builtin type named `Record` to create an empty object defining only an index signature. For example, the following types are equal: ```ts diff --git a/packages/eslint-plugin/docs/rules/consistent-type-assertions.md b/packages/eslint-plugin/docs/rules/consistent-type-assertions.md index 361feb26c38c..bb624e83b9d6 100644 --- a/packages/eslint-plugin/docs/rules/consistent-type-assertions.md +++ b/packages/eslint-plugin/docs/rules/consistent-type-assertions.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/consistent-type-assertions** for documentation. + ## Rule Details This rule aims to standardize the use of type assertion style across the codebase. diff --git a/packages/eslint-plugin/docs/rules/consistent-type-definitions.md b/packages/eslint-plugin/docs/rules/consistent-type-definitions.md index 60e539e5ef12..625bb7ba4935 100644 --- a/packages/eslint-plugin/docs/rules/consistent-type-definitions.md +++ b/packages/eslint-plugin/docs/rules/consistent-type-definitions.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/consistent-type-definitions** for documentation. + There are two ways to define a type. ```ts diff --git a/packages/eslint-plugin/docs/rules/consistent-type-exports.md b/packages/eslint-plugin/docs/rules/consistent-type-exports.md index f668a1d97614..5383a1225b10 100644 --- a/packages/eslint-plugin/docs/rules/consistent-type-exports.md +++ b/packages/eslint-plugin/docs/rules/consistent-type-exports.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/consistent-type-exports** for documentation. + TypeScript 3.8 added support for type-only exports. Type-only exports allow you to specify that 1 or more named exports are exported as type-only. This allows diff --git a/packages/eslint-plugin/docs/rules/consistent-type-imports.md b/packages/eslint-plugin/docs/rules/consistent-type-imports.md index c2722d348e49..be63fff55516 100644 --- a/packages/eslint-plugin/docs/rules/consistent-type-imports.md +++ b/packages/eslint-plugin/docs/rules/consistent-type-imports.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/consistent-type-imports** for documentation. + TypeScript 3.8 added support for type-only imports. Type-only imports allow you to specify that an import can only be used in a type location, allowing certain optimizations within compilers. diff --git a/packages/eslint-plugin/docs/rules/default-param-last.md b/packages/eslint-plugin/docs/rules/default-param-last.md index f1134510a827..3de8f8c8cd7a 100644 --- a/packages/eslint-plugin/docs/rules/default-param-last.md +++ b/packages/eslint-plugin/docs/rules/default-param-last.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/default-param-last** for documentation. + ## Rule Details This rule extends the base [`eslint/default-param-last`](https://eslint.org/docs/rules/default-param-last) rule. diff --git a/packages/eslint-plugin/docs/rules/dot-notation.md b/packages/eslint-plugin/docs/rules/dot-notation.md index fa137cb6d940..e0c7b390e5ad 100644 --- a/packages/eslint-plugin/docs/rules/dot-notation.md +++ b/packages/eslint-plugin/docs/rules/dot-notation.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/dot-notation** for documentation. + ## Rule Details This rule extends the base [`eslint/dot-notation`](https://eslint.org/docs/rules/dot-notation) rule. 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 6e2a343cadc0..d42e793a5cb2 100644 --- a/packages/eslint-plugin/docs/rules/explicit-function-return-type.md +++ b/packages/eslint-plugin/docs/rules/explicit-function-return-type.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/explicit-function-return-type** for documentation. + Explicit types for function return values makes it clear to any calling code what type is returned. This ensures that the return value is assigned to a variable of the correct type; or in the case where there is no return value, that the calling code doesn't try to use the undefined value when it diff --git a/packages/eslint-plugin/docs/rules/explicit-member-accessibility.md b/packages/eslint-plugin/docs/rules/explicit-member-accessibility.md index a9b6c94b3f72..98f297000bd5 100644 --- a/packages/eslint-plugin/docs/rules/explicit-member-accessibility.md +++ b/packages/eslint-plugin/docs/rules/explicit-member-accessibility.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/explicit-member-accessibility** for documentation. + Leaving off accessibility modifier and making everything public can make your interface hard to use by others. If you make all internal pieces private or protected, your interface will 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 d47241e9c3b9..9aa84b23a7c7 100644 --- a/packages/eslint-plugin/docs/rules/explicit-module-boundary-types.md +++ b/packages/eslint-plugin/docs/rules/explicit-module-boundary-types.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/explicit-module-boundary-types** for documentation. + Explicit types for function return values and arguments makes it clear to any calling code what is the module boundary's input and output. ## Rule Details diff --git a/packages/eslint-plugin/docs/rules/func-call-spacing.md b/packages/eslint-plugin/docs/rules/func-call-spacing.md index 94c2ebcf4d41..315e53882409 100644 --- a/packages/eslint-plugin/docs/rules/func-call-spacing.md +++ b/packages/eslint-plugin/docs/rules/func-call-spacing.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/func-call-spacing** for documentation. + ## Rule Details This rule extends the base [`eslint/func-call-spacing`](https://eslint.org/docs/rules/func-call-spacing) rule. diff --git a/packages/eslint-plugin/docs/rules/indent.md b/packages/eslint-plugin/docs/rules/indent.md index 6c12e5b84b1d..063087231a5d 100644 --- a/packages/eslint-plugin/docs/rules/indent.md +++ b/packages/eslint-plugin/docs/rules/indent.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/indent** for documentation. + ## Warning PLEASE READ THIS ISSUE BEFORE USING THIS RULE [#1824](https://github.com/typescript-eslint/typescript-eslint/issues/1824) diff --git a/packages/eslint-plugin/docs/rules/init-declarations.md b/packages/eslint-plugin/docs/rules/init-declarations.md index e730b3ec1ce2..3569bd70602a 100644 --- a/packages/eslint-plugin/docs/rules/init-declarations.md +++ b/packages/eslint-plugin/docs/rules/init-declarations.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/init-declarations** for documentation. + ## Rule Details This rule extends the base [`eslint/init-declarations`](https://eslint.org/docs/rules/init-declarations) rule. diff --git a/packages/eslint-plugin/docs/rules/keyword-spacing.md b/packages/eslint-plugin/docs/rules/keyword-spacing.md index 8ae810a56e05..6bf0de5e1870 100644 --- a/packages/eslint-plugin/docs/rules/keyword-spacing.md +++ b/packages/eslint-plugin/docs/rules/keyword-spacing.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/keyword-spacing** for documentation. + ## Rule Details This rule extends the base [`eslint/keyword-spacing`](https://eslint.org/docs/rules/keyword-spacing) rule. 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 1a73d9b1a791..2d9de3a73ce7 100644 --- a/packages/eslint-plugin/docs/rules/lines-between-class-members.md +++ b/packages/eslint-plugin/docs/rules/lines-between-class-members.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/lines-between-class-members** for documentation. + This rule improves readability by enforcing lines between class members. It will not check empty lines before the first member and after the last member. This rule require or disallow an empty line between class members. ## Rule Details diff --git a/packages/eslint-plugin/docs/rules/member-delimiter-style.md b/packages/eslint-plugin/docs/rules/member-delimiter-style.md index 36b3a20195e9..3935222e1c75 100644 --- a/packages/eslint-plugin/docs/rules/member-delimiter-style.md +++ b/packages/eslint-plugin/docs/rules/member-delimiter-style.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/member-delimiter-style** for documentation. + Enforces a consistent member delimiter style in interfaces and type literals. There are three member delimiter styles primarily used in TypeScript: - Semicolon style (default, preferred in TypeScript). diff --git a/packages/eslint-plugin/docs/rules/member-ordering.md b/packages/eslint-plugin/docs/rules/member-ordering.md index d482ef0c5beb..5dd18d6beec3 100644 --- a/packages/eslint-plugin/docs/rules/member-ordering.md +++ b/packages/eslint-plugin/docs/rules/member-ordering.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/member-ordering** for documentation. + A consistent ordering of fields, methods and constructors can make interfaces, type literals, classes and class expressions easier to read, navigate, and edit. ## Rule Details diff --git a/packages/eslint-plugin/docs/rules/method-signature-style.md b/packages/eslint-plugin/docs/rules/method-signature-style.md index 1e5094ca5d45..ad947db32610 100644 --- a/packages/eslint-plugin/docs/rules/method-signature-style.md +++ b/packages/eslint-plugin/docs/rules/method-signature-style.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/method-signature-style** for documentation. + There are two ways to define an object/interface function property. ```ts diff --git a/packages/eslint-plugin/docs/rules/naming-convention.md b/packages/eslint-plugin/docs/rules/naming-convention.md index 7ad9177be0a5..08da84d15b47 100644 --- a/packages/eslint-plugin/docs/rules/naming-convention.md +++ b/packages/eslint-plugin/docs/rules/naming-convention.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/naming-convention** for documentation. + Enforcing naming conventions helps keep the codebase consistent, and reduces overhead when thinking about how to name a variable. Additionally, a well-designed style guide can help communicate intent, such as by enforcing all private properties begin with an `_`, and all global-level constants are written in `UPPER_CASE`. diff --git a/packages/eslint-plugin/docs/rules/no-array-constructor.md b/packages/eslint-plugin/docs/rules/no-array-constructor.md index 534208b844b3..6251ddf53dc8 100644 --- a/packages/eslint-plugin/docs/rules/no-array-constructor.md +++ b/packages/eslint-plugin/docs/rules/no-array-constructor.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/no-array-constructor** for documentation. + ## Rule Details This rule extends the base [`eslint/no-array-constructor`](https://eslint.org/docs/rules/no-array-constructor) rule. 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 e5fcffc6bdbe..8e64d5eac789 100644 --- a/packages/eslint-plugin/docs/rules/no-base-to-string.md +++ b/packages/eslint-plugin/docs/rules/no-base-to-string.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/no-base-to-string** for documentation. + Requires `.toString()` to only be called on objects which provide useful information when stringified. JavaScript will call `toString()` on an object when it is converted to a string, such as when `+` adding to a string or in `${}` template literals. 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 9c077af2d8d6..f77d111bc8c8 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 @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/no-confusing-non-null-assertion** for documentation. + ## Rule Details Using a non-null assertion (`!`) next to an assign or equals check (`=` or `==` or `===`) creates code that is confusing as it looks similar to a not equals check (`!=` `!==`). 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 a1a6d744f6b4..b4d1503d3063 100644 --- a/packages/eslint-plugin/docs/rules/no-confusing-void-expression.md +++ b/packages/eslint-plugin/docs/rules/no-confusing-void-expression.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/no-confusing-void-expression** for documentation. + Returning the results of an expression whose type is void can be misleading. Attempting to do so is likely a symptom of expecting a different return type from a function. Even if used correctly, it can be misleading for other developers, 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 2d9e92431538..32e6c5dfdfba 100644 --- a/packages/eslint-plugin/docs/rules/no-dupe-class-members.md +++ b/packages/eslint-plugin/docs/rules/no-dupe-class-members.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/no-dupe-class-members** for documentation. + ## Rule Details This rule extends the base [`eslint/no-dupe-class-members`](https://eslint.org/docs/rules/no-dupe-class-members) rule. 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 ea723158974c..3e284d3eec62 100644 --- a/packages/eslint-plugin/docs/rules/no-duplicate-enum-values.md +++ b/packages/eslint-plugin/docs/rules/no-duplicate-enum-values.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/no-duplicate-enum-values** for documentation. + Although TypeScript supports duplicate enum member values, people usually expect members to have unique values within the same enum. Duplicate values can lead to bugs that are hard to track down. ## Rule Details diff --git a/packages/eslint-plugin/docs/rules/no-duplicate-imports.md b/packages/eslint-plugin/docs/rules/no-duplicate-imports.md index 67b53b8fe8ed..613043bedb4f 100644 --- a/packages/eslint-plugin/docs/rules/no-duplicate-imports.md +++ b/packages/eslint-plugin/docs/rules/no-duplicate-imports.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/no-duplicate-imports** for documentation. + ## DEPRECATED This rule has been deprecated in favour of the [`import/no-duplicates`](https://github.com/import-js/eslint-plugin-import/blob/HEAD/docs/rules/no-duplicates.md) rule. diff --git a/packages/eslint-plugin/docs/rules/no-dynamic-delete.md b/packages/eslint-plugin/docs/rules/no-dynamic-delete.md index 7d9a9f7005e2..7c6090f812f8 100644 --- a/packages/eslint-plugin/docs/rules/no-dynamic-delete.md +++ b/packages/eslint-plugin/docs/rules/no-dynamic-delete.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/no-dynamic-delete** for documentation. + Deleting dynamically computed keys can be dangerous and in some cases not well optimized. ## Rule Details diff --git a/packages/eslint-plugin/docs/rules/no-empty-function.md b/packages/eslint-plugin/docs/rules/no-empty-function.md index 60801436bc49..121db4ff8786 100644 --- a/packages/eslint-plugin/docs/rules/no-empty-function.md +++ b/packages/eslint-plugin/docs/rules/no-empty-function.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/no-empty-function** for documentation. + ## Rule Details This rule extends the base [`eslint/no-empty-function`](https://eslint.org/docs/rules/no-empty-function) rule. diff --git a/packages/eslint-plugin/docs/rules/no-empty-interface.md b/packages/eslint-plugin/docs/rules/no-empty-interface.md index 409acea106cd..beed5a85ecc7 100644 --- a/packages/eslint-plugin/docs/rules/no-empty-interface.md +++ b/packages/eslint-plugin/docs/rules/no-empty-interface.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/no-empty-interface** for documentation. + An empty interface is equivalent to its supertype. If the interface does not implement a supertype, then the interface is equivalent to an empty object (`{}`). In both cases it can be omitted. diff --git a/packages/eslint-plugin/docs/rules/no-explicit-any.md b/packages/eslint-plugin/docs/rules/no-explicit-any.md index cf2cefb78568..f8e42896dbd4 100644 --- a/packages/eslint-plugin/docs/rules/no-explicit-any.md +++ b/packages/eslint-plugin/docs/rules/no-explicit-any.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/no-explicit-any** for documentation. + Using the `any` type defeats the purpose of using TypeScript. When `any` is used, all compiler type checks around that value are ignored. 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 e038a5f00212..6c7068b693b0 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 @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/no-extra-non-null-assertion** for documentation. + ## Rule Details Examples of code for this rule: diff --git a/packages/eslint-plugin/docs/rules/no-extra-parens.md b/packages/eslint-plugin/docs/rules/no-extra-parens.md index 5eace5e8eded..8bd5ac2c7d68 100644 --- a/packages/eslint-plugin/docs/rules/no-extra-parens.md +++ b/packages/eslint-plugin/docs/rules/no-extra-parens.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/no-extra-parens** for documentation. + ## Rule Details This rule extends the base [`eslint/no-extra-parens`](https://eslint.org/docs/rules/no-extra-parens) rule. diff --git a/packages/eslint-plugin/docs/rules/no-extra-semi.md b/packages/eslint-plugin/docs/rules/no-extra-semi.md index b8fa04c6db70..0b94c91de590 100644 --- a/packages/eslint-plugin/docs/rules/no-extra-semi.md +++ b/packages/eslint-plugin/docs/rules/no-extra-semi.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/no-extra-semi** for documentation. + ## Rule Details This rule extends the base [`eslint/no-extra-semi`](https://eslint.org/docs/rules/no-extra-semi) rule. diff --git a/packages/eslint-plugin/docs/rules/no-extraneous-class.md b/packages/eslint-plugin/docs/rules/no-extraneous-class.md index 0a9b698868a9..fa990f2cebfd 100644 --- a/packages/eslint-plugin/docs/rules/no-extraneous-class.md +++ b/packages/eslint-plugin/docs/rules/no-extraneous-class.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/no-extraneous-class** for documentation. + This rule warns when a class has no non-static members, such as for a class used exclusively as a static namespace. ## Rule Details diff --git a/packages/eslint-plugin/docs/rules/no-floating-promises.md b/packages/eslint-plugin/docs/rules/no-floating-promises.md index 0feb4cfe72ce..45fddc3c6219 100644 --- a/packages/eslint-plugin/docs/rules/no-floating-promises.md +++ b/packages/eslint-plugin/docs/rules/no-floating-promises.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/no-floating-promises** for documentation. + A "floating" Promise is one that is created without any code set up to handle any errors it might throw. Floating Promises can cause several issues, such as improperly sequenced operations, ignored Promise rejections, and more. 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 b054549984b2..29d0c2548a48 100644 --- a/packages/eslint-plugin/docs/rules/no-for-in-array.md +++ b/packages/eslint-plugin/docs/rules/no-for-in-array.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/no-for-in-array** for documentation. + This rule prohibits iterating over an array with a for-in loop. ## Rule Details 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 9b03128039e1..97afdfd57877 100644 --- a/packages/eslint-plugin/docs/rules/no-implicit-any-catch.md +++ b/packages/eslint-plugin/docs/rules/no-implicit-any-catch.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/no-implicit-any-catch** for documentation. + TypeScript 4.0 added support for adding an explicit `any` or `unknown` type annotation on a catch clause variable. By default, TypeScript will type a catch clause variable as `any`, so explicitly annotating it as `unknown` can add a lot of safety to your codebase. diff --git a/packages/eslint-plugin/docs/rules/no-implied-eval.md b/packages/eslint-plugin/docs/rules/no-implied-eval.md index 2ef6560950fa..5cd9a9113a5d 100644 --- a/packages/eslint-plugin/docs/rules/no-implied-eval.md +++ b/packages/eslint-plugin/docs/rules/no-implied-eval.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/no-implied-eval** for documentation. + It's considered a good practice to avoid using `eval()`. There are security and performance implications involved with doing so, which is why many linters recommend disallowing `eval()`. However, there are some other ways to pass a string and have it interpreted as JavaScript code that have similar concerns. The first is using `setTimeout()`, `setInterval()`, `setImmediate` or `execScript()` (Internet Explorer only), all of which can accept a string of code as their first argument diff --git a/packages/eslint-plugin/docs/rules/no-inferrable-types.md b/packages/eslint-plugin/docs/rules/no-inferrable-types.md index cfcd4f6281f1..73fcfd7ae520 100644 --- a/packages/eslint-plugin/docs/rules/no-inferrable-types.md +++ b/packages/eslint-plugin/docs/rules/no-inferrable-types.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/no-inferrable-types** for documentation. + Explicit types where they can be easily inferred may add unnecessary verbosity. ## Rule Details diff --git a/packages/eslint-plugin/docs/rules/no-invalid-this.md b/packages/eslint-plugin/docs/rules/no-invalid-this.md index 37c468db8400..22e7de7260bf 100644 --- a/packages/eslint-plugin/docs/rules/no-invalid-this.md +++ b/packages/eslint-plugin/docs/rules/no-invalid-this.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/no-invalid-this** for documentation. + ## Rule Details This rule extends the base [`eslint/no-invalid-this`](https://eslint.org/docs/rules/no-invalid-this) rule. 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 bf94bd58b39b..0b4f93385225 100644 --- a/packages/eslint-plugin/docs/rules/no-invalid-void-type.md +++ b/packages/eslint-plugin/docs/rules/no-invalid-void-type.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/no-invalid-void-type** for documentation. + Disallows usage of `void` type outside of return types or generic type arguments. If `void` is used as return type, it shouldn’t be a part of intersection/union type with most other types. diff --git a/packages/eslint-plugin/docs/rules/no-loop-func.md b/packages/eslint-plugin/docs/rules/no-loop-func.md index d40d8a1aa8d2..906ab28e856a 100644 --- a/packages/eslint-plugin/docs/rules/no-loop-func.md +++ b/packages/eslint-plugin/docs/rules/no-loop-func.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/no-loop-func** for documentation. + ## Rule Details This rule extends the base [`eslint/no-loop-func`](https://eslint.org/docs/rules/no-loop-func) rule. 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 e4906b87b320..bf0ed85f39d3 100644 --- a/packages/eslint-plugin/docs/rules/no-loss-of-precision.md +++ b/packages/eslint-plugin/docs/rules/no-loss-of-precision.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/no-loss-of-precision** for documentation. + ## Rule Details This rule extends the base [`eslint/no-loss-of-precision`](https://eslint.org/docs/rules/no-loss-of-precision) rule. diff --git a/packages/eslint-plugin/docs/rules/no-magic-numbers.md b/packages/eslint-plugin/docs/rules/no-magic-numbers.md index c367e370ee33..b352b892ffcf 100644 --- a/packages/eslint-plugin/docs/rules/no-magic-numbers.md +++ b/packages/eslint-plugin/docs/rules/no-magic-numbers.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/no-magic-numbers** for documentation. + ## Rule Details This rule extends the base [`eslint/no-magic-numbers`](https://eslint.org/docs/rules/no-magic-numbers) rule. 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 6a664ef6862b..e0aba22a7232 100644 --- a/packages/eslint-plugin/docs/rules/no-meaningless-void-operator.md +++ b/packages/eslint-plugin/docs/rules/no-meaningless-void-operator.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/no-meaningless-void-operator** for documentation. + Disallows the `void` operator when its argument is already of type `void` or `undefined`. ## Rule Details diff --git a/packages/eslint-plugin/docs/rules/no-misused-new.md b/packages/eslint-plugin/docs/rules/no-misused-new.md index 250b02d49893..b79af1f3eb3b 100644 --- a/packages/eslint-plugin/docs/rules/no-misused-new.md +++ b/packages/eslint-plugin/docs/rules/no-misused-new.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/no-misused-new** for documentation. + Warns on apparent attempts to define constructors for interfaces or `new` for classes. ## Rule Details diff --git a/packages/eslint-plugin/docs/rules/no-misused-promises.md b/packages/eslint-plugin/docs/rules/no-misused-promises.md index 4e5bdcb32e68..62156bc8f134 100644 --- a/packages/eslint-plugin/docs/rules/no-misused-promises.md +++ b/packages/eslint-plugin/docs/rules/no-misused-promises.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/no-misused-promises** for documentation. + This rule forbids providing Promises to logical locations such as if statements in places where the TypeScript compiler allows them but they are not handled properly. These situations can often arise due to a missing `await` keyword or just a misunderstanding of the way async functions are handled/awaited. diff --git a/packages/eslint-plugin/docs/rules/no-namespace.md b/packages/eslint-plugin/docs/rules/no-namespace.md index ec0fe6af3805..f59c865c5b7d 100644 --- a/packages/eslint-plugin/docs/rules/no-namespace.md +++ b/packages/eslint-plugin/docs/rules/no-namespace.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/no-namespace** for documentation. + Custom TypeScript modules (`module foo {}`) and namespaces (`namespace foo {}`) are considered outdated ways to organize TypeScript code. ES2015 module syntax is now preferred (`import`/`export`). 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 659658349e8e..b9008a8f78c7 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 @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/no-non-null-asserted-nullish-coalescing** for documentation. + ## Rule Details The nullish coalescing operator is designed to provide a default value when dealing with `null` or `undefined`. 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 8dcb92b0e6bc..aff4d5b47c41 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 @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/no-non-null-asserted-optional-chain** for documentation. + ## Rule Details Optional chain expressions are designed to return `undefined` if the optional property is nullish. 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 42059d843645..0eb9b4970c58 100644 --- a/packages/eslint-plugin/docs/rules/no-non-null-assertion.md +++ b/packages/eslint-plugin/docs/rules/no-non-null-assertion.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/no-non-null-assertion** for documentation. + ## Rule Details Using non-null assertions cancels the benefits of the strict null-checking mode. diff --git a/packages/eslint-plugin/docs/rules/no-parameter-properties.md b/packages/eslint-plugin/docs/rules/no-parameter-properties.md index 7b5f772df1ca..3eaf06055033 100644 --- a/packages/eslint-plugin/docs/rules/no-parameter-properties.md +++ b/packages/eslint-plugin/docs/rules/no-parameter-properties.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/no-parameter-properties** for documentation. + Parameter properties can be confusing to those new to TypeScript as they are less explicit than other ways of declaring and initializing class members. diff --git a/packages/eslint-plugin/docs/rules/no-redeclare.md b/packages/eslint-plugin/docs/rules/no-redeclare.md index b69f50f3f981..4ebaba2ee5ee 100644 --- a/packages/eslint-plugin/docs/rules/no-redeclare.md +++ b/packages/eslint-plugin/docs/rules/no-redeclare.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/no-redeclare** for documentation. + ## Rule Details This rule extends the base [`eslint/no-redeclare`](https://eslint.org/docs/rules/no-redeclare) rule. 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 39b85e38f82a..cbfde25358fd 100644 --- a/packages/eslint-plugin/docs/rules/no-redundant-type-constituents.md +++ b/packages/eslint-plugin/docs/rules/no-redundant-type-constituents.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/no-redundant-type-constituents** for documentation. + ## Rule Details Some types can override some other types ("constituents") in a union or intersection and/or be overridden by some other types. diff --git a/packages/eslint-plugin/docs/rules/no-require-imports.md b/packages/eslint-plugin/docs/rules/no-require-imports.md index c7d697b2225f..0a3ddd5d2f9f 100644 --- a/packages/eslint-plugin/docs/rules/no-require-imports.md +++ b/packages/eslint-plugin/docs/rules/no-require-imports.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/no-require-imports** for documentation. + Prefer the newer ES6-style imports over `require()`. ## Rule Details diff --git a/packages/eslint-plugin/docs/rules/no-restricted-imports.md b/packages/eslint-plugin/docs/rules/no-restricted-imports.md index 5e13b4541f57..89f615c194e2 100644 --- a/packages/eslint-plugin/docs/rules/no-restricted-imports.md +++ b/packages/eslint-plugin/docs/rules/no-restricted-imports.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/no-restricted-imports** for documentation. + ## Rule Details This rule extends the base [`eslint/no-restricted-imports`](https://eslint.org/docs/rules/no-restricted-imports) rule. diff --git a/packages/eslint-plugin/docs/rules/no-shadow.md b/packages/eslint-plugin/docs/rules/no-shadow.md index fea79d118d0a..3da0a6bc6fbd 100644 --- a/packages/eslint-plugin/docs/rules/no-shadow.md +++ b/packages/eslint-plugin/docs/rules/no-shadow.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/no-shadow** for documentation. + ## Rule Details This rule extends the base [`eslint/no-shadow`](https://eslint.org/docs/rules/no-shadow) rule. diff --git a/packages/eslint-plugin/docs/rules/no-this-alias.md b/packages/eslint-plugin/docs/rules/no-this-alias.md index 0faf7881262e..3433ae28eb0c 100644 --- a/packages/eslint-plugin/docs/rules/no-this-alias.md +++ b/packages/eslint-plugin/docs/rules/no-this-alias.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/no-this-alias** for documentation. + This rule prohibits assigning variables to `this`. ## Rule Details diff --git a/packages/eslint-plugin/docs/rules/no-throw-literal.md b/packages/eslint-plugin/docs/rules/no-throw-literal.md index 249f8e1f97f9..a95aeb1a06b5 100644 --- a/packages/eslint-plugin/docs/rules/no-throw-literal.md +++ b/packages/eslint-plugin/docs/rules/no-throw-literal.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/no-throw-literal** for documentation. + It is considered good practice to only `throw` the `Error` object itself or an object using the `Error` object as base objects for user-defined exceptions. The fundamental benefit of `Error` objects is that they automatically keep track of where they were built and originated. diff --git a/packages/eslint-plugin/docs/rules/no-type-alias.md b/packages/eslint-plugin/docs/rules/no-type-alias.md index aca6603d9b63..e2b95b917382 100644 --- a/packages/eslint-plugin/docs/rules/no-type-alias.md +++ b/packages/eslint-plugin/docs/rules/no-type-alias.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/no-type-alias** for documentation. + In TypeScript, type aliases serve three purposes: - Aliasing other types so that we can refer to them using a simpler name. 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 a7b927298ac8..80142fe65380 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 @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/no-unnecessary-boolean-literal-compare** for documentation. + Comparing boolean values to boolean literals is unnecessary, those comparisons result in the same booleans. Using the boolean values directly, or via a unary negation (`!value`), is more concise and clearer. ## Rule Details diff --git a/packages/eslint-plugin/docs/rules/no-unnecessary-condition.md b/packages/eslint-plugin/docs/rules/no-unnecessary-condition.md index b65a67840945..2594184ea02b 100644 --- a/packages/eslint-plugin/docs/rules/no-unnecessary-condition.md +++ b/packages/eslint-plugin/docs/rules/no-unnecessary-condition.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/no-unnecessary-condition** for documentation. + Any expression being used as a condition must be able to evaluate as truthy or falsy in order to be considered "necessary". Conversely, any expression that always evaluates to truthy or always evaluates to falsy, as determined by the type of the expression, is considered unnecessary and will be flagged by this rule. The following expressions are checked: diff --git a/packages/eslint-plugin/docs/rules/no-unnecessary-qualifier.md b/packages/eslint-plugin/docs/rules/no-unnecessary-qualifier.md index 29d77d188157..31905c485f4d 100644 --- a/packages/eslint-plugin/docs/rules/no-unnecessary-qualifier.md +++ b/packages/eslint-plugin/docs/rules/no-unnecessary-qualifier.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/no-unnecessary-qualifier** for documentation. + ## Rule Details This rule aims to let users know when a namespace or enum qualifier is unnecessary, 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 871026d39f41..6f15d1493753 100644 --- a/packages/eslint-plugin/docs/rules/no-unnecessary-type-arguments.md +++ b/packages/eslint-plugin/docs/rules/no-unnecessary-type-arguments.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/no-unnecessary-type-arguments** for documentation. + Warns if an explicitly specified type argument is the default for that type parameter. ## Rule Details 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 fe1c25a2889d..b8e91cf74c49 100644 --- a/packages/eslint-plugin/docs/rules/no-unnecessary-type-assertion.md +++ b/packages/eslint-plugin/docs/rules/no-unnecessary-type-assertion.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/no-unnecessary-type-assertion** for documentation. + This rule prohibits using a type assertion that does not change the type of an expression. ## Rule Details 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 530243a90651..4cd813ec0d6d 100644 --- a/packages/eslint-plugin/docs/rules/no-unnecessary-type-constraint.md +++ b/packages/eslint-plugin/docs/rules/no-unnecessary-type-constraint.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/no-unnecessary-type-constraint** for documentation. + ## Rule Details Type parameters (``) may be "constrained" with an `extends` keyword ([docs](https://www.typescriptlang.org/docs/handbook/generics.html#generic-constraints)). diff --git a/packages/eslint-plugin/docs/rules/no-unsafe-argument.md b/packages/eslint-plugin/docs/rules/no-unsafe-argument.md index a49da4419448..15e1c82e7ff6 100644 --- a/packages/eslint-plugin/docs/rules/no-unsafe-argument.md +++ b/packages/eslint-plugin/docs/rules/no-unsafe-argument.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/no-unsafe-argument** for documentation. + Despite your best intentions, the `any` type can sometimes leak into your codebase. Call a function with `any` typed argument are not checked at all by TypeScript, so it creates a potential safety hole, and source of bugs in your codebase. diff --git a/packages/eslint-plugin/docs/rules/no-unsafe-assignment.md b/packages/eslint-plugin/docs/rules/no-unsafe-assignment.md index c793fae3d819..309d0b13d2e8 100644 --- a/packages/eslint-plugin/docs/rules/no-unsafe-assignment.md +++ b/packages/eslint-plugin/docs/rules/no-unsafe-assignment.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/no-unsafe-assignment** for documentation. + Despite your best intentions, the `any` type can sometimes leak into your codebase. Assigning an `any` typed value to a variable can be hard to pick up on, particularly if it leaks in from an external library. Operations on the variable will not be checked at all by TypeScript, so it creates a potential safety hole, and source of bugs in your codebase. diff --git a/packages/eslint-plugin/docs/rules/no-unsafe-call.md b/packages/eslint-plugin/docs/rules/no-unsafe-call.md index 1505882e8b26..103aa55e7b23 100644 --- a/packages/eslint-plugin/docs/rules/no-unsafe-call.md +++ b/packages/eslint-plugin/docs/rules/no-unsafe-call.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/no-unsafe-call** for documentation. + Despite your best intentions, the `any` type can sometimes leak into your codebase. The arguments to, and return value of calling an `any` typed variable are not checked at all by TypeScript, so it creates a potential safety hole, and source of bugs in your codebase. 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 cad9d4418746..c90028aa6643 100644 --- a/packages/eslint-plugin/docs/rules/no-unsafe-member-access.md +++ b/packages/eslint-plugin/docs/rules/no-unsafe-member-access.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/no-unsafe-member-access** for documentation. + Despite your best intentions, the `any` type can sometimes leak into your codebase. Member access on `any` typed variables is not checked at all by TypeScript, so it creates a potential safety hole, and source of bugs in your codebase. diff --git a/packages/eslint-plugin/docs/rules/no-unsafe-return.md b/packages/eslint-plugin/docs/rules/no-unsafe-return.md index 5c62e9e9f616..d2e5a36f309c 100644 --- a/packages/eslint-plugin/docs/rules/no-unsafe-return.md +++ b/packages/eslint-plugin/docs/rules/no-unsafe-return.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/no-unsafe-return** for documentation. + Despite your best intentions, the `any` type can sometimes leak into your codebase. Returned `any` typed values are not checked at all by TypeScript, so it creates a potential safety hole, and source of bugs in your codebase. diff --git a/packages/eslint-plugin/docs/rules/no-unused-expressions.md b/packages/eslint-plugin/docs/rules/no-unused-expressions.md index a5b8b84a6561..2e6a002ba51c 100644 --- a/packages/eslint-plugin/docs/rules/no-unused-expressions.md +++ b/packages/eslint-plugin/docs/rules/no-unused-expressions.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/no-unused-expressions** for documentation. + ## Rule Details This rule extends the base [`eslint/no-unused-expressions`](https://eslint.org/docs/rules/no-unused-expressions) rule. diff --git a/packages/eslint-plugin/docs/rules/no-unused-vars.md b/packages/eslint-plugin/docs/rules/no-unused-vars.md index ffd067aab1d4..4902c1e72592 100644 --- a/packages/eslint-plugin/docs/rules/no-unused-vars.md +++ b/packages/eslint-plugin/docs/rules/no-unused-vars.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/no-unused-vars** for documentation. + ## Rule Details This rule extends the base [`eslint/no-unused-vars`](https://eslint.org/docs/rules/no-unused-vars) rule. 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 6eac9eb60eaa..dfc9c354d49d 100644 --- a/packages/eslint-plugin/docs/rules/no-use-before-define.md +++ b/packages/eslint-plugin/docs/rules/no-use-before-define.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/no-use-before-define** for documentation. + ## Rule Details This rule extends the base [`eslint/no-use-before-define`](https://eslint.org/docs/rules/no-use-before-define) rule. diff --git a/packages/eslint-plugin/docs/rules/no-useless-constructor.md b/packages/eslint-plugin/docs/rules/no-useless-constructor.md index 14fb6bf345e7..8892c1c9e29e 100644 --- a/packages/eslint-plugin/docs/rules/no-useless-constructor.md +++ b/packages/eslint-plugin/docs/rules/no-useless-constructor.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/no-useless-constructor** for documentation. + ## Rule Details This rule extends the base [`eslint/no-useless-constructor`](https://eslint.org/docs/rules/no-useless-constructor) rule. 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 27783498fc40..1687bfacc91b 100644 --- a/packages/eslint-plugin/docs/rules/no-useless-empty-export.md +++ b/packages/eslint-plugin/docs/rules/no-useless-empty-export.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/no-useless-empty-export** for documentation. + ## Rule Details An empty `export {}` statement is sometimes useful in TypeScript code to turn a file that would otherwise be a script file into a module file. diff --git a/packages/eslint-plugin/docs/rules/no-var-requires.md b/packages/eslint-plugin/docs/rules/no-var-requires.md index 18bd664f8da0..247535b011e9 100644 --- a/packages/eslint-plugin/docs/rules/no-var-requires.md +++ b/packages/eslint-plugin/docs/rules/no-var-requires.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/no-var-requires** for documentation. + In other words, the use of forms such as `var foo = require("foo")` are banned. Instead use ES6 style imports or `import foo = require("foo")` imports. ## Rule Details 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 749d5f9f909b..486f464d77e1 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 @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/non-nullable-type-assertion-style** for documentation. + This rule detects when an `as` cast is doing the same job as a `!` would, and suggests fixing the code to be an `!`. ## Rule Details diff --git a/packages/eslint-plugin/docs/rules/object-curly-spacing.md b/packages/eslint-plugin/docs/rules/object-curly-spacing.md index e9e805ab9796..31f878363b19 100644 --- a/packages/eslint-plugin/docs/rules/object-curly-spacing.md +++ b/packages/eslint-plugin/docs/rules/object-curly-spacing.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/object-curly-spacing** for documentation. + ## Rule Details This rule extends the base [`eslint/object-curly-spacing`](https://eslint.org/docs/rules/object-curly-spacing) rule. 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 0668e3c05b78..69951c378524 100644 --- a/packages/eslint-plugin/docs/rules/padding-line-between-statements.md +++ b/packages/eslint-plugin/docs/rules/padding-line-between-statements.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/padding-line-between-statements** for documentation. + ## Rule Details This rule extends the base [`eslint/padding-line-between-statements`](https://eslint.org/docs/rules/padding-line-between-statements) rule. diff --git a/packages/eslint-plugin/docs/rules/parameter-properties.md b/packages/eslint-plugin/docs/rules/parameter-properties.md index d01a87596936..3b8e4821ea3b 100644 --- a/packages/eslint-plugin/docs/rules/parameter-properties.md +++ b/packages/eslint-plugin/docs/rules/parameter-properties.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/parameter-properties** for documentation. + Parameter properties can be confusing to those new to TypeScript as they are less explicit than other ways of declaring and initializing class members. diff --git a/packages/eslint-plugin/docs/rules/prefer-as-const.md b/packages/eslint-plugin/docs/rules/prefer-as-const.md index 871c04a04d05..ce6de3345444 100644 --- a/packages/eslint-plugin/docs/rules/prefer-as-const.md +++ b/packages/eslint-plugin/docs/rules/prefer-as-const.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/prefer-as-const** for documentation. + This rule recommends usage of `const` assertion when type primitive value is equal to type. ## Rule Details diff --git a/packages/eslint-plugin/docs/rules/prefer-enum-initializers.md b/packages/eslint-plugin/docs/rules/prefer-enum-initializers.md index 93dfe2fb6719..c16f00bc8641 100644 --- a/packages/eslint-plugin/docs/rules/prefer-enum-initializers.md +++ b/packages/eslint-plugin/docs/rules/prefer-enum-initializers.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/prefer-enum-initializers** for documentation. + This rule recommends having each `enum`s member value explicitly initialized. `enum`s are a practical way to organize semantically related constant values. However, by implicitly defining values, `enum`s can lead to unexpected bugs if it's modified without paying attention to the order of its items. diff --git a/packages/eslint-plugin/docs/rules/prefer-for-of.md b/packages/eslint-plugin/docs/rules/prefer-for-of.md index 06162217c783..575e45b39e15 100644 --- a/packages/eslint-plugin/docs/rules/prefer-for-of.md +++ b/packages/eslint-plugin/docs/rules/prefer-for-of.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/prefer-for-of** for documentation. + This rule recommends a for-of loop when the loop index is only used to read from an array that is being iterated. ## Rule Details diff --git a/packages/eslint-plugin/docs/rules/prefer-function-type.md b/packages/eslint-plugin/docs/rules/prefer-function-type.md index 7b8ec069f6d3..8c0e9de2b5ca 100644 --- a/packages/eslint-plugin/docs/rules/prefer-function-type.md +++ b/packages/eslint-plugin/docs/rules/prefer-function-type.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/prefer-function-type** for documentation. + ## Rule Details This rule suggests using a function type instead of an interface or object type literal with a single call signature. diff --git a/packages/eslint-plugin/docs/rules/prefer-includes.md b/packages/eslint-plugin/docs/rules/prefer-includes.md index 5309a204dbc4..3eec29ab8923 100644 --- a/packages/eslint-plugin/docs/rules/prefer-includes.md +++ b/packages/eslint-plugin/docs/rules/prefer-includes.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/prefer-includes** for documentation. + Until ES5, we were using `String#indexOf` method to check whether a string contains an arbitrary substring or not. Until ES2015, we were using `Array#indexOf` method to check whether an array contains an arbitrary value or not. 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 52bb1674e936..31f452be2ef4 100644 --- a/packages/eslint-plugin/docs/rules/prefer-literal-enum-member.md +++ b/packages/eslint-plugin/docs/rules/prefer-literal-enum-member.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/prefer-literal-enum-member** for documentation. + TypeScript allows the value of an enum member to be many different kinds of valid JavaScript expressions. However, because enums create their own scope whereby each enum member becomes a variable in that scope, unexpected values could be used at runtime. Example: ```ts diff --git a/packages/eslint-plugin/docs/rules/prefer-namespace-keyword.md b/packages/eslint-plugin/docs/rules/prefer-namespace-keyword.md index d2fe7e7a7781..bc7b601934d2 100644 --- a/packages/eslint-plugin/docs/rules/prefer-namespace-keyword.md +++ b/packages/eslint-plugin/docs/rules/prefer-namespace-keyword.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/prefer-namespace-keyword** for documentation. + In an effort to prevent further confusion between custom TypeScript modules and the new ES2015 modules, starting with TypeScript `v1.5` the keyword `namespace` is now the preferred way to declare custom TypeScript modules. diff --git a/packages/eslint-plugin/docs/rules/prefer-nullish-coalescing.md b/packages/eslint-plugin/docs/rules/prefer-nullish-coalescing.md index e8355f918650..5e47975ad3ff 100644 --- a/packages/eslint-plugin/docs/rules/prefer-nullish-coalescing.md +++ b/packages/eslint-plugin/docs/rules/prefer-nullish-coalescing.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/prefer-nullish-coalescing** for documentation. + TypeScript 3.7 added support for the nullish coalescing operator. This operator allows you to safely cascade a value when dealing with `null` or `undefined`. diff --git a/packages/eslint-plugin/docs/rules/prefer-optional-chain.md b/packages/eslint-plugin/docs/rules/prefer-optional-chain.md index a38008a888e6..730842c1512d 100644 --- a/packages/eslint-plugin/docs/rules/prefer-optional-chain.md +++ b/packages/eslint-plugin/docs/rules/prefer-optional-chain.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/prefer-optional-chain** for documentation. + TypeScript 3.7 added support for the optional chain operator. This operator allows you to safely access properties and methods on objects when they are potentially `null` or `undefined`. 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 8486a1281326..022b4e841bc9 100644 --- a/packages/eslint-plugin/docs/rules/prefer-readonly-parameter-types.md +++ b/packages/eslint-plugin/docs/rules/prefer-readonly-parameter-types.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/prefer-readonly-parameter-types** for documentation. + Mutating function arguments can lead to confusing, hard to debug behavior. Whilst it's easy to implicitly remember to not modify function arguments, explicitly typing arguments as readonly provides clear contract to consumers. This contract makes it easier for a consumer to reason about if a function has side-effects. diff --git a/packages/eslint-plugin/docs/rules/prefer-readonly.md b/packages/eslint-plugin/docs/rules/prefer-readonly.md index 1688ecd43b9d..e21f26a278ba 100644 --- a/packages/eslint-plugin/docs/rules/prefer-readonly.md +++ b/packages/eslint-plugin/docs/rules/prefer-readonly.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/prefer-readonly** for documentation. + This rule enforces that private members are marked as `readonly` if they're never modified outside of the constructor. ## Rule Details 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 5bf7ef200952..5db156aa47f2 100644 --- a/packages/eslint-plugin/docs/rules/prefer-reduce-type-parameter.md +++ b/packages/eslint-plugin/docs/rules/prefer-reduce-type-parameter.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/prefer-reduce-type-parameter** for documentation. + It's common to call `Array#reduce` with a generic type, such as an array or object, as the initial value. Since these values are empty, their types are not usable: diff --git a/packages/eslint-plugin/docs/rules/prefer-regexp-exec.md b/packages/eslint-plugin/docs/rules/prefer-regexp-exec.md index 135ede506c20..a487ea3d3e24 100644 --- a/packages/eslint-plugin/docs/rules/prefer-regexp-exec.md +++ b/packages/eslint-plugin/docs/rules/prefer-regexp-exec.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/prefer-regexp-exec** for documentation. + As `String#match` is defined to be the same as `RegExp#exec` when the regular expression does not include the `g` flag, prefer a consistent usage. ## Rule Details 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 a49c961af7a0..0581d81ad02b 100644 --- a/packages/eslint-plugin/docs/rules/prefer-return-this-type.md +++ b/packages/eslint-plugin/docs/rules/prefer-return-this-type.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/prefer-return-this-type** for documentation. + [Method chaining](https://en.wikipedia.org/wiki/Method_chaining) is a common pattern in OOP languages and TypeScript provides a special [polymorphic this type](https://www.typescriptlang.org/docs/handbook/2/classes.html#this-types). If any type other than `this` is specified as the return type of these chaining methods, TypeScript will fail to cast it when invoking in subclass. 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 e576d1958da8..2be24df3c21b 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 @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/prefer-string-starts-ends-with** for documentation. + There are multiple ways to verify if a string starts or ends with a specific string, such as `foo.indexOf('bar') === 0`. Since ES2015 has added `String#startsWith` and `String#endsWith`, this rule reports other ways to be consistent. 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 f46f9d95f888..bfcaad11b0ab 100644 --- a/packages/eslint-plugin/docs/rules/prefer-ts-expect-error.md +++ b/packages/eslint-plugin/docs/rules/prefer-ts-expect-error.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/prefer-ts-expect-error** for documentation. + TypeScript allows you to suppress all errors on a line by placing a single-line comment or a comment block line starting with `@ts-ignore` immediately before the erroring line. While powerful, there is no way to know if a `@ts-ignore` is actually suppressing an error without manually investigating what happens when the `@ts-ignore` is removed. diff --git a/packages/eslint-plugin/docs/rules/promise-function-async.md b/packages/eslint-plugin/docs/rules/promise-function-async.md index fa800fd6c081..424536ee5f24 100644 --- a/packages/eslint-plugin/docs/rules/promise-function-async.md +++ b/packages/eslint-plugin/docs/rules/promise-function-async.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/promise-function-async** for documentation. + Ensures that each function is only capable of: - returning a rejected promise, or diff --git a/packages/eslint-plugin/docs/rules/quotes.md b/packages/eslint-plugin/docs/rules/quotes.md index 608db1fc8e1e..61cadea2047a 100644 --- a/packages/eslint-plugin/docs/rules/quotes.md +++ b/packages/eslint-plugin/docs/rules/quotes.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/quotes** for documentation. + ## Rule Details This rule extends the base [`eslint/quotes`](https://eslint.org/docs/rules/quotes) rule. 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 49b54d8582b9..d4b006c1d70f 100644 --- a/packages/eslint-plugin/docs/rules/require-array-sort-compare.md +++ b/packages/eslint-plugin/docs/rules/require-array-sort-compare.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/require-array-sort-compare** for documentation. + This rule prevents invoking the `Array#sort()` method without providing a `compare` argument. When called without a compare function, `Array#sort()` converts all non-undefined array elements into strings and then compares said strings based off their UTF-16 code units. diff --git a/packages/eslint-plugin/docs/rules/require-await.md b/packages/eslint-plugin/docs/rules/require-await.md index 2b460a6f1ab8..21d6271c38c4 100644 --- a/packages/eslint-plugin/docs/rules/require-await.md +++ b/packages/eslint-plugin/docs/rules/require-await.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/require-await** for documentation. + ## Rule Details This rule extends the base [`eslint/require-await`](https://eslint.org/docs/rules/require-await) rule. diff --git a/packages/eslint-plugin/docs/rules/restrict-plus-operands.md b/packages/eslint-plugin/docs/rules/restrict-plus-operands.md index ace09e656a61..5b984f0b21c5 100644 --- a/packages/eslint-plugin/docs/rules/restrict-plus-operands.md +++ b/packages/eslint-plugin/docs/rules/restrict-plus-operands.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/restrict-plus-operands** for documentation. + ## Rule Details Examples of code for this rule: diff --git a/packages/eslint-plugin/docs/rules/restrict-template-expressions.md b/packages/eslint-plugin/docs/rules/restrict-template-expressions.md index a06c717b2b70..37423d23abc4 100644 --- a/packages/eslint-plugin/docs/rules/restrict-template-expressions.md +++ b/packages/eslint-plugin/docs/rules/restrict-template-expressions.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/restrict-template-expressions** for documentation. + ## Rule Details Examples of code for this rule: diff --git a/packages/eslint-plugin/docs/rules/return-await.md b/packages/eslint-plugin/docs/rules/return-await.md index 6162ddcef7e6..1aa62401ae49 100644 --- a/packages/eslint-plugin/docs/rules/return-await.md +++ b/packages/eslint-plugin/docs/rules/return-await.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/return-await** for documentation. + Returning an awaited promise can make sense for better stack trace information as well as for consistent error handling (returned promises will not be caught in an async function try/catch). ## Rule Details diff --git a/packages/eslint-plugin/docs/rules/semi.md b/packages/eslint-plugin/docs/rules/semi.md index 0c81c67779f9..0c37c9f4baa8 100644 --- a/packages/eslint-plugin/docs/rules/semi.md +++ b/packages/eslint-plugin/docs/rules/semi.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/semi** for documentation. + This rule enforces consistent use of semicolons after statements. ## Rule Details 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 1b6390d244b0..0e02b686b87e 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 @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/sort-type-union-intersection-members** for documentation. + Sorting union (`|`) and intersection (`&`) types can help: - keep your codebase standardized diff --git a/packages/eslint-plugin/docs/rules/space-before-blocks.md b/packages/eslint-plugin/docs/rules/space-before-blocks.md index 183e84d8b6a7..bb2ec8e4b890 100644 --- a/packages/eslint-plugin/docs/rules/space-before-blocks.md +++ b/packages/eslint-plugin/docs/rules/space-before-blocks.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/space-before-blocks** for documentation. + ## Rule Details This rule extends the base [`eslint/space-before-blocks`](https://eslint.org/docs/rules/space-before-blocks) rule. 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 936b6bd6bfc1..80ab4ffc6a0d 100644 --- a/packages/eslint-plugin/docs/rules/space-before-function-paren.md +++ b/packages/eslint-plugin/docs/rules/space-before-function-paren.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/space-before-function-paren** for documentation. + ## Rule Details This rule extends the base [`eslint/space-before-function-paren`](https://eslint.org/docs/rules/space-before-function-paren) rule. diff --git a/packages/eslint-plugin/docs/rules/space-infix-ops.md b/packages/eslint-plugin/docs/rules/space-infix-ops.md index e9c477ba99b2..e791420b6530 100644 --- a/packages/eslint-plugin/docs/rules/space-infix-ops.md +++ b/packages/eslint-plugin/docs/rules/space-infix-ops.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/space-infix-ops** for documentation. + This rule extends the base [`eslint/space-infix-ops`](https://eslint.org/docs/rules/space-infix-ops) rule. It also add support for enum members diff --git a/packages/eslint-plugin/docs/rules/strict-boolean-expressions.md b/packages/eslint-plugin/docs/rules/strict-boolean-expressions.md index 73df9337ae33..a86e8146ba6f 100644 --- a/packages/eslint-plugin/docs/rules/strict-boolean-expressions.md +++ b/packages/eslint-plugin/docs/rules/strict-boolean-expressions.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/strict-boolean-expressions** for documentation. + Forbids usage of non-boolean types in expressions where a boolean is expected. `boolean` and `never` types are always allowed. Additional types which are considered safe in a boolean context can be configured via options. diff --git a/packages/eslint-plugin/docs/rules/switch-exhaustiveness-check.md b/packages/eslint-plugin/docs/rules/switch-exhaustiveness-check.md index 7b71610f9383..cfe2ef234a46 100644 --- a/packages/eslint-plugin/docs/rules/switch-exhaustiveness-check.md +++ b/packages/eslint-plugin/docs/rules/switch-exhaustiveness-check.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/switch-exhaustiveness-check** for documentation. + Union type may have a lot of parts. It's easy to forget to consider all cases in switch. This rule reminds which parts are missing. If domain of the problem requires to have only a partial switch, developer may _explicitly_ add a default clause. ## Rule Details diff --git a/packages/eslint-plugin/docs/rules/triple-slash-reference.md b/packages/eslint-plugin/docs/rules/triple-slash-reference.md index 2d15174c38b8..ce73a33d5942 100644 --- a/packages/eslint-plugin/docs/rules/triple-slash-reference.md +++ b/packages/eslint-plugin/docs/rules/triple-slash-reference.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/triple-slash-reference** for documentation. + Use of triple-slash reference type directives is discouraged in favor of the newer `import` style. This rule allows you to ban use of `/// `, `/// `, or `/// ` directives. ## Rule Details diff --git a/packages/eslint-plugin/docs/rules/type-annotation-spacing.md b/packages/eslint-plugin/docs/rules/type-annotation-spacing.md index 711b4c6e194f..7adc9fd0e59e 100644 --- a/packages/eslint-plugin/docs/rules/type-annotation-spacing.md +++ b/packages/eslint-plugin/docs/rules/type-annotation-spacing.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/type-annotation-spacing** for documentation. + Spacing around type annotations improves readability of the code. Although the most commonly used style guideline for type annotations in TypeScript prescribes adding a space after the colon, but not before it, it is subjective to the preferences of a project. For example: diff --git a/packages/eslint-plugin/docs/rules/typedef.md b/packages/eslint-plugin/docs/rules/typedef.md index 85e5d7a1155a..8976c5211974 100644 --- a/packages/eslint-plugin/docs/rules/typedef.md +++ b/packages/eslint-plugin/docs/rules/typedef.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/typedef** for documentation. + TypeScript cannot always infer types for all places in code. Some locations require type annotations for their types to be inferred. diff --git a/packages/eslint-plugin/docs/rules/unbound-method.md b/packages/eslint-plugin/docs/rules/unbound-method.md index f5dbc8971945..b42e274ec59b 100644 --- a/packages/eslint-plugin/docs/rules/unbound-method.md +++ b/packages/eslint-plugin/docs/rules/unbound-method.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/unbound-method** for documentation. + Class functions don't preserve the class scope when passed as standalone variables. If your function does not access `this`, [you can annotate it with `this: void`](https://www.typescriptlang.org/docs/handbook/2/functions.html#declaring-this-in-a-function), or consider using an arrow function instead. diff --git a/packages/eslint-plugin/docs/rules/unified-signatures.md b/packages/eslint-plugin/docs/rules/unified-signatures.md index ccb24d9447ad..290c3f337399 100644 --- a/packages/eslint-plugin/docs/rules/unified-signatures.md +++ b/packages/eslint-plugin/docs/rules/unified-signatures.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/unified-signatures** for documentation. + ## Rule Details This rule aims to keep the source code as maintainable as possible by reducing the amount of overloads. diff --git a/packages/eslint-plugin/tests/docs.test.ts b/packages/eslint-plugin/tests/docs.test.ts index e6f067077463..7ab1095f4ad0 100644 --- a/packages/eslint-plugin/tests/docs.test.ts +++ b/packages/eslint-plugin/tests/docs.test.ts @@ -67,6 +67,20 @@ describe('Validating rule docs', () => { describe(ruleName, () => { const filePath = path.join(docsRoot, `${ruleName}.md`); + test(`${ruleName}.md must start with blockquote directing to website`, () => { + const tokens = parseMarkdownFile(filePath); + + expect(tokens[0]).toMatchObject({ + text: [ + `🛑 This file is source code, not the primary documentation location! 🛑`, + ``, + `See **https://typescript-eslint.io/rules/${ruleName}** for documentation.`, + ``, + ].join('\n'), + type: 'blockquote', + }); + }); + it(`Headers in ${ruleName}.md must be title-cased`, () => { const tokens = parseMarkdownFile(filePath); From 9a1d350c6f77d620befb75266d3773545413535b Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Sun, 26 Jun 2022 17:20:25 -0400 Subject: [PATCH 4/6] Update the template too --- packages/eslint-plugin/docs/rules/TEMPLATE.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/eslint-plugin/docs/rules/TEMPLATE.md b/packages/eslint-plugin/docs/rules/TEMPLATE.md index 0da7b3adedec..a49ed54ac02a 100644 --- a/packages/eslint-plugin/docs/rules/TEMPLATE.md +++ b/packages/eslint-plugin/docs/rules/TEMPLATE.md @@ -1,3 +1,7 @@ +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/your-rule-name** for documentation. + ## Rule Details To fill out: tell us more about this rule. From 3b5168f7cf00e197e0bf09e867c9d531c707b767 Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Fri, 22 Jul 2022 13:24:40 -0400 Subject: [PATCH 5/6] Remove the source code warning from generated pages --- packages/website/plugins/generated-rule-docs.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/website/plugins/generated-rule-docs.ts b/packages/website/plugins/generated-rule-docs.ts index e7c398a94185..e3c1036eeb42 100644 --- a/packages/website/plugins/generated-rule-docs.ts +++ b/packages/website/plugins/generated-rule-docs.ts @@ -17,7 +17,10 @@ const generatedRuleDocs: Plugin = () => { const parent = root as unist.Parent; - // 1. Add a description of the rule at the top of the file + // 1. Remove the " 🛑 This file is source code, not the primary documentation location! 🛑" + parent.children.splice(3, 1); + + // 2. Add a description of the rule at the top of the file parent.children.unshift({ children: [ { @@ -33,7 +36,7 @@ const generatedRuleDocs: Plugin = () => { type: 'blockquote', } as mdast.Blockquote); - // 2. Add a rule attributes list... + // 3. Add a rule attributes list... const h2Idx = // ...or the first h2, if it exists... parent.children.findIndex( From cf3c9af17982bdc46b4f59cdc5b3b99398c0a84c Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Fri, 22 Jul 2022 13:30:05 -0400 Subject: [PATCH 6/6] Nit: fix existing comment --- packages/website/plugins/generated-rule-docs.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/website/plugins/generated-rule-docs.ts b/packages/website/plugins/generated-rule-docs.ts index e3c1036eeb42..23ff08c54df1 100644 --- a/packages/website/plugins/generated-rule-docs.ts +++ b/packages/website/plugins/generated-rule-docs.ts @@ -38,7 +38,7 @@ const generatedRuleDocs: Plugin = () => { // 3. Add a rule attributes list... const h2Idx = - // ...or the first h2, if it exists... + // ...before the first h2, if it exists... parent.children.findIndex( child => child.type === 'heading' && (child as mdast.Heading).depth === 2,