diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 924efa875645..320f743b6d24 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -188,7 +188,9 @@ jobs: - name: Install Cypress run: yarn cypress install - - name: Cypress run + - env: + DEBUG: '@cypress/github-action' + name: Cypress run uses: cypress-io/github-action@v2 with: project: ./packages/website diff --git a/packages/eslint-plugin/docs/rules/TEMPLATE.md b/packages/eslint-plugin/docs/rules/TEMPLATE.md index a49ed54ac02a..20ca5d8bdbe6 100644 --- a/packages/eslint-plugin/docs/rules/TEMPLATE.md +++ b/packages/eslint-plugin/docs/rules/TEMPLATE.md @@ -20,33 +20,6 @@ To fill out: tell us more about this rule. // To fill out: correct code ``` -## Options - -This rule is not configurable. - -```jsonc -// .eslintrc.json -{ - "rules": { - "@typescript-eslint/your-rule-name": "error" - } -} -``` - -If not configurable: This rule is not configurable. - -If configurable... - -```ts -type Options = { - someOption?: boolean; -}; - -const defaultOptions: Options = { - someOption: false, -}; -``` - ## When Not To Use It To fill out: why wouldn't you want to use 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 27fc807e555f..422824d7f3e9 100644 --- a/packages/eslint-plugin/docs/rules/adjacent-overload-signatures.md +++ b/packages/eslint-plugin/docs/rules/adjacent-overload-signatures.md @@ -88,19 +88,6 @@ export function foo(n: number): void; export function foo(sn: string | number): void; ``` -## Options - -```jsonc -// .eslintrc.json -{ - "rules": { - "@typescript-eslint/adjacent-overload-signatures": "error" - } -} -``` - -This rule is not configurable. - ## When Not To Use It If you don't care about the general structure of the code, then you will not need this rule. diff --git a/packages/eslint-plugin/docs/rules/array-type.md b/packages/eslint-plugin/docs/rules/array-type.md index e72266ff31ce..08b9ddfb3861 100644 --- a/packages/eslint-plugin/docs/rules/array-type.md +++ b/packages/eslint-plugin/docs/rules/array-type.md @@ -14,25 +14,6 @@ This rule aims to standardize usage of array types within your codebase. ## Options -```ts -type ArrayOption = 'array' | 'generic' | 'array-simple'; -type Options = { - default: ArrayOption; - readonly?: ArrayOption; -}; - -const defaultOptions: Options = { - default: 'array', -}; -``` - -The rule accepts an options object with the following properties: - -- `default` - sets the array type expected for mutable cases. -- `readonly` - sets the array type expected for readonly arrays. If this is omitted, then the value for `default` will be used. - -Each property can be set to one of three strings: `'array' | 'generic' | 'array-simple'`. - The default config will enforce that all mutable and readonly arrays use the `'array'` syntax. ### `"array"` diff --git a/packages/eslint-plugin/docs/rules/await-thenable.md b/packages/eslint-plugin/docs/rules/await-thenable.md index b47107e48dfd..dda209099712 100644 --- a/packages/eslint-plugin/docs/rules/await-thenable.md +++ b/packages/eslint-plugin/docs/rules/await-thenable.md @@ -33,19 +33,6 @@ const createValue = async () => 'value'; await createValue(); ``` -## Options - -```jsonc -// .eslintrc.json -{ - "rules": { - "@typescript-eslint/await-thenable": "error" - } -} -``` - -This rule is not configurable. - ## When Not To Use It If you want to allow code to `await` non-Promise values. diff --git a/packages/eslint-plugin/docs/rules/ban-ts-comment.md b/packages/eslint-plugin/docs/rules/ban-ts-comment.md index d658b599a003..efadc961e104 100644 --- a/packages/eslint-plugin/docs/rules/ban-ts-comment.md +++ b/packages/eslint-plugin/docs/rules/ban-ts-comment.md @@ -21,32 +21,10 @@ The directive comments supported by TypeScript are: ## Rule Details This rule lets you set which directive comments you want to allow in your codebase. -By default, only `@ts-check` is allowed, as it enables rather than suppresses errors. - -The configuration looks like this: -```ts -type DirectiveConfig = - | boolean - | 'allow-with-description' - | { descriptionFormat: string }; - -interface Options { - 'ts-expect-error'?: DirectiveConfig; - 'ts-ignore'?: DirectiveConfig; - 'ts-nocheck'?: DirectiveConfig; - 'ts-check'?: DirectiveConfig; - minimumDescriptionLength?: number; -} +## Options -const defaultOptions: Options = { - 'ts-expect-error': 'allow-with-description', - 'ts-ignore': true, - 'ts-nocheck': true, - 'ts-check': false, - minimumDescriptionLength: 3, -}; -``` +By default, only `@ts-check` is allowed, as it enables rather than suppresses errors. ### `ts-expect-error`, `ts-ignore`, `ts-nocheck`, `ts-check` directives diff --git a/packages/eslint-plugin/docs/rules/ban-tslint-comment.md b/packages/eslint-plugin/docs/rules/ban-tslint-comment.md index 9b37077d74ba..fc9fe81af6bc 100644 --- a/packages/eslint-plugin/docs/rules/ban-tslint-comment.md +++ b/packages/eslint-plugin/docs/rules/ban-tslint-comment.md @@ -34,19 +34,6 @@ someCode(); // tslint:disable-line someCode(); // This is a comment that just happens to mention tslint ``` -## Options - -```jsonc -// .eslintrc.json -{ - "rules": { - "@typescript-eslint/ban-tslint-comment": "warn" - } -} -``` - -This rule is not configurable. - ## When Not To Use It If you are still using TSLint. diff --git a/packages/eslint-plugin/docs/rules/ban-types.md b/packages/eslint-plugin/docs/rules/ban-types.md index ca557b88dab1..2d0b345cda80 100644 --- a/packages/eslint-plugin/docs/rules/ban-types.md +++ b/packages/eslint-plugin/docs/rules/ban-types.md @@ -6,7 +6,7 @@ description: 'Disallow certain types.' > > See **https://typescript-eslint.io/rules/ban-types** for documentation. -Some builtin types have aliases, some types are considered dangerous or harmful. +Some built-in types have aliases, while some types are considered dangerous or harmful. It's often a good idea to ban certain types to help with consistency and safety. ## Rule Details @@ -14,72 +14,53 @@ It's often a good idea to ban certain types to help with consistency and safety. This rule bans specific types and can suggest alternatives. Note that it does not ban the corresponding runtime objects from being used. -## Options - -```ts -type Options = { - types?: { - [typeName: string]: - | false - | string - | { - message: string; - fixWith?: string; - }; - }; - extendDefaults?: boolean; -}; -``` - -The rule accepts a single object as options. - -### `types` +Examples of code with the default options: -An object whose keys are the types you want to ban, and the values are error messages. + -The type can either be a type name literal (`Foo`), a type name with generic parameter instantiation(s) (`Foo`), the empty object literal (`{}`), or the empty tuple type (`[]`). +### ❌ Incorrect -The values can be: +```ts +// use lower-case primitives for consistency +const str: String = 'foo'; +const bool: Boolean = true; +const num: Number = 1; +const symb: Symbol = Symbol('foo'); +const bigInt: BigInt = 1n; -- A string, which is the error message to be reported; or -- `false` to specifically un-ban this type (useful when you are using `extendDefaults`); or -- An object with the following properties: - - `message: string` - the message to display when the type is matched. - - `fixWith?: string` - a string to replace the banned type with when the fixer is run. If this is omitted, no fix will be done. +// use a proper function type +const func: Function = () => 1; -### `extendDefaults` +// use safer object types +const lowerObj: Object = {}; +const capitalObj: Object = { a: 'string' }; -If you're specifying custom `types`, you can set this to `true` to extend the default `types` configuration. This is a convenience option to save you copying across the defaults when adding another type. +const curly1: {} = 1; +const curly2: {} = { a: 'string' }; +``` -If this is `false`, the rule will _only_ use the types defined in your configuration. +### ✅ Correct -Example configuration: +```ts +// use lower-case primitives for consistency +const str: string = 'foo'; +const bool: boolean = true; +const num: number = 1; +const symb: symbol = Symbol('foo'); +const bigInt: bigint = 1n; -```jsonc -{ - "@typescript-eslint/ban-types": [ - "error", - { - "types": { - // add a custom message to help explain why not to use it - "Foo": "Don't use Foo because it is unsafe", +// use a proper function type +const func: () => number = () => 1; - // add a custom message, AND tell the plugin how to fix it - "OldAPI": { - "message": "Use NewAPI instead", - "fixWith": "NewAPI" - }, +// use safer object types +const lowerObj: object = {}; +const capitalObj: { a: string } = { a: 'string' }; - // un-ban a type that's banned by default - "{}": false - }, - "extendDefaults": true - } - ] -} +const curly1: number = 1; +const curly2: Record<'a', string> = { a: 'string' }; ``` -### Default Options +## Options The default options provide a set of "best practices", intended to provide safety and standardization in your codebase: @@ -122,7 +103,6 @@ const defaultTypes = { message: 'Use bigint instead', fixWith: 'bigint', }, - Function: { message: [ 'The `Function` type accepts any function-like value.', @@ -131,7 +111,6 @@ const defaultTypes = { 'If you are expecting the function to accept certain arguments, you should explicitly define the function shape.', ].join('\n'), }, - // object typing Object: { message: [ @@ -152,52 +131,48 @@ const defaultTypes = { -### Examples - -Examples of code with the default options: - - +### `types` -#### ❌ Incorrect +An object whose keys are the types you want to ban, and the values are error messages. -```ts -// use lower-case primitives for consistency -const str: String = 'foo'; -const bool: Boolean = true; -const num: Number = 1; -const symb: Symbol = Symbol('foo'); -const bigInt: BigInt = 1n; +The type can either be a type name literal (`Foo`), a type name with generic parameter instantiation(s) (`Foo`), the empty object literal (`{}`), or the empty tuple type (`[]`). -// use a proper function type -const func: Function = () => 1; +The values can be: -// use safer object types -const capitalObj1: Object = 1; -const capitalObj2: Object = { a: 'string' }; +- A string, which is the error message to be reported; or +- `false` to specifically un-ban this type (useful when you are using `extendDefaults`); or +- An object with the following properties: + - `message: string` - the message to display when the type is matched. + - `fixWith?: string` - a string to replace the banned type with when the fixer is run. If this is omitted, no fix will be done. -const curly1: {} = 1; -const curly2: {} = { a: 'string' }; -``` +### `extendDefaults` -#### ✅ Correct +If you're specifying custom `types`, you can set this to `true` to extend the default `types` configuration. This is a convenience option to save you copying across the defaults when adding another type. -```ts -// use lower-case primitives for consistency -const str: string = 'foo'; -const bool: boolean = true; -const num: number = 1; -const symb: symbol = Symbol('foo'); -const bigInt: bigint = 1n; +If this is `false`, the rule will _only_ use the types defined in your configuration. -// use a proper function type -const func: () => number = () => 1; +Example configuration: -// use safer object types -const lowerObj: object = {}; +```jsonc +{ + "@typescript-eslint/ban-types": [ + "error", + { + "types": { + // add a custom message to help explain why not to use it + "Foo": "Don't use Foo because it is unsafe", -const capitalObj1: number = 1; -const capitalObj2: { a: string } = { a: 'string' }; + // add a custom message, AND tell the plugin how to fix it + "OldAPI": { + "message": "Use NewAPI instead", + "fixWith": "NewAPI" + }, -const curly1: number = 1; -const curly2: Record<'a', string> = { a: 'string' }; + // un-ban a type that's banned by default + "{}": false + }, + "extendDefaults": true + } + ] +} ``` diff --git a/packages/eslint-plugin/docs/rules/brace-style.md b/packages/eslint-plugin/docs/rules/brace-style.md index 3487df67fb31..18f93c48a5ed 100644 --- a/packages/eslint-plugin/docs/rules/brace-style.md +++ b/packages/eslint-plugin/docs/rules/brace-style.md @@ -10,23 +10,3 @@ description: 'Enforce consistent brace style for blocks.' This rule extends the base [`eslint/brace-style`](https://eslint.org/docs/rules/brace-style) rule. It adds support for `enum`, `interface`, `namespace` and `module` declarations. - -## How to Use - -```jsonc -{ - // note you must disable the base rule as it can report incorrect errors - "brace-style": "off", - "@typescript-eslint/brace-style": ["error"] -} -``` - -## Options - -See [`eslint/brace-style` options](https://eslint.org/docs/rules/brace-style#options). - - - -Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/main/docs/rules/brace-style.md) - - diff --git a/packages/eslint-plugin/docs/rules/camelcase.md b/packages/eslint-plugin/docs/rules/camelcase.md index cea28224965f..1b3c0e893183 100644 --- a/packages/eslint-plugin/docs/rules/camelcase.md +++ b/packages/eslint-plugin/docs/rules/camelcase.md @@ -1,7 +1,9 @@ -## DEPRECATED +:::danger Deprecated This rule has been deprecated in favour of the [`naming-convention`](./naming-convention.md) rule. +::: + 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 474d7352632f..918c27fef618 100644 --- a/packages/eslint-plugin/docs/rules/consistent-indexed-object-style.md +++ b/packages/eslint-plugin/docs/rules/consistent-indexed-object-style.md @@ -20,34 +20,24 @@ type Foo = { type Foo = Record; ``` -## Options - -- `"record"`: Set to `"record"` to only allow the `Record` type. Set to `"index-signature"` to only allow index signatures. (Defaults to `"record"`) - -For example: - -```json -{ - "@typescript-eslint/consistent-indexed-object-style": [ - "error", - "index-signature" - ] -} -``` - ## Rule Details This rule enforces a consistent way to define records. -### `record` +## Options + +- `"record"` _(default)_: only allow the `Record` type. +- `"index-signature"`: only allow index signatures. -Examples of code with `record` option. +### `record` #### ❌ Incorrect ```ts +/* eslint @typescript-eslint/consistent-indexed-object-style: ["error", "record"] */ + interface Foo { [key: string]: unknown; } @@ -60,24 +50,28 @@ type Foo = { #### ✅ Correct ```ts +/* eslint @typescript-eslint/consistent-indexed-object-style: ["error", "record"] */ + type Foo = Record; ``` ### `index-signature` -Examples of code with `index-signature` option. - #### ❌ Incorrect ```ts +/* eslint @typescript-eslint/consistent-indexed-object-style: ["error", "index-signature"] */ + type Foo = Record; ``` #### ✅ Correct ```ts +/* eslint @typescript-eslint/consistent-indexed-object-style: ["error", "index-signature"] */ + interface Foo { [key: string]: unknown; } diff --git a/packages/eslint-plugin/docs/rules/consistent-type-assertions.md b/packages/eslint-plugin/docs/rules/consistent-type-assertions.md index c8c192259174..f6d439613cba 100644 --- a/packages/eslint-plugin/docs/rules/consistent-type-assertions.md +++ b/packages/eslint-plugin/docs/rules/consistent-type-assertions.md @@ -14,26 +14,10 @@ Type assertions are also commonly referred as "type casting" in TypeScript (even In addition to ensuring that type assertions are written in a consistent way, this rule also helps make your codebase more type-safe. -`const` assertions, [introduced in TypeScript 3.4](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-4.html#const-assertions), is always allowed by this rule. Examples of it include `let x = "hello" as const;` and `let x = "hello";`. +[`const` assertions](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-4.html#const-assertions) are always allowed by this rule. Examples of them include `let x = "hello" as const;` and `let x = "hello";`. ## Options -```ts -type Options = - | { - assertionStyle: 'as' | 'angle-bracket'; - objectLiteralTypeAssertions: 'allow' | 'allow-as-parameter' | 'never'; - } - | { - assertionStyle: 'never'; - }; - -const defaultOptions: Options = { - assertionStyle: 'as', - objectLiteralTypeAssertions: 'allow', -}; -``` - ### `assertionStyle` This option defines the expected assertion style. Valid values for `assertionStyle` are: @@ -56,7 +40,7 @@ The const assertion `const x = { foo: 1 } as const`, introduced in TypeScript 3. Assertions to `any` are also ignored by this option. -Examples of code for `{ assertionStyle: 'as', objectLiteralTypeAssertions: 'never' }` +Examples of code for `{ assertionStyle: 'as', objectLiteralTypeAssertions: 'never' }`: @@ -84,7 +68,7 @@ function foo(): T { -Examples of code for `{ assertionStyle: 'as', objectLiteralTypeAssertions: 'allow-as-parameter' }` +Examples of code for `{ assertionStyle: 'as', objectLiteralTypeAssertions: 'allow-as-parameter' }`: diff --git a/packages/eslint-plugin/docs/rules/consistent-type-definitions.md b/packages/eslint-plugin/docs/rules/consistent-type-definitions.md index f662841bfd58..5d400a28a1c2 100644 --- a/packages/eslint-plugin/docs/rules/consistent-type-definitions.md +++ b/packages/eslint-plugin/docs/rules/consistent-type-definitions.md @@ -24,35 +24,26 @@ interface T2 { ## Options -This rule accepts one string option: - -- `"interface"`: enforce using `interface`s for object type definitions. +- `"interface"` _(default)_: enforce using `interface`s for object type definitions. - `"type"`: enforce using `type`s for object type definitions. -For example: - -```jsonc -{ - // Use type for object definitions - "@typescript-eslint/consistent-type-definitions": ["error", "type"] -} -``` - ### `interface` -Examples of code with `interface` option. - #### ❌ Incorrect ```ts +/* eslint @typescript-eslint/consistent-type-definitions: ["error", "interface"] */ + type T = { x: number }; ``` #### ✅ Correct ```ts +/* eslint @typescript-eslint/consistent-type-definitions: ["error", "interface"] */ + type T = string; type Foo = string | {}; @@ -63,13 +54,13 @@ interface T { ### `type` -Examples of code with `type` option. - #### ❌ Incorrect ```ts +/* eslint @typescript-eslint/consistent-type-definitions: ["error", "type"] */ + interface T { x: number; } @@ -78,6 +69,8 @@ interface T { #### ✅ Correct ```ts +/* eslint @typescript-eslint/consistent-type-definitions: ["error", "type"] */ + type T = { x: number }; ``` diff --git a/packages/eslint-plugin/docs/rules/consistent-type-exports.md b/packages/eslint-plugin/docs/rules/consistent-type-exports.md index 2f5f72802512..97a11e65a28f 100644 --- a/packages/eslint-plugin/docs/rules/consistent-type-exports.md +++ b/packages/eslint-plugin/docs/rules/consistent-type-exports.md @@ -6,14 +6,12 @@ description: 'Enforce consistent usage of type exports.' > > 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 transpilers to drop exports without knowing the types of the dependencies. ## Rule Details -This rule aims to standardize the use of type exports style across a codebase. +This rule aims to standardize the use of type exports style. Given a class `Button`, and an interface `ButtonProps`, examples of code: @@ -25,11 +23,13 @@ Given a class `Button`, and an interface `ButtonProps`, examples of code: interface ButtonProps { onClick: () => void; } + class Button implements ButtonProps { onClick() { console.log('button!'); } } + export { Button, ButtonProps }; ``` @@ -50,16 +50,6 @@ export type { ButtonProps }; ## Options -```ts -interface Options { - fixMixedExportsWithInlineTypeSpecifier?: boolean; -} - -const defaultOptions: Options = { - fixMixedExportsWithInlineTypeSpecifier: false, -}; -``` - ### `fixMixedExportsWithInlineTypeSpecifier` When this is set to true, the rule will autofix "mixed" export cases using TS 4.5's "inline type specifier". @@ -110,6 +100,5 @@ export { Button, type ButtonProps } from 'some-library'; ## When Not To Use It -- If you are using a TypeScript version less than 3.8, then you will not be able to use this rule as type exports are not supported. - If you specifically want to use both export kinds for stylistic reasons, you can disable this rule. - If you use `--isolatedModules` the compiler would error if a type is not re-exported using `export type`. If you also don't wish to enforce one style over the other, you can disable this rule. diff --git a/packages/eslint-plugin/docs/rules/consistent-type-imports.md b/packages/eslint-plugin/docs/rules/consistent-type-imports.md index 192454f13e7b..9293fca42c6a 100644 --- a/packages/eslint-plugin/docs/rules/consistent-type-imports.md +++ b/packages/eslint-plugin/docs/rules/consistent-type-imports.md @@ -6,27 +6,14 @@ description: 'Enforce consistent usage of type imports.' > > 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. ## Rule Details -This rule aims to standardize the use of type imports style across the codebase. +This rule aims to standardize the use of type imports style. ## Options -```ts -type Options = { - prefer: 'type-imports' | 'no-type-imports'; - disallowTypeAnnotations: boolean; -}; - -const defaultOptions: Options = { - prefer: 'type-imports', - disallowTypeAnnotations: true, -}; -``` - ### `prefer` This option defines the expected import kind for type-only imports. Valid values for `prefer` are: @@ -54,10 +41,10 @@ const x: Bar = 1; ### `disallowTypeAnnotations` -If `true`, type imports in type annotations (`import()`) is not allowed. +If `true`, type imports in type annotations (`import()`) are not allowed. Default is `true`. -Examples of **incorrect** code with `{disallowTypeAnnotations: true}`. +Examples of **incorrect** code with `{disallowTypeAnnotations: true}`: ```ts type T = import('Foo').Foo; @@ -66,5 +53,4 @@ const x: import('Bar') = 1; ## When Not To Use It -- If you are not using TypeScript 3.8 (or greater), then you will not be able to use this rule, as type-only imports are not allowed. - If you specifically want to use both import kinds for stylistic reasons, you can disable this rule. diff --git a/packages/eslint-plugin/docs/rules/default-param-last.md b/packages/eslint-plugin/docs/rules/default-param-last.md index ff5ad9facc3f..9a0624fca227 100644 --- a/packages/eslint-plugin/docs/rules/default-param-last.md +++ b/packages/eslint-plugin/docs/rules/default-param-last.md @@ -16,7 +16,7 @@ It adds support for optional parameters. ### ❌ Incorrect ```ts -/* eslint @typescript-eslint/default-param-last: ["error"] */ +/* eslint @typescript-eslint/default-param-last: "error" */ function f(a = 0, b: number) {} function f(a: number, b = 0, c: number) {} @@ -32,7 +32,7 @@ class Foo { ### ✅ Correct ```ts -/* eslint @typescript-eslint/default-param-last: ["error"] */ +/* eslint @typescript-eslint/default-param-last: "error" */ function f(a = 0) {} function f(a: number, b = 0) {} @@ -46,23 +46,3 @@ class Foo { constructor(public a, private b?: number) {} } ``` - -## How to Use - -```jsonc -{ - // note you must disable the base rule as it can report incorrect errors - "default-param-last": "off", - "@typescript-eslint/default-param-last": ["error"] -} -``` - -## Options - -See [`eslint/default-param-last` options](https://eslint.org/docs/rules/default-param-last#options). - - - -Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/main/docs/rules/default-param-last.md) - - diff --git a/packages/eslint-plugin/docs/rules/dot-notation.md b/packages/eslint-plugin/docs/rules/dot-notation.md index 6051e369c791..741de5ee5e71 100644 --- a/packages/eslint-plugin/docs/rules/dot-notation.md +++ b/packages/eslint-plugin/docs/rules/dot-notation.md @@ -14,19 +14,8 @@ It adds: - Support for optionally ignoring computed `private` and/or `protected` member access. - Compatibility with TypeScript's `noPropertyAccessFromIndexSignature` option. -## How to Use - -```jsonc -{ - // note you must disable the base rule as it can report incorrect errors - "dot-notation": "off", - "@typescript-eslint/dot-notation": ["error"] -} -``` - ## Options -See [`eslint/dot-notation`](https://eslint.org/docs/rules/dot-notation#options) options. This rule adds the following options: ```ts @@ -35,6 +24,7 @@ interface Options extends BaseDotNotationOptions { allowProtectedClassPropertyAccess?: boolean; allowIndexSignaturePropertyAccess?: boolean; } + const defaultOptions: Options = { ...baseDotNotationDefaultOptions, allowPrivateClassPropertyAccess: false, @@ -47,7 +37,7 @@ If the TypeScript compiler option `noPropertyAccessFromIndexSignature` is set to ### `allowPrivateClassPropertyAccess` -Example of a correct code when `allowPrivateClassPropertyAccess` is set to `true` +Example of a correct code when `allowPrivateClassPropertyAccess` is set to `true`: ```ts class X { @@ -60,7 +50,7 @@ x['priv_prop'] = 123; ### `allowProtectedClassPropertyAccess` -Example of a correct code when `allowProtectedClassPropertyAccess` is set to `true` +Example of a correct code when `allowProtectedClassPropertyAccess` is set to `true`: ```ts class X { @@ -73,7 +63,7 @@ x['protected_prop'] = 123; ### `allowIndexSignaturePropertyAccess` -Example of correct code when `allowIndexSignaturePropertyAccess` is set to `true` +Example of correct code when `allowIndexSignaturePropertyAccess` is set to `true`: ```ts class X { @@ -85,9 +75,3 @@ x['hello'] = 123; ``` If the TypeScript compiler option `noPropertyAccessFromIndexSignature` is set to `true`, then the above code is always allowed, even if `allowIndexSignaturePropertyAccess` is `false`. - - - -Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/main/docs/rules/dot-notation.md) - - 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 e0b96592eda3..5697be355b57 100644 --- a/packages/eslint-plugin/docs/rules/explicit-function-return-type.md +++ b/packages/eslint-plugin/docs/rules/explicit-function-return-type.md @@ -67,36 +67,6 @@ class Test { ## Options -The rule accepts an options object with the following properties: - -```ts -type Options = { - // if true, only functions which are part of a declaration will be checked - allowExpressions?: boolean; - // if true, type annotations are also allowed on the variable of a function expression rather than on the function directly - allowTypedFunctionExpressions?: boolean; - // if true, functions immediately returning another function expression will not be checked - allowHigherOrderFunctions?: boolean; - // if true, arrow functions immediately returning a `as const` value will not be checked - allowDirectConstAssertionInArrowFunctions?: boolean; - // if true, concise arrow functions that start with the void keyword will not be checked - allowConciseArrowFunctionExpressionsStartingWithVoid?: boolean; - /** - * An array of function/method names that will not have their arguments or their return values checked. - */ - allowedNames?: string[]; -}; - -const defaults = { - allowExpressions: false, - allowTypedFunctionExpressions: true, - allowHigherOrderFunctions: true, - allowDirectConstAssertionInArrowFunctions: true, - allowConciseArrowFunctionExpressionsStartingWithVoid: false, - allowedNames: [], -}; -``` - ### Configuring in a mixed JS/TS codebase If you are working on a codebase within which you lint non-TypeScript code (i.e. `.js`/`.mjs`/`.cjs`/`.jsx`), you should ensure that you should use [ESLint `overrides`](https://eslint.org/docs/user-guide/configuring#disabling-rules-only-for-a-group-of-files) to only enable the rule on `.ts`/`.mts`/`.cts`/`.tsx` files. If you don't, then you will get unfixable lint errors reported within `.js`/`.mjs`/`.cjs`/`.jsx` files. @@ -112,7 +82,7 @@ If you are working on a codebase within which you lint non-TypeScript code (i.e. // enable the rule specifically for TypeScript files "files": ["*.ts", "*.mts", "*.cts", "*.tsx"], "rules": { - "@typescript-eslint/explicit-function-return-type": ["error"] + "@typescript-eslint/explicit-function-return-type": "error" } } ] diff --git a/packages/eslint-plugin/docs/rules/explicit-member-accessibility.md b/packages/eslint-plugin/docs/rules/explicit-member-accessibility.md index d32100f534e7..6cb6068a8874 100644 --- a/packages/eslint-plugin/docs/rules/explicit-member-accessibility.md +++ b/packages/eslint-plugin/docs/rules/explicit-member-accessibility.md @@ -18,29 +18,6 @@ which properties. ## Options -```ts -type AccessibilityLevel = - | 'explicit' // require an accessor (including public) - | 'no-public' // don't require public - | 'off'; // don't check - -type Options = { - accessibility?: AccessibilityLevel; - ignoredMethodNames?: string[]; - overrides?: { - accessors?: AccessibilityLevel; - constructors?: AccessibilityLevel; - methods?: AccessibilityLevel; - properties?: AccessibilityLevel; - parameterProperties?: AccessibilityLevel; - }; -}; - -const defaultOptions: Options = { - accessibility: 'explicit', -}; -``` - ### Configuring in a mixed JS/TS codebase If you are working on a codebase within which you lint non-TypeScript code (i.e. `.js`/`.mjs`/`.cjs`/`.jsx`), you should ensure that you should use [ESLint `overrides`](https://eslint.org/docs/user-guide/configuring#disabling-rules-only-for-a-group-of-files) to only enable the rule on `.ts`/`.mts`/`.cts`/`.tsx` files. If you don't, then you will get unfixable lint errors reported within `.js`/`.mjs`/`.cjs`/`.jsx` files. @@ -56,7 +33,7 @@ If you are working on a codebase within which you lint non-TypeScript code (i.e. // enable the rule specifically for TypeScript files "files": ["*.ts", "*.mts", "*.cts", "*.tsx"], "rules": { - "@typescript-eslint/explicit-member-accessibility": ["error"] + "@typescript-eslint/explicit-member-accessibility": "error" } } ] 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 6c0525688c07..48626a34b08f 100644 --- a/packages/eslint-plugin/docs/rules/explicit-module-boundary-types.md +++ b/packages/eslint-plugin/docs/rules/explicit-module-boundary-types.md @@ -72,46 +72,6 @@ class Test { ## Options -The rule accepts an options object with the following properties: - -```ts -type Options = { - /** - * If true, the rule will not report for arguments that are explicitly typed as `any` - */ - allowArgumentsExplicitlyTypedAsAny?: boolean; - /** - * If true, body-less arrow functions that return an `as const` type assertion will not - * require an explicit return value annotation. - * You must still type the parameters of the function. - */ - allowDirectConstAssertionInArrowFunctions?: boolean; - /** - * An array of function/method names that will not have their arguments or their return values checked. - */ - allowedNames?: string[]; - /** - * If true, functions immediately returning another function expression will not - * require an explicit return value annotation. - * You must still type the parameters of the function. - */ - allowHigherOrderFunctions?: boolean; - /** - * If true, type annotations are also allowed on the variable of a function expression - * rather than on the function arguments/return value directly. - */ - allowTypedFunctionExpressions?: boolean; -}; - -const defaults = { - allowArgumentsExplicitlyTypedAsAny: false, - allowDirectConstAssertionInArrowFunctions: true, - allowedNames: [], - allowHigherOrderFunctions: true, - allowTypedFunctionExpressions: true, -}; -``` - ### Configuring in a mixed JS/TS codebase If you are working on a codebase within which you lint non-TypeScript code (i.e. `.js`/`.mjs`/`.cjs`/`.jsx`), you should ensure that you should use [ESLint `overrides`](https://eslint.org/docs/user-guide/configuring#disabling-rules-only-for-a-group-of-files) to only enable the rule on `.ts`/`.mts`/`.cts`/`.tsx` files. If you don't, then you will get unfixable lint errors reported within `.js`/`.mjs`/`.cjs`/`.jsx` files. @@ -127,7 +87,7 @@ If you are working on a codebase within which you lint non-TypeScript code (i.e. // enable the rule specifically for TypeScript files "files": ["*.ts", "*.mts", "*.cts", "*.tsx"], "rules": { - "@typescript-eslint/explicit-module-boundary-types": ["error"] + "@typescript-eslint/explicit-module-boundary-types": "error" } } ] diff --git a/packages/eslint-plugin/docs/rules/func-call-spacing.md b/packages/eslint-plugin/docs/rules/func-call-spacing.md index 772c86e7c709..74de5955e9b7 100644 --- a/packages/eslint-plugin/docs/rules/func-call-spacing.md +++ b/packages/eslint-plugin/docs/rules/func-call-spacing.md @@ -10,23 +10,3 @@ description: 'Require or disallow spacing between function identifiers and their This rule extends the base [`eslint/func-call-spacing`](https://eslint.org/docs/rules/func-call-spacing) rule. It adds support for generic type parameters on function calls. - -## How to Use - -```jsonc -{ - // note you must disable the base rule as it can report incorrect errors - "func-call-spacing": "off", - "@typescript-eslint/func-call-spacing": ["error"] -} -``` - -## Options - -See [`eslint/func-call-spacing` options](https://eslint.org/docs/rules/func-call-spacing#options). - - - -Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/main/docs/rules/func-call-spacing.md) - - diff --git a/packages/eslint-plugin/docs/rules/indent.md b/packages/eslint-plugin/docs/rules/indent.md index 7f937d3747cd..6c16f6f0c21d 100644 --- a/packages/eslint-plugin/docs/rules/indent.md +++ b/packages/eslint-plugin/docs/rules/indent.md @@ -8,29 +8,13 @@ description: 'Enforce consistent indentation.' ## Warning -PLEASE READ THIS ISSUE BEFORE USING THIS RULE [#1824](https://github.com/typescript-eslint/typescript-eslint/issues/1824) +:::warning + +Please read [Issue #1824: Problems with the indent rule](https://github.com/typescript-eslint/typescript-eslint/issues/1824) before using this rule! + +::: ## Rule Details This rule extends the base [`eslint/indent`](https://eslint.org/docs/rules/indent) rule. It adds support for TypeScript nodes. - -## How to Use - -```jsonc -{ - // note you must disable the base rule as it can report incorrect errors - "indent": "off", - "@typescript-eslint/indent": ["error"] -} -``` - -## Options - -See [`eslint/indent` options](https://eslint.org/docs/rules/indent#options). - - - -Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/main/docs/rules/indent.md) - - diff --git a/packages/eslint-plugin/docs/rules/init-declarations.md b/packages/eslint-plugin/docs/rules/init-declarations.md index b03db42de89c..97fc51bc5c32 100644 --- a/packages/eslint-plugin/docs/rules/init-declarations.md +++ b/packages/eslint-plugin/docs/rules/init-declarations.md @@ -10,23 +10,3 @@ description: 'Require or disallow initialization in variable declarations.' This rule extends the base [`eslint/init-declarations`](https://eslint.org/docs/rules/init-declarations) rule. It adds support for TypeScript's `declare` variables. - -## How to Use - -```jsonc -{ - // note you must disable the base rule as it can report incorrect errors - "init-declarations": "off", - "@typescript-eslint/init-declarations": ["error"] -} -``` - -## Options - -See [`eslint/init-declarations` options](https://eslint.org/docs/rules/init-declarations#options). - - - -Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/main/docs/rules/init-declarations.md) - - diff --git a/packages/eslint-plugin/docs/rules/keyword-spacing.md b/packages/eslint-plugin/docs/rules/keyword-spacing.md index 062da3253072..17f731cfc948 100644 --- a/packages/eslint-plugin/docs/rules/keyword-spacing.md +++ b/packages/eslint-plugin/docs/rules/keyword-spacing.md @@ -10,23 +10,3 @@ description: 'Enforce consistent spacing before and after keywords.' This rule extends the base [`eslint/keyword-spacing`](https://eslint.org/docs/rules/keyword-spacing) rule. This version adds support for generic type parameters on function calls. - -## How to Use - -```jsonc -{ - // note you must disable the base rule as it can report incorrect errors - "keyword-spacing": "off", - "@typescript-eslint/keyword-spacing": ["error"] -} -``` - -## Options - -See [`eslint/keyword-spacing` options](https://eslint.org/docs/rules/keyword-spacing#options). - - - -Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/main/docs/rules/keyword-spacing.md) - - 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 c1e3f7734556..f8d40de40899 100644 --- a/packages/eslint-plugin/docs/rules/lines-between-class-members.md +++ b/packages/eslint-plugin/docs/rules/lines-between-class-members.md @@ -6,30 +6,16 @@ description: 'Require or disallow an empty line between class members.' > > 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. +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 will require or disallow an empty line between class members. ## Rule Details This rule extends the base [`eslint/lines-between-class-members`](https://eslint.org/docs/rules/lines-between-class-members) rule. It adds support for ignoring overload methods in a class. -See the [ESLint documentation](https://eslint.org/docs/rules/lines-between-class-members) for more details on the `lines-between-class-members` rule. - -## Rule Changes - -```jsonc -{ - // note you must disable the base rule as it can report incorrect errors - "lines-between-class-members": "off", - "@typescript-eslint/lines-between-class-members": ["error"] -} -``` - -In addition to the options supported by the `lines-between-class-members` rule in ESLint core, the rule adds the following options: - ## Options -This rule has a string option and an object option. +In addition to the options supported by the `lines-between-class-members` rule in ESLint core, the rule adds the following options: - Object option: @@ -75,9 +61,3 @@ class foo { qux() {} } ``` - - - -Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/main/docs/rules/lines-between-class-members.md) - - diff --git a/packages/eslint-plugin/docs/rules/no-array-constructor.md b/packages/eslint-plugin/docs/rules/no-array-constructor.md index 6d301cca2bd7..54b69eb91ba1 100644 --- a/packages/eslint-plugin/docs/rules/no-array-constructor.md +++ b/packages/eslint-plugin/docs/rules/no-array-constructor.md @@ -33,23 +33,3 @@ new Array(x, y, z); Array(500); new Array(someOtherArray.length); ``` - -## How to Use - -```jsonc -{ - // note you must disable the base rule as it can report incorrect errors - "no-array-constructor": "off", - "@typescript-eslint/no-array-constructor": ["error"] -} -``` - -## Options - -See [`eslint/no-array-constructor` options](https://eslint.org/docs/rules/no-array-constructor#options). - - - -Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/main/docs/rules/no-array-constructor.md) - - 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 cfc9007ca12b..857c82091f6a 100644 --- a/packages/eslint-plugin/docs/rules/no-base-to-string.md +++ b/packages/eslint-plugin/docs/rules/no-base-to-string.md @@ -64,16 +64,6 @@ const literalWithToString = { ## Options -```ts -type Options = { - ignoredTypeNames?: string[]; -}; - -const defaultOptions: Options = { - ignoredTypeNames: ['RegExp'], -}; -``` - ### `ignoredTypeNames` A string array of type names to ignore, this is useful for types missing `toString()` (but actually has `toString()`). 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 43f2a34558e5..1b67f558af50 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 @@ -45,19 +45,6 @@ const isEqualsBar = foo.bar == 'hello'; const isEqualsNum = (1 + foo.num!) == 2; ``` -## Options - -```jsonc -// .eslintrc.json -{ - "rules": { - "@typescript-eslint/no-confusing-non-null-assertion": "warn" - } -} -``` - -This rule is not configurable. - ## When Not To Use It If you don't care about this confusion, then you will not need this rule. 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 7e5d84584683..4c4f6b1fa216 100644 --- a/packages/eslint-plugin/docs/rules/no-confusing-void-expression.md +++ b/packages/eslint-plugin/docs/rules/no-confusing-void-expression.md @@ -70,33 +70,8 @@ cond ? console.log('true') : console.error('false'); ## Options -An object option can be specified. Each boolean flag makes the rule less strict. - -```ts -type Options = { - ignoreArrowShorthand?: boolean; - ignoreVoidOperator?: boolean; -}; - -const defaults: Options = { - ignoreArrowShorthand: false, - ignoreVoidOperator: false, -}; -``` - ### `ignoreArrowShorthand` -`false` by default. - -```json -{ - "@typescript-eslint/no-confusing-void-expression": [ - "error", - { "ignoreArrowShorthand": true } - ] -} -``` - It might be undesirable to wrap every arrow function shorthand expression with braces. Especially when using Prettier formatter, which spreads such code across 3 lines instead of 1. @@ -108,17 +83,6 @@ promise.then(value => window.postMessage(value)); ### `ignoreVoidOperator` -`false` by default. - -```json -{ - "@typescript-eslint/no-confusing-void-expression": [ - "error", - { "ignoreVoidOperator": true } - ] -} -``` - It might be preferable to only use some distinct syntax to explicitly mark the confusing but valid usage of void expressions. This option allows void expressions which are explicitly wrapped in the `void` operator. 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 0e099a252cf7..2bfc1864f7e2 100644 --- a/packages/eslint-plugin/docs/rules/no-dupe-class-members.md +++ b/packages/eslint-plugin/docs/rules/no-dupe-class-members.md @@ -10,23 +10,3 @@ description: 'Disallow duplicate class members.' This rule extends the base [`eslint/no-dupe-class-members`](https://eslint.org/docs/rules/no-dupe-class-members) rule. It adds support for TypeScript's method overload definitions. - -## How to Use - -```jsonc -{ - // note you must disable the base rule as it can report incorrect errors - "no-dupe-class-members": "off", - "@typescript-eslint/no-dupe-class-members": ["error"] -} -``` - -## Options - -See [`eslint/no-dupe-class-members` options](https://eslint.org/docs/rules/no-dupe-class-members#options). - - - -Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/main/docs/rules/no-dupe-class-members.md) - - 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 31f8928b8cbc..e65884f821f4 100644 --- a/packages/eslint-plugin/docs/rules/no-duplicate-enum-values.md +++ b/packages/eslint-plugin/docs/rules/no-duplicate-enum-values.md @@ -45,16 +45,3 @@ enum E { B = 'B', } ``` - -## Options - -```jsonc -// .eslintrc.json -{ - "rules": { - "@typescript-eslint/no-duplicate-enum-values": "warn" - } -} -``` - -This rule is not configurable. diff --git a/packages/eslint-plugin/docs/rules/no-duplicate-imports.md b/packages/eslint-plugin/docs/rules/no-duplicate-imports.md index d6ac06cac786..5f523a7b0f4c 100644 --- a/packages/eslint-plugin/docs/rules/no-duplicate-imports.md +++ b/packages/eslint-plugin/docs/rules/no-duplicate-imports.md @@ -6,31 +6,7 @@ description: 'Disallow duplicate imports.' > > See **https://typescript-eslint.io/rules/no-duplicate-imports** for documentation. -## DEPRECATED +:::danger 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. - -## Rule Details - -This rule extends the base [`eslint/no-duplicate-imports`](https://eslint.org/docs/rules/no-duplicate-imports) rule. -This version adds support for type-only import and export. - -## How to Use - -```jsonc -{ - // note you must disable the base rule as it can report incorrect errors - "no-duplicate-imports": "off", - "@typescript-eslint/no-duplicate-imports": ["error"] -} -``` - -## Options - -See [`eslint/no-duplicate-imports` options](https://eslint.org/docs/rules/no-duplicate-imports#options). - - - -Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/main/docs/rules/no-duplicate-imports.md) - - +::: diff --git a/packages/eslint-plugin/docs/rules/no-dynamic-delete.md b/packages/eslint-plugin/docs/rules/no-dynamic-delete.md index 2ba81ffd88a7..78b1a1453bd1 100644 --- a/packages/eslint-plugin/docs/rules/no-dynamic-delete.md +++ b/packages/eslint-plugin/docs/rules/no-dynamic-delete.md @@ -44,19 +44,6 @@ delete container[7]; delete container['-Infinity']; ``` -## Options - -```jsonc -// .eslintrc.json -{ - "rules": { - "@typescript-eslint/no-dynamic-delete": "warn" - } -} -``` - -This rule is not configurable. - ## When Not To Use It When you know your keys are safe to delete, this rule can be unnecessary. diff --git a/packages/eslint-plugin/docs/rules/no-empty-function.md b/packages/eslint-plugin/docs/rules/no-empty-function.md index 91335c1cb87d..b889968c0718 100644 --- a/packages/eslint-plugin/docs/rules/no-empty-function.md +++ b/packages/eslint-plugin/docs/rules/no-empty-function.md @@ -13,19 +13,8 @@ It adds support for handling TypeScript specific code that would otherwise trigg One example of valid TypeScript specific code that would otherwise trigger the `no-empty-function` rule is the use of [parameter properties](https://www.typescriptlang.org/docs/handbook/classes.html#parameter-properties) in constructor functions. -## How to Use - -```jsonc -{ - // note you must disable the base rule as it can report incorrect errors - "no-empty-function": "off", - "@typescript-eslint/no-empty-function": ["error"] -} -``` - ## Options -See [`eslint/no-empty-function` options](https://eslint.org/docs/rules/no-empty-function#options). This rule adds the following options: ```ts @@ -97,19 +86,3 @@ class Foo extends Base { protected override greet(): void {} } ``` - -## How to Use - -```jsonc -{ - // note you must disable the base rule as it can report incorrect errors - "no-empty-function": "off", - "@typescript-eslint/no-empty-function": ["error"] -} -``` - - - -Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/main/docs/rules/no-empty-function.md) - - diff --git a/packages/eslint-plugin/docs/rules/no-explicit-any.md b/packages/eslint-plugin/docs/rules/no-explicit-any.md index 1f9723aedbac..b32acb43902d 100644 --- a/packages/eslint-plugin/docs/rules/no-explicit-any.md +++ b/packages/eslint-plugin/docs/rules/no-explicit-any.md @@ -97,22 +97,6 @@ function greet(param: Array): Array {} ## Options -The rule accepts an options object with the following properties: - -```ts -type Options = { - // if true, auto-fixing will be made available in which the "any" type is converted to an "unknown" type - fixToUnknown: boolean; - // specify if arrays from the rest operator are considered okay - ignoreRestArgs: boolean; -}; - -const defaults = { - fixToUnknown: false, - ignoreRestArgs: false, -}; -``` - ### `ignoreRestArgs` A boolean to specify if arrays from the rest operator are considered okay. `false` by default. 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 1a54ecc8c8d6..28b47a745319 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 @@ -49,16 +49,3 @@ function foo(bar?: { n: number }) { return bar?.n; } ``` - -## Options - -```jsonc -// .eslintrc.json -{ - "rules": { - "@typescript-eslint/no-extra-non-null-assertion": "error" - } -} -``` - -This rule is not configurable. diff --git a/packages/eslint-plugin/docs/rules/no-extra-parens.md b/packages/eslint-plugin/docs/rules/no-extra-parens.md index 8707c381047d..4bd89ac91b9c 100644 --- a/packages/eslint-plugin/docs/rules/no-extra-parens.md +++ b/packages/eslint-plugin/docs/rules/no-extra-parens.md @@ -10,23 +10,3 @@ description: 'Disallow unnecessary parentheses.' This rule extends the base [`eslint/no-extra-parens`](https://eslint.org/docs/rules/no-extra-parens) rule. It adds support for TypeScript type assertions. - -## How to Use - -```jsonc -{ - // note you must disable the base rule as it can report incorrect errors - "no-extra-parens": "off", - "@typescript-eslint/no-extra-parens": ["error"] -} -``` - -## Options - -See [`eslint/no-extra-parens` options](https://eslint.org/docs/rules/no-extra-parens#options). - - - -Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/main/docs/rules/no-extra-parens.md) - - diff --git a/packages/eslint-plugin/docs/rules/no-extra-semi.md b/packages/eslint-plugin/docs/rules/no-extra-semi.md index 4cf29eaaee3c..a8f3cdca1b2e 100644 --- a/packages/eslint-plugin/docs/rules/no-extra-semi.md +++ b/packages/eslint-plugin/docs/rules/no-extra-semi.md @@ -10,23 +10,3 @@ description: 'Disallow unnecessary semicolons.' This rule extends the base [`eslint/no-extra-semi`](https://eslint.org/docs/rules/no-extra-semi) rule. It adds support for class properties. - -## How to Use - -```jsonc -{ - // note you must disable the base rule as it can report incorrect errors - "no-extra-semi": "off", - "@typescript-eslint/no-extra-semi": ["error"] -} -``` - -## Options - -See [`eslint/no-extra-semi` options](https://eslint.org/docs/rules/no-extra-semi#options). - - - -Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/main/docs/rules/no-extra-semi.md) - - diff --git a/packages/eslint-plugin/docs/rules/no-extraneous-class.md b/packages/eslint-plugin/docs/rules/no-extraneous-class.md index ecc01b9db501..2efb49e95564 100644 --- a/packages/eslint-plugin/docs/rules/no-extraneous-class.md +++ b/packages/eslint-plugin/docs/rules/no-extraneous-class.md @@ -196,28 +196,6 @@ export function incrementCount() { ## Options -This rule accepts a single object option. - -```ts -type Options = { - // allow extraneous classes if they only contain a constructor - allowConstructorOnly?: boolean; - // allow extraneous classes if they have no body (i.e. are empty) - allowEmpty?: boolean; - // allow extraneous classes if they only contain static members - allowStaticOnly?: boolean; - // allow extraneous classes if they have a decorator - allowWithDecorator?: boolean; -}; - -const defaultOptions: Options = { - allowConstructorOnly: false, - allowEmpty: false, - allowStaticOnly: false, - allowWithDecorator: false, -}; -``` - This rule normally bans classes that are empty (have no constructor or fields). The rule's options each add an exemption for a specific type of class. diff --git a/packages/eslint-plugin/docs/rules/no-floating-promises.md b/packages/eslint-plugin/docs/rules/no-floating-promises.md index 597ebcd7b505..09e86b853086 100644 --- a/packages/eslint-plugin/docs/rules/no-floating-promises.md +++ b/packages/eslint-plugin/docs/rules/no-floating-promises.md @@ -65,22 +65,6 @@ Promise.reject('value').finally(() => {}); ## Options -The rule accepts an options object with the following properties: - -```ts -type Options = { - // if true, checking void expressions will be skipped - ignoreVoid?: boolean; - // if true, checking for async iife will be skipped - ignoreIIFE?: boolean; -}; - -const defaults = { - ignoreVoid: true, - ignoreIIFE: false, -}; -``` - ### `ignoreVoid` This allows you to stop the rule reporting promises consumed with void operator. 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 2f4a5c699cce..f046ff8ddd6b 100644 --- a/packages/eslint-plugin/docs/rules/no-for-in-array.md +++ b/packages/eslint-plugin/docs/rules/no-for-in-array.md @@ -43,19 +43,6 @@ for (const x in { a: 3, b: 4, c: 5 }) { } ``` -## Options - -```jsonc -// .eslintrc.json -{ - "rules": { - "@typescript-eslint/no-for-in-array": "error" - } -} -``` - -This rule is not configurable. - ## When Not To Use It If you want to iterate through a loop using the indices in an array as strings, you can turn off this rule. 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 6b3d00db3ce4..943e2c75b21b 100644 --- a/packages/eslint-plugin/docs/rules/no-implicit-any-catch.md +++ b/packages/eslint-plugin/docs/rules/no-implicit-any-catch.md @@ -6,6 +6,11 @@ description: 'Disallow usage of the implicit `any` type in catch clauses.' > > See **https://typescript-eslint.io/rules/no-implicit-any-catch** for documentation. +:::danger Deprecated + +This rule has been deprecated as TypeScript versions >=4 includes a `useUnknownInCatchVariables` compiler option with the same check. +::: + 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. @@ -49,26 +54,10 @@ try { ## Options -The rule accepts an options object with the following properties: - -```ts -type Options = { - // if false, disallow specifying `: any` as the error type as well. See also `no-explicit-any` - allowExplicitAny: boolean; -}; - -const defaults = { - allowExplicitAny: false, -}; -``` - ### `allowExplicitAny` The follow is is **_not_** considered a warning with `{ allowExplicitAny: true }` - - - ```ts try { // ... @@ -77,8 +66,6 @@ try { } ``` - - ## When Not To Use It If you are not using TypeScript 4.0 (or greater), then you will not be able to use this rule, annotations on catch clauses is not supported. diff --git a/packages/eslint-plugin/docs/rules/no-implied-eval.md b/packages/eslint-plugin/docs/rules/no-implied-eval.md index 4bc269775c0d..9f3ad17180f7 100644 --- a/packages/eslint-plugin/docs/rules/no-implied-eval.md +++ b/packages/eslint-plugin/docs/rules/no-implied-eval.md @@ -98,22 +98,6 @@ class Foo { setTimeout(Foo.fn, 100); ``` -## How to Use - -```jsonc -{ - // note you must disable the base rule as it can report incorrect errors - "no-implied-eval": "off", - "@typescript-eslint/no-implied-eval": ["error"] -} -``` - ## When Not To Use It If you want to allow `new Function()` or `setTimeout()`, `setInterval()`, `setImmediate()` and `execScript()` with string arguments, then you can safely disable this rule. - - - -Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/main/docs/rules/no-implied-eval.md) - - diff --git a/packages/eslint-plugin/docs/rules/no-inferrable-types.md b/packages/eslint-plugin/docs/rules/no-inferrable-types.md index 743efe035156..a29427a33cfb 100644 --- a/packages/eslint-plugin/docs/rules/no-inferrable-types.md +++ b/packages/eslint-plugin/docs/rules/no-inferrable-types.md @@ -13,33 +13,11 @@ Explicit types where they can be easily inferred may add unnecessary verbosity. This rule disallows explicit type declarations on parameters, variables and properties where the type can be easily inferred from its value. -## Options - -This rule accepts the following options: - -```ts -interface Options { - ignoreParameters?: boolean; - ignoreProperties?: boolean; -} -``` - -### Default - -The default options are: - -```json -{ - "ignoreParameters": false, - "ignoreProperties": false -} -``` - -With these options, the following patterns are: +Examples of code with the default options: -#### ❌ Incorrect +### ❌ Incorrect ```ts const a: bigint = 10n; @@ -80,7 +58,7 @@ class Foo { function fn(a: number = 5, b: boolean = true) {} ``` -#### ✅ Correct +### ✅ Correct ```ts const a = 10n; @@ -125,6 +103,8 @@ function fn(a: number, b: boolean, c: string) {} +## Options + ### `ignoreParameters` When set to true, the following pattern is considered valid: diff --git a/packages/eslint-plugin/docs/rules/no-invalid-this.md b/packages/eslint-plugin/docs/rules/no-invalid-this.md index 17cff6a0af4d..53e0f68fa9f0 100644 --- a/packages/eslint-plugin/docs/rules/no-invalid-this.md +++ b/packages/eslint-plugin/docs/rules/no-invalid-this.md @@ -10,27 +10,3 @@ description: 'Disallow `this` keywords outside of classes or class-like objects. This rule extends the base [`eslint/no-invalid-this`](https://eslint.org/docs/rules/no-invalid-this) rule. It adds support for TypeScript's `this` parameters. - -## How to Use - -```jsonc -{ - // note you must disable the base rule as it can report incorrect errors - "no-invalid-this": "off", - "@typescript-eslint/no-invalid-this": ["error"] -} -``` - -## Options - -See [`eslint/no-invalid-this` options](https://eslint.org/docs/rules/no-invalid-this#options). - -## When Not To Use It - -When you are indifferent as to how your variables are initialized. - - - -Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/main/docs/rules/no-invalid-this.md) - - 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 c39e932a7787..a36919363715 100644 --- a/packages/eslint-plugin/docs/rules/no-invalid-void-type.md +++ b/packages/eslint-plugin/docs/rules/no-invalid-void-type.md @@ -61,18 +61,6 @@ type stillVoid = void | never; ## Options -```ts -interface Options { - allowInGenericTypeArguments?: boolean | string[]; - allowAsThisParameter?: boolean; -} - -const defaultOptions: Options = { - allowInGenericTypeArguments: true, - allowAsThisParameter: false, -}; -``` - ### `allowInGenericTypeArguments` This option lets you control if `void` can be used as a valid value for generic type parameters. diff --git a/packages/eslint-plugin/docs/rules/no-loop-func.md b/packages/eslint-plugin/docs/rules/no-loop-func.md index 7a63fd52c7cf..753eb115cfbb 100644 --- a/packages/eslint-plugin/docs/rules/no-loop-func.md +++ b/packages/eslint-plugin/docs/rules/no-loop-func.md @@ -10,23 +10,3 @@ description: 'Disallow function declarations that contain unsafe references insi This rule extends the base [`eslint/no-loop-func`](https://eslint.org/docs/rules/no-loop-func) rule. It adds support for TypeScript types. - -## How to Use - -```jsonc -{ - // note you must disable the base rule as it can report incorrect errors - "no-loop-func": "off", - "@typescript-eslint/no-loop-func": ["error"] -} -``` - -## Options - -See [`eslint/no-loop-func` options](https://eslint.org/docs/rules/no-loop-func#options). - - - -Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/main/docs/rules/no-loop-func.md) - - 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 21ac3c6abb52..62e263219e85 100644 --- a/packages/eslint-plugin/docs/rules/no-loss-of-precision.md +++ b/packages/eslint-plugin/docs/rules/no-loss-of-precision.md @@ -10,20 +10,3 @@ description: 'Disallow literal numbers that lose precision.' This rule extends the base [`eslint/no-loss-of-precision`](https://eslint.org/docs/rules/no-loss-of-precision) rule. It adds support for [numeric separators](https://github.com/tc39/proposal-numeric-separator). -Note that this rule requires ESLint v7. - -## How to Use - -```jsonc -{ - // note you must disable the base rule as it can report incorrect errors - "no-loss-of-precision": "off", - "@typescript-eslint/no-loss-of-precision": ["error"] -} -``` - - - -Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/main/docs/rules/no-loss-of-precision.md) - - diff --git a/packages/eslint-plugin/docs/rules/no-magic-numbers.md b/packages/eslint-plugin/docs/rules/no-magic-numbers.md index 1690ea371a71..7af0e561536a 100644 --- a/packages/eslint-plugin/docs/rules/no-magic-numbers.md +++ b/packages/eslint-plugin/docs/rules/no-magic-numbers.md @@ -15,24 +15,8 @@ It adds support for: - `enum` members (`enum Foo { bar = 1 }`), - `readonly` class properties (`class Foo { readonly bar = 1 }`). -## How to Use - -```jsonc -{ - // note you must disable the base rule as it can report incorrect errors - "no-magic-numbers": "off", - "@typescript-eslint/no-magic-numbers": [ - "error", - { - /* options */ - } - ] -} -``` - ## Options -See [`eslint/no-magic-numbers` options](https://eslint.org/docs/rules/no-magic-numbers#options). This rule adds the following options: ```ts @@ -145,9 +129,3 @@ Examples of **correct** code for the `{ "ignoreTypeIndexes": true }` option: type Foo = Bar[0]; type Baz = Parameters[2]; ``` - - - -Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/main/docs/rules/no-magic-numbers.md) - - diff --git a/packages/eslint-plugin/docs/rules/no-misused-new.md b/packages/eslint-plugin/docs/rules/no-misused-new.md index bc602bcc6e82..08459fba7962 100644 --- a/packages/eslint-plugin/docs/rules/no-misused-new.md +++ b/packages/eslint-plugin/docs/rules/no-misused-new.md @@ -37,16 +37,3 @@ interface I { new (): C; } ``` - -## Options - -```jsonc -// .eslintrc.json -{ - "rules": { - "@typescript-eslint/no-misused-new": "error" - } -} -``` - -This rule is not configurable. diff --git a/packages/eslint-plugin/docs/rules/no-namespace.md b/packages/eslint-plugin/docs/rules/no-namespace.md index 665bf273d26e..6e4bda690bef 100644 --- a/packages/eslint-plugin/docs/rules/no-namespace.md +++ b/packages/eslint-plugin/docs/rules/no-namespace.md @@ -15,16 +15,7 @@ This rule still allows the use of TypeScript module declarations to describe ext This rule aims to standardize the way modules are declared. -## Options - -This rule, in its default state, does not require any argument. If you would like to enable one -or more of the following you may pass an object with the options set as follows: - -- `allowDeclarations` set to `true` will allow you to `declare` custom TypeScript modules and namespaces (Default: `false`). -- `allowDefinitionFiles` set to `true` will allow you to `declare` and use custom TypeScript modules and namespaces - inside definition files (Default: `true`). - -Examples of code for the default `{ "allowDeclarations": false, "allowDefinitionFiles": true }` options: +Examples of code with the default options: @@ -48,9 +39,11 @@ declare module 'foo' {} +## Options + ### `allowDeclarations` -Examples of code for the `{ "allowDeclarations": true }` option: +Examples of code with the `{ "allowDeclarations": true }` option: 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 68a334042637..19fd65779f8f 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 @@ -49,19 +49,6 @@ let x: string; x! ?? ''; ``` -## Options - -```jsonc -// .eslintrc.json -{ - "rules": { - "@typescript-eslint/no-non-null-asserted-nullish-coalescing": "warn" - } -} -``` - -This rule is not configurable. - ## When Not To Use It If you are not using TypeScript 3.7 (or greater), then you will not need to use this rule, as the nullish coalescing operator is not supported. 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 b68e55a8256f..89f9a3c87b76 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 @@ -48,19 +48,6 @@ foo?.bar!(); foo?.bar!().baz; ``` -## Options - -```jsonc -// .eslintrc.json -{ - "rules": { - "@typescript-eslint/no-non-null-asserted-optional-chain": "error" - } -} -``` - -This rule is not configurable. - ## When Not To Use It If you are not using TypeScript 3.7 (or greater), then you will not need to use this rule, as the operator is not supported. 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 3b23982fd285..6e60483bc54d 100644 --- a/packages/eslint-plugin/docs/rules/no-non-null-assertion.md +++ b/packages/eslint-plugin/docs/rules/no-non-null-assertion.md @@ -36,19 +36,6 @@ const foo: Foo = getFoo(); const includesBaz: boolean = foo.bar?.includes('baz') ?? false; ``` -## Options - -```jsonc -// .eslintrc.json -{ - "rules": { - "@typescript-eslint/no-non-null-assertion": "warn" - } -} -``` - -This rule is not configurable. - ## When Not To Use It If you don't care about strict null-checking, then you will not need this rule. diff --git a/packages/eslint-plugin/docs/rules/no-parameter-properties.md b/packages/eslint-plugin/docs/rules/no-parameter-properties.md index 329ecbb732ed..18b9829a5eee 100644 --- a/packages/eslint-plugin/docs/rules/no-parameter-properties.md +++ b/packages/eslint-plugin/docs/rules/no-parameter-properties.md @@ -6,6 +6,11 @@ description: 'Disallow the use of parameter properties in class constructors.' > > See **https://typescript-eslint.io/rules/no-parameter-properties** for documentation. +:::danger Deprecated + +This rule has been deprecated in favour of the equivalent, better named [`parameter-properties`](./parameter-properties) rule. +::: + 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 1ba99ea379c7..b51ba369ce51 100644 --- a/packages/eslint-plugin/docs/rules/no-redeclare.md +++ b/packages/eslint-plugin/docs/rules/no-redeclare.md @@ -11,19 +11,8 @@ description: 'Disallow variable redeclaration.' This rule extends the base [`eslint/no-redeclare`](https://eslint.org/docs/rules/no-redeclare) rule. It adds support for TypeScript function overloads, and declaration merging. -## How to Use - -```jsonc -{ - // note you must disable the base rule as it can report incorrect errors - "no-redeclare": "off", - "@typescript-eslint/no-redeclare": ["error"] -} -``` - ## Options -See [`eslint/no-redeclare` options](https://eslint.org/docs/rules/no-redeclare#options). This rule adds the following options: ```ts @@ -82,9 +71,3 @@ type something = string; // eslint-disable-next-line @typescript-eslint/no-redeclare -- intentionally naming the variable the same as the type const something = 2; ``` - - - -Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/main/docs/rules/no-redeclare.md) - - 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 be06806c681a..3cf63d4df491 100644 --- a/packages/eslint-plugin/docs/rules/no-redundant-type-constituents.md +++ b/packages/eslint-plugin/docs/rules/no-redundant-type-constituents.md @@ -70,19 +70,6 @@ type IntersectionStringLiteral = 'foo'; type ReturnUnionNever = () => string | never; ``` -## Options - -```jsonc -// .eslintrc.json -{ - "rules": { - "@typescript-eslint/no-redundant-type-constituents": "warn" - } -} -``` - -This rule is not configurable. - ## Limitations This rule plays it safe and only works with bottom types, top types, and comparing literal types to primitive types. diff --git a/packages/eslint-plugin/docs/rules/no-require-imports.md b/packages/eslint-plugin/docs/rules/no-require-imports.md index b5bd6f136c45..b38486837e18 100644 --- a/packages/eslint-plugin/docs/rules/no-require-imports.md +++ b/packages/eslint-plugin/docs/rules/no-require-imports.md @@ -35,19 +35,6 @@ import lib9 = lib2.anotherSubImport; import lib10 from 'lib10'; ``` -## Options - -```jsonc -// .eslintrc.json -{ - "rules": { - "@typescript-eslint/no-require-imports": "warn" - } -} -``` - -This rule is not configurable. - ## When Not To Use It If you don't care about TypeScript module syntax, then you will not need this rule. diff --git a/packages/eslint-plugin/docs/rules/no-restricted-imports.md b/packages/eslint-plugin/docs/rules/no-restricted-imports.md index 3329ca588420..202143581f22 100644 --- a/packages/eslint-plugin/docs/rules/no-restricted-imports.md +++ b/packages/eslint-plugin/docs/rules/no-restricted-imports.md @@ -10,19 +10,8 @@ description: 'Disallow specified modules when loaded by `import`.' This rule extends the base [`eslint/no-restricted-imports`](https://eslint.org/docs/rules/no-restricted-imports) rule. -## How to Use - -```jsonc -{ - // note you must disable the base rule as it can report incorrect errors - "no-restricted-imports": "off", - "@typescript-eslint/no-restricted-imports": ["error"] -} -``` - ## Options -See [`eslint/no-restricted-imports` options](https://eslint.org/docs/rules/no-restricted-imports#options). This rule adds the following options: ### `allowTypeImports` diff --git a/packages/eslint-plugin/docs/rules/no-shadow.md b/packages/eslint-plugin/docs/rules/no-shadow.md index 4487ecccc0af..c990ff97230e 100644 --- a/packages/eslint-plugin/docs/rules/no-shadow.md +++ b/packages/eslint-plugin/docs/rules/no-shadow.md @@ -11,19 +11,8 @@ description: 'Disallow variable declarations from shadowing variables declared i This rule extends the base [`eslint/no-shadow`](https://eslint.org/docs/rules/no-shadow) rule. It adds support for TypeScript's `this` parameters and global augmentation, and adds options for TypeScript features. -## How to Use - -```jsonc -{ - // note you must disable the base rule as it can report incorrect errors - "no-shadow": "off", - "@typescript-eslint/no-shadow": ["error"] -} -``` - ## Options -See [`eslint/no-shadow` options](https://eslint.org/docs/rules/no-shadow#options). This rule adds the following options: ```ts @@ -89,9 +78,3 @@ Examples of **correct** code with `{ ignoreFunctionTypeParameterNameValueShadow: const test = 1; type Func = (test: string) => typeof test; ``` - - - -Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/main/docs/rules/no-shadow.md) - - diff --git a/packages/eslint-plugin/docs/rules/no-this-alias.md b/packages/eslint-plugin/docs/rules/no-this-alias.md index 5cd741ac3ac3..8ba520d7af68 100644 --- a/packages/eslint-plugin/docs/rules/no-this-alias.md +++ b/packages/eslint-plugin/docs/rules/no-this-alias.md @@ -39,22 +39,6 @@ Examples of **correct** code for this rule: (see the rationale above) -## Options - -You can pass an object option: - -```jsonc -{ - "@typescript-eslint/no-this-alias": [ - "error", - { - "allowDestructuring": false, // Disallow `const { props, state } = this`; true by default - "allowedNames": ["self"] // Allow `const self = this`; `[]` by default - } - ] -} -``` - ## When Not To Use It If you need to assign `this` to variables, you shouldn’t use this rule. diff --git a/packages/eslint-plugin/docs/rules/no-throw-literal.md b/packages/eslint-plugin/docs/rules/no-throw-literal.md index 9cefca0cee9b..6a017d5ac4be 100644 --- a/packages/eslint-plugin/docs/rules/no-throw-literal.md +++ b/packages/eslint-plugin/docs/rules/no-throw-literal.md @@ -89,34 +89,26 @@ class CustomError extends Error { throw new CustomError(); ``` -## How to Use +## Options -```jsonc -{ - // note you must disable the base rule as it can report incorrect errors - "no-throw-literal": "off", - "@typescript-eslint/no-throw-literal": ["error"] -} -``` +This rule adds the following options: -### Options - -```jsonc -{ - "@typescript-eslint/no-throw-literal": [ - "error", - { - "allowThrowingAny": true, // Default is to allow throwing values of type any - "allowThrowingUnknown": true // Default is to allow throwing values of type unknown - } - ] +```ts +interface Options extends BaseNoShadowOptions { + /** + * Whether to always allow throwing values typed as `any`. + */ + allowThrowingAny?: boolean; + + /** + * Whether to always allow throwing values typed as `unknown`. + */ + allowThrowingUnknown?: boolean; } -``` - ---- - - - -Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/main/docs/rules/no-throw-literal.md) - +const defaultOptions: Options = { + ...baseNoShadowDefaultOptions, + allowThrowingAny: false, + allowThrowingUnknown: false, +}; +``` diff --git a/packages/eslint-plugin/docs/rules/no-type-alias.md b/packages/eslint-plugin/docs/rules/no-type-alias.md index cb6c76ee9ec1..4117d6133451 100644 --- a/packages/eslint-plugin/docs/rules/no-type-alias.md +++ b/packages/eslint-plugin/docs/rules/no-type-alias.md @@ -85,18 +85,6 @@ and simplified types (primitives, tuples, unions, intersections, etc). ## Options -This rule, in its default state, does not require any argument. If you would like to enable one -or more of the following you may pass an object with the options set as follows: - -- `allowAliases` set to `"always"` will allow you to do aliasing (Defaults to `"never"`). -- `allowCallbacks` set to `"always"` will allow you to use type aliases with callbacks (Defaults to `"never"`) -- `allowConditionalTypes` set to `"always"` will allow you to use type aliases with conditional types (Defaults to `"never"`) -- `allowConstructors` set to `"always"` will allow you to use type aliases with constructors (Defaults to `"never"`) -- `allowLiterals` set to `"always"` will allow you to use type aliases with literal objects (Defaults to `"never"`) -- `allowMappedTypes` set to `"always"` will allow you to use type aliases as mapping tools (Defaults to `"never"`) -- `allowTupleTypes` set to `"always"` will allow you to use type aliases with tuples (Defaults to `"never"`) -- `allowGenerics` set to `"always"` will allow you to use type aliases with generics (Defaults to `"never"`) - ### `allowAliases` This applies to primitive types and reference types. 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 84843a245fe1..8e148460a42b 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 @@ -54,30 +54,10 @@ if (someStringBoolean === true) { ## Options -The rule accepts an options object with the following properties. - -```ts -type Options = { - // if false, comparisons between a nullable boolean variable to `true` will be checked and fixed - allowComparingNullableBooleansToTrue?: boolean; - // if false, comparisons between a nullable boolean variable to `false` will be checked and fixed - allowComparingNullableBooleansToFalse?: boolean; -}; -``` - -### Defaults - This rule always checks comparisons between a boolean variable and a boolean literal. Comparisons between nullable boolean variables and boolean literals are **not** checked by default. -```ts -const defaults = { - allowComparingNullableBooleansToTrue: true, - allowComparingNullableBooleansToFalse: true, -}; -``` - ### `allowComparingNullableBooleansToTrue` Examples of code for this rule with `{ allowComparingNullableBooleansToTrue: false }`: diff --git a/packages/eslint-plugin/docs/rules/no-unnecessary-condition.md b/packages/eslint-plugin/docs/rules/no-unnecessary-condition.md index 9ae1eb01107d..ac50dc295f3a 100644 --- a/packages/eslint-plugin/docs/rules/no-unnecessary-condition.md +++ b/packages/eslint-plugin/docs/rules/no-unnecessary-condition.md @@ -74,20 +74,6 @@ function bar(arg?: string | null) { ## Options -```ts -type Options = { - // if true, the rule will ignore constant loop conditions - allowConstantLoopConditions?: boolean; - // if true, the rule will not error when running with a tsconfig that has strictNullChecks turned **off** - allowRuleToRunWithoutStrictNullChecksIKnowWhatIAmDoing?: boolean; -}; - -const defaultOptions: Options = { - allowConstantLoopConditions: false, - allowRuleToRunWithoutStrictNullChecksIKnowWhatIAmDoing: false, -}; -``` - ### `allowConstantLoopConditions` Example of correct code for `{ allowConstantLoopConditions: true }`: diff --git a/packages/eslint-plugin/docs/rules/no-unnecessary-qualifier.md b/packages/eslint-plugin/docs/rules/no-unnecessary-qualifier.md index e0a627050478..58a2b80bf5d8 100644 --- a/packages/eslint-plugin/docs/rules/no-unnecessary-qualifier.md +++ b/packages/eslint-plugin/docs/rules/no-unnecessary-qualifier.md @@ -80,19 +80,6 @@ namespace X { } ``` -## Options - -```jsonc -// .eslintrc.json -{ - "rules": { - "@typescript-eslint/no-unnecessary-qualifier": "warn" - } -} -``` - -This rule is not configurable. - ## When Not To Use It If you don't care about having unneeded namespace or enum qualifiers, then you don't need to use this rule. 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 63364396c55b..976cf23e372a 100644 --- a/packages/eslint-plugin/docs/rules/no-unnecessary-type-arguments.md +++ b/packages/eslint-plugin/docs/rules/no-unnecessary-type-arguments.md @@ -57,16 +57,3 @@ class D extends C {} interface I {} class Impl implements I {} ``` - -## Options - -```jsonc -// .eslintrc.json -{ - "rules": { - "@typescript-eslint/no-unnecessary-type-arguments": "warn" - } -} -``` - -This rule is not configurable. 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 5479988a502d..30e81b4c9b69 100644 --- a/packages/eslint-plugin/docs/rules/no-unnecessary-type-assertion.md +++ b/packages/eslint-plugin/docs/rules/no-unnecessary-type-assertion.md @@ -65,9 +65,9 @@ function foo(x: number | undefined): number { ## Options -This rule optionally takes an object with a single property `typesToIgnore`, which can be set to a list of type names to ignore. +### `typesToIgnore` -For example, with `@typescript-eslint/no-unnecessary-type-assertion: ["error", { typesToIgnore: ['Foo'] }]`, the following is **correct** code": +With `@typescript-eslint/no-unnecessary-type-assertion: ["error", { typesToIgnore: ['Foo'] }]`, the following is **correct** code": ```ts type Foo = 3; 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 02a1df88dda9..c5b078810fa4 100644 --- a/packages/eslint-plugin/docs/rules/no-unnecessary-type-constraint.md +++ b/packages/eslint-plugin/docs/rules/no-unnecessary-type-constraint.md @@ -60,19 +60,6 @@ const Quux = () => {}; function Quuz() {} ``` -## Options - -```jsonc -// .eslintrc.json -{ - "rules": { - "@typescript-eslint/no-unnecessary-type-constraint": "error" - } -} -``` - -This rule is not configurable. - ## When Not To Use It If you don't care about the specific styles of your type constraints, or never use them in the first place, then you will not need this rule. diff --git a/packages/eslint-plugin/docs/rules/no-unsafe-argument.md b/packages/eslint-plugin/docs/rules/no-unsafe-argument.md index db1612f5a4fc..63068ce497c6 100644 --- a/packages/eslint-plugin/docs/rules/no-unsafe-argument.md +++ b/packages/eslint-plugin/docs/rules/no-unsafe-argument.md @@ -75,19 +75,6 @@ declare function foo(arg1: unknown, arg2: Set, arg3: unknown[]): void; foo(1 as any, new Set(), [] as any[]); ``` -## Options - -```jsonc -// .eslintrc.json -{ - "rules": { - "@typescript-eslint/no-unsafe-argument": "error" - } -} -``` - -This rule is not configurable. - ## Related To - [`no-explicit-any`](./no-explicit-any.md) diff --git a/packages/eslint-plugin/docs/rules/no-unsafe-assignment.md b/packages/eslint-plugin/docs/rules/no-unsafe-assignment.md index e0b7c5ec9e22..9e797f4319f5 100644 --- a/packages/eslint-plugin/docs/rules/no-unsafe-assignment.md +++ b/packages/eslint-plugin/docs/rules/no-unsafe-assignment.md @@ -78,19 +78,6 @@ const x: unknown[] = y as any[]; const x: Set = y as Set; ``` -## Options - -```jsonc -// .eslintrc.json -{ - "rules": { - "@typescript-eslint/no-unsafe-assignment": "error" - } -} -``` - -This rule is not configurable. - ## Related To - [`no-explicit-any`](./no-explicit-any.md) diff --git a/packages/eslint-plugin/docs/rules/no-unsafe-call.md b/packages/eslint-plugin/docs/rules/no-unsafe-call.md index d4f21f6cc4dc..9191dca9ae86 100644 --- a/packages/eslint-plugin/docs/rules/no-unsafe-call.md +++ b/packages/eslint-plugin/docs/rules/no-unsafe-call.md @@ -52,19 +52,6 @@ new Map(); String.raw`foo`; ``` -## Options - -```jsonc -// .eslintrc.json -{ - "rules": { - "@typescript-eslint/no-unsafe-call": "error" - } -} -``` - -This rule is not configurable. - ## Related To - [`no-explicit-any`](./no-explicit-any.md) 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 3c3416e3dd66..393a4bb46cdd 100644 --- a/packages/eslint-plugin/docs/rules/no-unsafe-member-access.md +++ b/packages/eslint-plugin/docs/rules/no-unsafe-member-access.md @@ -58,19 +58,6 @@ arr[idx]; arr[idx++]; ``` -## Options - -```jsonc -// .eslintrc.json -{ - "rules": { - "@typescript-eslint/no-unsafe-member-access": "error" - } -} -``` - -This rule is not configurable. - ## Related To - [`no-explicit-any`](./no-explicit-any.md) diff --git a/packages/eslint-plugin/docs/rules/no-unsafe-return.md b/packages/eslint-plugin/docs/rules/no-unsafe-return.md index 430b4be2ca34..9c5537229590 100644 --- a/packages/eslint-plugin/docs/rules/no-unsafe-return.md +++ b/packages/eslint-plugin/docs/rules/no-unsafe-return.md @@ -95,19 +95,6 @@ function foo2(): unknown[] { } ``` -## Options - -```jsonc -// .eslintrc.json -{ - "rules": { - "@typescript-eslint/no-unsafe-return": "error" - } -} -``` - -This rule is not configurable. - ## Related To - [`no-explicit-any`](./no-explicit-any.md) diff --git a/packages/eslint-plugin/docs/rules/no-unused-expressions.md b/packages/eslint-plugin/docs/rules/no-unused-expressions.md index a851db4d4731..db3120db3e25 100644 --- a/packages/eslint-plugin/docs/rules/no-unused-expressions.md +++ b/packages/eslint-plugin/docs/rules/no-unused-expressions.md @@ -10,23 +10,3 @@ description: 'Disallow unused expressions.' This rule extends the base [`eslint/no-unused-expressions`](https://eslint.org/docs/rules/no-unused-expressions) rule. It adds support for optional call expressions `x?.()`, and directive in module declarations. - -## How to Use - -```jsonc -{ - // note you must disable the base rule as it can report incorrect errors - "no-unused-expressions": "off", - "@typescript-eslint/no-unused-expressions": ["error"] -} -``` - -## Options - -See [`eslint/no-unused-expressions` options](https://eslint.org/docs/rules/no-unused-expressions#options). - - - -Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/main/docs/rules/no-unused-expressions.md) - - diff --git a/packages/eslint-plugin/docs/rules/no-unused-vars.md b/packages/eslint-plugin/docs/rules/no-unused-vars.md index 4ad1f19d7efe..ffd1ceb0f6a5 100644 --- a/packages/eslint-plugin/docs/rules/no-unused-vars.md +++ b/packages/eslint-plugin/docs/rules/no-unused-vars.md @@ -10,23 +10,3 @@ description: 'Disallow unused variables.' This rule extends the base [`eslint/no-unused-vars`](https://eslint.org/docs/rules/no-unused-vars) rule. It adds support for TypeScript features, such as types. - -## How to Use - -```jsonc -{ - // note you must disable the base rule as it can report incorrect errors - "no-unused-vars": "off", - "@typescript-eslint/no-unused-vars": ["error"] -} -``` - -## Options - -See [`eslint/no-unused-vars` options](https://eslint.org/docs/rules/no-unused-vars#options). - - - -Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/main/docs/rules/no-unused-vars.md) - - 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 fec9e8dbf764..e17a8b873e37 100644 --- a/packages/eslint-plugin/docs/rules/no-use-before-define.md +++ b/packages/eslint-plugin/docs/rules/no-use-before-define.md @@ -11,19 +11,8 @@ description: 'Disallow the use of variables before they are defined.' This rule extends the base [`eslint/no-use-before-define`](https://eslint.org/docs/rules/no-use-before-define) rule. It adds support for `type`, `interface` and `enum` declarations. -## How to Use - -```jsonc -{ - // note you must disable the base rule as it can report incorrect errors - "no-use-before-define": "off", - "@typescript-eslint/no-use-before-define": ["error"] -} -``` - ## Options -See [`eslint/no-use-before-define` options](https://eslint.org/docs/rules/no-use-before-define#options). This rule adds the following options: ```ts @@ -106,13 +95,3 @@ type StringOrNumber = string | number; let var2: Enum; enum Enum {} ``` - -### Other Options - -See [`eslint/no-use-before-define` options](https://eslint.org/docs/rules/no-use-before-define#options). - - - -Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/main/docs/rules/no-use-before-define.md) - - diff --git a/packages/eslint-plugin/docs/rules/no-useless-constructor.md b/packages/eslint-plugin/docs/rules/no-useless-constructor.md index a5acf42b7b90..e1a8297fefe7 100644 --- a/packages/eslint-plugin/docs/rules/no-useless-constructor.md +++ b/packages/eslint-plugin/docs/rules/no-useless-constructor.md @@ -15,27 +15,7 @@ It adds support for: - `public` constructors when there is no superclass, - constructors with only parameter properties. -## How to Use - -```jsonc -{ - // note you must disable the base rule as it can report incorrect errors - "no-useless-constructor": "off", - "@typescript-eslint/no-useless-constructor": ["error"] -} -``` - -## Options - -See [`eslint/no-useless-constructor` options](https://eslint.org/docs/rules/no-useless-constructor#options). - - - -Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/main/docs/rules/no-useless-constructor.md) - - - -## Caveat +### Caveat This lint rule will report on constructors whose sole purpose is to change visibility of a parent constructor. See [discussion on this rule's lack of type information](https://github.com/typescript-eslint/typescript-eslint/issues/3820#issuecomment-917821240) for context. 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 ca02d12c8cdd..bf0f2b94ff2d 100644 --- a/packages/eslint-plugin/docs/rules/no-useless-empty-export.md +++ b/packages/eslint-plugin/docs/rules/no-useless-empty-export.md @@ -41,16 +41,3 @@ export const value = 'Hello, world!'; ```ts import 'some-other-module'; ``` - -## Options - -```jsonc -// .eslintrc.json -{ - "rules": { - "@typescript-eslint/no-useless-empty-export": "warn" - } -} -``` - -This rule is not configurable. diff --git a/packages/eslint-plugin/docs/rules/no-var-requires.md b/packages/eslint-plugin/docs/rules/no-var-requires.md index 0b6a7a2454bc..f7c0f8b8fb50 100644 --- a/packages/eslint-plugin/docs/rules/no-var-requires.md +++ b/packages/eslint-plugin/docs/rules/no-var-requires.md @@ -30,19 +30,6 @@ require('foo'); import foo from 'foo'; ``` -## Options - -```jsonc -// .eslintrc.json -{ - "rules": { - "@typescript-eslint/no-var-requires": "error" - } -} -``` - -This rule is not configurable. - ## When Not To Use It If you don't care about TypeScript module syntax, then you will not need this rule. 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 dbd38cdb8668..c6aaa0913248 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 @@ -32,19 +32,6 @@ const definitely = maybe!; const alsoDefinitely = maybe!; ``` -## Options - -```jsonc -// .eslintrc.json -{ - "rules": { - "@typescript-eslint/non-nullable-type-assertion-style": "warn" - } -} -``` - -This rule is not configurable. - ## When Not To Use It If you don't mind having unnecessarily verbose type casts, you can avoid this rule. diff --git a/packages/eslint-plugin/docs/rules/object-curly-spacing.md b/packages/eslint-plugin/docs/rules/object-curly-spacing.md index f6780dbef80c..9dcf431db32c 100644 --- a/packages/eslint-plugin/docs/rules/object-curly-spacing.md +++ b/packages/eslint-plugin/docs/rules/object-curly-spacing.md @@ -10,23 +10,3 @@ description: 'Enforce consistent spacing inside braces.' This rule extends the base [`eslint/object-curly-spacing`](https://eslint.org/docs/rules/object-curly-spacing) rule. It adds support for TypeScript's object types. - -## How to Use - -```jsonc -{ - // note you must disable the base rule as it can report incorrect errors - "object-curly-spacing": "off", - "@typescript-eslint/object-curly-spacing": ["error"] -} -``` - -## Options - -See [`eslint/object-curly-spacing` options](https://eslint.org/docs/rules/object-curly-spacing#options). - - - -Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/main/docs/rules/object-curly-spacing.md) - - 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 2849230d3412..d3687c11a22d 100644 --- a/packages/eslint-plugin/docs/rules/padding-line-between-statements.md +++ b/packages/eslint-plugin/docs/rules/padding-line-between-statements.md @@ -9,30 +9,17 @@ description: 'Require or disallow 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. +It adds support for TypeScript constructs such as `interface` and `type`. -**It adds support for TypeScript constructs such as `interface` and `type`.** +## Options -## How to Use +In addition to options provided by ESLint, `interface` and `type` can be used as statement types. -```jsonc -{ - // note you must disable the base rule as it can report incorrect errors - "padding-line-between-statements": "off", - "@typescript-eslint/padding-line-between-statements": [ - "error", - { - "blankLine": "always", - "prev": "var", - "next": "return" - } - ] -} -``` +For example, to add blank lines before interfaces and type definitions: ```jsonc { // Example - Add blank lines before interface and type definitions. - // note you must disable the base rule as it can report incorrect errors "padding-line-between-statements": "off", "@typescript-eslint/padding-line-between-statements": [ "error", @@ -45,16 +32,4 @@ This rule extends the base [`eslint/padding-line-between-statements`](https://es } ``` -## Options - -See [`eslint/padding-line-between-statements` options](https://eslint.org/docs/rules/padding-line-between-statements#options). - -In addition to options provided by ESLint, `interface` and `type` can be used as statement types. - **Note:** ESLint `cjs-export` and `cjs-import` statement types are renamed to `exports` and `require` respectively. - - - -Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/main/docs/rules/padding-line-between-statements.md) - - diff --git a/packages/eslint-plugin/docs/rules/prefer-as-const.md b/packages/eslint-plugin/docs/rules/prefer-as-const.md index 0670268bfaba..ce930aa3390a 100644 --- a/packages/eslint-plugin/docs/rules/prefer-as-const.md +++ b/packages/eslint-plugin/docs/rules/prefer-as-const.md @@ -35,19 +35,6 @@ let foo = { bar: 'baz' }; -## Options - -```jsonc -// .eslintrc.json -{ - "rules": { - "@typescript-eslint/prefer-as-const": "error" - } -} -``` - -This rule is not configurable. - ## When Not To Use It If you are using TypeScript < 3.4 diff --git a/packages/eslint-plugin/docs/rules/prefer-enum-initializers.md b/packages/eslint-plugin/docs/rules/prefer-enum-initializers.md index 8e2c05125204..08e19754b2b6 100644 --- a/packages/eslint-plugin/docs/rules/prefer-enum-initializers.md +++ b/packages/eslint-plugin/docs/rules/prefer-enum-initializers.md @@ -75,19 +75,6 @@ enum Color { } ``` -## Options - -```jsonc -// .eslintrc.json -{ - "rules": { - "@typescript-eslint/prefer-enum-initializers": "warn" - } -} -``` - -This rule is not configurable. - ## When Not To Use It If you don't care about `enum`s having implicit values you can safely disable this rule. diff --git a/packages/eslint-plugin/docs/rules/prefer-for-of.md b/packages/eslint-plugin/docs/rules/prefer-for-of.md index fed26d5af269..815059bcc9a5 100644 --- a/packages/eslint-plugin/docs/rules/prefer-for-of.md +++ b/packages/eslint-plugin/docs/rules/prefer-for-of.md @@ -42,19 +42,6 @@ for (let i = 0; i < arr.length; i++) { } ``` -## Options - -```jsonc -// .eslintrc.json -{ - "rules": { - "@typescript-eslint/prefer-for-of": "warn" - } -} -``` - -This rule is not configurable. - ## When Not To Use It If you transpile for browsers that do not support for-of loops, you may wish to use traditional for loops that produce more compact code. diff --git a/packages/eslint-plugin/docs/rules/prefer-function-type.md b/packages/eslint-plugin/docs/rules/prefer-function-type.md index 7e8c1f73817c..1ba1cf22a2cc 100644 --- a/packages/eslint-plugin/docs/rules/prefer-function-type.md +++ b/packages/eslint-plugin/docs/rules/prefer-function-type.md @@ -82,19 +82,6 @@ interface Overloaded { type Intersection = ((data: string) => number) & ((id: number) => string); ``` -## Options - -```jsonc -// .eslintrc.json -{ - "rules": { - "@typescript-eslint/prefer-function-type": "warn" - } -} -``` - -This rule is not configurable. - ## When Not To Use It If you specifically want to use an interface or type literal with a single call signature for stylistic reasons, you can disable this rule. diff --git a/packages/eslint-plugin/docs/rules/prefer-includes.md b/packages/eslint-plugin/docs/rules/prefer-includes.md index e0d05b6662f5..c06a82d8d642 100644 --- a/packages/eslint-plugin/docs/rules/prefer-includes.md +++ b/packages/eslint-plugin/docs/rules/prefer-includes.md @@ -74,19 +74,6 @@ userDefined.includes(value); mismatchExample.indexOf(value) >= 0; ``` -## Options - -```jsonc -// .eslintrc.json -{ - "rules": { - "@typescript-eslint/prefer-includes": "warn" - } -} -``` - -This rule is not configurable. - ## When Not To Use It If you don't want to suggest `includes`, you can safely turn this rule off. diff --git a/packages/eslint-plugin/docs/rules/prefer-namespace-keyword.md b/packages/eslint-plugin/docs/rules/prefer-namespace-keyword.md index b7320e728513..ccb97abbec81 100644 --- a/packages/eslint-plugin/docs/rules/prefer-namespace-keyword.md +++ b/packages/eslint-plugin/docs/rules/prefer-namespace-keyword.md @@ -17,19 +17,6 @@ This rule aims to standardize the way modules are declared. If you are using the ES2015 module syntax, then you will not need this rule. -## Options - -```jsonc -// .eslintrc.json -{ - "rules": { - "@typescript-eslint/prefer-namespace-keyword": "error" - } -} -``` - -This rule is not configurable. - ## Further Reading - [Modules](https://www.typescriptlang.org/docs/handbook/modules.html) diff --git a/packages/eslint-plugin/docs/rules/prefer-optional-chain.md b/packages/eslint-plugin/docs/rules/prefer-optional-chain.md index d2f252bb878e..a0ff0a0ab224 100644 --- a/packages/eslint-plugin/docs/rules/prefer-optional-chain.md +++ b/packages/eslint-plugin/docs/rules/prefer-optional-chain.md @@ -89,19 +89,6 @@ foo?.a?.b?.c?.d?.e; **Note:** there are a few edge cases where this rule will false positive. Use your best judgement when evaluating reported errors. -## Options - -```jsonc -// .eslintrc.json -{ - "rules": { - "@typescript-eslint/prefer-optional-chain": "warn" - } -} -``` - -This rule is not configurable. - ## When Not To Use It If you are not using TypeScript 3.7 (or greater), then you will not be able to use this rule, as the operator is not supported. 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 3a1f34d9413e..8a281aa38685 100644 --- a/packages/eslint-plugin/docs/rules/prefer-readonly-parameter-types.md +++ b/packages/eslint-plugin/docs/rules/prefer-readonly-parameter-types.md @@ -131,19 +131,6 @@ interface Foo { ## Options -```ts -interface Options { - checkParameterProperties?: boolean; - ignoreInferredTypes?: boolean; -} - -const defaultOptions: Options = { - checkParameterProperties: true, - ignoreInferredTypes: false, - treatMethodsAsReadonly: false, -}; -``` - ### `checkParameterProperties` This option allows you to enable or disable the checking of parameter properties. diff --git a/packages/eslint-plugin/docs/rules/prefer-readonly.md b/packages/eslint-plugin/docs/rules/prefer-readonly.md index 16d7d2f4f67f..c4384e266c3a 100644 --- a/packages/eslint-plugin/docs/rules/prefer-readonly.md +++ b/packages/eslint-plugin/docs/rules/prefer-readonly.md @@ -56,8 +56,6 @@ class Container { ## Options -This rule, in its default state, does not require any argument. - ### `onlyInlineLambdas` You may pass `"onlyInlineLambdas": true` as a rule option within an object to restrict checking only to members immediately assigned a lambda value. 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 4e8cdde8527a..d66c91ba9438 100644 --- a/packages/eslint-plugin/docs/rules/prefer-reduce-type-parameter.md +++ b/packages/eslint-plugin/docs/rules/prefer-reduce-type-parameter.md @@ -55,19 +55,6 @@ Examples of code for this rule: ); ``` -## Options - -```jsonc -// .eslintrc.json -{ - "rules": { - "@typescript-eslint/prefer-reduce-type-parameter": "warn" - } -} -``` - -This rule is not configurable. - ## When Not To Use It If you don't want to use typechecking in your linting, you can't use this rule. diff --git a/packages/eslint-plugin/docs/rules/prefer-regexp-exec.md b/packages/eslint-plugin/docs/rules/prefer-regexp-exec.md index 74a3649de76a..38cae500fa03 100644 --- a/packages/eslint-plugin/docs/rules/prefer-regexp-exec.md +++ b/packages/eslint-plugin/docs/rules/prefer-regexp-exec.md @@ -46,19 +46,6 @@ const search = /thing/; search.exec(text); ``` -## Options - -```jsonc -// .eslintrc.json -{ - "rules": { - "@typescript-eslint/prefer-regexp-exec": "warn" - } -} -``` - -This rule is not configurable. - ## When Not To Use It If you prefer consistent use of `String#match` for both, with `g` flag and without it, you can turn this rule off. 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 535ec053e236..836938ee8921 100644 --- a/packages/eslint-plugin/docs/rules/prefer-return-this-type.md +++ b/packages/eslint-plugin/docs/rules/prefer-return-this-type.md @@ -97,19 +97,6 @@ class Derived extends Base { } ``` -## Options - -```jsonc -// .eslintrc.json -{ - "rules": { - "@typescript-eslint/prefer-return-this-type": "warn" - } -} -``` - -This rule is not configurable. - ## When Not To Use It If you don't use method chaining or explicit return values, you can safely turn this rule off. 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 de5233ec0b80..99ead1d79344 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 @@ -48,19 +48,6 @@ foo.startsWith('bar'); foo.endsWith('bar'); ``` -## Options - -```jsonc -// .eslintrc.json -{ - "rules": { - "@typescript-eslint/prefer-string-starts-ends-with": "warn" - } -} -``` - -This rule is not configurable. - ## When Not To Use It If you don't mind that style, you can turn this rule off safely. 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 255e30e7ea5a..85308e4786fb 100644 --- a/packages/eslint-plugin/docs/rules/prefer-ts-expect-error.md +++ b/packages/eslint-plugin/docs/rules/prefer-ts-expect-error.md @@ -66,19 +66,6 @@ const isOptionEnabled = (key: string): boolean => { }; ``` -## Options - -```jsonc -// .eslintrc.json -{ - "rules": { - "@typescript-eslint/prefer-ts-expect-error": "warn" - } -} -``` - -This rule is not configurable. - ## When Not To Use It If you are **NOT** using TypeScript 3.9 (or greater), then you will not be able to use this rule, as the directive is not supported diff --git a/packages/eslint-plugin/docs/rules/promise-function-async.md b/packages/eslint-plugin/docs/rules/promise-function-async.md index 137dd051ab53..3c6b1922cd58 100644 --- a/packages/eslint-plugin/docs/rules/promise-function-async.md +++ b/packages/eslint-plugin/docs/rules/promise-function-async.md @@ -40,32 +40,3 @@ async function functionReturnsPromise() { return Promise.resolve('value'); } ``` - -## Options - -Options may be provided as an object with: - -- `allowAny` to indicate that `any` or `unknown` shouldn't be considered Promises (`true` by default). -- `allowedPromiseNames` to indicate any extra names of classes or interfaces to be considered Promises when returned. - -In addition, each of the following properties may be provided, and default to `true`: - -- `checkArrowFunctions` -- `checkFunctionDeclarations` -- `checkFunctionExpressions` -- `checkMethodDeclarations` - -```json -{ - "@typescript-eslint/promise-function-async": [ - "error", - { - "allowedPromiseNames": ["Thenable"], - "checkArrowFunctions": true, - "checkFunctionDeclarations": true, - "checkFunctionExpressions": true, - "checkMethodDeclarations": true - } - ] -} -``` diff --git a/packages/eslint-plugin/docs/rules/quotes.md b/packages/eslint-plugin/docs/rules/quotes.md index 8cbf3e58b7ff..64a5704454cd 100644 --- a/packages/eslint-plugin/docs/rules/quotes.md +++ b/packages/eslint-plugin/docs/rules/quotes.md @@ -10,23 +10,3 @@ description: 'Enforce the consistent use of either backticks, double, or single This rule extends the base [`eslint/quotes`](https://eslint.org/docs/rules/quotes) rule. It adds support for TypeScript features which allow quoted names, but not backtick quoted names. - -## How to Use - -```jsonc -{ - // note you must disable the base rule as it can report incorrect errors - "quotes": "off", - "@typescript-eslint/quotes": ["error"] -} -``` - -## Options - -See [`eslint/quotes` options](https://eslint.org/docs/rules/quotes#options). - - - -Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/main/docs/rules/quotes.md) - - 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 7b44dfa38dd4..e2e43c811435 100644 --- a/packages/eslint-plugin/docs/rules/require-array-sort-compare.md +++ b/packages/eslint-plugin/docs/rules/require-array-sort-compare.md @@ -58,21 +58,6 @@ userDefinedType.sort(); ## Options -The rule accepts an options object with the following properties: - -```ts -type Options = { - /** - * If true, an array which all elements are string is ignored. - */ - ignoreStringArrays?: boolean; -}; - -const defaults = { - ignoreStringArrays: false, -}; -``` - ### `ignoreStringArrays` Examples of code for this rule with `{ ignoreStringArrays: true }`: diff --git a/packages/eslint-plugin/docs/rules/require-await.md b/packages/eslint-plugin/docs/rules/require-await.md index 58936c414790..a578f0c4b42c 100644 --- a/packages/eslint-plugin/docs/rules/require-await.md +++ b/packages/eslint-plugin/docs/rules/require-await.md @@ -22,21 +22,3 @@ const returnsPromise2 = () => returnsPromise1(); ``` ## How to Use - -```jsonc -{ - // note you must disable the base rule as it can report incorrect errors - "require-await": "off", - "@typescript-eslint/require-await": "error" -} -``` - -## Options - -See [`eslint/require-await` options](https://eslint.org/docs/rules/require-await#options). - - - -Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/main/docs/rules/require-await.md) - - diff --git a/packages/eslint-plugin/docs/rules/restrict-plus-operands.md b/packages/eslint-plugin/docs/rules/restrict-plus-operands.md index 32b19602ccbe..cf08200be7f5 100644 --- a/packages/eslint-plugin/docs/rules/restrict-plus-operands.md +++ b/packages/eslint-plugin/docs/rules/restrict-plus-operands.md @@ -28,22 +28,6 @@ var foo = 1n + 1n; ## Options -The rule accepts an options object with the following properties: - -```ts -type Options = { - // if true, check compound assignments (`+=`) - checkCompoundAssignments?: boolean; - // if true, 'any' itself and `string`,`bigint`, `number` is allowed. - allowAny?: boolean; -}; - -const defaults = { - checkCompoundAssignments: false, - allowAny: false, -}; -``` - ### `checkCompoundAssignments` Examples of code for this rule with `{ checkCompoundAssignments: true }`: @@ -98,9 +82,3 @@ var fn = (a: any, b: number) => a + b; ``` ## How to Use - -```json -{ - "@typescript-eslint/restrict-plus-operands": "error" -} -``` diff --git a/packages/eslint-plugin/docs/rules/restrict-template-expressions.md b/packages/eslint-plugin/docs/rules/restrict-template-expressions.md index 88bac9de873f..d22b66dac1de 100644 --- a/packages/eslint-plugin/docs/rules/restrict-template-expressions.md +++ b/packages/eslint-plugin/docs/rules/restrict-template-expressions.md @@ -35,31 +35,6 @@ const msg3 = `stringWithKindProp = ${stringWithKindProp}`; ## Options -The rule accepts an options object with the following properties: - -```ts -type Options = { - // if true, also allow number type in template expressions - allowNumber?: boolean; - // if true, also allow boolean type in template expressions - allowBoolean?: boolean; - // if true, also allow any in template expressions - allowAny?: boolean; - // if true, also allow null and undefined in template expressions - allowNullish?: boolean; - // if true, also allow RegExp in template expressions - allowRegExp?: boolean; -}; - -const defaults = { - allowNumber: true, - allowBoolean: false, - allowAny: false, - allowNullish: false, - allowRegExp: false, -}; -``` - ### `allowNumber` Examples of additional **correct** code for this rule with `{ allowNumber: true }`: diff --git a/packages/eslint-plugin/docs/rules/return-await.md b/packages/eslint-plugin/docs/rules/return-await.md index 89f8e6276d81..13d04d014eb9 100644 --- a/packages/eslint-plugin/docs/rules/return-await.md +++ b/packages/eslint-plugin/docs/rules/return-await.md @@ -13,16 +13,6 @@ Returning an awaited promise can make sense for better stack trace information a This rule builds on top of the [`eslint/no-return-await`](https://eslint.org/docs/rules/no-return-await) rule. It expands upon the base rule to add support for optionally requiring `return await` in certain cases. -## How to Use - -```jsonc -{ - // note you must disable the base rule as it can report incorrect errors - "no-return-await": "off", - "@typescript-eslint/return-await": "error" -} -``` - ## Options ```ts diff --git a/packages/eslint-plugin/docs/rules/semi.md b/packages/eslint-plugin/docs/rules/semi.md index 23b9852dc71d..ee33eca92236 100644 --- a/packages/eslint-plugin/docs/rules/semi.md +++ b/packages/eslint-plugin/docs/rules/semi.md @@ -14,23 +14,3 @@ This rule extends the base [`eslint/semi`](https://eslint.org/docs/rules/semi) r It adds support for TypeScript features that require semicolons. See also the [`@typescript-eslint/member-delimiter-style`](member-delimiter-style.md) rule, which allows you to specify the delimiter for `type` and `interface` members. - -## How to Use - -```jsonc -{ - // note you must disable the base rule as it can report incorrect errors - "semi": "off", - "@typescript-eslint/semi": ["error"] -} -``` - -## Options - -See [`eslint/semi` options](https://eslint.org/docs/rules/semi#options). - - - -Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/main/docs/rules/semi.md) - - 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 2ddfd8a88dec..68b5fce8aca2 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 @@ -95,49 +95,6 @@ type T4 = ## Options -```ts -type Options = { - // true to check intersection types, false otherwise - checkIntersections?: boolean; - // true to check union types, false otherwise - checkUnions?: boolean; - // the ordering of the groups - groupOrder?: ( - | 'conditional' - | 'function' - | 'import' - | 'intersection' - | 'keyword' - | 'literal' - | 'named' - | 'object' - | 'operator' - | 'tuple' - | 'union' - | 'nullish' - )[]; -}; - -const defaultOptions: Options = { - checkIntersections: true, - checkUnions: true, - groupOrder: [ - 'named', - 'keyword', - 'operator', - 'literal', - 'function', - 'import', - 'conditional', - 'object', - 'tuple', - 'intersection', - 'union', - 'nullish', - ], -}; -``` - ### `groupOrder` Each member of the type is placed into a group, and then the rule sorts alphabetically within each group. diff --git a/packages/eslint-plugin/docs/rules/space-before-blocks.md b/packages/eslint-plugin/docs/rules/space-before-blocks.md index b6dbb740962e..daba57a2ec21 100644 --- a/packages/eslint-plugin/docs/rules/space-before-blocks.md +++ b/packages/eslint-plugin/docs/rules/space-before-blocks.md @@ -9,7 +9,9 @@ description: 'Enforce consistent spacing before blocks.' ## Rule Details This rule extends the base [`eslint/space-before-blocks`](https://eslint.org/docs/rules/space-before-blocks) rule. -It adds support for interfaces and enums: +It adds support for interfaces and enums. + + ### ❌ Incorrect @@ -35,24 +37,6 @@ interface State { } ``` -In case a more specific options object is passed these blocks will follow `classes` configuration option. - -## How to Use - -```jsonc -{ - // note you must disable the base rule as it can report incorrect errors - "space-before-blocks": "off", - "@typescript-eslint/space-before-blocks": ["error"] -} -``` - ## Options -See [`eslint/space-before-blocks` options](https://eslint.org/docs/rules/space-before-blocks#options). - - - -Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/master/docs/rules/space-before-blocks.md) - - +In case a more specific options object is passed these blocks will follow `classes` configuration option. 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 962f8f674de3..5760b5128d10 100644 --- a/packages/eslint-plugin/docs/rules/space-before-function-paren.md +++ b/packages/eslint-plugin/docs/rules/space-before-function-paren.md @@ -10,23 +10,3 @@ description: 'Enforce consistent spacing before function parenthesis.' This rule extends the base [`eslint/space-before-function-paren`](https://eslint.org/docs/rules/space-before-function-paren) rule. It adds support for generic type parameters on function calls. - -## How to Use - -```jsonc -{ - // note you must disable the base rule as it can report incorrect errors - "space-before-function-paren": "off", - "@typescript-eslint/space-before-function-paren": ["error"] -} -``` - -## Options - -See [`eslint/space-before-function-paren` options](https://eslint.org/docs/rules/space-before-function-paren#options). - - - -Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/main/docs/rules/space-before-function-paren.md) - - diff --git a/packages/eslint-plugin/docs/rules/space-infix-ops.md b/packages/eslint-plugin/docs/rules/space-infix-ops.md index 4e322bb9837d..b6b0ecda788c 100644 --- a/packages/eslint-plugin/docs/rules/space-infix-ops.md +++ b/packages/eslint-plugin/docs/rules/space-infix-ops.md @@ -7,30 +7,10 @@ description: 'Require spacing around infix operators.' > 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 +It adds support for enum members. ```ts enum MyEnum { KEY = 'value', } ``` - -## How to Use - -```jsonc -{ - "space-infix-ops": "off", - "@typescript-eslint/space-infix-ops": ["error", { "int32Hint": false }] -} -``` - -## Options - -See [`eslint/space-infix-ops` options](https://eslint.org/docs/rules/space-infix-ops#options). - - - -Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/main/docs/rules/space-infix-ops.md) - - diff --git a/packages/eslint-plugin/docs/rules/strict-boolean-expressions.md b/packages/eslint-plugin/docs/rules/strict-boolean-expressions.md index a1bead76670d..f25aa3efc1d3 100644 --- a/packages/eslint-plugin/docs/rules/strict-boolean-expressions.md +++ b/packages/eslint-plugin/docs/rules/strict-boolean-expressions.md @@ -89,29 +89,6 @@ const foo = (arg: any) => (Boolean(arg) ? 1 : 0); ## Options -```ts -type Options = { - allowString?: boolean; - allowNumber?: boolean; - allowNullableObject?: boolean; - allowNullableBoolean?: boolean; - allowNullableString?: boolean; - allowNullableNumber?: boolean; - allowAny?: boolean; -}; - -const defaultOptions: Options = { - allowString: true, - allowNumber: true, - allowNullableObject: true, - allowNullableBoolean: false, - allowNullableString: false, - allowNullableNumber: false, - allowAny: false, - allowRuleToRunWithoutStrictNullChecksIKnowWhatIAmDoing: false, -}; -``` - ### `allowString` Allows `string` in a boolean context. diff --git a/packages/eslint-plugin/docs/rules/switch-exhaustiveness-check.md b/packages/eslint-plugin/docs/rules/switch-exhaustiveness-check.md index 5a726f738445..4cc7e152e7ad 100644 --- a/packages/eslint-plugin/docs/rules/switch-exhaustiveness-check.md +++ b/packages/eslint-plugin/docs/rules/switch-exhaustiveness-check.md @@ -110,19 +110,6 @@ switch (day) { } ``` -## Options - -```jsonc -// .eslintrc.json -{ - "rules": { - "@typescript-eslint/switch-exhaustiveness-check": "warn" - } -} -``` - -This rule is not configurable. - ## When Not To Use It If program doesn't have union types with many parts. Downside of this rule is the need for type information, so it's slower than regular rules. diff --git a/packages/eslint-plugin/docs/rules/triple-slash-reference.md b/packages/eslint-plugin/docs/rules/triple-slash-reference.md index df7b0901e6ce..75edec3261a2 100644 --- a/packages/eslint-plugin/docs/rules/triple-slash-reference.md +++ b/packages/eslint-plugin/docs/rules/triple-slash-reference.md @@ -6,9 +6,11 @@ description: 'Disallow certain triple slash directives in favor of ES6-style imp > > See **https://typescript-eslint.io/rules/triple-slash-reference** for documentation. +## Rule Details + 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 +## Options With `{ "path": "never", "types": "never", "lib": "never" }` options set, the following will all be **incorrect** usage: @@ -48,22 +50,6 @@ import * as foo from 'foo'; import foo = require('foo'); ``` -## Options - -```ts -type Options = { - lib?: 'always' | 'never'; - path?: 'always' | 'never'; - types?: 'always' | 'never' | 'prefer-import'; -}; - -const defaultOptions: Options = { - lib: 'always', - path: 'never', - types: 'prefer-import', -}; -``` - ## When To Use It If you want to ban use of one or all of the triple slash reference directives, or any time you might use triple-slash type reference directives and ES6 import declarations in the same file. diff --git a/packages/eslint-plugin/docs/rules/type-annotation-spacing.md b/packages/eslint-plugin/docs/rules/type-annotation-spacing.md index 78f16a927138..d3a97920072f 100644 --- a/packages/eslint-plugin/docs/rules/type-annotation-spacing.md +++ b/packages/eslint-plugin/docs/rules/type-annotation-spacing.md @@ -41,21 +41,11 @@ This rule aims to enforce specific spacing patterns around type annotations and ## Options -This rule has an object option: - -- `"before": false`, (default for colon) disallows spaces before the colon/arrow. -- `"before": true`, (default for arrow) requires a space before the colon/arrow. -- `"after": true`, (default) requires a space after the colon/arrow. -- `"after": false`, disallows spaces after the colon/arrow. -- `"overrides"`, overrides the default options for type annotations with `colon` (e.g. `const foo: string`) and function types with `arrow` (e.g. `type Foo = () => {}`). Additionally allows granular overrides for `variable` (`const foo: string`),`parameter` (`function foo(bar: string) {...}`),`property` (`interface Foo { bar: string }`) and `returnType` (`function foo(): string {...}`) annotations. - -### defaults - Examples of code for this rule with no options at all: -#### ❌ Incorrect +### ❌ Incorrect ```ts @@ -84,7 +74,7 @@ type Foo = () =>{}; type Foo = ()=> {}; ``` -#### ✅ Correct +### ✅ Correct ```ts diff --git a/packages/eslint-plugin/docs/rules/typedef.md b/packages/eslint-plugin/docs/rules/typedef.md index 74152a49f87b..317f96879578 100644 --- a/packages/eslint-plugin/docs/rules/typedef.md +++ b/packages/eslint-plugin/docs/rules/typedef.md @@ -22,11 +22,15 @@ class ContainsText { } ``` -**_Note:_** requiring type annotations unnecessarily can be cumbersome to maintain and generally reduces code readability. +:::caution + +Requiring type annotations unnecessarily can be cumbersome to maintain and generally reduces code readability. TypeScript is often better at inferring types than easily written type annotations would allow. **Instead of enabling `typedef`, it is generally recommended to use the `--noImplicitAny` and `--strictPropertyInitialization` compiler options to enforce type annotations only when useful.** +::: + ## Rule Details This rule can enforce type annotations in locations regardless of whether they're required. @@ -36,30 +40,6 @@ This is typically used to maintain consistency for element types that sometimes ## Options -```ts -type Options = { - arrayDestructuring?: boolean; - arrowParameter?: boolean; - memberVariableDeclaration?: boolean; - objectDestructuring?: boolean; - parameter?: boolean; - propertyDeclaration?: boolean; - variableDeclaration?: boolean; - variableDeclarationIgnoreFunction?: boolean; -}; - -const defaultOptions: Options = { - arrayDestructuring: false, - arrowParameter: false, - memberVariableDeclaration: false, - objectDestructuring: false, - parameter: false, - propertyDeclaration: false, - variableDeclaration: false, - variableDeclarationIgnoreFunction: false, -}; -``` - For example, with the following configuration: ```json diff --git a/packages/eslint-plugin/docs/rules/unbound-method.md b/packages/eslint-plugin/docs/rules/unbound-method.md index 6a74e898a9b4..fe030ad5facc 100644 --- a/packages/eslint-plugin/docs/rules/unbound-method.md +++ b/packages/eslint-plugin/docs/rules/unbound-method.md @@ -13,7 +13,7 @@ If you're working with `jest`, you can use [`eslint-plugin-jest`'s version of th ## Rule Details -Examples of code for this rule +Examples of code for this rule with the default options: @@ -76,10 +76,6 @@ const { double } = arith; ## Options -The rule accepts an options object with the following property: - -- `ignoreStatic` to not check whether `static` methods are correctly bound - ### `ignoreStatic` Examples of **correct** code for this rule with `{ ignoreStatic: true }`: @@ -97,19 +93,6 @@ const { log } = OtherClass; log(); ``` -## Example - -```json -{ - "@typescript-eslint/unbound-method": [ - "error", - { - "ignoreStatic": true - } - ] -} -``` - ## When Not To Use It If your code intentionally waits to bind methods after use, such as by passing a `scope: this` along with the method, you can disable this rule. diff --git a/packages/eslint-plugin/docs/rules/unified-signatures.md b/packages/eslint-plugin/docs/rules/unified-signatures.md index cb03bc45b737..ad6bbb917aa3 100644 --- a/packages/eslint-plugin/docs/rules/unified-signatures.md +++ b/packages/eslint-plugin/docs/rules/unified-signatures.md @@ -10,22 +10,6 @@ description: 'Disallow two overloads that could be unified into one with a union This rule aims to keep the source code as maintainable as possible by reducing the amount of overloads. -## Options - -```ts -type Options = { - ignoreDifferentlyNamedParameters?: boolean; -}; - -const defaultOptions: Options = { - ignoreDifferentlyNamedParameters: false, -}; -``` - -The rule accepts an options object with the following property: - -- `ignoreDifferentlyNamedParameters`: whether two parameters with different names at the same index should be considered different even if their types are the same. - Examples of code for this rule with the default options: @@ -52,6 +36,10 @@ function x(x: number | string): void; function y(...x: number[]): void; ``` +## Options + +### `ignoreDifferentlyNamedParameters` + Examples of code for this rule with `ignoreDifferentlyNamedParameters`: @@ -79,3 +67,5 @@ function f(b: string): void; function f(...a: number[]): void; function f(...a: string[]): void; ``` + +## Options diff --git a/packages/eslint-plugin/src/rules/array-type.ts b/packages/eslint-plugin/src/rules/array-type.ts index c84afee195f6..2618225b5990 100644 --- a/packages/eslint-plugin/src/rules/array-type.ts +++ b/packages/eslint-plugin/src/rules/array-type.ts @@ -83,8 +83,6 @@ type MessageIds = | 'errorStringArraySimple' | 'errorStringGenericSimple'; -const arrayOption = { enum: ['array', 'generic', 'array-simple'] }; - export default util.createRule({ name: 'array-type', meta: { @@ -106,11 +104,23 @@ export default util.createRule({ }, schema: [ { - type: 'object', + definitions: { + arrayOption: { + enum: ['array', 'generic', 'array-simple'], + }, + }, properties: { - default: arrayOption, - readonly: arrayOption, + default: { + $ref: '#/definitions/arrayOption', + description: 'The array type expected for mutable cases...', + }, + readonly: { + $ref: '#/definitions/arrayOption', + description: + 'The array type expected for readonly cases. If omitted, the value for `default` will be used.', + }, }, + type: 'object', }, ], }, diff --git a/packages/eslint-plugin/src/rules/ban-ts-comment.ts b/packages/eslint-plugin/src/rules/ban-ts-comment.ts index e5cb60876ea3..e8857c21eb45 100644 --- a/packages/eslint-plugin/src/rules/ban-ts-comment.ts +++ b/packages/eslint-plugin/src/rules/ban-ts-comment.ts @@ -14,24 +14,6 @@ interface Options { minimumDescriptionLength?: number; } -const directiveConfigSchema = { - oneOf: [ - { - type: 'boolean', - default: true, - }, - { - enum: ['allow-with-description'], - }, - { - type: 'object', - properties: { - descriptionFormat: { type: 'string' }, - }, - }, - ], -}; - export const defaultMinimumDescriptionLength = 3; type MessageIds = @@ -58,12 +40,33 @@ export default util.createRule<[Options], MessageIds>({ }, schema: [ { + definitions: { + directiveConfigSchema: { + oneOf: [ + { + type: 'boolean', + default: true, + }, + { + enum: ['allow-with-description'], + }, + { + type: 'object', + properties: { + descriptionFormat: { type: 'string' }, + }, + }, + ], + }, + }, type: 'object', properties: { - 'ts-expect-error': directiveConfigSchema, - 'ts-ignore': directiveConfigSchema, - 'ts-nocheck': directiveConfigSchema, - 'ts-check': directiveConfigSchema, + 'ts-expect-error': { + $ref: '#/definitions/directiveConfigSchema', + }, + 'ts-ignore': { $ref: '#/definitions/directiveConfigSchema' }, + 'ts-nocheck': { $ref: '#/definitions/directiveConfigSchema' }, + 'ts-check': { $ref: '#/definitions/directiveConfigSchema' }, minimumDescriptionLength: { type: 'number', default: defaultMinimumDescriptionLength, diff --git a/packages/eslint-plugin/src/rules/explicit-function-return-type.ts b/packages/eslint-plugin/src/rules/explicit-function-return-type.ts index 1f69834d4784..9e5a377ee5fc 100644 --- a/packages/eslint-plugin/src/rules/explicit-function-return-type.ts +++ b/packages/eslint-plugin/src/rules/explicit-function-return-type.ts @@ -34,26 +34,38 @@ export default util.createRule({ { type: 'object', properties: { - allowExpressions: { + allowConciseArrowFunctionExpressionsStartingWithVoid: { + description: + 'Whether to allow arrow functions that start with the `void` keyword.', type: 'boolean', }, - allowTypedFunctionExpressions: { + allowExpressions: { + description: + 'Whether to ignore function expressions (functions which are not part of a declaration).', type: 'boolean', }, allowHigherOrderFunctions: { + description: + 'Whether to ignore functions immediately returning another function expression.', type: 'boolean', }, - allowDirectConstAssertionInArrowFunctions: { + allowTypedFunctionExpressions: { + description: + 'Whether to ignore type annotations on the variable of function expressions.', type: 'boolean', }, - allowConciseArrowFunctionExpressionsStartingWithVoid: { + allowDirectConstAssertionInArrowFunctions: { + description: + 'Whether to ignore arrow functions immediately returning a `as const` value.', type: 'boolean', }, allowedNames: { - type: 'array', + description: + 'An array of function/method names that will not have their arguments or return values checked.', items: { type: 'string', }, + type: 'array', }, }, additionalProperties: false, diff --git a/packages/eslint-plugin/src/rules/explicit-member-accessibility.ts b/packages/eslint-plugin/src/rules/explicit-member-accessibility.ts index b67221aee54f..40ad832b1322 100644 --- a/packages/eslint-plugin/src/rules/explicit-member-accessibility.ts +++ b/packages/eslint-plugin/src/rules/explicit-member-accessibility.ts @@ -27,7 +27,22 @@ type Options = [Config]; type MessageIds = 'unwantedPublicAccessibility' | 'missingAccessibility'; -const accessibilityLevel = { enum: ['explicit', 'no-public', 'off'] }; +const accessibilityLevel = { + oneOf: [ + { + const: 'explicit', + description: 'Always require an accessor.', + }, + { + const: 'no-public', + description: 'Require an accessor except when public.', + }, + { + const: 'off', + description: 'Never check whether there is an accessor.', + }, + ], +}; export default util.createRule({ name: 'explicit-member-accessibility', @@ -48,17 +63,20 @@ export default util.createRule({ }, schema: [ { + definitions: { + accessibilityLevel, + }, type: 'object', properties: { - accessibility: accessibilityLevel, + accessibility: { $ref: '#/definitions/accessibilityLevel' }, overrides: { type: 'object', properties: { - accessors: accessibilityLevel, - constructors: accessibilityLevel, - methods: accessibilityLevel, - properties: accessibilityLevel, - parameterProperties: accessibilityLevel, + accessors: { $ref: '#/definitions/accessibilityLevel' }, + constructors: { $ref: '#/definitions/accessibilityLevel' }, + methods: { $ref: '#/definitions/accessibilityLevel' }, + properties: { $ref: '#/definitions/accessibilityLevel' }, + parameterProperties: { $ref: '#/definitions/accessibilityLevel' }, }, additionalProperties: false, diff --git a/packages/eslint-plugin/src/rules/explicit-module-boundary-types.ts b/packages/eslint-plugin/src/rules/explicit-module-boundary-types.ts index 3f9f50086ccf..a3c414203544 100644 --- a/packages/eslint-plugin/src/rules/explicit-module-boundary-types.ts +++ b/packages/eslint-plugin/src/rules/explicit-module-boundary-types.ts @@ -50,21 +50,35 @@ export default util.createRule({ type: 'object', properties: { allowArgumentsExplicitlyTypedAsAny: { + description: + 'Whether to ignore arguments that are explicitly typed as `any`.', type: 'boolean', }, allowDirectConstAssertionInArrowFunctions: { + description: [ + 'Whether to ignore return type annotations on body-less arrow functions that return an `as const` type assertion.', + 'You must still type the parameters of the function.', + ].join('\n'), type: 'boolean', }, allowedNames: { - type: 'array', + description: + 'An array of function/method names that will not have their arguments or return values checked.', items: { type: 'string', }, + type: 'array', }, allowHigherOrderFunctions: { + description: [ + 'Whether to ignore return type annotations on functions immediately returning another function expression.', + 'You must still type the parameters of the function.', + ].join('\n'), type: 'boolean', }, allowTypedFunctionExpressions: { + description: + 'Whether to ignore type annotations on the variable of a function expresion.', type: 'boolean', }, // DEPRECATED - To be removed in next major diff --git a/packages/eslint-plugin/src/rules/no-explicit-any.ts b/packages/eslint-plugin/src/rules/no-explicit-any.ts index 8ab4d033ba83..e32d00bcd706 100644 --- a/packages/eslint-plugin/src/rules/no-explicit-any.ts +++ b/packages/eslint-plugin/src/rules/no-explicit-any.ts @@ -32,9 +32,12 @@ export default util.createRule({ additionalProperties: false, properties: { fixToUnknown: { + description: + 'Whether to enable auto-fixing in which the `any` type is converted to the `unknown` type.', type: 'boolean', }, ignoreRestArgs: { + description: 'Whether to ignore rest parameter arrays.', type: 'boolean', }, }, diff --git a/packages/eslint-plugin/src/rules/no-extraneous-class.ts b/packages/eslint-plugin/src/rules/no-extraneous-class.ts index f280780ef89c..6bd2ba910377 100644 --- a/packages/eslint-plugin/src/rules/no-extraneous-class.ts +++ b/packages/eslint-plugin/src/rules/no-extraneous-class.ts @@ -25,15 +25,23 @@ export default util.createRule({ additionalProperties: false, properties: { allowConstructorOnly: { + description: + 'Whether to allow extraneous classes that contain only a constructor.', type: 'boolean', }, allowEmpty: { + description: + 'Whether to allow extraneous classes that have no body (i.e. are empty).', type: 'boolean', }, allowStaticOnly: { + description: + 'Whether to allow extraneous classes that only contain static members.', type: 'boolean', }, allowWithDecorator: { + description: + 'Whether to allow extraneous classes that include a decorator.', type: 'boolean', }, }, diff --git a/packages/eslint-plugin/src/rules/no-floating-promises.ts b/packages/eslint-plugin/src/rules/no-floating-promises.ts index 168cd3c55231..06b02fb297ab 100644 --- a/packages/eslint-plugin/src/rules/no-floating-promises.ts +++ b/packages/eslint-plugin/src/rules/no-floating-promises.ts @@ -35,8 +35,15 @@ export default util.createRule({ { type: 'object', properties: { - ignoreVoid: { type: 'boolean' }, - ignoreIIFE: { type: 'boolean' }, + ignoreVoid: { + description: 'Whether to ignore `void` expressions.', + type: 'boolean', + }, + ignoreIIFE: { + description: + 'Whether to ignore async IIFEs (Immediately Invocated Function Expressions).', + type: 'boolean', + }, }, additionalProperties: false, }, diff --git a/packages/eslint-plugin/src/rules/no-implicit-any-catch.ts b/packages/eslint-plugin/src/rules/no-implicit-any-catch.ts index d020e81522f3..439378070d69 100644 --- a/packages/eslint-plugin/src/rules/no-implicit-any-catch.ts +++ b/packages/eslint-plugin/src/rules/no-implicit-any-catch.ts @@ -34,6 +34,8 @@ export default util.createRule({ additionalProperties: false, properties: { allowExplicitAny: { + description: + 'Whether to disallow specifying `: any` as the error type as well. See also `no-explicit-any`.', type: 'boolean', }, }, diff --git a/packages/eslint-plugin/src/rules/no-namespace.ts b/packages/eslint-plugin/src/rules/no-namespace.ts index 2a840fda3143..ac306e6b299c 100644 --- a/packages/eslint-plugin/src/rules/no-namespace.ts +++ b/packages/eslint-plugin/src/rules/no-namespace.ts @@ -26,9 +26,13 @@ export default util.createRule({ type: 'object', properties: { allowDeclarations: { + description: + 'Whether to allow `declare` with custom TypeScript namespaces.', type: 'boolean', }, allowDefinitionFiles: { + description: + 'Whether to allow `declare` with custom TypeScript namespaces inside definition files.', type: 'boolean', }, }, diff --git a/packages/eslint-plugin/src/rules/no-this-alias.ts b/packages/eslint-plugin/src/rules/no-this-alias.ts index 5750b8209b11..9df6f8d0a01f 100644 --- a/packages/eslint-plugin/src/rules/no-this-alias.ts +++ b/packages/eslint-plugin/src/rules/no-this-alias.ts @@ -23,9 +23,13 @@ export default util.createRule({ additionalProperties: false, properties: { allowDestructuring: { + description: + 'Whether to ignore destructurings, such as `const { props, state } = this`.', type: 'boolean', }, allowedNames: { + description: + 'Names to ignore, such as ["self"] for `const self = this;`.', type: 'array', items: { type: 'string', diff --git a/packages/eslint-plugin/src/rules/no-type-alias.ts b/packages/eslint-plugin/src/rules/no-type-alias.ts index ba656ea4124a..69742eb61032 100644 --- a/packages/eslint-plugin/src/rules/no-type-alias.ts +++ b/packages/eslint-plugin/src/rules/no-type-alias.ts @@ -60,27 +60,36 @@ export default util.createRule({ type: 'object', properties: { allowAliases: { + description: 'Whether to allow direct one-to-one type aliases.', enum: enumValues, }, allowCallbacks: { + description: 'Whether to allow type aliases for callbacks.', enum: ['always', 'never'], }, allowConditionalTypes: { + description: 'Whether to allow type aliases for conditional types.', enum: ['always', 'never'], }, allowConstructors: { + description: 'Whether to allow type aliases with constructors.', enum: ['always', 'never'], }, allowLiterals: { + description: + 'Whether to allow type aliases with object literal types.', enum: enumValues, }, allowMappedTypes: { + description: 'Whether to allow type aliases with mapped types.', enum: enumValues, }, allowTupleTypes: { + description: 'Whether to allow type aliases with tuple types.', enum: enumValues, }, allowGenerics: { + description: 'Whether to allow type aliases with generic types.', enum: ['always', 'never'], }, }, diff --git a/packages/eslint-plugin/src/rules/no-unnecessary-boolean-literal-compare.ts b/packages/eslint-plugin/src/rules/no-unnecessary-boolean-literal-compare.ts index d135b3dd18a9..592f2d03c024 100644 --- a/packages/eslint-plugin/src/rules/no-unnecessary-boolean-literal-compare.ts +++ b/packages/eslint-plugin/src/rules/no-unnecessary-boolean-literal-compare.ts @@ -56,9 +56,13 @@ export default util.createRule({ type: 'object', properties: { allowComparingNullableBooleansToTrue: { + description: + 'Whether to allow comparisons between nullable boolean variables and `true`.', type: 'boolean', }, allowComparingNullableBooleansToFalse: { + description: + 'Whether to allow comparisons between nullable boolean variables and `false`.', type: 'boolean', }, }, diff --git a/packages/eslint-plugin/src/rules/no-unnecessary-condition.ts b/packages/eslint-plugin/src/rules/no-unnecessary-condition.ts index df6580be86a6..865fc959743c 100644 --- a/packages/eslint-plugin/src/rules/no-unnecessary-condition.ts +++ b/packages/eslint-plugin/src/rules/no-unnecessary-condition.ts @@ -98,9 +98,13 @@ export default createRule({ type: 'object', properties: { allowConstantLoopConditions: { + description: + 'Whether to ignore constant loop conditions, such as `while (true)`.', type: 'boolean', }, allowRuleToRunWithoutStrictNullChecksIKnowWhatIAmDoing: { + description: + 'Whether to not error when running with a tsconfig that has strictNullChecks turned.', type: 'boolean', }, }, diff --git a/packages/eslint-plugin/src/rules/no-unnecessary-type-assertion.ts b/packages/eslint-plugin/src/rules/no-unnecessary-type-assertion.ts index d9ef180abd5f..59e257b9e0bf 100644 --- a/packages/eslint-plugin/src/rules/no-unnecessary-type-assertion.ts +++ b/packages/eslint-plugin/src/rules/no-unnecessary-type-assertion.ts @@ -37,6 +37,7 @@ export default util.createRule({ type: 'object', properties: { typesToIgnore: { + description: 'A list of type names to ignore.', type: 'array', items: { type: 'string', diff --git a/packages/eslint-plugin/src/rules/parameter-properties.ts b/packages/eslint-plugin/src/rules/parameter-properties.ts index 58d834088977..a2f6fcb8009f 100644 --- a/packages/eslint-plugin/src/rules/parameter-properties.ts +++ b/packages/eslint-plugin/src/rules/parameter-properties.ts @@ -38,20 +38,25 @@ export default util.createRule({ }, schema: [ { + definitions: { + modifier: { + enum: [ + 'readonly', + 'private', + 'protected', + 'public', + 'private readonly', + 'protected readonly', + 'public readonly', + ], + }, + }, type: 'object', properties: { allow: { type: 'array', items: { - enum: [ - 'readonly', - 'private', - 'protected', - 'public', - 'private readonly', - 'protected readonly', - 'public readonly', - ], + $ref: '#/definitions/modifier', }, minItems: 1, }, diff --git a/packages/eslint-plugin/src/rules/promise-function-async.ts b/packages/eslint-plugin/src/rules/promise-function-async.ts index b1ade7bf01b7..8f81a0f8b2a2 100644 --- a/packages/eslint-plugin/src/rules/promise-function-async.ts +++ b/packages/eslint-plugin/src/rules/promise-function-async.ts @@ -37,9 +37,13 @@ export default util.createRule({ type: 'object', properties: { allowAny: { + description: + 'Whether to consider `any` and `unknown` to be Promises.', type: 'boolean', }, allowedPromiseNames: { + description: + 'Any extra names of classes or interfaces to be considered Promises.', type: 'array', items: { type: 'string', diff --git a/packages/eslint-plugin/src/rules/require-array-sort-compare.ts b/packages/eslint-plugin/src/rules/require-array-sort-compare.ts index 5354c87afa64..26cc035acfda 100644 --- a/packages/eslint-plugin/src/rules/require-array-sort-compare.ts +++ b/packages/eslint-plugin/src/rules/require-array-sort-compare.ts @@ -32,6 +32,8 @@ export default util.createRule({ type: 'object', properties: { ignoreStringArrays: { + description: + 'Whether to ignore arrays in which all elements are strings.', type: 'boolean', }, }, diff --git a/packages/eslint-plugin/src/rules/restrict-plus-operands.ts b/packages/eslint-plugin/src/rules/restrict-plus-operands.ts index 3884dec24dd0..c72579b5fafd 100644 --- a/packages/eslint-plugin/src/rules/restrict-plus-operands.ts +++ b/packages/eslint-plugin/src/rules/restrict-plus-operands.ts @@ -42,9 +42,11 @@ export default util.createRule({ additionalProperties: false, properties: { checkCompoundAssignments: { + description: 'Whether to check compound assignments such as `+=`.', type: 'boolean', }, allowAny: { + description: 'Whether to allow `any` typed values.', type: 'boolean', }, }, diff --git a/packages/eslint-plugin/src/rules/restrict-template-expressions.ts b/packages/eslint-plugin/src/rules/restrict-template-expressions.ts index 0140c3dc0d47..fb4e7bb7bea7 100644 --- a/packages/eslint-plugin/src/rules/restrict-template-expressions.ts +++ b/packages/eslint-plugin/src/rules/restrict-template-expressions.ts @@ -31,11 +31,31 @@ export default util.createRule({ { type: 'object', properties: { - allowNumber: { type: 'boolean' }, - allowBoolean: { type: 'boolean' }, - allowAny: { type: 'boolean' }, - allowNullish: { type: 'boolean' }, - allowRegExp: { type: 'boolean' }, + allowNumber: { + description: + 'Whether to allow `number` typed values in template expressions.', + type: 'boolean', + }, + allowBoolean: { + description: + 'Whether to allow `boolean` typed values in template expressions.', + type: 'boolean', + }, + allowAny: { + description: + 'Whether to allow `any` typed values in template expressions.', + type: 'boolean', + }, + allowNullish: { + description: + 'Whether to allow `nullish` typed values in template expressions.', + type: 'boolean', + }, + allowRegExp: { + description: + 'Whether to allow `regexp` typed values in template expressions.', + type: 'boolean', + }, }, }, ], diff --git a/packages/eslint-plugin/src/rules/sort-type-union-intersection-members.ts b/packages/eslint-plugin/src/rules/sort-type-union-intersection-members.ts index f96c4677506d..201c411afee8 100644 --- a/packages/eslint-plugin/src/rules/sort-type-union-intersection-members.ts +++ b/packages/eslint-plugin/src/rules/sort-type-union-intersection-members.ts @@ -121,12 +121,15 @@ export default util.createRule({ type: 'object', properties: { checkIntersections: { + description: 'Whether to check intersection types.', type: 'boolean', }, checkUnions: { + description: 'Whether to check union types.', type: 'boolean', }, groupOrder: { + description: 'Ordering of the groups.', type: 'array', items: { type: 'string', diff --git a/packages/eslint-plugin/src/rules/unbound-method.ts b/packages/eslint-plugin/src/rules/unbound-method.ts index 2c62881e81b1..2151cd7b3e86 100644 --- a/packages/eslint-plugin/src/rules/unbound-method.ts +++ b/packages/eslint-plugin/src/rules/unbound-method.ts @@ -142,6 +142,8 @@ export default util.createRule({ type: 'object', properties: { ignoreStatic: { + description: + 'Whether to skip checking whether `static` methods are correctly bound.', type: 'boolean', }, }, diff --git a/packages/eslint-plugin/src/rules/unified-signatures.ts b/packages/eslint-plugin/src/rules/unified-signatures.ts index dc1f683ee35b..ec502b5661a1 100644 --- a/packages/eslint-plugin/src/rules/unified-signatures.ts +++ b/packages/eslint-plugin/src/rules/unified-signatures.ts @@ -81,6 +81,8 @@ export default util.createRule({ additionalProperties: false, properties: { ignoreDifferentlyNamedParameters: { + description: + 'Whether two parameters with different names at the same index should be considered different even if their types are the same.', type: 'boolean', }, }, diff --git a/packages/eslint-plugin/tests/docs.test.ts b/packages/eslint-plugin/tests/docs.test.ts index 7fc703255d89..dc30898d6311 100644 --- a/packages/eslint-plugin/tests/docs.test.ts +++ b/packages/eslint-plugin/tests/docs.test.ts @@ -1,5 +1,4 @@ import fs from 'fs'; -import { JSONSchema4 } from 'json-schema'; import path from 'path'; import { marked } from 'marked'; @@ -18,22 +17,8 @@ function parseMarkdownFile(filePath: string): marked.TokensList { }); } -function isEmptySchema(schema: JSONSchema4 | JSONSchema4[]): boolean { - return Array.isArray(schema) - ? schema.length === 0 - : Object.keys(schema).length === 0; -} - type TokenType = marked.Token['type']; -function tokenAs( - token: marked.Token, - type: Type, -): marked.Token & { type: Type } { - expect(token.type).toBe(type); - return token as marked.Token & { type: Type }; -} - function tokenIs( token: marked.Token, type: Type, @@ -108,46 +93,6 @@ describe('Validating rule docs', () => { expect(header.text).toBe(titleCase(header.text)), ); }); - - test(`options must match the rule meta`, () => { - // TODO(#4365): We don't yet enforce formatting for all rules. - if ( - !isEmptySchema(rule.meta.schema) || - !rule.meta.docs?.recommended || - rule.meta.docs.extendsBaseRule - ) { - return; - } - - const optionsIndex = tokens.findIndex( - token => tokenIsH2(token) && token.text === 'Options', - ); - expect(optionsIndex).toBeGreaterThan(0); - - const codeBlock = tokenAs(tokens[optionsIndex + 1], 'code'); - tokenAs(tokens[optionsIndex + 2], 'space'); - const descriptionBlock = tokenAs(tokens[optionsIndex + 3], 'paragraph'); - - expect(codeBlock).toMatchObject({ - lang: 'jsonc', - text: ` -// .eslintrc.json -{ - "rules": { - "@typescript-eslint/${ruleName}": "${ - rule.meta.docs.recommended === 'strict' - ? 'warn' - : rule.meta.docs.recommended - }" - } -} - `.trim(), - type: 'code', - }); - expect(descriptionBlock).toMatchObject({ - text: 'This rule is not configurable.', - }); - }); }); } }); diff --git a/packages/utils/src/eslint-utils/RuleCreator.ts b/packages/utils/src/eslint-utils/RuleCreator.ts index 2bd24323e782..2e2646db3506 100644 --- a/packages/utils/src/eslint-utils/RuleCreator.ts +++ b/packages/utils/src/eslint-utils/RuleCreator.ts @@ -95,13 +95,14 @@ function createRule< TRuleListener > { return { - meta, create( context: Readonly>, ): TRuleListener { const optionsWithDefault = applyDefault(defaultOptions, context.options); return create(context, optionsWithDefault); }, + defaultOptions, + meta, }; } diff --git a/packages/utils/src/ts-eslint/Rule.ts b/packages/utils/src/ts-eslint/Rule.ts index 25d29bddf115..ff3053863219 100644 --- a/packages/utils/src/ts-eslint/Rule.ts +++ b/packages/utils/src/ts-eslint/Rule.ts @@ -433,6 +433,11 @@ interface RuleModule< // for extending base rules TRuleListener extends RuleListener = RuleListener, > { + /** + * Default options the rule will be run with + */ + defaultOptions: TOptions; + /** * Metadata about the rule */ diff --git a/packages/website/docusaurusConfig.ts b/packages/website/docusaurusConfig.ts index 89a97f1c81e7..2750a983d35e 100644 --- a/packages/website/docusaurusConfig.ts +++ b/packages/website/docusaurusConfig.ts @@ -23,8 +23,11 @@ const presetClassicOptions: PresetClassicOptions = { sidebarPath: require.resolve('./sidebars/sidebar.rules.js'), routeBasePath: 'rules', editUrl: `${githubUrl}/edit/main/packages/website/`, - beforeDefaultRemarkPlugins, - remarkPlugins: [...remarkPlugins, [generatedRuleDocs, {}]], + beforeDefaultRemarkPlugins: [ + ...beforeDefaultRemarkPlugins, + [generatedRuleDocs, {}], + ], + remarkPlugins: remarkPlugins, exclude: ['TEMPLATE.md'], breadcrumbs: false, }, diff --git a/packages/website/package.json b/packages/website/package.json index 1b7aa4f25b9f..6eebfc237fbc 100644 --- a/packages/website/package.json +++ b/packages/website/package.json @@ -20,12 +20,16 @@ "@docusaurus/remark-plugin-npm2yarn": "2.0.0-beta.21", "@docusaurus/theme-common": "2.0.0-beta.21", "@mdx-js/react": "1.6.22", + "@typescript-eslint/parser": "^5.33.1", "@typescript-eslint/website-eslint": "5.33.1", "clsx": "^1.1.1", "eslint": "*", + "json-schema": "^0.4.0", + "json-schema-to-typescript": "^11.0.1", "json5": "^2.2.1", "konamimojisplosion": "^0.5.1", "lzstring.ts": "^2.0.2", + "prettier": "*", "prism-react-renderer": "^1.3.3", "react": "^18.1.0", "react-dom": "^18.1.0", diff --git a/packages/website/plugins/generated-rule-docs.ts b/packages/website/plugins/generated-rule-docs.ts index f074db043551..29906807c038 100644 --- a/packages/website/plugins/generated-rule-docs.ts +++ b/packages/website/plugins/generated-rule-docs.ts @@ -1,17 +1,33 @@ import type * as unist from 'unist'; -import type * as mdast from 'mdast'; +import * as mdast from 'mdast'; +import { format } from 'prettier'; import type { Plugin } from 'unified'; +import { compile } from 'json-schema-to-typescript'; +import * as tseslintParser from '@typescript-eslint/parser'; import * as eslintPlugin from '@typescript-eslint/eslint-plugin'; +import { EOL } from 'os'; -const generatedRuleDocs: Plugin = () => { - return (root, file) => { +/** + * Rules whose options schema generate annoyingly complex schemas. + * + * @remarks These need to be typed in manually in their .md docs file. + * @todo Get these schemas printing nicely in their .md docs files! + */ +const COMPLICATED_RULE_OPTIONS = new Set([ + 'member-ordering', + 'naming-convention', +]); + +export const generatedRuleDocs: Plugin = () => { + return async (root, file) => { if (file.stem == null) { return; } - const docs = eslintPlugin.rules[file.stem]?.meta.docs; - if (!docs) { + const rule = eslintPlugin.rules[file.stem]; + const meta = rule?.meta; + if (!meta?.docs) { return; } @@ -27,7 +43,7 @@ const generatedRuleDocs: Plugin = () => { parent.children.unshift({ children: [ { - children: docs.description + children: meta.docs.description .split(/`(.+?)`/) .map((value, index, array) => ({ type: index % 2 === 0 ? 'text' : 'inlineCode', @@ -40,22 +56,252 @@ const generatedRuleDocs: Plugin = () => { } as mdast.Blockquote); // 3. Add a rule attributes list... - const h2Idx = + const attributesH2Index = // ...before the first h2, if it exists... parent.children.findIndex( - child => - child.type === 'heading' && (child as mdast.Heading).depth === 2, + child => nodeIsHeading(child) && child.depth === 2, ) ?? // ...or at the very end, if not. parent.children.length; // The actual content will be injected on client side. - const attrNode = { + const attributesNode = { type: 'jsx', value: ``, }; - parent.children.splice(h2Idx, 0, attrNode); + parent.children.splice(attributesH2Index, 0, attributesNode); + + // 4. Make sure the appropriate headers exist to place content under + const [howToUseH2Index, optionsH2Index] = ((): [number, number] => { + let howToUseH2Index = parent.children.findIndex( + createH2TextFilter('How to Use'), + ); + let optionsH2Index = parent.children.findIndex( + createH2TextFilter('Options'), + ); + const relatedToH2Index = parent.children.findIndex( + createH2TextFilter('Related To'), + ); + let whenNotToUseItH2Index = parent.children.findIndex( + createH2TextFilter('When Not To Use It'), + ); + + if (meta.docs.extendsBaseRule) { + if (howToUseH2Index === -1) { + if (optionsH2Index !== -1) { + howToUseH2Index = optionsH2Index; + optionsH2Index += 1; + + if (whenNotToUseItH2Index !== -1) { + whenNotToUseItH2Index += 1; + } + } else { + howToUseH2Index = + whenNotToUseItH2Index === -1 + ? parent.children.length + : ++whenNotToUseItH2Index; + } + + parent.children.splice(howToUseH2Index, 0, { + children: [ + { + type: 'text', + value: 'How to Use', + }, + ], + depth: 2, + type: 'heading', + } as mdast.Heading); + } + } + + if (optionsH2Index === -1) { + optionsH2Index = + whenNotToUseItH2Index === -1 + ? relatedToH2Index === -1 + ? parent.children.length + : relatedToH2Index + : whenNotToUseItH2Index; + parent.children.splice(optionsH2Index, 0, { + children: [ + { + type: 'text', + value: 'Options', + }, + ], + depth: 2, + type: 'heading', + } as mdast.Heading); + + optionsH2Index += 1; + } + + return [howToUseH2Index, optionsH2Index]; + })(); + + // 5. Add a description of how to use / options for the rule + const optionLevel = meta.docs.recommended === 'error' ? 'error' : 'warn'; + + if (meta.docs.extendsBaseRule) { + parent.children.splice(optionsH2Index + 1, 0, { + children: [ + { + value: 'See ', + type: 'text', + }, + { + children: [ + { + type: 'inlineCode', + value: `eslint/${file.stem}`, + }, + { + type: 'text', + value: ' options', + }, + ], + type: 'link', + url: `https://eslint.org/docs/rules/${file.stem}#options`, + }, + { + type: 'text', + value: '.', + }, + ], + type: 'paragraph', + } as mdast.Paragraph); + + parent.children.splice(howToUseH2Index + 1, 0, { + lang: 'js', + type: 'code', + meta: 'title=".eslintrc.cjs"', + value: `module.exports = { + // Note: you must disable the base rule as it can report incorrect errors + "${file.stem}": "off", + "@typescript-eslint/${file.stem}": "${optionLevel}" +};`, + } as mdast.Code); + } else { + parent.children.splice(optionsH2Index, 0, { + lang: 'js', + type: 'code', + meta: 'title=".eslintrc.cjs"', + value: `module.exports = { + "rules": { + "@typescript-eslint/${file.stem}": "${optionLevel}" + } +};`, + } as mdast.Code); + + if (meta.schema.length === 0) { + parent.children.splice(optionsH2Index + 1, 0, { + children: [ + { + type: 'text', + value: 'This rule is not configurable.', + }, + ], + type: 'paragraph', + } as mdast.Paragraph); + } else if (!COMPLICATED_RULE_OPTIONS.has(file.stem)) { + const optionsSchema = + meta.schema instanceof Array ? meta.schema[0] : meta.schema; + + parent.children.splice( + optionsH2Index + 2, + 0, + { + children: [ + { + type: 'text', + value: `This rule accepts an options ${ + 'enum' in optionsSchema + ? 'string of the following possible values' + : 'object with the following properties' + }:`, + } as mdast.Text, + ], + type: 'paragraph', + } as mdast.Paragraph, + { + lang: 'ts', + type: 'code', + value: [ + ( + await compile( + { + title: `Options`, + ...optionsSchema, + }, + file.stem, + { + additionalProperties: false, + bannerComment: '', + declareExternallyReferenced: true, + }, + ) + ).replace(/^export /gm, ''), + format( + `const defaultOptions: Options = ${JSON.stringify( + rule.defaultOptions, + )};`, + { + parser: tseslintParser.parse, + }, + ), + ] + .join(EOL) + .trim(), + } as mdast.Code, + ); + } + } + + // 6. Add a notice about coming from ESLint core for extension rules + if (meta.docs.extendsBaseRule) { + parent.children.push({ + children: [ + { + type: 'jsx', + value: '', + }, + { + type: 'text', + value: 'Taken with ❤️ ', + }, + { + type: 'link', + title: null, + url: `https://github.com/eslint/eslint/blob/main/docs/rules/${file.stem}.md`, + children: [ + { + type: 'text', + value: 'from ESLint core', + }, + ], + }, + { + type: 'jsx', + value: '', + }, + ], + type: 'paragraph', + } as mdast.Paragraph); + } }; }; -export { generatedRuleDocs }; +function nodeIsHeading(node: unist.Node): node is mdast.Heading { + return node.type === 'heading'; +} + +function createH2TextFilter( + text: string, +): (node: unist.Node) => node is mdast.Heading { + return (node: unist.Node): node is mdast.Heading => + nodeIsHeading(node) && + node.depth === 2 && + node.children.length === 1 && + node.children[0].type === 'text' && + node.children[0].value === text; +} diff --git a/yarn.lock b/yarn.lock index 2af309cfae8f..19bc6314daa3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -130,6 +130,15 @@ dependencies: "@jridgewell/trace-mapping" "^0.3.0" +"@apidevtools/json-schema-ref-parser@https://github.com/bcherny/json-schema-ref-parser.git#984282d34a2993e5243aa35100fe32a63699164d": + version "0.0.0-dev" + resolved "https://github.com/bcherny/json-schema-ref-parser.git#984282d34a2993e5243aa35100fe32a63699164d" + dependencies: + "@jsdevtools/ono" "^7.1.3" + "@types/json-schema" "^7.0.6" + call-me-maybe "^1.0.1" + js-yaml "^4.1.0" + "@babel/code-frame@*", "@babel/code-frame@^7.0.0", "@babel/code-frame@^7.10.4", "@babel/code-frame@^7.12.13", "@babel/code-frame@^7.16.0", "@babel/code-frame@^7.16.7", "@babel/code-frame@^7.8.3": version "7.18.6" resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.18.6.tgz#3b25d38c89600baa2dcc219edfa88a74eb2c427a" @@ -2329,6 +2338,11 @@ "@jridgewell/resolve-uri" "^3.0.3" "@jridgewell/sourcemap-codec" "^1.4.10" +"@jsdevtools/ono@^7.1.3": + version "7.1.3" + resolved "https://registry.yarnpkg.com/@jsdevtools/ono/-/ono-7.1.3.tgz#9df03bbd7c696a5c58885c34aa06da41c8543796" + integrity sha512-4JQNk+3mVzK3xh2rqd6RB4J46qUR19azEHBneZyTZM+c456qOrbbM/5xcR8huNCCcbVt7+UmizG6GuUvPvKUYg== + "@leichtgewicht/ip-codec@^2.0.1": version "2.0.4" resolved "https://registry.yarnpkg.com/@leichtgewicht/ip-codec/-/ip-codec-2.0.4.tgz#b2ac626d6cb9c8718ab459166d4bb405b8ffa78b" @@ -4044,7 +4058,7 @@ "@types/qs" "*" "@types/serve-static" "*" -"@types/glob@*", "@types/glob@^7.2.0": +"@types/glob@*", "@types/glob@^7.1.3", "@types/glob@^7.2.0": version "7.2.0" resolved "https://registry.yarnpkg.com/@types/glob/-/glob-7.2.0.tgz#bc1b5bf3aa92f25bd5dd39f35c57361bdce5b2eb" integrity sha512-ZUxbzKl0IfJILTS6t7ip5fQQM/J3TJYubDm3nMbgubNNYS62eXeUpoLUC8/7fJNiFYHTrGPQn7hspDUzIHX3UA== @@ -4122,7 +4136,7 @@ jest-matcher-utils "^28.0.0" pretty-format "^28.0.0" -"@types/json-schema@*", "@types/json-schema@^7.0.4", "@types/json-schema@^7.0.5", "@types/json-schema@^7.0.8", "@types/json-schema@^7.0.9": +"@types/json-schema@*", "@types/json-schema@^7.0.11", "@types/json-schema@^7.0.4", "@types/json-schema@^7.0.5", "@types/json-schema@^7.0.6", "@types/json-schema@^7.0.8", "@types/json-schema@^7.0.9": version "7.0.11" resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.11.tgz#d421b6c527a3037f7c84433fd2c4229e016863d3" integrity sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ== @@ -4196,10 +4210,10 @@ resolved "https://registry.yarnpkg.com/@types/parse5/-/parse5-5.0.3.tgz#e7b5aebbac150f8b5fdd4a46e7f0bd8e65e19109" integrity sha512-kUNnecmtkunAoQ3CnjmMkzNU/gtxG8guhi+Fk2U/kOpIKjIMKnXGp4IJCgQJrXSgMsWYimYG4TGjz/UzbGEBTw== -"@types/prettier@*", "@types/prettier@^2.1.5", "@types/prettier@^2.6.0": - version "2.6.0" - resolved "https://registry.yarnpkg.com/@types/prettier/-/prettier-2.6.0.tgz#efcbd41937f9ae7434c714ab698604822d890759" - integrity sha512-G/AdOadiZhnJp0jXCaBQU449W2h716OW/EoXeYkCytxKL06X1WCXB4DZpp8TpZ8eyIJVS1cw4lrlkkSYU21cDw== +"@types/prettier@*", "@types/prettier@^2.1.5", "@types/prettier@^2.6.0", "@types/prettier@^2.6.1": + version "2.6.4" + resolved "https://registry.yarnpkg.com/@types/prettier/-/prettier-2.6.4.tgz#ad899dad022bab6b5a9f0a0fe67c2f7a4a8950ed" + integrity sha512-fOwvpvQYStpb/zHMx0Cauwywu9yLDmzWiiQBC7gJyq5tYLUXFZvDG7VK1B7WBxxjBJNKFOZ0zLoOQn8vmATbhw== "@types/prop-types@*": version "15.7.4" @@ -4698,6 +4712,11 @@ ansi-styles@^6.0.0, ansi-styles@^6.1.0: resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-6.1.0.tgz#87313c102b8118abd57371afab34618bf7350ed3" integrity sha512-VbqNsoz55SYGczauuup0MFUyXNQviSpFTj1RQtFzmQLk18qbVSpTFFGMT293rmDaQuKCT6InmbuEyUne4mTuxQ== +any-promise@^1.0.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/any-promise/-/any-promise-1.3.0.tgz#abc6afeedcea52e809cdc0376aed3ce39635d17f" + integrity sha512-7UvmKalWRt1wgjL1RrGxoSJW/0QZFIegpeGvZG9kjp8vrRu55XTHbwnqq2GpXm9uLbcuhxm3IqX9OB4MZR1b2A== + anymatch@^3.0.3, anymatch@~3.1.2: version "3.1.2" resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-3.1.2.tgz#c0557c096af32f106198f4f4e2a383537e378716" @@ -5312,6 +5331,11 @@ call-bind@^1.0.0, call-bind@^1.0.2: function-bind "^1.1.1" get-intrinsic "^1.0.2" +call-me-maybe@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/call-me-maybe/-/call-me-maybe-1.0.1.tgz#26d208ea89e37b5cbde60250a15f031c16a4d66b" + integrity sha512-wCyFsDQkKPwwF8BDwOiWNx/9K45L/hvggQiDbve+viMNMQnWhrlYIuBk09offfwCRtCO9P6XwUttufzU11WCVw== + callsites@^3.0.0, callsites@^3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/callsites/-/callsites-3.1.0.tgz#b3630abd8943432f54b3f0519238e33cd7df2f73" @@ -5552,6 +5576,17 @@ cli-boxes@^3.0.0: resolved "https://registry.yarnpkg.com/cli-boxes/-/cli-boxes-3.0.0.tgz#71a10c716feeba005e4504f36329ef0b17cf3145" integrity sha512-/lzGpEWL/8PfI0BmBOPRwp0c/wFNX1RdUML3jK/RcSBA9T8mZDdQpqYBKtCFTOfQbwPqWEOpjqW+Fnayc0969g== +cli-color@^2.0.2: + version "2.0.3" + resolved "https://registry.yarnpkg.com/cli-color/-/cli-color-2.0.3.tgz#73769ba969080629670f3f2ef69a4bf4e7cc1879" + integrity sha512-OkoZnxyC4ERN3zLzZaY9Emb7f/MhBOIpePv0Ycok0fJYT+Ouo00UBEIwsVsr0yoow++n5YWlSUgST9GKhNHiRQ== + dependencies: + d "^1.0.1" + es5-ext "^0.10.61" + es6-iterator "^2.0.3" + memoizee "^0.4.15" + timers-ext "^0.1.7" + cli-cursor@3.1.0, cli-cursor@^3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/cli-cursor/-/cli-cursor-3.1.0.tgz#264305a7ae490d1d03bf0c9ba7c925d1753af307" @@ -6366,6 +6401,14 @@ cypress@8.3.0: url "^0.11.0" yauzl "^2.10.0" +d@1, d@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/d/-/d-1.0.1.tgz#8698095372d58dbee346ffd0c7093f99f8f9eb5a" + integrity sha512-m62ShEObQ39CfralilEQRjH6oAMtNCV1xJyEx5LpRYUVN+EviphDgUc/F3hnYbADmkiNs67Y+3ylmlG7Lnu+FA== + dependencies: + es5-ext "^0.10.50" + type "^1.0.1" + damerau-levenshtein@^1.0.8: version "1.0.8" resolved "https://registry.yarnpkg.com/damerau-levenshtein/-/damerau-levenshtein-1.0.8.tgz#b43d286ccbd36bc5b2f7ed41caf2d0aba1f8a6e7" @@ -6972,6 +7015,42 @@ es-to-primitive@^1.2.1: is-date-object "^1.0.1" is-symbol "^1.0.2" +es5-ext@^0.10.35, es5-ext@^0.10.46, es5-ext@^0.10.50, es5-ext@^0.10.53, es5-ext@^0.10.61, es5-ext@~0.10.14, es5-ext@~0.10.2, es5-ext@~0.10.46: + version "0.10.61" + resolved "https://registry.yarnpkg.com/es5-ext/-/es5-ext-0.10.61.tgz#311de37949ef86b6b0dcea894d1ffedb909d3269" + integrity sha512-yFhIqQAzu2Ca2I4SE2Au3rxVfmohU9Y7wqGR+s7+H7krk26NXhIRAZDgqd6xqjCEFUomDEA3/Bo/7fKmIkW1kA== + dependencies: + es6-iterator "^2.0.3" + es6-symbol "^3.1.3" + next-tick "^1.1.0" + +es6-iterator@^2.0.3: + version "2.0.3" + resolved "https://registry.yarnpkg.com/es6-iterator/-/es6-iterator-2.0.3.tgz#a7de889141a05a94b0854403b2d0a0fbfa98f3b7" + integrity sha512-zw4SRzoUkd+cl+ZoE15A9o1oQd920Bb0iOJMQkQhl3jNc03YqVjAhG7scf9C5KWRU/R13Orf588uCC6525o02g== + dependencies: + d "1" + es5-ext "^0.10.35" + es6-symbol "^3.1.1" + +es6-symbol@^3.1.1, es6-symbol@^3.1.3: + version "3.1.3" + resolved "https://registry.yarnpkg.com/es6-symbol/-/es6-symbol-3.1.3.tgz#bad5d3c1bcdac28269f4cb331e431c78ac705d18" + integrity sha512-NJ6Yn3FuDinBaBRWl/q5X/s4koRHBrgKAu+yGI6JCBeiu3qrcbJhwT2GeR/EXVfylRk8dpQVJoLEFhK+Mu31NA== + dependencies: + d "^1.0.1" + ext "^1.1.2" + +es6-weak-map@^2.0.3: + version "2.0.3" + resolved "https://registry.yarnpkg.com/es6-weak-map/-/es6-weak-map-2.0.3.tgz#b6da1f16cc2cc0d9be43e6bdbfc5e7dfcdf31d53" + integrity sha512-p5um32HOTO1kP+w7PRnB+5lQ43Z6muuMuIMffvDN8ZB4GcnjLBV6zGStpbASIMk4DCAvEaamhe2zhyCb/QXXsA== + dependencies: + d "1" + es5-ext "^0.10.46" + es6-iterator "^2.0.3" + es6-symbol "^3.1.1" + escalade@^3.1.1: version "3.1.1" resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.1.1.tgz#d8cfdc7000965c5a0174b4a82eaa5c0552742e40" @@ -7254,6 +7333,14 @@ eval@^0.1.8: "@types/node" "*" require-like ">= 0.1.1" +event-emitter@^0.3.5: + version "0.3.5" + resolved "https://registry.yarnpkg.com/event-emitter/-/event-emitter-0.3.5.tgz#df8c69eef1647923c7157b9ce83840610b02cc39" + integrity sha512-D9rRn9y7kLPnJ+hMq7S/nhvoKwwvVJahBi2BPmx3bvbsEdK3W9ii8cBSGjP+72/LnM4n6fo3+dkCX5FeTQruXA== + dependencies: + d "1" + es5-ext "~0.10.14" + eventemitter2@^6.4.3: version "6.4.5" resolved "https://registry.yarnpkg.com/eventemitter2/-/eventemitter2-6.4.5.tgz#97380f758ae24ac15df8353e0cc27f8b95644655" @@ -7385,6 +7472,13 @@ express@^4.17.3: utils-merge "1.0.1" vary "~1.1.2" +ext@^1.1.2: + version "1.6.0" + resolved "https://registry.yarnpkg.com/ext/-/ext-1.6.0.tgz#3871d50641e874cc172e2b53f919842d19db4c52" + integrity sha512-sdBImtzkq2HpkdRLtlLWDa6w4DX22ijZLKx8BMPUuKe1c5lbN6xwQDQCxSfxBQnHZ13ls/FH0MQZx/q/gr6FQg== + dependencies: + type "^2.5.0" + extend-shallow@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/extend-shallow/-/extend-shallow-2.0.1.tgz#51af7d614ad9a9f610ea1bafbb989d6b1c56890f" @@ -7979,6 +8073,13 @@ glob-parent@^6.0.1: dependencies: is-glob "^4.0.3" +glob-promise@^4.2.2: + version "4.2.2" + resolved "https://registry.yarnpkg.com/glob-promise/-/glob-promise-4.2.2.tgz#15f44bcba0e14219cd93af36da6bb905ff007877" + integrity sha512-xcUzJ8NWN5bktoTIX7eOclO1Npxd/dyVqUJxlLIDasT4C7KZyqlPIwkdJ0Ypiy3p2ZKahTjK4M9uC3sNSfNMzw== + dependencies: + "@types/glob" "^7.1.3" + glob-to-regexp@^0.4.1: version "0.4.1" resolved "https://registry.yarnpkg.com/glob-to-regexp/-/glob-to-regexp-0.4.1.tgz#c75297087c851b9a578bd217dd59a92f59fe546e" @@ -8968,6 +9069,11 @@ is-plain-object@^5.0.0: resolved "https://registry.yarnpkg.com/is-plain-object/-/is-plain-object-5.0.0.tgz#4427f50ab3429e9025ea7d52e9043a9ef4159344" integrity sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q== +is-promise@^2.2.2: + version "2.2.2" + resolved "https://registry.yarnpkg.com/is-promise/-/is-promise-2.2.2.tgz#39ab959ccbf9a774cf079f7b40c7a26f763135f1" + integrity sha512-+lP4/6lKUBfQjZ2pdxThZvLUAafmZb8OAxFb8XXtiQmS35INgr85hdOGoEs124ez1FCnZJt6jau/T+alh58QFQ== + is-reference@^1.2.1: version "1.2.1" resolved "https://registry.yarnpkg.com/is-reference/-/is-reference-1.2.1.tgz#8b2dac0b371f4bc994fdeaba9eb542d03002d0b7" @@ -9755,6 +9861,26 @@ json-parse-even-better-errors@^2.3.0, json-parse-even-better-errors@^2.3.1: resolved "https://registry.yarnpkg.com/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz#7c47805a94319928e05777405dc12e1f7a4ee02d" integrity sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w== +json-schema-to-typescript@^11.0.1: + version "11.0.1" + resolved "https://registry.yarnpkg.com/json-schema-to-typescript/-/json-schema-to-typescript-11.0.1.tgz#9203036817ca797f1116cbfe9163e8a4ec948bc3" + integrity sha512-iQFEErdr9PWQUN3kLvaFFdgWAfwBeqH3PMzxza4NpSU/8uadwHKKi66Hgu5Rb3NeVSk85xkwTYIeuah+R0ASeA== + dependencies: + "@apidevtools/json-schema-ref-parser" "https://github.com/bcherny/json-schema-ref-parser.git#984282d34a2993e5243aa35100fe32a63699164d" + "@types/json-schema" "^7.0.11" + "@types/lodash" "^4.14.182" + "@types/prettier" "^2.6.1" + cli-color "^2.0.2" + get-stdin "^8.0.0" + glob "^7.1.6" + glob-promise "^4.2.2" + is-glob "^4.0.3" + lodash "^4.17.21" + minimist "^1.2.6" + mkdirp "^1.0.4" + mz "^2.7.0" + prettier "^2.6.2" + json-schema-traverse@^0.4.1: version "0.4.1" resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz#69f6a87d9513ab8bb8fe63bdb0979c448e684660" @@ -9765,7 +9891,7 @@ json-schema-traverse@^1.0.0: resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz#ae7bcb3656ab77a73ba5c49bf654f38e6b6860e2" integrity sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug== -json-schema@*, json-schema@0.4.0: +json-schema@*, json-schema@0.4.0, json-schema@^0.4.0: version "0.4.0" resolved "https://registry.yarnpkg.com/json-schema/-/json-schema-0.4.0.tgz#f7de4cf6efab838ebaeb3236474cbba5a1930ab5" integrity sha512-es94M3nTIfsEPisRafak+HDLfHXnKBhV3vU5eqPcS3flIWqcxJWgXHXiey3YrpaNsanY5ei1VoYEbOzijuq9BA== @@ -10266,6 +10392,13 @@ lru-cache@^7.4.4, lru-cache@^7.5.1, lru-cache@^7.7.1: resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-7.10.1.tgz#db577f42a94c168f676b638d15da8fb073448cab" integrity sha512-BQuhQxPuRl79J5zSXRP+uNzPOyZw2oFI9JLRQ80XswSvg21KMKNtQza9eF42rfI/3Z40RvzBdXgziEkudzjo8A== +lru-queue@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/lru-queue/-/lru-queue-0.1.0.tgz#2738bd9f0d3cf4f84490c5736c48699ac632cda3" + integrity sha512-BpdYkt9EvGl8OfWHDQPISVpcl5xZthb+XPsbELj5AQXxIC8IriDZIQYjBJPEm5rS420sjZ0TLEzRcq5KdBhYrQ== + dependencies: + es5-ext "~0.10.2" + lzstring.ts@^2.0.2: version "2.0.2" resolved "https://registry.yarnpkg.com/lzstring.ts/-/lzstring.ts-2.0.2.tgz#1d269bd6ab423713f31e614f67018110ed860129" @@ -10443,6 +10576,20 @@ memfs@^3.1.2, memfs@^3.4.1: dependencies: fs-monkey "1.0.3" +memoizee@^0.4.15: + version "0.4.15" + resolved "https://registry.yarnpkg.com/memoizee/-/memoizee-0.4.15.tgz#e6f3d2da863f318d02225391829a6c5956555b72" + integrity sha512-UBWmJpLZd5STPm7PMUlOw/TSy972M+z8gcyQ5veOnSDRREz/0bmpyTfKt3/51DhEBqCZQn1udM/5flcSPYhkdQ== + dependencies: + d "^1.0.1" + es5-ext "^0.10.53" + es6-weak-map "^2.0.3" + event-emitter "^0.3.5" + is-promise "^2.2.2" + lru-queue "^0.1.0" + next-tick "^1.1.0" + timers-ext "^0.1.7" + meow@^8.0.0: version "8.1.2" resolved "https://registry.yarnpkg.com/meow/-/meow-8.1.2.tgz#bcbe45bda0ee1729d350c03cffc8395a36c4e897" @@ -10743,6 +10890,15 @@ mute-stream@0.0.8, mute-stream@~0.0.4: resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.8.tgz#1630c42b2251ff81e2a283de96a5497ea92e5e0d" integrity sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA== +mz@^2.7.0: + version "2.7.0" + resolved "https://registry.yarnpkg.com/mz/-/mz-2.7.0.tgz#95008057a56cafadc2bc63dde7f9ff6955948e32" + integrity sha512-z81GNO7nnYMEhrGh9LeymoE4+Yr0Wn5McHIZMK5cfQCl+NDX08sCZgUc9/6MHni9IWuFLm1Z3HTCXu2z9fN62Q== + dependencies: + any-promise "^1.0.0" + object-assign "^4.0.1" + thenify-all "^1.0.0" + nanoid@^3.3.4: version "3.3.4" resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.4.tgz#730b67e3cd09e2deacf03c027c81c9d9dbc5e8ab" @@ -10768,6 +10924,11 @@ neo-async@^2.6.0, neo-async@^2.6.2: resolved "https://registry.yarnpkg.com/neo-async/-/neo-async-2.6.2.tgz#b4aafb93e3aeb2d8174ca53cf163ab7d7308305f" integrity sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw== +next-tick@1, next-tick@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/next-tick/-/next-tick-1.1.0.tgz#1836ee30ad56d67ef281b22bd199f709449b35eb" + integrity sha512-CXdUiJembsNjuToQvxayPZF9Vqht7hewsvy2sOWafLvi2awflj9mOC6bHIg50orX8IJvWKY9wYQ/zB2kogPslQ== + no-case@^3.0.4: version "3.0.4" resolved "https://registry.yarnpkg.com/no-case/-/no-case-3.0.4.tgz#d361fd5c9800f558551a8369fc0dcd4662b6124d" @@ -11109,7 +11270,7 @@ nx@14.5.4, "nx@>=14.5.4 < 16": yargs "^17.4.0" yargs-parser "21.0.1" -object-assign@^4.1.0, object-assign@^4.1.1: +object-assign@^4.0.1, object-assign@^4.1.0, object-assign@^4.1.1: version "4.1.1" resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863" integrity sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM= @@ -11997,6 +12158,11 @@ prettier@*, prettier@2.7.1: resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.7.1.tgz#e235806850d057f97bb08368a4f7d899f7760c64" integrity sha512-ujppO+MkdPqoVINuDFDRLClm7D78qbDt0/NR+wp5FqEZOoTNAjPHWj17QRhu7geIHJfcNhRk1XVQmF8Bp3ye+g== +prettier@^2.6.2: + version "2.7.1" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.7.1.tgz#e235806850d057f97bb08368a4f7d899f7760c64" + integrity sha512-ujppO+MkdPqoVINuDFDRLClm7D78qbDt0/NR+wp5FqEZOoTNAjPHWj17QRhu7geIHJfcNhRk1XVQmF8Bp3ye+g== + pretty-bytes@^5.6.0: version "5.6.0" resolved "https://registry.yarnpkg.com/pretty-bytes/-/pretty-bytes-5.6.0.tgz#356256f643804773c82f64723fe78c92c62beaeb" @@ -13762,6 +13928,20 @@ text-table@^0.2.0: resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4" integrity sha1-f17oI66AUgfACvLfSoTsP8+lcLQ= +thenify-all@^1.0.0: + version "1.6.0" + resolved "https://registry.yarnpkg.com/thenify-all/-/thenify-all-1.6.0.tgz#1a1918d402d8fc3f98fbf234db0bcc8cc10e9726" + integrity sha512-RNxQH/qI8/t3thXJDwcstUO4zeqo64+Uy/+sNVRBx4Xn2OX+OZ9oP+iJnNFqplFra2ZUVeKCSa2oVWi3T4uVmA== + dependencies: + thenify ">= 3.1.0 < 4" + +"thenify@>= 3.1.0 < 4": + version "3.3.1" + resolved "https://registry.yarnpkg.com/thenify/-/thenify-3.3.1.tgz#8932e686a4066038a016dd9e2ca46add9838a95f" + integrity sha512-RVZSIV5IG10Hk3enotrhvz0T9em6cyHBLkH/YAZuKqd8hRkKhSfCGIcP2KUY0EPxndzANBmNllzWPwak+bheSw== + dependencies: + any-promise "^1.0.0" + throat@^6.0.1: version "6.0.1" resolved "https://registry.yarnpkg.com/throat/-/throat-6.0.1.tgz#d514fedad95740c12c2d7fc70ea863eb51ade375" @@ -13797,6 +13977,14 @@ thunky@^1.0.2: resolved "https://registry.yarnpkg.com/thunky/-/thunky-1.1.0.tgz#5abaf714a9405db0504732bbccd2cedd9ef9537d" integrity sha512-eHY7nBftgThBqOyHGVN+l8gF0BucP09fMo0oO/Lb0w1OF80dJv+lDVpXG60WMQvkcxAkNybKsrEIE3ZtKGmPrA== +timers-ext@^0.1.7: + version "0.1.7" + resolved "https://registry.yarnpkg.com/timers-ext/-/timers-ext-0.1.7.tgz#6f57ad8578e07a3fb9f91d9387d65647555e25c6" + integrity sha512-b85NUNzTSdodShTIbky6ZF02e8STtVVfD+fu4aXXShEELpozH+bCpJLYMPZbsABN2wDH7fJpqIoXxJpzbf0NqQ== + dependencies: + es5-ext "~0.10.46" + next-tick "1" + timsort@~0.3.0: version "0.3.0" resolved "https://registry.yarnpkg.com/timsort/-/timsort-0.3.0.tgz#405411a8e7e6339fe64db9a234de11dc31e02bd4" @@ -14054,6 +14242,16 @@ type-is@~1.6.18: media-typer "0.3.0" mime-types "~2.1.24" +type@^1.0.1: + version "1.2.0" + resolved "https://registry.yarnpkg.com/type/-/type-1.2.0.tgz#848dd7698dafa3e54a6c479e759c4bc3f18847a0" + integrity sha512-+5nt5AAniqsCnu2cEQQdpzCAh33kVx8n0VoFidKpB1dVVLAN/F+bgVOqOJqOnEnrhp222clB5p3vUlD+1QAnfg== + +type@^2.5.0: + version "2.6.0" + resolved "https://registry.yarnpkg.com/type/-/type-2.6.0.tgz#3ca6099af5981d36ca86b78442973694278a219f" + integrity sha512-eiDBDOmkih5pMbo9OqsqPRGMljLodLcwd5XD5JbtNB0o89xZAwynY9EdCDsJU7LtcVCClu9DvM7/0Ep1hYX3EQ== + typedarray-to-buffer@^3.1.5: version "3.1.5" resolved "https://registry.yarnpkg.com/typedarray-to-buffer/-/typedarray-to-buffer-3.1.5.tgz#a97ee7a9ff42691b9f783ff1bc5112fe3fca9080"