diff --git a/packages/eslint-plugin/docs/rules/TEMPLATE.md b/packages/eslint-plugin/docs/rules/TEMPLATE.md index 7528ad501a31..a49ed54ac02a 100644 --- a/packages/eslint-plugin/docs/rules/TEMPLATE.md +++ b/packages/eslint-plugin/docs/rules/TEMPLATE.md @@ -1,6 +1,6 @@ -# `your-rule-name` - -Your rule description here. +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/your-rule-name** for documentation. ## Rule Details diff --git a/packages/eslint-plugin/docs/rules/adjacent-overload-signatures.md b/packages/eslint-plugin/docs/rules/adjacent-overload-signatures.md index a30dfe06142e..57677bd4ac1f 100644 --- a/packages/eslint-plugin/docs/rules/adjacent-overload-signatures.md +++ b/packages/eslint-plugin/docs/rules/adjacent-overload-signatures.md @@ -1,6 +1,6 @@ -# `adjacent-overload-signatures` - -Requires that member overloads be consecutive. +> 🛑 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. diff --git a/packages/eslint-plugin/docs/rules/array-type.md b/packages/eslint-plugin/docs/rules/array-type.md index 1e0ea89327dc..9a9ac0985bc3 100644 --- a/packages/eslint-plugin/docs/rules/array-type.md +++ b/packages/eslint-plugin/docs/rules/array-type.md @@ -1,6 +1,6 @@ -# `array-type` - -Requires using either `T[]` or `Array` for arrays. +> 🛑 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. diff --git a/packages/eslint-plugin/docs/rules/await-thenable.md b/packages/eslint-plugin/docs/rules/await-thenable.md index 4a2398719275..d0d3d5f7d521 100644 --- a/packages/eslint-plugin/docs/rules/await-thenable.md +++ b/packages/eslint-plugin/docs/rules/await-thenable.md @@ -1,6 +1,6 @@ -# `await-thenable` - -Disallows awaiting a value that is not a Thenable. +> 🛑 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 2e62bfcd4a80..f560c55ff054 100644 --- a/packages/eslint-plugin/docs/rules/ban-ts-comment.md +++ b/packages/eslint-plugin/docs/rules/ban-ts-comment.md @@ -1,6 +1,6 @@ -# `ban-ts-comment` - -Disallows `@ts-` comments or requires descriptions after directive. +> 🛑 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 b89e9929167a..3e5789bc005b 100644 --- a/packages/eslint-plugin/docs/rules/ban-tslint-comment.md +++ b/packages/eslint-plugin/docs/rules/ban-tslint-comment.md @@ -1,6 +1,6 @@ -# `ban-tslint-comment` - -Disallows `// tslint:` comments. +> 🛑 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`). diff --git a/packages/eslint-plugin/docs/rules/ban-types.md b/packages/eslint-plugin/docs/rules/ban-types.md index b5dc1b0e33cd..256b12372fe7 100644 --- a/packages/eslint-plugin/docs/rules/ban-types.md +++ b/packages/eslint-plugin/docs/rules/ban-types.md @@ -1,6 +1,6 @@ -# `ban-types` - -Disallows certain types. +> 🛑 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 a21884184608..923a841fcbde 100644 --- a/packages/eslint-plugin/docs/rules/brace-style.md +++ b/packages/eslint-plugin/docs/rules/brace-style.md @@ -1,6 +1,6 @@ -# `brace-style` - -Enforces consistent brace style for blocks. +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/brace-style** for documentation. ## Rule Details 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..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,6 +1,6 @@ -# `class-literal-property-style` - -Enforces that literals on classes are exposed in a consistent style. +> 🛑 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 9c827252f3b9..0af19151a0eb 100644 --- a/packages/eslint-plugin/docs/rules/comma-dangle.md +++ b/packages/eslint-plugin/docs/rules/comma-dangle.md @@ -1,6 +1,6 @@ -# `comma-dangle` - -Requires or disallows trailing commas. +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/comma-dangle** for documentation. ## Rule Details diff --git a/packages/eslint-plugin/docs/rules/comma-spacing.md b/packages/eslint-plugin/docs/rules/comma-spacing.md index 7fa6056759dc..28ea99602d90 100644 --- a/packages/eslint-plugin/docs/rules/comma-spacing.md +++ b/packages/eslint-plugin/docs/rules/comma-spacing.md @@ -1,6 +1,6 @@ -# `comma-spacing` - -Enforces consistent spacing before and after commas. +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/comma-spacing** for documentation. ## Rule Details diff --git a/packages/eslint-plugin/docs/rules/consistent-generic-constructors.md b/packages/eslint-plugin/docs/rules/consistent-generic-constructors.md index db717dbcbd3d..e62ba44bbb91 100644 --- a/packages/eslint-plugin/docs/rules/consistent-generic-constructors.md +++ b/packages/eslint-plugin/docs/rules/consistent-generic-constructors.md @@ -1,6 +1,6 @@ -# `consistent-generic-constructors` - -Enforces specifying generic type arguments on type annotation or constructor name of a constructor call. +> 🛑 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): 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..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,6 +1,6 @@ -# `consistent-indexed-object-style` - -Requires or disallows the `Record` type. +> 🛑 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: diff --git a/packages/eslint-plugin/docs/rules/consistent-type-assertions.md b/packages/eslint-plugin/docs/rules/consistent-type-assertions.md index 7e1d4d0487c8..bb624e83b9d6 100644 --- a/packages/eslint-plugin/docs/rules/consistent-type-assertions.md +++ b/packages/eslint-plugin/docs/rules/consistent-type-assertions.md @@ -1,6 +1,6 @@ -# `consistent-type-assertions` - -Enforces consistent usage of type assertions. +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/consistent-type-assertions** for documentation. ## Rule Details diff --git a/packages/eslint-plugin/docs/rules/consistent-type-definitions.md b/packages/eslint-plugin/docs/rules/consistent-type-definitions.md index 1df12bcde43f..625bb7ba4935 100644 --- a/packages/eslint-plugin/docs/rules/consistent-type-definitions.md +++ b/packages/eslint-plugin/docs/rules/consistent-type-definitions.md @@ -1,6 +1,6 @@ -# `consistent-type-definitions` - -Enforces type definitions to consistently use either `interface` or `type`. +> 🛑 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. diff --git a/packages/eslint-plugin/docs/rules/consistent-type-exports.md b/packages/eslint-plugin/docs/rules/consistent-type-exports.md index bd10a616261c..5383a1225b10 100644 --- a/packages/eslint-plugin/docs/rules/consistent-type-exports.md +++ b/packages/eslint-plugin/docs/rules/consistent-type-exports.md @@ -1,6 +1,6 @@ -# `consistent-type-exports` - -Enforces consistent usage of type exports. +> 🛑 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. diff --git a/packages/eslint-plugin/docs/rules/consistent-type-imports.md b/packages/eslint-plugin/docs/rules/consistent-type-imports.md index 47022b04ec57..be63fff55516 100644 --- a/packages/eslint-plugin/docs/rules/consistent-type-imports.md +++ b/packages/eslint-plugin/docs/rules/consistent-type-imports.md @@ -1,6 +1,6 @@ -# `consistent-type-imports` - -Enforces consistent usage of type imports. +> 🛑 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 5db33411d1d5..3de8f8c8cd7a 100644 --- a/packages/eslint-plugin/docs/rules/default-param-last.md +++ b/packages/eslint-plugin/docs/rules/default-param-last.md @@ -1,6 +1,6 @@ -# `default-param-last` - -Enforces default parameters to be last. +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/default-param-last** for documentation. ## Rule Details diff --git a/packages/eslint-plugin/docs/rules/dot-notation.md b/packages/eslint-plugin/docs/rules/dot-notation.md index 414170416846..e0c7b390e5ad 100644 --- a/packages/eslint-plugin/docs/rules/dot-notation.md +++ b/packages/eslint-plugin/docs/rules/dot-notation.md @@ -1,6 +1,6 @@ -# `dot-notation` - -Enforces dot notation whenever possible. +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/dot-notation** for documentation. ## Rule Details 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..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,6 +1,6 @@ -# `explicit-function-return-type` - -Requires explicit return types on functions and class methods. +> 🛑 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 diff --git a/packages/eslint-plugin/docs/rules/explicit-member-accessibility.md b/packages/eslint-plugin/docs/rules/explicit-member-accessibility.md index 4b41a1327eda..98f297000bd5 100644 --- a/packages/eslint-plugin/docs/rules/explicit-member-accessibility.md +++ b/packages/eslint-plugin/docs/rules/explicit-member-accessibility.md @@ -1,6 +1,6 @@ -# `explicit-member-accessibility` - -Requires explicit accessibility modifiers on class properties and methods. +> 🛑 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. 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..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,6 +1,6 @@ -# `explicit-module-boundary-types` - -Requires explicit return and argument types on exported functions' and classes' public class methods. +> 🛑 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. diff --git a/packages/eslint-plugin/docs/rules/func-call-spacing.md b/packages/eslint-plugin/docs/rules/func-call-spacing.md index 88b73e2eda25..315e53882409 100644 --- a/packages/eslint-plugin/docs/rules/func-call-spacing.md +++ b/packages/eslint-plugin/docs/rules/func-call-spacing.md @@ -1,6 +1,6 @@ -# `func-call-spacing` - -Requires or disallows spacing between function identifiers and their invocations. +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/func-call-spacing** for documentation. ## Rule Details diff --git a/packages/eslint-plugin/docs/rules/indent.md b/packages/eslint-plugin/docs/rules/indent.md index 5d732a305bf4..063087231a5d 100644 --- a/packages/eslint-plugin/docs/rules/indent.md +++ b/packages/eslint-plugin/docs/rules/indent.md @@ -1,6 +1,6 @@ -# `indent` - -Enforces consistent indentation. +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/indent** for documentation. ## Warning diff --git a/packages/eslint-plugin/docs/rules/init-declarations.md b/packages/eslint-plugin/docs/rules/init-declarations.md index 6a4ce4786512..3569bd70602a 100644 --- a/packages/eslint-plugin/docs/rules/init-declarations.md +++ b/packages/eslint-plugin/docs/rules/init-declarations.md @@ -1,6 +1,6 @@ -# `init-declarations` - -Requires or disallows initialization in variable declarations. +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/init-declarations** for documentation. ## Rule Details diff --git a/packages/eslint-plugin/docs/rules/keyword-spacing.md b/packages/eslint-plugin/docs/rules/keyword-spacing.md index 4b9b386b940f..6bf0de5e1870 100644 --- a/packages/eslint-plugin/docs/rules/keyword-spacing.md +++ b/packages/eslint-plugin/docs/rules/keyword-spacing.md @@ -1,6 +1,6 @@ -# `keyword-spacing` - -Enforces consistent spacing before and after keywords. +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/keyword-spacing** for documentation. ## Rule Details 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..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,6 +1,6 @@ -# `lines-between-class-members` - -Requires or disallows an empty line between class members. +> 🛑 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. diff --git a/packages/eslint-plugin/docs/rules/member-delimiter-style.md b/packages/eslint-plugin/docs/rules/member-delimiter-style.md index 858d3777d069..3935222e1c75 100644 --- a/packages/eslint-plugin/docs/rules/member-delimiter-style.md +++ b/packages/eslint-plugin/docs/rules/member-delimiter-style.md @@ -1,6 +1,6 @@ -# `member-delimiter-style` - -Requires a specific member delimiter style for interfaces and type literals. +> 🛑 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: diff --git a/packages/eslint-plugin/docs/rules/member-ordering.md b/packages/eslint-plugin/docs/rules/member-ordering.md index aacc062008f9..5dd18d6beec3 100644 --- a/packages/eslint-plugin/docs/rules/member-ordering.md +++ b/packages/eslint-plugin/docs/rules/member-ordering.md @@ -1,6 +1,6 @@ -# `member-ordering` - -Requires a consistent member declaration order. +> 🛑 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. diff --git a/packages/eslint-plugin/docs/rules/method-signature-style.md b/packages/eslint-plugin/docs/rules/method-signature-style.md index 53a6d3e17a02..ad947db32610 100644 --- a/packages/eslint-plugin/docs/rules/method-signature-style.md +++ b/packages/eslint-plugin/docs/rules/method-signature-style.md @@ -1,6 +1,6 @@ -# `method-signature-style` - -Enforces using a particular method signature syntax. +> 🛑 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. diff --git a/packages/eslint-plugin/docs/rules/naming-convention.md b/packages/eslint-plugin/docs/rules/naming-convention.md index 9032119ca40d..08da84d15b47 100644 --- a/packages/eslint-plugin/docs/rules/naming-convention.md +++ b/packages/eslint-plugin/docs/rules/naming-convention.md @@ -1,6 +1,6 @@ -# `naming-convention` - -Enforces naming conventions for everything across a codebase. +> 🛑 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 01fd843caf16..6251ddf53dc8 100644 --- a/packages/eslint-plugin/docs/rules/no-array-constructor.md +++ b/packages/eslint-plugin/docs/rules/no-array-constructor.md @@ -1,6 +1,6 @@ -# `no-array-constructor` - -Disallows generic `Array` constructors. +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/no-array-constructor** for documentation. ## Rule Details 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..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,4 +1,6 @@ -# `no-base-to-string` +> 🛑 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. 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..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,6 +1,6 @@ -# `no-confusing-non-null-assertion` - -Disallows non-null assertion in locations that may be confusing. +> 🛑 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 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..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,6 +1,6 @@ -# `no-confusing-void-expression` - -Requires expressions of type void to appear in statement position. +> 🛑 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. 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..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,6 +1,6 @@ -# `no-dupe-class-members` - -Disallows duplicate class members. +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/no-dupe-class-members** for documentation. ## Rule Details 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..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,6 +1,6 @@ -# `no-duplicate-enum-values` - -Disallows duplicate enum member values. +> 🛑 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. diff --git a/packages/eslint-plugin/docs/rules/no-duplicate-imports.md b/packages/eslint-plugin/docs/rules/no-duplicate-imports.md index 90ab3da41235..613043bedb4f 100644 --- a/packages/eslint-plugin/docs/rules/no-duplicate-imports.md +++ b/packages/eslint-plugin/docs/rules/no-duplicate-imports.md @@ -1,6 +1,6 @@ -# `no-duplicate-imports` - -Disallows duplicate imports. +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/no-duplicate-imports** for documentation. ## DEPRECATED diff --git a/packages/eslint-plugin/docs/rules/no-dynamic-delete.md b/packages/eslint-plugin/docs/rules/no-dynamic-delete.md index e0c590a9de97..7c6090f812f8 100644 --- a/packages/eslint-plugin/docs/rules/no-dynamic-delete.md +++ b/packages/eslint-plugin/docs/rules/no-dynamic-delete.md @@ -1,6 +1,6 @@ -# `no-dynamic-delete` - -Disallows using the `delete` operator on computed key expressions. +> 🛑 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. diff --git a/packages/eslint-plugin/docs/rules/no-empty-function.md b/packages/eslint-plugin/docs/rules/no-empty-function.md index e23cc10bdd43..121db4ff8786 100644 --- a/packages/eslint-plugin/docs/rules/no-empty-function.md +++ b/packages/eslint-plugin/docs/rules/no-empty-function.md @@ -1,6 +1,6 @@ -# `no-empty-function` - -Disallows empty functions. +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/no-empty-function** for documentation. ## Rule Details diff --git a/packages/eslint-plugin/docs/rules/no-empty-interface.md b/packages/eslint-plugin/docs/rules/no-empty-interface.md index c9e36a528b1c..beed5a85ecc7 100644 --- a/packages/eslint-plugin/docs/rules/no-empty-interface.md +++ b/packages/eslint-plugin/docs/rules/no-empty-interface.md @@ -1,6 +1,6 @@ -# `no-empty-interface` - -Disallows the declaration of empty interfaces. +> 🛑 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 ebf043104986..f8e42896dbd4 100644 --- a/packages/eslint-plugin/docs/rules/no-explicit-any.md +++ b/packages/eslint-plugin/docs/rules/no-explicit-any.md @@ -1,6 +1,6 @@ -# `no-explicit-any` - -Disallows the `any` type. +> 🛑 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 43cfacf756ff..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,6 +1,6 @@ -# `no-extra-non-null-assertion` - -Disallows extra non-null assertion. +> 🛑 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 diff --git a/packages/eslint-plugin/docs/rules/no-extra-parens.md b/packages/eslint-plugin/docs/rules/no-extra-parens.md index f123b70d1417..8bd5ac2c7d68 100644 --- a/packages/eslint-plugin/docs/rules/no-extra-parens.md +++ b/packages/eslint-plugin/docs/rules/no-extra-parens.md @@ -1,6 +1,6 @@ -# `no-extra-parens` - -Disallows unnecessary parentheses. +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/no-extra-parens** for documentation. ## Rule Details diff --git a/packages/eslint-plugin/docs/rules/no-extra-semi.md b/packages/eslint-plugin/docs/rules/no-extra-semi.md index b0649081b5c3..0b94c91de590 100644 --- a/packages/eslint-plugin/docs/rules/no-extra-semi.md +++ b/packages/eslint-plugin/docs/rules/no-extra-semi.md @@ -1,6 +1,6 @@ -# `no-extra-semi` - -Disallows unnecessary semicolons. +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/no-extra-semi** for documentation. ## Rule Details diff --git a/packages/eslint-plugin/docs/rules/no-extraneous-class.md b/packages/eslint-plugin/docs/rules/no-extraneous-class.md index e1697254ef91..fa990f2cebfd 100644 --- a/packages/eslint-plugin/docs/rules/no-extraneous-class.md +++ b/packages/eslint-plugin/docs/rules/no-extraneous-class.md @@ -1,6 +1,6 @@ -# `no-extraneous-class` - -Disallows classes used as namespaces. +> 🛑 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. diff --git a/packages/eslint-plugin/docs/rules/no-floating-promises.md b/packages/eslint-plugin/docs/rules/no-floating-promises.md index 1df8ea23c72b..45fddc3c6219 100644 --- a/packages/eslint-plugin/docs/rules/no-floating-promises.md +++ b/packages/eslint-plugin/docs/rules/no-floating-promises.md @@ -1,6 +1,6 @@ -# `no-floating-promises` - -Requires Promise-like statements to be handled appropriately. +> 🛑 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. 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..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,6 +1,6 @@ -# `no-for-in-array` - -Disallows iterating over an array with a for-in loop. +> 🛑 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. 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..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,6 +1,6 @@ -# `no-implicit-any-catch` - -Disallows usage of the implicit `any` type in catch clauses. +> 🛑 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. diff --git a/packages/eslint-plugin/docs/rules/no-implied-eval.md b/packages/eslint-plugin/docs/rules/no-implied-eval.md index d39a6f70609f..5cd9a9113a5d 100644 --- a/packages/eslint-plugin/docs/rules/no-implied-eval.md +++ b/packages/eslint-plugin/docs/rules/no-implied-eval.md @@ -1,6 +1,6 @@ -# `no-implied-eval` - -Disallows the use of `eval()`-like methods. +> 🛑 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. diff --git a/packages/eslint-plugin/docs/rules/no-inferrable-types.md b/packages/eslint-plugin/docs/rules/no-inferrable-types.md index 137d6c558bef..73fcfd7ae520 100644 --- a/packages/eslint-plugin/docs/rules/no-inferrable-types.md +++ b/packages/eslint-plugin/docs/rules/no-inferrable-types.md @@ -1,6 +1,6 @@ -# `no-inferrable-types` - -Disallows explicit type declarations for variables or parameters initialized to a number, string, or boolean. +> 🛑 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. diff --git a/packages/eslint-plugin/docs/rules/no-invalid-this.md b/packages/eslint-plugin/docs/rules/no-invalid-this.md index 5061e60559d1..22e7de7260bf 100644 --- a/packages/eslint-plugin/docs/rules/no-invalid-this.md +++ b/packages/eslint-plugin/docs/rules/no-invalid-this.md @@ -1,6 +1,6 @@ -# `no-invalid-this` - -Disallows `this` keywords outside of classes or class-like objects. +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/no-invalid-this** for documentation. ## Rule Details 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..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,6 +1,6 @@ -# `no-invalid-void-type` - -Disallows `void` type outside of generic or return types. +> 🛑 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 890bd80ecc06..906ab28e856a 100644 --- a/packages/eslint-plugin/docs/rules/no-loop-func.md +++ b/packages/eslint-plugin/docs/rules/no-loop-func.md @@ -1,6 +1,6 @@ -# `no-loop-func` - -Disallows function declarations that contain unsafe references inside loop statements. +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/no-loop-func** for documentation. ## Rule Details 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..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,6 +1,6 @@ -# `no-loss-of-precision` - -Disallows literal numbers that lose precision. +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/no-loss-of-precision** for documentation. ## Rule Details diff --git a/packages/eslint-plugin/docs/rules/no-magic-numbers.md b/packages/eslint-plugin/docs/rules/no-magic-numbers.md index e5edc2e280d0..b352b892ffcf 100644 --- a/packages/eslint-plugin/docs/rules/no-magic-numbers.md +++ b/packages/eslint-plugin/docs/rules/no-magic-numbers.md @@ -1,6 +1,6 @@ -# `no-magic-numbers` - -Disallows magic numbers. +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/no-magic-numbers** for documentation. ## Rule Details 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..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,6 +1,6 @@ -# `no-meaningless-void-operator` - -Disallows the `void` operator except when used to discard a value. +> 🛑 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`. diff --git a/packages/eslint-plugin/docs/rules/no-misused-new.md b/packages/eslint-plugin/docs/rules/no-misused-new.md index 10d0470f67bf..b79af1f3eb3b 100644 --- a/packages/eslint-plugin/docs/rules/no-misused-new.md +++ b/packages/eslint-plugin/docs/rules/no-misused-new.md @@ -1,6 +1,6 @@ -# `no-misused-new` - -Enforces valid definition of `new` and `constructor`. +> 🛑 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. diff --git a/packages/eslint-plugin/docs/rules/no-misused-promises.md b/packages/eslint-plugin/docs/rules/no-misused-promises.md index f3e67234c6fe..62156bc8f134 100644 --- a/packages/eslint-plugin/docs/rules/no-misused-promises.md +++ b/packages/eslint-plugin/docs/rules/no-misused-promises.md @@ -1,6 +1,6 @@ -# `no-misused-promises` - -Disallows Promises in places not designed to handle them. +> 🛑 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 diff --git a/packages/eslint-plugin/docs/rules/no-namespace.md b/packages/eslint-plugin/docs/rules/no-namespace.md index e1e83fd1c7e5..f59c865c5b7d 100644 --- a/packages/eslint-plugin/docs/rules/no-namespace.md +++ b/packages/eslint-plugin/docs/rules/no-namespace.md @@ -1,6 +1,6 @@ -# `no-namespace` - -Disallows custom TypeScript modules and namespaces. +> 🛑 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 29eac71f2f4e..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,6 +1,6 @@ -# `no-non-null-asserted-nullish-coalescing` - -Disallows non-null assertions in the left operand of a nullish coalescing operator. +> 🛑 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 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..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,6 +1,6 @@ -# `no-non-null-asserted-optional-chain` - -Disallows non-null assertions after an optional chain expression. +> 🛑 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 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..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,6 +1,6 @@ -# `no-non-null-assertion` - -Disallows non-null assertions using the `!` postfix operator. +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/no-non-null-assertion** for documentation. ## Rule Details diff --git a/packages/eslint-plugin/docs/rules/no-parameter-properties.md b/packages/eslint-plugin/docs/rules/no-parameter-properties.md index 3ff367fb2e2b..3eaf06055033 100644 --- a/packages/eslint-plugin/docs/rules/no-parameter-properties.md +++ b/packages/eslint-plugin/docs/rules/no-parameter-properties.md @@ -1,6 +1,6 @@ -# `no-parameter-properties` - -Disallows the use of parameter properties in class constructors. +> 🛑 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 6ddb0d6d7302..4ebaba2ee5ee 100644 --- a/packages/eslint-plugin/docs/rules/no-redeclare.md +++ b/packages/eslint-plugin/docs/rules/no-redeclare.md @@ -1,6 +1,6 @@ -# `no-redeclare` - -Disallows variable redeclaration. +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/no-redeclare** for documentation. ## Rule Details 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..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,6 +1,6 @@ -# `no-redundant-type-constituents` - -Disallows members of unions and intersections that do nothing or override type information. +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/no-redundant-type-constituents** for documentation. ## Rule Details diff --git a/packages/eslint-plugin/docs/rules/no-require-imports.md b/packages/eslint-plugin/docs/rules/no-require-imports.md index 9e45c8bd4339..0a3ddd5d2f9f 100644 --- a/packages/eslint-plugin/docs/rules/no-require-imports.md +++ b/packages/eslint-plugin/docs/rules/no-require-imports.md @@ -1,6 +1,6 @@ -# `no-require-imports` - -Disallows invocation of `require()`. +> 🛑 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()`. diff --git a/packages/eslint-plugin/docs/rules/no-restricted-imports.md b/packages/eslint-plugin/docs/rules/no-restricted-imports.md index 2e741490d098..89f615c194e2 100644 --- a/packages/eslint-plugin/docs/rules/no-restricted-imports.md +++ b/packages/eslint-plugin/docs/rules/no-restricted-imports.md @@ -1,6 +1,6 @@ -# `no-restricted-imports` - -Disallows specified modules when loaded by `import`. +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/no-restricted-imports** for documentation. ## Rule Details diff --git a/packages/eslint-plugin/docs/rules/no-shadow.md b/packages/eslint-plugin/docs/rules/no-shadow.md index 4ed7f199c2ca..3da0a6bc6fbd 100644 --- a/packages/eslint-plugin/docs/rules/no-shadow.md +++ b/packages/eslint-plugin/docs/rules/no-shadow.md @@ -1,6 +1,6 @@ -# `no-shadow` - -Disallows variable declarations from shadowing variables declared in the outer scope. +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/no-shadow** for documentation. ## Rule Details diff --git a/packages/eslint-plugin/docs/rules/no-this-alias.md b/packages/eslint-plugin/docs/rules/no-this-alias.md index 8485ef88c071..3433ae28eb0c 100644 --- a/packages/eslint-plugin/docs/rules/no-this-alias.md +++ b/packages/eslint-plugin/docs/rules/no-this-alias.md @@ -1,6 +1,6 @@ -# `no-this-alias` - -Disallows aliasing `this`. +> 🛑 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`. diff --git a/packages/eslint-plugin/docs/rules/no-throw-literal.md b/packages/eslint-plugin/docs/rules/no-throw-literal.md index 4bb8bbcc58c9..a95aeb1a06b5 100644 --- a/packages/eslint-plugin/docs/rules/no-throw-literal.md +++ b/packages/eslint-plugin/docs/rules/no-throw-literal.md @@ -1,6 +1,6 @@ -# `no-throw-literal` - -Disallows throwing literals as exceptions. +> 🛑 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 3a02c4b9760d..e2b95b917382 100644 --- a/packages/eslint-plugin/docs/rules/no-type-alias.md +++ b/packages/eslint-plugin/docs/rules/no-type-alias.md @@ -1,6 +1,6 @@ -# `no-type-alias` - -Disallows type aliases. +> 🛑 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: 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..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,6 +1,6 @@ -# `no-unnecessary-boolean-literal-compare` - -Disallows unnecessary equality comparisons against boolean literals. +> 🛑 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. diff --git a/packages/eslint-plugin/docs/rules/no-unnecessary-condition.md b/packages/eslint-plugin/docs/rules/no-unnecessary-condition.md index 3c03a5655217..2594184ea02b 100644 --- a/packages/eslint-plugin/docs/rules/no-unnecessary-condition.md +++ b/packages/eslint-plugin/docs/rules/no-unnecessary-condition.md @@ -1,6 +1,6 @@ -# `no-unnecessary-condition` - -Disallows conditionals where the type is always truthy or always falsy. +> 🛑 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. diff --git a/packages/eslint-plugin/docs/rules/no-unnecessary-qualifier.md b/packages/eslint-plugin/docs/rules/no-unnecessary-qualifier.md index db73814ee788..31905c485f4d 100644 --- a/packages/eslint-plugin/docs/rules/no-unnecessary-qualifier.md +++ b/packages/eslint-plugin/docs/rules/no-unnecessary-qualifier.md @@ -1,6 +1,6 @@ -# `no-unnecessary-qualifier` - -Disallows unnecessary namespace qualifiers. +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/no-unnecessary-qualifier** for documentation. ## Rule Details 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..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,6 +1,6 @@ -# `no-unnecessary-type-arguments` - -Disallows type arguments that are equal to the default. +> 🛑 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. 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..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,6 +1,6 @@ -# `no-unnecessary-type-assertion` - -Disallows type assertions that do not change the type of an expression. +> 🛑 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. 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..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,6 +1,6 @@ -# `no-unnecessary-type-constraint` - -Disallows unnecessary constraints on generic types. +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/no-unnecessary-type-constraint** for documentation. ## Rule Details diff --git a/packages/eslint-plugin/docs/rules/no-unsafe-argument.md b/packages/eslint-plugin/docs/rules/no-unsafe-argument.md index 30d7e441e661..15e1c82e7ff6 100644 --- a/packages/eslint-plugin/docs/rules/no-unsafe-argument.md +++ b/packages/eslint-plugin/docs/rules/no-unsafe-argument.md @@ -1,6 +1,6 @@ -# `no-unsafe-argument` - -Disallows calling a function with a value with type `any`. +> 🛑 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 98bb047e7863..309d0b13d2e8 100644 --- a/packages/eslint-plugin/docs/rules/no-unsafe-assignment.md +++ b/packages/eslint-plugin/docs/rules/no-unsafe-assignment.md @@ -1,6 +1,6 @@ -# `no-unsafe-assignment` - -Disallows assigning a value with type `any` to variables and properties. +> 🛑 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 68c5ba8b81c5..103aa55e7b23 100644 --- a/packages/eslint-plugin/docs/rules/no-unsafe-call.md +++ b/packages/eslint-plugin/docs/rules/no-unsafe-call.md @@ -1,6 +1,6 @@ -# `no-unsafe-call` - -Disallows calling a value with type `any`. +> 🛑 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 a79a8c648c5c..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,6 +1,6 @@ -# `no-unsafe-member-access` - -Disallows member access on a value with type `any`. +> 🛑 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 a3401b3b94ee..d2e5a36f309c 100644 --- a/packages/eslint-plugin/docs/rules/no-unsafe-return.md +++ b/packages/eslint-plugin/docs/rules/no-unsafe-return.md @@ -1,6 +1,6 @@ -# `no-unsafe-return` - -Disallows returning a value with type `any` from a function. +> 🛑 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 f89aa6349e7d..2e6a002ba51c 100644 --- a/packages/eslint-plugin/docs/rules/no-unused-expressions.md +++ b/packages/eslint-plugin/docs/rules/no-unused-expressions.md @@ -1,6 +1,6 @@ -# `no-unused-expressions` - -Disallows unused expressions. +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/no-unused-expressions** for documentation. ## Rule Details diff --git a/packages/eslint-plugin/docs/rules/no-unused-vars.md b/packages/eslint-plugin/docs/rules/no-unused-vars.md index 7b46ad3f59cf..4902c1e72592 100644 --- a/packages/eslint-plugin/docs/rules/no-unused-vars.md +++ b/packages/eslint-plugin/docs/rules/no-unused-vars.md @@ -1,6 +1,6 @@ -# `no-unused-vars` - -Disallows unused variables. +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/no-unused-vars** for documentation. ## Rule Details 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..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,6 +1,6 @@ -# `no-use-before-define` - -Disallows the use of variables before they are defined. +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/no-use-before-define** for documentation. ## Rule Details diff --git a/packages/eslint-plugin/docs/rules/no-useless-constructor.md b/packages/eslint-plugin/docs/rules/no-useless-constructor.md index 221a0aaad202..8892c1c9e29e 100644 --- a/packages/eslint-plugin/docs/rules/no-useless-constructor.md +++ b/packages/eslint-plugin/docs/rules/no-useless-constructor.md @@ -1,6 +1,6 @@ -# `no-useless-constructor` - -Disallows unnecessary constructors. +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/no-useless-constructor** for documentation. ## Rule Details 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..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,6 +1,6 @@ -# `no-useless-empty-export` - -Disallows empty exports that don't change anything in a module file. +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/no-useless-empty-export** for documentation. ## Rule Details diff --git a/packages/eslint-plugin/docs/rules/no-var-requires.md b/packages/eslint-plugin/docs/rules/no-var-requires.md index 1ec377b2ba13..247535b011e9 100644 --- a/packages/eslint-plugin/docs/rules/no-var-requires.md +++ b/packages/eslint-plugin/docs/rules/no-var-requires.md @@ -1,6 +1,6 @@ -# `no-var-requires` - -Disallows `require` statements except in import statements. +> 🛑 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. 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..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,6 +1,6 @@ -# `non-nullable-type-assertion-style` - -Enforces non-null assertions over explicit type casts. +> 🛑 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 `!`. diff --git a/packages/eslint-plugin/docs/rules/object-curly-spacing.md b/packages/eslint-plugin/docs/rules/object-curly-spacing.md index 4789df3e14e4..31f878363b19 100644 --- a/packages/eslint-plugin/docs/rules/object-curly-spacing.md +++ b/packages/eslint-plugin/docs/rules/object-curly-spacing.md @@ -1,6 +1,6 @@ -# `object-curly-spacing` - -Enforces consistent spacing inside braces. +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/object-curly-spacing** for documentation. ## Rule Details 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..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,6 +1,6 @@ -# `padding-line-between-statements` - -Requires or disallows padding lines between statements. +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/padding-line-between-statements** for documentation. ## Rule Details diff --git a/packages/eslint-plugin/docs/rules/parameter-properties.md b/packages/eslint-plugin/docs/rules/parameter-properties.md index e4ff9a4ea8a1..3b8e4821ea3b 100644 --- a/packages/eslint-plugin/docs/rules/parameter-properties.md +++ b/packages/eslint-plugin/docs/rules/parameter-properties.md @@ -1,6 +1,6 @@ -# `parameter-properties` - -Requires or disallows parameter properties in class constructors. +> 🛑 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 76d3dede5472..ce6de3345444 100644 --- a/packages/eslint-plugin/docs/rules/prefer-as-const.md +++ b/packages/eslint-plugin/docs/rules/prefer-as-const.md @@ -1,6 +1,6 @@ -# `prefer-as-const` - -Enforces the use of `as const` over literal type. +> 🛑 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. diff --git a/packages/eslint-plugin/docs/rules/prefer-enum-initializers.md b/packages/eslint-plugin/docs/rules/prefer-enum-initializers.md index fb3a24494d46..c16f00bc8641 100644 --- a/packages/eslint-plugin/docs/rules/prefer-enum-initializers.md +++ b/packages/eslint-plugin/docs/rules/prefer-enum-initializers.md @@ -1,6 +1,6 @@ -# `prefer-enum-initializers` - -Requires each enum member value to be explicitly initialized. +> 🛑 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. diff --git a/packages/eslint-plugin/docs/rules/prefer-for-of.md b/packages/eslint-plugin/docs/rules/prefer-for-of.md index f4a4f207e78d..575e45b39e15 100644 --- a/packages/eslint-plugin/docs/rules/prefer-for-of.md +++ b/packages/eslint-plugin/docs/rules/prefer-for-of.md @@ -1,6 +1,6 @@ -# `prefer-for-of` - -Enforces the use of `for-of` loop over the standard `for` loop where possible. +> 🛑 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. diff --git a/packages/eslint-plugin/docs/rules/prefer-function-type.md b/packages/eslint-plugin/docs/rules/prefer-function-type.md index 22b579798fc5..8c0e9de2b5ca 100644 --- a/packages/eslint-plugin/docs/rules/prefer-function-type.md +++ b/packages/eslint-plugin/docs/rules/prefer-function-type.md @@ -1,6 +1,6 @@ -# `prefer-function-type` - -Enforces using function types instead of interfaces with call signatures. +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/prefer-function-type** for documentation. ## Rule Details diff --git a/packages/eslint-plugin/docs/rules/prefer-includes.md b/packages/eslint-plugin/docs/rules/prefer-includes.md index 448d6bef4a31..3eec29ab8923 100644 --- a/packages/eslint-plugin/docs/rules/prefer-includes.md +++ b/packages/eslint-plugin/docs/rules/prefer-includes.md @@ -1,6 +1,6 @@ -# `prefer-includes` - -Enforces `includes` method over `indexOf` method. +> 🛑 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 4f4db49cb625..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,6 +1,6 @@ -# `prefer-literal-enum-member` - -Requires all enum members to be literal values. +> 🛑 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: diff --git a/packages/eslint-plugin/docs/rules/prefer-namespace-keyword.md b/packages/eslint-plugin/docs/rules/prefer-namespace-keyword.md index 01bd2377a0fa..bc7b601934d2 100644 --- a/packages/eslint-plugin/docs/rules/prefer-namespace-keyword.md +++ b/packages/eslint-plugin/docs/rules/prefer-namespace-keyword.md @@ -1,6 +1,6 @@ -# `prefer-namespace-keyword` - -Requires using `namespace` keyword over `module` keyword to declare custom TypeScript modules. +> 🛑 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 9b1dfe988209..5e47975ad3ff 100644 --- a/packages/eslint-plugin/docs/rules/prefer-nullish-coalescing.md +++ b/packages/eslint-plugin/docs/rules/prefer-nullish-coalescing.md @@ -1,6 +1,6 @@ -# `prefer-nullish-coalescing` - -Enforces using the nullish coalescing operator instead of logical chaining. +> 🛑 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 c2b196a04a47..730842c1512d 100644 --- a/packages/eslint-plugin/docs/rules/prefer-optional-chain.md +++ b/packages/eslint-plugin/docs/rules/prefer-optional-chain.md @@ -1,6 +1,6 @@ -# `prefer-optional-chain` - -Enforces using concise optional chain expressions instead of chained logical ands. +> 🛑 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 5ac98d6f043f..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,6 +1,6 @@ -# `prefer-readonly-parameter-types` - -Requires function parameters to be typed as `readonly` to prevent accidental mutation of inputs. +> 🛑 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. diff --git a/packages/eslint-plugin/docs/rules/prefer-readonly.md b/packages/eslint-plugin/docs/rules/prefer-readonly.md index bfc297ae8fc3..e21f26a278ba 100644 --- a/packages/eslint-plugin/docs/rules/prefer-readonly.md +++ b/packages/eslint-plugin/docs/rules/prefer-readonly.md @@ -1,6 +1,6 @@ -# `prefer-readonly` - -Requires private members to be marked as `readonly` if they're never modified outside of the constructor. +> 🛑 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. 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..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,6 +1,6 @@ -# `prefer-reduce-type-parameter` - -Enforces using type parameter when calling `Array#reduce` instead of casting. +> 🛑 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 7c7756646b91..a487ea3d3e24 100644 --- a/packages/eslint-plugin/docs/rules/prefer-regexp-exec.md +++ b/packages/eslint-plugin/docs/rules/prefer-regexp-exec.md @@ -1,6 +1,6 @@ -# `prefer-regexp-exec` - -Enforces `RegExp#exec` over `String#match` if no global flag is provided. +> 🛑 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. 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..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,6 +1,6 @@ -# `prefer-return-this-type` - -Enforces that `this` is used when only `this` type is returned. +> 🛑 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 c103769e1ef1..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,9 +1,8 @@ -# `prefer-string-starts-ends-with` - -Enforces using `String#startsWith` and `String#endsWith` over other equivalent methods of checking substrings. +> 🛑 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. ## 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..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,6 +1,6 @@ -# `prefer-ts-expect-error` - -Enforces using `@ts-expect-error` over `@ts-ignore`. +> 🛑 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 7316e02f1b32..424536ee5f24 100644 --- a/packages/eslint-plugin/docs/rules/promise-function-async.md +++ b/packages/eslint-plugin/docs/rules/promise-function-async.md @@ -1,6 +1,6 @@ -# `promise-function-async` - -Requires any function or method that returns a Promise to be marked async. +> 🛑 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: diff --git a/packages/eslint-plugin/docs/rules/quotes.md b/packages/eslint-plugin/docs/rules/quotes.md index 1e3f6d32363d..61cadea2047a 100644 --- a/packages/eslint-plugin/docs/rules/quotes.md +++ b/packages/eslint-plugin/docs/rules/quotes.md @@ -1,6 +1,6 @@ -# `quotes` - -Enforces the consistent use of either backticks, double, or single quotes. +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/quotes** for documentation. ## Rule Details 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..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,9 +1,8 @@ -# `require-array-sort-compare` - -Requires `Array#sort` calls to always provide a `compareFunction`. +> 🛑 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. 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..21d6271c38c4 100644 --- a/packages/eslint-plugin/docs/rules/require-await.md +++ b/packages/eslint-plugin/docs/rules/require-await.md @@ -1,6 +1,6 @@ -# `require-await` - -Disallows async functions which have no `await` expression. +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/require-await** for documentation. ## Rule Details diff --git a/packages/eslint-plugin/docs/rules/restrict-plus-operands.md b/packages/eslint-plugin/docs/rules/restrict-plus-operands.md index a8b4a83f288f..5b984f0b21c5 100644 --- a/packages/eslint-plugin/docs/rules/restrict-plus-operands.md +++ b/packages/eslint-plugin/docs/rules/restrict-plus-operands.md @@ -1,6 +1,6 @@ -# `restrict-plus-operands` - -Requires both operands of addition to have type `number` or `string`. +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/restrict-plus-operands** for documentation. ## Rule Details diff --git a/packages/eslint-plugin/docs/rules/restrict-template-expressions.md b/packages/eslint-plugin/docs/rules/restrict-template-expressions.md index 59c507f167e2..37423d23abc4 100644 --- a/packages/eslint-plugin/docs/rules/restrict-template-expressions.md +++ b/packages/eslint-plugin/docs/rules/restrict-template-expressions.md @@ -1,6 +1,6 @@ -# `restrict-template-expressions` - -Enforces template literal expressions to be of `string` type. +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/restrict-template-expressions** for documentation. ## Rule Details diff --git a/packages/eslint-plugin/docs/rules/return-await.md b/packages/eslint-plugin/docs/rules/return-await.md index 20e99158dffa..1aa62401ae49 100644 --- a/packages/eslint-plugin/docs/rules/return-await.md +++ b/packages/eslint-plugin/docs/rules/return-await.md @@ -1,6 +1,6 @@ -# `return-await` - -Enforces consistent returning of awaited values. +> 🛑 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). diff --git a/packages/eslint-plugin/docs/rules/semi.md b/packages/eslint-plugin/docs/rules/semi.md index 307637c7168e..0c37c9f4baa8 100644 --- a/packages/eslint-plugin/docs/rules/semi.md +++ b/packages/eslint-plugin/docs/rules/semi.md @@ -1,6 +1,6 @@ -# `semi` - -Requires or disallows semicolons instead of ASI. +> 🛑 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. 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..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,6 +1,6 @@ -# `sort-type-union-intersection-members` - -Enforces members of a type union/intersection to be sorted alphabetically. +> 🛑 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: diff --git a/packages/eslint-plugin/docs/rules/space-before-blocks.md b/packages/eslint-plugin/docs/rules/space-before-blocks.md index 5ff10537795f..bb2ec8e4b890 100644 --- a/packages/eslint-plugin/docs/rules/space-before-blocks.md +++ b/packages/eslint-plugin/docs/rules/space-before-blocks.md @@ -1,6 +1,6 @@ -# `space-before-blocks` - -Enforces consistent spacing before blocks. +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/space-before-blocks** for documentation. ## Rule Details 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..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,6 +1,6 @@ -# `space-before-function-paren` - -Enforces consistent spacing before function parenthesis. +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/space-before-function-paren** for documentation. ## Rule Details diff --git a/packages/eslint-plugin/docs/rules/space-infix-ops.md b/packages/eslint-plugin/docs/rules/space-infix-ops.md index afcb5de8e788..e791420b6530 100644 --- a/packages/eslint-plugin/docs/rules/space-infix-ops.md +++ b/packages/eslint-plugin/docs/rules/space-infix-ops.md @@ -1,6 +1,6 @@ -# `space-infix-ops` - -Requires spacing around infix operators. +> 🛑 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. diff --git a/packages/eslint-plugin/docs/rules/strict-boolean-expressions.md b/packages/eslint-plugin/docs/rules/strict-boolean-expressions.md index 16ceb26aa8fe..a86e8146ba6f 100644 --- a/packages/eslint-plugin/docs/rules/strict-boolean-expressions.md +++ b/packages/eslint-plugin/docs/rules/strict-boolean-expressions.md @@ -1,6 +1,6 @@ -# `strict-boolean-expressions` - -Disallows certain types in boolean expressions. +> 🛑 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. diff --git a/packages/eslint-plugin/docs/rules/switch-exhaustiveness-check.md b/packages/eslint-plugin/docs/rules/switch-exhaustiveness-check.md index 7e6126830d4c..cfe2ef234a46 100644 --- a/packages/eslint-plugin/docs/rules/switch-exhaustiveness-check.md +++ b/packages/eslint-plugin/docs/rules/switch-exhaustiveness-check.md @@ -1,6 +1,6 @@ -# `switch-exhaustiveness-check` - -Requires switch-case statements to be exhaustive with union type. +> 🛑 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. diff --git a/packages/eslint-plugin/docs/rules/triple-slash-reference.md b/packages/eslint-plugin/docs/rules/triple-slash-reference.md index 97f4fb77dab4..ce73a33d5942 100644 --- a/packages/eslint-plugin/docs/rules/triple-slash-reference.md +++ b/packages/eslint-plugin/docs/rules/triple-slash-reference.md @@ -1,6 +1,6 @@ -# `triple-slash-reference` - -Disallows certain triple slash directives in favor of ES6-style import declarations. +> 🛑 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. diff --git a/packages/eslint-plugin/docs/rules/type-annotation-spacing.md b/packages/eslint-plugin/docs/rules/type-annotation-spacing.md index 475ad29ca4d1..7adc9fd0e59e 100644 --- a/packages/eslint-plugin/docs/rules/type-annotation-spacing.md +++ b/packages/eslint-plugin/docs/rules/type-annotation-spacing.md @@ -1,6 +1,6 @@ -# `type-annotation-spacing` - -Requires consistent spacing around type annotations. +> 🛑 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 5356cdd7a2d7..8976c5211974 100644 --- a/packages/eslint-plugin/docs/rules/typedef.md +++ b/packages/eslint-plugin/docs/rules/typedef.md @@ -1,6 +1,6 @@ -# `typedef` - -Requires type annotations in certain places. +> 🛑 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 9f71738f5a91..b42e274ec59b 100644 --- a/packages/eslint-plugin/docs/rules/unbound-method.md +++ b/packages/eslint-plugin/docs/rules/unbound-method.md @@ -1,11 +1,8 @@ -# `unbound-method` - -Enforces unbound methods are called with their expected scope. - -Warns when a method is used outside of a method call. +> 🛑 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. 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..290c3f337399 100644 --- a/packages/eslint-plugin/docs/rules/unified-signatures.md +++ b/packages/eslint-plugin/docs/rules/unified-signatures.md @@ -1,6 +1,6 @@ -# `unified-signatures` - -Disallows two overloads that could be unified into one with a union or an optional/rest parameter. +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/unified-signatures** for documentation. ## Rule Details diff --git a/packages/eslint-plugin/tests/docs.test.ts b/packages/eslint-plugin/tests/docs.test.ts index 13262e4ce73c..7ab1095f4ad0 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,26 +67,17 @@ 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 + test(`${ruleName}.md must start with blockquote directing to website`, () => { 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( - /(? { - 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..23ff08c54df1 --- /dev/null +++ b/packages/website/plugins/generated-rule-docs.ts @@ -0,0 +1,58 @@ +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. 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: [ + { + children: [ + { + type: 'text', + value: `${docs.description}.`, + }, + ], + type: 'paragraph', + }, + ], + type: 'blockquote', + } as mdast.Blockquote); + + // 3. Add a rule attributes list... + const h2Idx = + // ...before 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 };