From 93505f50d6c371d0b0af1536a7282f167c95870f Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Thu, 22 Aug 2024 23:17:05 -0400 Subject: [PATCH] docs: fill in most remainng rule option descriptions --- .../docs/rules/ban-ts-comment.mdx | 2 +- .../docs/rules/consistent-type-assertions.mdx | 7 ++- .../docs/rules/consistent-type-exports.mdx | 2 +- .../docs/rules/consistent-type-imports.mdx | 6 +-- .../eslint-plugin/docs/rules/dot-notation.mdx | 8 ++++ .../rules/explicit-member-accessibility.mdx | 3 +- .../eslint-plugin/docs/rules/max-params.mdx | 42 ++++++++++++++++ .../docs/rules/no-base-to-string.mdx | 3 +- .../rules/no-confusing-void-expression.mdx | 8 +++- .../docs/rules/no-inferrable-types.mdx | 4 ++ .../docs/rules/no-invalid-void-type.mdx | 4 +- .../docs/rules/no-magic-numbers.mdx | 8 ++-- .../rules/no-meaningless-void-operator.mdx | 2 +- .../docs/rules/no-misused-promises.mdx | 2 + .../eslint-plugin/docs/rules/no-redeclare.mdx | 2 +- .../docs/rules/no-restricted-imports.mdx | 2 +- .../eslint-plugin/docs/rules/no-shadow.mdx | 4 +- .../docs/rules/no-use-before-define.mdx | 8 +++- .../docs/rules/prefer-literal-enum-member.mdx | 2 +- .../docs/rules/prefer-nullish-coalescing.mdx | 10 ++-- .../rules/prefer-readonly-parameter-types.mdx | 10 ++-- .../docs/rules/promise-function-async.mdx | 4 +- packages/eslint-plugin/docs/rules/typedef.mdx | 2 +- .../eslint-plugin/src/rules/ban-ts-comment.ts | 2 + .../src/rules/consistent-type-assertions.ts | 4 ++ .../src/rules/consistent-type-exports.ts | 3 +- .../src/rules/consistent-type-imports.ts | 6 ++- .../eslint-plugin/src/rules/dot-notation.ts | 8 ++++ .../rules/explicit-member-accessibility.ts | 2 +- .../eslint-plugin/src/rules/max-params.ts | 10 +++- .../src/rules/no-base-to-string.ts | 2 + .../src/rules/no-confusing-void-expression.ts | 12 ++++- .../rules/no-duplicate-type-constituents.ts | 2 + .../src/rules/no-empty-function.ts | 2 + .../src/rules/no-empty-interface.ts | 2 + .../src/rules/no-empty-object-type.ts | 4 ++ .../src/rules/no-floating-promises.ts | 11 ++++- .../src/rules/no-inferrable-types.ts | 2 + .../src/rules/no-invalid-void-type.ts | 4 ++ .../src/rules/no-magic-numbers.ts | 5 ++ .../src/rules/no-meaningless-void-operator.ts | 2 + .../src/rules/no-misused-promises.ts | 37 +++++++++++--- .../eslint-plugin/src/rules/no-redeclare.ts | 4 ++ packages/eslint-plugin/src/rules/no-shadow.ts | 11 +++++ .../eslint-plugin/src/rules/no-unused-vars.ts | 24 ++++++++-- .../src/rules/no-use-before-define.ts | 33 ++++++++++--- .../src/rules/only-throw-error.ts | 4 ++ .../src/rules/parameter-properties.ts | 4 ++ .../src/rules/prefer-literal-enum-member.ts | 2 + .../src/rules/prefer-nullish-coalescing.ts | 10 ++++ .../src/rules/prefer-promise-reject-errors.ts | 2 + .../rules/prefer-readonly-parameter-types.ts | 15 ++++-- .../src/rules/prefer-readonly.ts | 2 + .../src/rules/promise-function-async.ts | 5 ++ .../eslint-plugin/src/rules/return-await.ts | 30 +++++++++--- .../src/rules/strict-boolean-expressions.ts | 45 +++++++++++++---- .../src/rules/triple-slash-reference.ts | 6 +++ packages/eslint-plugin/src/rules/typedef.ts | 48 +++++++++++++++---- .../max-params.shot | 22 +++++++++ .../schema-snapshots/ban-ts-comment.shot | 2 + .../consistent-type-assertions.shot | 20 ++++++-- .../consistent-type-exports.shot | 2 + .../consistent-type-imports.shot | 16 ++++++- .../tests/schema-snapshots/dot-notation.shot | 10 ++++ .../explicit-member-accessibility.shot | 2 + .../tests/schema-snapshots/max-params.shot | 6 +++ .../schema-snapshots/no-base-to-string.shot | 2 + .../no-confusing-void-expression.shot | 4 ++ .../no-duplicate-type-constituents.shot | 4 ++ .../schema-snapshots/no-empty-function.shot | 2 + .../schema-snapshots/no-empty-interface.shot | 2 + .../no-empty-object-type.shot | 17 ++++++- .../no-floating-promises.shot | 4 ++ .../schema-snapshots/no-inferrable-types.shot | 4 ++ .../no-invalid-void-type.shot | 9 +++- .../schema-snapshots/no-magic-numbers.shot | 8 ++++ .../no-meaningless-void-operator.shot | 2 + .../schema-snapshots/no-misused-promises.shot | 14 ++++++ .../tests/schema-snapshots/no-redeclare.shot | 4 ++ .../tests/schema-snapshots/no-shadow.shot | 18 ++++++- .../schema-snapshots/no-unused-vars.shot | 36 ++++++++++++-- .../no-use-before-define.shot | 12 +++++ .../schema-snapshots/only-throw-error.shot | 4 ++ .../parameter-properties.shot | 9 +++- .../prefer-literal-enum-member.shot | 2 + .../prefer-nullish-coalescing.shot | 15 +++++- .../prefer-promise-reject-errors.shot | 2 + .../prefer-readonly-parameter-types.shot | 8 ++++ .../schema-snapshots/prefer-readonly.shot | 2 + .../promise-function-async.shot | 8 ++++ .../tests/schema-snapshots/return-await.shot | 35 +++++++++++--- .../strict-boolean-expressions.shot | 16 +++++++ .../triple-slash-reference.shot | 22 +++++++-- .../tests/schema-snapshots/typedef.shot | 16 +++++++ 94 files changed, 764 insertions(+), 107 deletions(-) create mode 100644 packages/eslint-plugin/tests/docs-eslint-output-snapshots/max-params.shot diff --git a/packages/eslint-plugin/docs/rules/ban-ts-comment.mdx b/packages/eslint-plugin/docs/rules/ban-ts-comment.mdx index ca36964e28cb..8f287665a3ce 100644 --- a/packages/eslint-plugin/docs/rules/ban-ts-comment.mdx +++ b/packages/eslint-plugin/docs/rules/ban-ts-comment.mdx @@ -153,7 +153,7 @@ if (false) { ## When Not To Use It -If your project or its dependencies were not architected with strong type safety in mind, it can be difficult to always adhere to proper TypeScript semantics. +If your project or its dependencies were not architected with strong type safety in mind, it can be difficult to always adhere to proper TypeScript semantics. You might consider using [ESLint disable comments](https://eslint.org/docs/latest/use/configure/rules#using-configuration-comments-1) for those specific situations instead of completely disabling this rule. ## Further Reading diff --git a/packages/eslint-plugin/docs/rules/consistent-type-assertions.mdx b/packages/eslint-plugin/docs/rules/consistent-type-assertions.mdx index 225c35e92195..cf437b9ed714 100644 --- a/packages/eslint-plugin/docs/rules/consistent-type-assertions.mdx +++ b/packages/eslint-plugin/docs/rules/consistent-type-assertions.mdx @@ -30,7 +30,7 @@ Examples of them include `let x = "hello" as const;` and `let x = "hello" ### `assertionStyle` -This option defines the expected assertion style. Valid values for `assertionStyle` are: +The expected assertion style to enforce. Valid values for `assertionStyle` are: - `as` will enforce that you always use `... as foo`. - `angle-bracket` will enforce that you always use `...` @@ -42,7 +42,10 @@ Some codebases like to go for an extra level of type safety, and ban assertions ### `objectLiteralTypeAssertions` -Always prefer `const x: T = { ... };` to `const x = { ... } as T;` (or similar with angle brackets). The type assertion in the latter case is either unnecessary or will probably hide an error. +Whether to always prefer type declarations for object literals used as variable initializers, rather than type assertions. + +For example, this would prefer `const x: T = { ... };` to `const x = { ... } as T;` (or similar with angle brackets). +The type assertion in the latter case is either unnecessary or will probably hide an error. The compiler will warn for excess properties with this syntax, but not missing _required_ fields. For example: `const x: { foo: number } = {};` will fail to compile, but `const x = {} as { foo: number }` will succeed. diff --git a/packages/eslint-plugin/docs/rules/consistent-type-exports.mdx b/packages/eslint-plugin/docs/rules/consistent-type-exports.mdx index 7c699d1096aa..7c2ed45dcda9 100644 --- a/packages/eslint-plugin/docs/rules/consistent-type-exports.mdx +++ b/packages/eslint-plugin/docs/rules/consistent-type-exports.mdx @@ -54,7 +54,7 @@ export type { ButtonProps }; ### `fixMixedExportsWithInlineTypeSpecifier` -When this is set to true, the rule will autofix "mixed" export cases using TS 4.5's "inline type specifier". +Whether the rule will autofix "mixed" export cases using TS inline type specifiers. If you are using a TypeScript version less than 4.5, then you will not be able to use this option. For example the following code: diff --git a/packages/eslint-plugin/docs/rules/consistent-type-imports.mdx b/packages/eslint-plugin/docs/rules/consistent-type-imports.mdx index 8df00017e565..cacc53d50a2c 100644 --- a/packages/eslint-plugin/docs/rules/consistent-type-imports.mdx +++ b/packages/eslint-plugin/docs/rules/consistent-type-imports.mdx @@ -18,7 +18,7 @@ This allows transpilers to drop imports without knowing the types of the depende ### `prefer` -This option defines the expected import kind for type-only imports. Valid values for `prefer` are: +The expected import kind for type-only imports. Valid values for `prefer` are: - `type-imports` will enforce that you always use `import type Foo from '...'` except referenced by metadata of decorators. It is the default. - `no-type-imports` will enforce that you always use `import Foo from '...'`. @@ -43,7 +43,7 @@ const x: Bar = 1; ### `fixStyle` -This option defines the expected type modifier to be added when an import is detected as used only in the type position. Valid values for `fixStyle` are: +The expected type modifier to be added when an import is detected as used only in the type position. Valid values for `fixStyle` are: - `separate-type-imports` will add the type keyword after the import keyword `import type { A } from '...'`. It is the default. - `inline-type-imports` will inline the type keyword `import { type A } from '...'` and is only available in TypeScript 4.5 and onwards. See [documentation here](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-5.html#type-modifiers-on-import-names 'TypeScript 4.5 documentation on type modifiers and import names'). @@ -83,7 +83,7 @@ const x: Bar = 1; ### `disallowTypeAnnotations` -If `true`, type imports in type annotations (`import()`) are not allowed. +Whether to disallow type imports in type annotations (`import()`). Default is `true`. Examples of **incorrect** code with `{disallowTypeAnnotations: true}`: diff --git a/packages/eslint-plugin/docs/rules/dot-notation.mdx b/packages/eslint-plugin/docs/rules/dot-notation.mdx index ba23d98b366f..cf44c44028b8 100644 --- a/packages/eslint-plugin/docs/rules/dot-notation.mdx +++ b/packages/eslint-plugin/docs/rules/dot-notation.mdx @@ -38,6 +38,9 @@ If the TypeScript compiler option `noPropertyAccessFromIndexSignature` is set to ### `allowPrivateClassPropertyAccess` +Whether to allow accessing class members marked as `private` with array notation. +This can be useful because TypeScript will report a type error on dot notation but not array notation. + Example of a correct code when `allowPrivateClassPropertyAccess` is set to `true`: ```ts option='{ "allowPrivateClassPropertyAccess": true }' showPlaygroundButton @@ -51,6 +54,9 @@ x['priv_prop'] = 123; ### `allowProtectedClassPropertyAccess` +Whether to allow accessing class members marked as `protected` with array notation. +This can be useful because TypeScript will report a type error on dot notation but not array notation. + Example of a correct code when `allowProtectedClassPropertyAccess` is set to `true`: ```ts option='{ "allowProtectedClassPropertyAccess": true }' showPlaygroundButton @@ -64,6 +70,8 @@ x['protected_prop'] = 123; ### `allowIndexSignaturePropertyAccess` +Whether to allow accessing properties matching an index signature with array notation. + Example of correct code when `allowIndexSignaturePropertyAccess` is set to `true`: ```ts option='{ "allowIndexSignaturePropertyAccess": true }' showPlaygroundButton diff --git a/packages/eslint-plugin/docs/rules/explicit-member-accessibility.mdx b/packages/eslint-plugin/docs/rules/explicit-member-accessibility.mdx index 59eaa315afb1..60f4f6c2a810 100644 --- a/packages/eslint-plugin/docs/rules/explicit-member-accessibility.mdx +++ b/packages/eslint-plugin/docs/rules/explicit-member-accessibility.mdx @@ -317,7 +317,8 @@ class Animal { ### `ignoredMethodNames` -If you want to ignore some specific methods, you can do it by specifying method names. Note that this option does not care for the context, and will ignore every method with these names, which could lead to it missing some cases. You should use this sparingly. +Specific method names that may be ignored. +Note that this option does not care for the context, and will ignore every method with these names, which could lead to it missing some cases. You should use this sparingly. e.g. `[ { ignoredMethodNames: ['specificMethod', 'whateverMethod'] } ]` ```ts option='{ "ignoredMethodNames": ["specificMethod", "whateverMethod"] }' showPlaygroundButton diff --git a/packages/eslint-plugin/docs/rules/max-params.mdx b/packages/eslint-plugin/docs/rules/max-params.mdx index 3e1d80bb1563..1797dffaec73 100644 --- a/packages/eslint-plugin/docs/rules/max-params.mdx +++ b/packages/eslint-plugin/docs/rules/max-params.mdx @@ -11,3 +11,45 @@ import TabItem from '@theme/TabItem'; This rule extends the base [`eslint/max-params`](https://eslint.org/docs/rules/max-params) rule. This version adds support for TypeScript `this` parameters so they won't be counted as a parameter. + +## Options + +This rule adds the following options: + +```ts +interface Options extends BaseMaxParamsOptions { + countVoidThis?: boolean; +} + +const defaultOptions: Options = { + ...baseMaxParamsOptions, + countVoidThis: false, +}; +``` + +### `countVoidThis` + +Whether to count a `this` declaration when the type is `void`. + +Example of a code when `countVoidThis` is set to `false` and `max` is `1`: + + + + +```ts option='{ "countVoidThis": false, "max": 1 }' +function hasNoThis(this: void, first: string, second: string) { + // ... +} +``` + + + + +```ts option='{ "countVoidThis": false, "max": 1 }' +function hasNoThis(this: void, first: string) { + // ... +} +``` + + + diff --git a/packages/eslint-plugin/docs/rules/no-base-to-string.mdx b/packages/eslint-plugin/docs/rules/no-base-to-string.mdx index f959897d7e68..97767da415b8 100644 --- a/packages/eslint-plugin/docs/rules/no-base-to-string.mdx +++ b/packages/eslint-plugin/docs/rules/no-base-to-string.mdx @@ -66,7 +66,8 @@ const literalWithToString = { ### `ignoredTypeNames` -A string array of type names to ignore, this is useful for types missing `toString()` (but actually has `toString()`). +Stringified regular expressions of type names to ignore. +This is useful for types missing `toString()` (but actually has `toString()`). There are some types missing `toString()` in old version TypeScript, like `RegExp`, `URL`, `URLSearchParams` etc. The following patterns are considered correct with the default options `{ ignoredTypeNames: ["RegExp"] }`: diff --git a/packages/eslint-plugin/docs/rules/no-confusing-void-expression.mdx b/packages/eslint-plugin/docs/rules/no-confusing-void-expression.mdx index 043b07521c6b..b779558319b7 100644 --- a/packages/eslint-plugin/docs/rules/no-confusing-void-expression.mdx +++ b/packages/eslint-plugin/docs/rules/no-confusing-void-expression.mdx @@ -77,8 +77,10 @@ cond ? console.log('true') : console.error('false'); ### `ignoreArrowShorthand` -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. +Whether to ignore "shorthand" `() =>` arrow functions: those without `{ ... }` braces. + +It might be undesirable to wrap every arrow function shorthand expression. +Especially when using the Prettier formatter, which spreads such code across 3 lines instead of 1. Examples of additional **correct** code with this option enabled: @@ -88,6 +90,8 @@ promise.then(value => window.postMessage(value)); ### `ignoreVoidOperator` +Whether to ignore returns that start with the `void` operator. + 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-inferrable-types.mdx b/packages/eslint-plugin/docs/rules/no-inferrable-types.mdx index ff21a3538a35..0cf7caa4d767 100644 --- a/packages/eslint-plugin/docs/rules/no-inferrable-types.mdx +++ b/packages/eslint-plugin/docs/rules/no-inferrable-types.mdx @@ -80,6 +80,8 @@ function fn(a = 5, b = true) {} ### `ignoreParameters` +Whether to ignore function parameters. + When set to true, the following pattern is considered valid: ```ts option='{ "ignoreParameters": true }' showPlaygroundButton @@ -90,6 +92,8 @@ function foo(a: number = 5, b: boolean = true) { ### `ignoreProperties` +Whether to ignore class properties. + When set to true, the following pattern is considered valid: ```ts option='{ "ignoreProperties": true }' showPlaygroundButton diff --git a/packages/eslint-plugin/docs/rules/no-invalid-void-type.mdx b/packages/eslint-plugin/docs/rules/no-invalid-void-type.mdx index d73d09512264..1e6a1507a3fa 100644 --- a/packages/eslint-plugin/docs/rules/no-invalid-void-type.mdx +++ b/packages/eslint-plugin/docs/rules/no-invalid-void-type.mdx @@ -62,7 +62,7 @@ type stillVoid = void | never; ### `allowInGenericTypeArguments` -This option lets you control if `void` can be used as a valid value for generic type parameters. +Whether `void` can be used as a valid value for generic type parameters. Alternatively, you can provide an array of strings which whitelist which types may accept `void` as a generic type parameter. @@ -98,7 +98,7 @@ type AllowedVoidUnion = void | Ex.Mx.Tx; ### `allowAsThisParameter` -This option allows specifying a `this` parameter of a function to be `void` when set to `true`. +Whether a `this` parameter of a function may be `void`. This pattern can be useful to explicitly label function types that do not use a `this` argument. [See the TypeScript docs for more information](https://www.typescriptlang.org/docs/handbook/functions.html#this-parameters-in-callbacks). This option is `false` by default. diff --git a/packages/eslint-plugin/docs/rules/no-magic-numbers.mdx b/packages/eslint-plugin/docs/rules/no-magic-numbers.mdx index c8a2058791ee..2110f5bed847 100644 --- a/packages/eslint-plugin/docs/rules/no-magic-numbers.mdx +++ b/packages/eslint-plugin/docs/rules/no-magic-numbers.mdx @@ -39,7 +39,7 @@ const defaultOptions: Options = { ### `ignoreEnums` -A boolean to specify if enums used in TypeScript are considered okay. `false` by default. +Whether enums used in TypeScript are considered okay. `false` by default. Examples of **incorrect** code for the `{ "ignoreEnums": false }` option: @@ -59,7 +59,7 @@ enum foo { ### `ignoreNumericLiteralTypes` -A boolean to specify if numbers used in TypeScript numeric literal types are considered okay. `false` by default. +Whether numbers used in TypeScript numeric literal types are considered okay. `false` by default. Examples of **incorrect** code for the `{ "ignoreNumericLiteralTypes": false }` option: @@ -75,6 +75,8 @@ type SmallPrimes = 2 | 3 | 5 | 7 | 11; ### `ignoreReadonlyClassProperties` +Whether `readonly` class properties are considered okay. + Examples of **incorrect** code for the `{ "ignoreReadonlyClassProperties": false }` option: ```ts option='{ "ignoreReadonlyClassProperties": false }' showPlaygroundButton @@ -99,7 +101,7 @@ class Foo { ### `ignoreTypeIndexes` -A boolean to specify if numbers used to index types are okay. `false` by default. +Whether numbers used to index types are okay. `false` by default. Examples of **incorrect** code for the `{ "ignoreTypeIndexes": false }` option: diff --git a/packages/eslint-plugin/docs/rules/no-meaningless-void-operator.mdx b/packages/eslint-plugin/docs/rules/no-meaningless-void-operator.mdx index 905c70618710..518da46b3328 100644 --- a/packages/eslint-plugin/docs/rules/no-meaningless-void-operator.mdx +++ b/packages/eslint-plugin/docs/rules/no-meaningless-void-operator.mdx @@ -54,7 +54,7 @@ void bar(1); // discarding a number ### `checkNever` -`checkNever: true` will suggest removing `void` when the argument has type `never`. +Whether to suggest removing `void` when the argument has type `never`. ## When Not To Use It diff --git a/packages/eslint-plugin/docs/rules/no-misused-promises.mdx b/packages/eslint-plugin/docs/rules/no-misused-promises.mdx index 4ac2c491cde0..bc8ae0f33b6e 100644 --- a/packages/eslint-plugin/docs/rules/no-misused-promises.mdx +++ b/packages/eslint-plugin/docs/rules/no-misused-promises.mdx @@ -101,6 +101,8 @@ Disables checking an asynchronous function used as a variable whose return type ### `checksSpreads` +Whether to warn when `...` spreading a `Promise`. + If you don't want to check object spreads, you can add this configuration: ```json diff --git a/packages/eslint-plugin/docs/rules/no-redeclare.mdx b/packages/eslint-plugin/docs/rules/no-redeclare.mdx index 8c896acb20c9..cf0171d484e8 100644 --- a/packages/eslint-plugin/docs/rules/no-redeclare.mdx +++ b/packages/eslint-plugin/docs/rules/no-redeclare.mdx @@ -33,7 +33,7 @@ const defaultOptions: Options = { ### `ignoreDeclarationMerge` -When set to `true`, the rule will ignore declaration merges between the following sets: +Whether to ignore declaration merges between the following sets: - interface + interface - namespace + namespace diff --git a/packages/eslint-plugin/docs/rules/no-restricted-imports.mdx b/packages/eslint-plugin/docs/rules/no-restricted-imports.mdx index d74494d41e18..621bf351e833 100644 --- a/packages/eslint-plugin/docs/rules/no-restricted-imports.mdx +++ b/packages/eslint-plugin/docs/rules/no-restricted-imports.mdx @@ -45,7 +45,7 @@ You can specify this option for a specific path or pattern as follows: } ``` -When set to `true`, the rule will allow [Type-Only Imports](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export). +Whether to allow [Type-Only Imports](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export). Examples of code with the above config: diff --git a/packages/eslint-plugin/docs/rules/no-shadow.mdx b/packages/eslint-plugin/docs/rules/no-shadow.mdx index 2e9328907161..40651e2fbe99 100644 --- a/packages/eslint-plugin/docs/rules/no-shadow.mdx +++ b/packages/eslint-plugin/docs/rules/no-shadow.mdx @@ -31,7 +31,7 @@ const defaultOptions: Options = { ### `ignoreTypeValueShadow` -When set to `true`, the rule will ignore the case when you name a type the same as a variable. This is generally safe because you cannot use variables in type locations without a `typeof` operator, so there's little risk of confusion. +Whether to ignore types named the same as a variable. This is generally safe because you cannot use variables in type locations without a `typeof` operator, so there's little risk of confusion. Examples of **correct** code with `{ ignoreTypeValueShadow: true }`: @@ -55,7 +55,7 @@ _Shadowing_ specifically refers to two identical identifiers that are in differe ### `ignoreFunctionTypeParameterNameValueShadow` -When set to `true`, the rule will ignore the case when you name a parameter in a function type the same as a variable. +Whether to ignore function parameters named the same as a variable. Each of a function type's arguments creates a value variable within the scope of the function type. This is done so that you can reference the type later using the `typeof` operator: diff --git a/packages/eslint-plugin/docs/rules/no-use-before-define.mdx b/packages/eslint-plugin/docs/rules/no-use-before-define.mdx index 09afc8b973d1..29bf8b75a0a7 100644 --- a/packages/eslint-plugin/docs/rules/no-use-before-define.mdx +++ b/packages/eslint-plugin/docs/rules/no-use-before-define.mdx @@ -33,6 +33,8 @@ const defaultOptions: Options = { ### `enums` +Whether to check references to enums before the enum declaration. + If this is `true`, this rule warns every reference to a enum before the enum declaration. If this is `false`, this rule will ignore references to enums, when the reference is in a child scope. @@ -67,6 +69,8 @@ enum Foo { ### `typedefs` +Whether to check references to types before the type declaration. + If this is `true`, this rule warns every reference to a type before the type declaration. If this is `false`, this rule will ignore references to types. @@ -79,7 +83,9 @@ type StringOrNumber = string | number; ### `ignoreTypeReferences` -If this is `true`, this rule ignores all type references, such as in type annotations and assertions. +Whether to ignore type references, such as in type annotations and assertions. + +If this is `true`, this rule ignores all type references. If this is `false`, this will check all type references. Examples of **correct** code for the `{ "ignoreTypeReferences": true }` option: diff --git a/packages/eslint-plugin/docs/rules/prefer-literal-enum-member.mdx b/packages/eslint-plugin/docs/rules/prefer-literal-enum-member.mdx index a2088d0d1956..5f9e4ac03736 100644 --- a/packages/eslint-plugin/docs/rules/prefer-literal-enum-member.mdx +++ b/packages/eslint-plugin/docs/rules/prefer-literal-enum-member.mdx @@ -67,7 +67,7 @@ enum Valid { ### `allowBitwiseExpressions` -When set to `true` will allow you to use bitwise expressions in enum initializer (default: `false`). +Whether to allow using bitwise expressions in enum initializers (default: `false`). Examples of code for the `{ "allowBitwiseExpressions": true }` option: diff --git a/packages/eslint-plugin/docs/rules/prefer-nullish-coalescing.mdx b/packages/eslint-plugin/docs/rules/prefer-nullish-coalescing.mdx index 6748b58873ba..f36acad8e05f 100644 --- a/packages/eslint-plugin/docs/rules/prefer-nullish-coalescing.mdx +++ b/packages/eslint-plugin/docs/rules/prefer-nullish-coalescing.mdx @@ -25,7 +25,7 @@ This rule will not work as expected if [`strictNullChecks`](https://www.typescri ### `ignoreTernaryTests` -Setting this option to `true` will cause the rule to ignore any ternary expressions that could be simplified by using the nullish coalescing operator. This is set to `false` by default. +Whether to ignore any ternary expressions that could be simplified by using the nullish coalescing operator. This is set to `false` by default. Incorrect code for `ignoreTernaryTests: false`, and correct code for `ignoreTernaryTests: true`: @@ -65,7 +65,7 @@ foo ?? 'a string'; ### `ignoreConditionalTests` -Setting this option to `false` will cause the rule to also check cases that are located within a conditional test. This is set to `true` by default. +Whether to ignore cases that are located within a conditional test. This is set to `true` by default. Generally expressions within conditional tests intentionally use the falsy fallthrough behavior of the logical or operator, meaning that fixing the operator to the nullish coalesce operator could cause bugs. @@ -107,7 +107,7 @@ a ?? b ? true : false; ### `ignoreMixedLogicalExpressions` -Setting this option to `true` will cause the rule to ignore any logical or expressions that are part of a mixed logical expression (with `&&`). This is set to `false` by default. +Whether to ignore any logical or expressions that are part of a mixed logical expression (with `&&`). This is set to `false` by default. Generally expressions within mixed logical expressions intentionally use the falsy fallthrough behavior of the logical or operator, meaning that fixing the operator to the nullish coalesce operator could cause bugs. @@ -147,6 +147,8 @@ a ?? (b && c && d); ### `ignorePrimitives` +Whether to ignore all (`true`) or some (an object with properties) primitive types. + If you would like to ignore expressions containing operands of certain primitive types that can be falsy then you may pass an object containing a boolean value for each primitive: - `string: true`, ignores `null` or `undefined` unions with `string` (default: false). @@ -172,7 +174,7 @@ Also, if you would like to ignore all primitives types, you can set `ignorePrimi ### `allowRuleToRunWithoutStrictNullChecksIKnowWhatIAmDoing` -If this is set to `false`, then the rule will error on every file whose `tsconfig.json` does _not_ have the `strictNullChecks` compiler option (or `strict`) set to `true`. +Unless this is set to `true`, the rule will error on every file whose `tsconfig.json` does _not_ have the `strictNullChecks` compiler option (or `strict`) set to `true`. Without `strictNullChecks`, TypeScript essentially erases `undefined` and `null` from the types. This means when this rule inspects the types from a variable, **it will not be able to tell that the variable might be `null` or `undefined`**, which essentially makes this rule useless. diff --git a/packages/eslint-plugin/docs/rules/prefer-readonly-parameter-types.mdx b/packages/eslint-plugin/docs/rules/prefer-readonly-parameter-types.mdx index e2ddcef23048..e700b429f4f6 100644 --- a/packages/eslint-plugin/docs/rules/prefer-readonly-parameter-types.mdx +++ b/packages/eslint-plugin/docs/rules/prefer-readonly-parameter-types.mdx @@ -140,9 +140,9 @@ interface Foo { ### `allow` +An array of type specifiers to ignore. Some complex types cannot easily be made readonly, for example the `HTMLElement` type or the `JQueryStatic` type from `@types/jquery`. This option allows you to globally disable reporting of such types. -This option takes an array of type specifiers to ignore. Each item in the array must have one of the following forms: - A type defined in a file (`{ from: "file", name: "Foo", path: "src/foo-file.ts" }` with `path` being an optional path relative to the project root directory) @@ -258,7 +258,7 @@ function fn(arg: Foo) {} ### `checkParameterProperties` -This option allows you to enable or disable the checking of parameter properties. +Whether to check class parameter properties. Because parameter properties create properties on the class, it may be undesirable to force them to be readonly. Examples of code for this rule with `{checkParameterProperties: true}`: @@ -297,7 +297,8 @@ class Foo { ### `ignoreInferredTypes` -This option allows you to ignore parameters which don't explicitly specify a type. This may be desirable in cases where an external dependency specifies a callback with mutable parameters, and manually annotating the callback's parameters is undesirable. +Whether to ignore parameters which don't explicitly specify a type. +This may be desirable in cases where an external dependency specifies a callback with mutable parameters, and manually annotating the callback's parameters is undesirable. Examples of code for this rule with `{ignoreInferredTypes: true}`: @@ -354,7 +355,8 @@ export const acceptsCallback: AcceptsCallback; ### `treatMethodsAsReadonly` -This option allows you to treat all mutable methods as though they were readonly. This may be desirable when you are never reassigning methods. +Whether to treat all mutable methods as though they are readonly. +This may be desirable when you are never reassigning methods. Examples of code for this rule with `{treatMethodsAsReadonly: false}`: diff --git a/packages/eslint-plugin/docs/rules/promise-function-async.mdx b/packages/eslint-plugin/docs/rules/promise-function-async.mdx index bb506ad08bfc..aabe921925d3 100644 --- a/packages/eslint-plugin/docs/rules/promise-function-async.mdx +++ b/packages/eslint-plugin/docs/rules/promise-function-async.mdx @@ -68,7 +68,7 @@ async function functionReturnsUnionWithPromiseImplicitly(p: boolean) { ### `allowAny` -Whether to ignore functions that return `any` and `unknown`. +Whether to ignore functions that return `any` or `unknown`. If you want additional safety, consider turning this option off, as it makes the rule less able to catch incorrect Promise behaviors. Examples of code with `{ "allowAny": false }`: @@ -135,7 +135,7 @@ Whether to check inline function expressions. ### `checkMethodDeclarations` -Whether to check methods on classes and object literals +Whether to check methods on classes and object literals. `true` by default, but can be set to `false` to ignore them. ## When Not To Use It diff --git a/packages/eslint-plugin/docs/rules/typedef.mdx b/packages/eslint-plugin/docs/rules/typedef.mdx index cfbe5fa1a8c5..46fa0134c90f 100644 --- a/packages/eslint-plugin/docs/rules/typedef.mdx +++ b/packages/eslint-plugin/docs/rules/typedef.mdx @@ -306,7 +306,7 @@ let delayedText: string; ### `variableDeclarationIgnoreFunction` -Ignore variable declarations for non-arrow and arrow functions. +Whether to ignore variable declarations for non-arrow and arrow functions. Examples of code with `{ "variableDeclaration": true, "variableDeclarationIgnoreFunction": true }`: diff --git a/packages/eslint-plugin/src/rules/ban-ts-comment.ts b/packages/eslint-plugin/src/rules/ban-ts-comment.ts index b554510f57d3..44970393cfc7 100644 --- a/packages/eslint-plugin/src/rules/ban-ts-comment.ts +++ b/packages/eslint-plugin/src/rules/ban-ts-comment.ts @@ -84,6 +84,8 @@ export default createRule<[Options], MessageIds>({ 'ts-nocheck': { $ref: '#/items/0/$defs/directiveConfigSchema' }, 'ts-check': { $ref: '#/items/0/$defs/directiveConfigSchema' }, minimumDescriptionLength: { + description: + 'A minimum character length for descriptions when `allow-with-description` is enabled.', type: 'number', default: defaultMinimumDescriptionLength, }, diff --git a/packages/eslint-plugin/src/rules/consistent-type-assertions.ts b/packages/eslint-plugin/src/rules/consistent-type-assertions.ts index 4c45d12e5a74..76e1386cf6e3 100644 --- a/packages/eslint-plugin/src/rules/consistent-type-assertions.ts +++ b/packages/eslint-plugin/src/rules/consistent-type-assertions.ts @@ -57,6 +57,7 @@ export default createRule({ type: 'object', properties: { assertionStyle: { + description: 'The expected assertion style to enforce.', type: 'string', enum: ['never'], }, @@ -68,10 +69,13 @@ export default createRule({ type: 'object', properties: { assertionStyle: { + description: 'The expected assertion style to enforce.', type: 'string', enum: ['as', 'angle-bracket'], }, objectLiteralTypeAssertions: { + description: + 'Whether to always prefer type declarations for object literals used as variable initializers, rather than type assertions.', type: 'string', enum: ['allow', 'allow-as-parameter', 'never'], }, diff --git a/packages/eslint-plugin/src/rules/consistent-type-exports.ts b/packages/eslint-plugin/src/rules/consistent-type-exports.ts index 236659d13adb..7f9568533710 100644 --- a/packages/eslint-plugin/src/rules/consistent-type-exports.ts +++ b/packages/eslint-plugin/src/rules/consistent-type-exports.ts @@ -48,7 +48,6 @@ export default createRule({ messages: { typeOverValue: 'All exports in the declaration are only used as types. Use `export type`.', - singleExportIsType: 'Type export {{exportNames}} is not a value and should be exported using `export type`.', multipleExportsAreTypes: @@ -59,6 +58,8 @@ export default createRule({ type: 'object', properties: { fixMixedExportsWithInlineTypeSpecifier: { + description: + 'Whether the rule will autofix "mixed" export cases using TS inline type specifiers.', type: 'boolean', }, }, diff --git a/packages/eslint-plugin/src/rules/consistent-type-imports.ts b/packages/eslint-plugin/src/rules/consistent-type-imports.ts index b0428aa71645..3158d9ad78e2 100644 --- a/packages/eslint-plugin/src/rules/consistent-type-imports.ts +++ b/packages/eslint-plugin/src/rules/consistent-type-imports.ts @@ -60,7 +60,6 @@ export default createRule({ typeOverValue: 'All imports in the declaration are only used as types. Use `import type`.', someImportsAreOnlyTypes: 'Imports {{typeImports}} are only used as type.', - avoidImportType: 'Use an `import` instead of an `import type`.', noImportTypeAnnotations: '`import()` type annotations are forbidden.', }, @@ -69,13 +68,18 @@ export default createRule({ type: 'object', properties: { disallowTypeAnnotations: { + description: + 'Whether to disallow type imports in type annotations (`import()`).', type: 'boolean', }, fixStyle: { + description: + 'The expected type modifier to be added when an import is detected as used only in the type position.', type: 'string', enum: ['separate-type-imports', 'inline-type-imports'], }, prefer: { + description: 'The expected import kind for type-only imports.', type: 'string', enum: ['type-imports', 'no-type-imports'], }, diff --git a/packages/eslint-plugin/src/rules/dot-notation.ts b/packages/eslint-plugin/src/rules/dot-notation.ts index 06b1c78c29d9..f7b1c612288c 100644 --- a/packages/eslint-plugin/src/rules/dot-notation.ts +++ b/packages/eslint-plugin/src/rules/dot-notation.ts @@ -30,22 +30,30 @@ export default createRule({ type: 'object', properties: { allowKeywords: { + description: 'Whether to allow keywords such as ["class"]`.', type: 'boolean', default: true, }, allowPattern: { + description: 'Regular expression of names to allow.', type: 'string', default: '', }, allowPrivateClassPropertyAccess: { + description: + 'Whether to allow accessing class members marked as `private` with array notation.', type: 'boolean', default: false, }, allowProtectedClassPropertyAccess: { + description: + 'Whether to allow accessing class members marked as `protected` with array notation.', type: 'boolean', default: false, }, allowIndexSignaturePropertyAccess: { + description: + 'Whether to allow accessing properties matching an index signature with array notation.', type: 'boolean', default: false, }, diff --git a/packages/eslint-plugin/src/rules/explicit-member-accessibility.ts b/packages/eslint-plugin/src/rules/explicit-member-accessibility.ts index 5947d292f8bd..2661949b57d7 100644 --- a/packages/eslint-plugin/src/rules/explicit-member-accessibility.ts +++ b/packages/eslint-plugin/src/rules/explicit-member-accessibility.ts @@ -91,10 +91,10 @@ export default createRule({ $ref: '#/items/0/$defs/accessibilityLevel', }, }, - additionalProperties: false, }, ignoredMethodNames: { + description: 'Specific method names that may be ignored.', type: 'array', items: { type: 'string', diff --git a/packages/eslint-plugin/src/rules/max-params.ts b/packages/eslint-plugin/src/rules/max-params.ts index 622848affce1..680cea10a40c 100644 --- a/packages/eslint-plugin/src/rules/max-params.ts +++ b/packages/eslint-plugin/src/rules/max-params.ts @@ -33,15 +33,21 @@ export default createRule({ { type: 'object', properties: { - maximum: { + max: { + description: + 'A maximum number of parameters in function definitions.', type: 'integer', minimum: 0, }, - max: { + maximum: { + description: + '(deprecated) A maximum number of parameters in function definitions.', type: 'integer', minimum: 0, }, countVoidThis: { + description: + 'Whether to count a `this` declaration when the type is `void`.', type: 'boolean', }, }, diff --git a/packages/eslint-plugin/src/rules/no-base-to-string.ts b/packages/eslint-plugin/src/rules/no-base-to-string.ts index 0369e66fe66f..d4620aa7c031 100644 --- a/packages/eslint-plugin/src/rules/no-base-to-string.ts +++ b/packages/eslint-plugin/src/rules/no-base-to-string.ts @@ -35,6 +35,8 @@ export default createRule({ type: 'object', properties: { ignoredTypeNames: { + description: + 'Stringified regular expressions of type names to ignore.', type: 'array', items: { type: 'string', diff --git a/packages/eslint-plugin/src/rules/no-confusing-void-expression.ts b/packages/eslint-plugin/src/rules/no-confusing-void-expression.ts index 38df4fb0dc44..f82bdb5e3c10 100644 --- a/packages/eslint-plugin/src/rules/no-confusing-void-expression.ts +++ b/packages/eslint-plugin/src/rules/no-confusing-void-expression.ts @@ -70,8 +70,16 @@ export default createRule({ { type: 'object', properties: { - ignoreArrowShorthand: { type: 'boolean' }, - ignoreVoidOperator: { type: 'boolean' }, + ignoreArrowShorthand: { + description: + 'Whether to ignore "shorthand" `() =>` arrow functions: those without `{ ... }` braces.', + type: 'boolean', + }, + ignoreVoidOperator: { + description: + 'Whether to ignore returns that start with the `void` operator.', + type: 'boolean', + }, }, additionalProperties: false, }, diff --git a/packages/eslint-plugin/src/rules/no-duplicate-type-constituents.ts b/packages/eslint-plugin/src/rules/no-duplicate-type-constituents.ts index d92de657aa47..49de6d8a0435 100644 --- a/packages/eslint-plugin/src/rules/no-duplicate-type-constituents.ts +++ b/packages/eslint-plugin/src/rules/no-duplicate-type-constituents.ts @@ -86,9 +86,11 @@ export default createRule({ type: 'object', properties: { ignoreIntersections: { + description: 'Whether to ignore `&` intersections.', type: 'boolean', }, ignoreUnions: { + description: 'Whether to ignore `|` unions.', type: 'boolean', }, }, diff --git a/packages/eslint-plugin/src/rules/no-empty-function.ts b/packages/eslint-plugin/src/rules/no-empty-function.ts index 6a8e90ebaf13..1b5061dc2d36 100644 --- a/packages/eslint-plugin/src/rules/no-empty-function.ts +++ b/packages/eslint-plugin/src/rules/no-empty-function.ts @@ -22,6 +22,8 @@ const schema = deepMerge( { properties: { allow: { + description: + 'Locations and kinds of functions that are allowed to be empty.', items: { type: 'string', enum: [ diff --git a/packages/eslint-plugin/src/rules/no-empty-interface.ts b/packages/eslint-plugin/src/rules/no-empty-interface.ts index 03d00c1a9535..da40f8a88020 100644 --- a/packages/eslint-plugin/src/rules/no-empty-interface.ts +++ b/packages/eslint-plugin/src/rules/no-empty-interface.ts @@ -33,6 +33,8 @@ export default createRule({ additionalProperties: false, properties: { allowSingleExtends: { + description: + 'Whether to allow empty interfaces that extend a single other interface.', type: 'boolean', }, }, diff --git a/packages/eslint-plugin/src/rules/no-empty-object-type.ts b/packages/eslint-plugin/src/rules/no-empty-object-type.ts index 2471726240b8..cf41ee2031cd 100644 --- a/packages/eslint-plugin/src/rules/no-empty-object-type.ts +++ b/packages/eslint-plugin/src/rules/no-empty-object-type.ts @@ -56,14 +56,18 @@ export default createRule({ additionalProperties: false, properties: { allowInterfaces: { + description: 'Whether to allow empty interfaces.', enum: ['always', 'never', 'with-single-extends'], type: 'string', }, allowObjectTypes: { + description: 'Whether to allow empty object type literals.', enum: ['always', 'never'], type: 'string', }, allowWithName: { + description: + 'A stringified regular expression to allow interfaces and object type aliases with the configured name.', type: 'string', }, }, diff --git a/packages/eslint-plugin/src/rules/no-floating-promises.ts b/packages/eslint-plugin/src/rules/no-floating-promises.ts index e59c32665427..3b0265e1718f 100644 --- a/packages/eslint-plugin/src/rules/no-floating-promises.ts +++ b/packages/eslint-plugin/src/rules/no-floating-promises.ts @@ -76,8 +76,15 @@ export default createRule({ { type: 'object', properties: { - allowForKnownSafePromises: readonlynessOptionsSchema.properties.allow, - allowForKnownSafeCalls: readonlynessOptionsSchema.properties.allow, + allowForKnownSafePromises: { + ...readonlynessOptionsSchema.properties.allow, + description: 'Type specifiers that are known to be safe to float.', + }, + allowForKnownSafeCalls: { + ...readonlynessOptionsSchema.properties.allow, + description: + 'Type specifiers of functions whose calls are safe to float.', + }, checkThenables: { description: 'Whether to check all "Thenable"s, not just the built-in Promise type.', diff --git a/packages/eslint-plugin/src/rules/no-inferrable-types.ts b/packages/eslint-plugin/src/rules/no-inferrable-types.ts index 51ead2ae476a..2b54267a503a 100644 --- a/packages/eslint-plugin/src/rules/no-inferrable-types.ts +++ b/packages/eslint-plugin/src/rules/no-inferrable-types.ts @@ -31,9 +31,11 @@ export default createRule({ type: 'object', properties: { ignoreParameters: { + description: 'Whether to ignore function parameters.', type: 'boolean', }, ignoreProperties: { + description: 'Whether to ignore class properties.', type: 'boolean', }, }, diff --git a/packages/eslint-plugin/src/rules/no-invalid-void-type.ts b/packages/eslint-plugin/src/rules/no-invalid-void-type.ts index f518e2dc861b..81faa510faf9 100644 --- a/packages/eslint-plugin/src/rules/no-invalid-void-type.ts +++ b/packages/eslint-plugin/src/rules/no-invalid-void-type.ts @@ -42,6 +42,8 @@ export default createRule<[Options], MessageIds>({ type: 'object', properties: { allowInGenericTypeArguments: { + description: + 'Whether `void` can be used as a valid value for generic type parameters.', oneOf: [ { type: 'boolean' }, { @@ -52,6 +54,8 @@ export default createRule<[Options], MessageIds>({ ], }, allowAsThisParameter: { + description: + 'Whether a `this` parameter of a function may be `void`.', type: 'boolean', }, }, diff --git a/packages/eslint-plugin/src/rules/no-magic-numbers.ts b/packages/eslint-plugin/src/rules/no-magic-numbers.ts index 5a86056cb90d..a2f97a78b249 100644 --- a/packages/eslint-plugin/src/rules/no-magic-numbers.ts +++ b/packages/eslint-plugin/src/rules/no-magic-numbers.ts @@ -23,15 +23,20 @@ const schema = deepMerge( { properties: { ignoreNumericLiteralTypes: { + description: + 'Whether numbers used in TypeScript numeric literal types are considered okay.', type: 'boolean', }, ignoreEnums: { + description: 'Whether enums used in TypeScript are considered okay.', type: 'boolean', }, ignoreReadonlyClassProperties: { + description: 'Whether `readonly` class properties are considered okay.', type: 'boolean', }, ignoreTypeIndexes: { + description: 'Whether numbers used to index types are okay.', type: 'boolean', }, }, diff --git a/packages/eslint-plugin/src/rules/no-meaningless-void-operator.ts b/packages/eslint-plugin/src/rules/no-meaningless-void-operator.ts index e8fdde8d1f33..a75bb04afc13 100644 --- a/packages/eslint-plugin/src/rules/no-meaningless-void-operator.ts +++ b/packages/eslint-plugin/src/rules/no-meaningless-void-operator.ts @@ -33,6 +33,8 @@ export default createRule({ type: 'object', properties: { checkNever: { + description: + 'Whether to suggest removing `void` when the argument has type `never`.', type: 'boolean', default: false, }, diff --git a/packages/eslint-plugin/src/rules/no-misused-promises.ts b/packages/eslint-plugin/src/rules/no-misused-promises.ts index a5433edf7d10..22ef01b37927 100644 --- a/packages/eslint-plugin/src/rules/no-misused-promises.ts +++ b/packages/eslint-plugin/src/rules/no-misused-promises.ts @@ -107,18 +107,43 @@ export default createRule({ { additionalProperties: false, properties: { - arguments: { type: 'boolean' }, - attributes: { type: 'boolean' }, - inheritedMethods: { type: 'boolean' }, - properties: { type: 'boolean' }, - returns: { type: 'boolean' }, - variables: { type: 'boolean' }, + arguments: { + description: + 'Disables checking an asynchronous function passed as argument where the parameter type expects a function that returns `void`.', + type: 'boolean', + }, + attributes: { + description: + 'Disables checking an asynchronous function passed as a JSX attribute expected to be a function that returns `void`.', + type: 'boolean', + }, + inheritedMethods: { + description: + 'Disables checking an asynchronous method in a type that extends or implements another type expecting that method to return `void`.', + type: 'boolean', + }, + properties: { + description: + 'Disables checking an asynchronous function passed as an object property expected to be a function that returns `void`.', + type: 'boolean', + }, + returns: { + description: + 'Disables checking an asynchronous function returned in a function whose return type is a function that returns `void`.', + type: 'boolean', + }, + variables: { + description: + 'Disables checking an asynchronous function used as a variable whose return type is a function that returns `void`.', + type: 'boolean', + }, }, type: 'object', }, ], }, checksSpreads: { + description: 'Whether to warn when `...` spreading a `Promise`.', type: 'boolean', }, }, diff --git a/packages/eslint-plugin/src/rules/no-redeclare.ts b/packages/eslint-plugin/src/rules/no-redeclare.ts index b084d90650b0..a2060a0ea4da 100644 --- a/packages/eslint-plugin/src/rules/no-redeclare.ts +++ b/packages/eslint-plugin/src/rules/no-redeclare.ts @@ -25,9 +25,13 @@ export default createRule({ type: 'object', properties: { builtinGlobals: { + description: + 'Whether to report shadowing of built-in global variables.', type: 'boolean', }, ignoreDeclarationMerge: { + description: + 'Whether to ignore declaration merges between certain TypeScript declaration types.', type: 'boolean', }, }, diff --git a/packages/eslint-plugin/src/rules/no-shadow.ts b/packages/eslint-plugin/src/rules/no-shadow.ts index 152d536239e8..2de2cbf0ff60 100644 --- a/packages/eslint-plugin/src/rules/no-shadow.ts +++ b/packages/eslint-plugin/src/rules/no-shadow.ts @@ -37,25 +37,36 @@ export default createRule({ type: 'object', properties: { builtinGlobals: { + description: + 'Whether to report shadowing of built-in global variables.', type: 'boolean', }, hoist: { + description: + 'Whether to report shadowing before outer functions or variables are defined.', type: 'string', enum: ['all', 'functions', 'never'], }, allow: { + description: 'Identifier names for which shadowing is allowed.', type: 'array', items: { type: 'string', }, }, ignoreOnInitialization: { + description: + 'Whether to ignore the variable initializers when the shadowed variable is presumably still unitialized.', type: 'boolean', }, ignoreTypeValueShadow: { + description: + 'Whether to ignore types named the same as a variable.', type: 'boolean', }, ignoreFunctionTypeParameterNameValueShadow: { + description: + 'Whether to ignore function parameters named the same as a variable.', type: 'boolean', }, }, diff --git a/packages/eslint-plugin/src/rules/no-unused-vars.ts b/packages/eslint-plugin/src/rules/no-unused-vars.ts index d98c2f5bf5a5..417467a1faef 100644 --- a/packages/eslint-plugin/src/rules/no-unused-vars.ts +++ b/packages/eslint-plugin/src/rules/no-unused-vars.ts @@ -77,36 +77,54 @@ export default createRule({ type: 'object', properties: { vars: { + description: + 'Whether to check all variables or only locally-declared variables.', type: 'string', enum: ['all', 'local'], }, varsIgnorePattern: { + description: + 'Regular expressions of variable names to not check for usage.', type: 'string', }, args: { + description: 'Whether to check all, some, or no arguments.', type: 'string', enum: ['all', 'after-used', 'none'], }, - ignoreRestSiblings: { - type: 'boolean', - }, argsIgnorePattern: { + description: + 'Regular expressions of argument names to not check for usage.', type: 'string', }, caughtErrors: { + description: 'Whether to check catch block arguments.', type: 'string', enum: ['all', 'none'], }, caughtErrorsIgnorePattern: { + description: + 'Regular expressions of catch block argument names to not check for usage.', type: 'string', }, destructuredArrayIgnorePattern: { + description: + 'Regular expressions of destructured array variable names to not check for usage.', type: 'string', }, ignoreClassWithStaticInitBlock: { + description: + 'Whether to ignore classes with at least one static initialization block.', + type: 'boolean', + }, + ignoreRestSiblings: { + description: + 'Whether to ignore sibling properties in `...` destructurings.', type: 'boolean', }, reportUsedIgnorePattern: { + description: + 'Whether to report variables that match any of the valid ignore pattern options if they have been used.', type: 'boolean', }, }, diff --git a/packages/eslint-plugin/src/rules/no-use-before-define.ts b/packages/eslint-plugin/src/rules/no-use-before-define.ts index f333683d2f42..4c6cc0041971 100644 --- a/packages/eslint-plugin/src/rules/no-use-before-define.ts +++ b/packages/eslint-plugin/src/rules/no-use-before-define.ts @@ -235,12 +235,33 @@ export default createRule({ { type: 'object', properties: { - functions: { type: 'boolean' }, - classes: { type: 'boolean' }, - enums: { type: 'boolean' }, - variables: { type: 'boolean' }, - typedefs: { type: 'boolean' }, - ignoreTypeReferences: { type: 'boolean' }, + functions: { + description: + 'Whether to ignore references to function declarations.', + type: 'boolean', + }, + classes: { + description: + 'Whether to ignore references to class declarations.', + type: 'boolean', + }, + enums: { + description: 'Whether to check references to enums.', + type: 'boolean', + }, + variables: { + description: 'Whether to ignore references to variables.', + type: 'boolean', + }, + typedefs: { + description: 'Whether to check references to types.', + type: 'boolean', + }, + ignoreTypeReferences: { + description: + 'Whether to ignore type references, such as in type annotations and assertions.', + type: 'boolean', + }, allowNamedExports: { type: 'boolean' }, }, additionalProperties: false, diff --git a/packages/eslint-plugin/src/rules/only-throw-error.ts b/packages/eslint-plugin/src/rules/only-throw-error.ts index 45a6dac0942d..14bebfd4945a 100644 --- a/packages/eslint-plugin/src/rules/only-throw-error.ts +++ b/packages/eslint-plugin/src/rules/only-throw-error.ts @@ -34,9 +34,13 @@ export default createRule({ type: 'object', properties: { allowThrowingAny: { + description: + 'Whether to always allow throwing values typed as `any`.', type: 'boolean', }, allowThrowingUnknown: { + description: + 'Whether to always allow throwing values typed as `unknown`.', type: 'boolean', }, }, diff --git a/packages/eslint-plugin/src/rules/parameter-properties.ts b/packages/eslint-plugin/src/rules/parameter-properties.ts index 5246594e912e..34cd6da38140 100644 --- a/packages/eslint-plugin/src/rules/parameter-properties.ts +++ b/packages/eslint-plugin/src/rules/parameter-properties.ts @@ -56,12 +56,16 @@ export default createRule({ type: 'object', properties: { allow: { + description: + 'Whether to allow certain kinds of properties to be ignored.', type: 'array', items: { $ref: '#/items/0/$defs/modifier', }, }, prefer: { + description: + 'Whether to prefer class properties or parameter properties.', type: 'string', enum: ['class-property', 'parameter-property'], }, diff --git a/packages/eslint-plugin/src/rules/prefer-literal-enum-member.ts b/packages/eslint-plugin/src/rules/prefer-literal-enum-member.ts index efc3eacdd518..dcc31ba5742a 100644 --- a/packages/eslint-plugin/src/rules/prefer-literal-enum-member.ts +++ b/packages/eslint-plugin/src/rules/prefer-literal-enum-member.ts @@ -20,6 +20,8 @@ export default createRule({ type: 'object', properties: { allowBitwiseExpressions: { + description: + 'Whether to allow using bitwise expressions in enum initializers.', type: 'boolean', }, }, diff --git a/packages/eslint-plugin/src/rules/prefer-nullish-coalescing.ts b/packages/eslint-plugin/src/rules/prefer-nullish-coalescing.ts index 87a23ab98808..05de88296a4f 100644 --- a/packages/eslint-plugin/src/rules/prefer-nullish-coalescing.ts +++ b/packages/eslint-plugin/src/rules/prefer-nullish-coalescing.ts @@ -65,15 +65,23 @@ export default createRule({ type: 'object', properties: { allowRuleToRunWithoutStrictNullChecksIKnowWhatIAmDoing: { + description: + 'Unless this is set to `true`, the rule will error on every file whose `tsconfig.json` does _not_ have the `strictNullChecks` compiler option (or `strict`) set to `true`.', type: 'boolean', }, ignoreConditionalTests: { + description: + 'Whether to ignore cases that are located within a conditional test.', type: 'boolean', }, ignoreMixedLogicalExpressions: { + description: + 'Whether to ignore any logical or expressions that are part of a mixed logical expression (with `&&`).', type: 'boolean', }, ignorePrimitives: { + description: + 'Whether to ignore all (`true`) or some (an object with properties) primitive types.', oneOf: [ { type: 'object', @@ -91,6 +99,8 @@ export default createRule({ ], }, ignoreTernaryTests: { + description: + 'Whether to ignore any ternary expressions that could be simplified by using the nullish coalescing operator.', type: 'boolean', }, }, diff --git a/packages/eslint-plugin/src/rules/prefer-promise-reject-errors.ts b/packages/eslint-plugin/src/rules/prefer-promise-reject-errors.ts index ef15fe918c17..ae5a344a299e 100644 --- a/packages/eslint-plugin/src/rules/prefer-promise-reject-errors.ts +++ b/packages/eslint-plugin/src/rules/prefer-promise-reject-errors.ts @@ -35,6 +35,8 @@ export default createRule({ type: 'object', properties: { allowEmptyReject: { + description: + 'Whether to allow calls to `Promise.reject()` with no arguments.', type: 'boolean', }, }, diff --git a/packages/eslint-plugin/src/rules/prefer-readonly-parameter-types.ts b/packages/eslint-plugin/src/rules/prefer-readonly-parameter-types.ts index 6cb935c1db9a..edc66bf2a76e 100644 --- a/packages/eslint-plugin/src/rules/prefer-readonly-parameter-types.ts +++ b/packages/eslint-plugin/src/rules/prefer-readonly-parameter-types.ts @@ -34,15 +34,24 @@ export default createRule({ type: 'object', additionalProperties: false, properties: { - allow: readonlynessOptionsSchema.properties.allow, + allow: { + ...readonlynessOptionsSchema.properties.allow, + description: 'An array of type specifiers to ignore.', + }, checkParameterProperties: { + description: 'Whether to check class parameter properties.', type: 'boolean', }, ignoreInferredTypes: { + description: + "Whether to ignore parameters which don't explicitly specify a type.", type: 'boolean', }, - treatMethodsAsReadonly: - readonlynessOptionsSchema.properties.treatMethodsAsReadonly, + treatMethodsAsReadonly: { + ...readonlynessOptionsSchema.properties.treatMethodsAsReadonly, + description: + 'Whether to treat all mutable methods as though they are readonly.', + }, }, }, ], diff --git a/packages/eslint-plugin/src/rules/prefer-readonly.ts b/packages/eslint-plugin/src/rules/prefer-readonly.ts index f163b1aaab34..df05668299a2 100644 --- a/packages/eslint-plugin/src/rules/prefer-readonly.ts +++ b/packages/eslint-plugin/src/rules/prefer-readonly.ts @@ -46,6 +46,8 @@ export default createRule({ additionalProperties: false, properties: { onlyInlineLambdas: { + description: + 'Whether to restrict checking only to members immediately assigned a lambda value.', type: 'boolean', }, }, diff --git a/packages/eslint-plugin/src/rules/promise-function-async.ts b/packages/eslint-plugin/src/rules/promise-function-async.ts index c191ce45b0db..942ef6b8fa46 100644 --- a/packages/eslint-plugin/src/rules/promise-function-async.ts +++ b/packages/eslint-plugin/src/rules/promise-function-async.ts @@ -55,15 +55,20 @@ export default createRule({ }, }, checkArrowFunctions: { + description: 'Whether to check arrow functions.', type: 'boolean', }, checkFunctionDeclarations: { + description: 'Whether to check standalone function declarations.', type: 'boolean', }, checkFunctionExpressions: { + description: 'Whether to check inline function expressions', type: 'boolean', }, checkMethodDeclarations: { + description: + 'Whether to check methods on classes and object literals.', type: 'boolean', }, }, diff --git a/packages/eslint-plugin/src/rules/return-await.ts b/packages/eslint-plugin/src/rules/return-await.ts index 716962a8a11b..5152cc61466f 100644 --- a/packages/eslint-plugin/src/rules/return-await.ts +++ b/packages/eslint-plugin/src/rules/return-await.ts @@ -59,12 +59,30 @@ export default createRule({ schema: [ { type: 'string', - enum: [ - 'in-try-catch', - 'always', - 'never', - 'error-handling-correctness-only', - ] satisfies Option[], + oneOf: [ + { + type: 'string', + enum: ['always'], + description: 'Requires that all returned promises be awaited.', + }, + { + type: 'string', + enum: ['error-handling-correctness-only'], + description: + 'In error-handling contexts, the rule enforces that returned promises must be awaited. In ordinary contexts, the rule does not enforce any particular behavior around whether returned promises are awaited.', + }, + { + type: 'string', + enum: ['in-try-catch'], + description: + 'In error-handling contexts, the rule enforces that returned promises must be awaited. In ordinary contexts, the rule enforces that returned promises _must not_ be awaited.', + }, + { + type: 'string', + enum: ['never'], + description: 'Disallows awaiting any returned promises.', + }, + ], }, ], }, diff --git a/packages/eslint-plugin/src/rules/strict-boolean-expressions.ts b/packages/eslint-plugin/src/rules/strict-boolean-expressions.ts index 3e01b5c15a1a..7bd708ac6f9c 100644 --- a/packages/eslint-plugin/src/rules/strict-boolean-expressions.ts +++ b/packages/eslint-plugin/src/rules/strict-boolean-expressions.ts @@ -67,14 +67,43 @@ export default createRule({ { type: 'object', properties: { - allowString: { type: 'boolean' }, - allowNumber: { type: 'boolean' }, - allowNullableObject: { type: 'boolean' }, - allowNullableBoolean: { type: 'boolean' }, - allowNullableString: { type: 'boolean' }, - allowNullableNumber: { type: 'boolean' }, - allowNullableEnum: { type: 'boolean' }, - allowAny: { type: 'boolean' }, + allowString: { + description: 'Whether to allow `string` in a boolean context.', + type: 'boolean', + }, + allowNumber: { + description: 'Whether to allow `number` in a boolean context.', + type: 'boolean', + }, + allowNullableObject: { + description: + 'Whether to allow nullable `object`s in a boolean context.', + type: 'boolean', + }, + allowNullableBoolean: { + description: + 'Whether to allow nullable `boolean`s in a boolean context.', + type: 'boolean', + }, + allowNullableString: { + description: + 'Whether to allow nullable `string`s in a boolean context.', + type: 'boolean', + }, + allowNullableNumber: { + description: + 'Whether to allow nullable `number`s in a boolean context.', + type: 'boolean', + }, + allowNullableEnum: { + description: + 'Whether to allow nullable `enum`s in a boolean context.', + type: 'boolean', + }, + allowAny: { + description: 'Whether to allow `any` in a boolean context.', + type: 'boolean', + }, allowRuleToRunWithoutStrictNullChecksIKnowWhatIAmDoing: { type: 'boolean', }, diff --git a/packages/eslint-plugin/src/rules/triple-slash-reference.ts b/packages/eslint-plugin/src/rules/triple-slash-reference.ts index a45662c33d4c..7512f8ce0778 100644 --- a/packages/eslint-plugin/src/rules/triple-slash-reference.ts +++ b/packages/eslint-plugin/src/rules/triple-slash-reference.ts @@ -30,14 +30,20 @@ export default createRule({ type: 'object', properties: { lib: { + description: + 'What to enforce for `/// ` references.', type: 'string', enum: ['always', 'never'], }, path: { + description: + 'What to enforce for `/// ` references.', type: 'string', enum: ['always', 'never'], }, types: { + description: + 'What to enforce for `/// ` references.', type: 'string', enum: ['always', 'never', 'prefer-import'], }, diff --git a/packages/eslint-plugin/src/rules/typedef.ts b/packages/eslint-plugin/src/rules/typedef.ts index 187f4d620365..5853c79dfff9 100644 --- a/packages/eslint-plugin/src/rules/typedef.ts +++ b/packages/eslint-plugin/src/rules/typedef.ts @@ -33,14 +33,46 @@ export default createRule<[Options], MessageIds>({ type: 'object', additionalProperties: false, properties: { - [OptionKeys.ArrayDestructuring]: { type: 'boolean' }, - [OptionKeys.ArrowParameter]: { type: 'boolean' }, - [OptionKeys.MemberVariableDeclaration]: { type: 'boolean' }, - [OptionKeys.ObjectDestructuring]: { type: 'boolean' }, - [OptionKeys.Parameter]: { type: 'boolean' }, - [OptionKeys.PropertyDeclaration]: { type: 'boolean' }, - [OptionKeys.VariableDeclaration]: { type: 'boolean' }, - [OptionKeys.VariableDeclarationIgnoreFunction]: { type: 'boolean' }, + [OptionKeys.ArrayDestructuring]: { + description: + 'Whether to enforce type annotations on variables declared using array destructuring.', + type: 'boolean', + }, + [OptionKeys.ArrowParameter]: { + description: + 'Whether to enforce type annotations for parameters of arrow functions.', + type: 'boolean', + }, + [OptionKeys.MemberVariableDeclaration]: { + description: + 'Whether to enforce type annotations on member variables of classes.', + type: 'boolean', + }, + [OptionKeys.ObjectDestructuring]: { + description: + 'Whether to enforce type annotations on variables declared using object destructuring.', + type: 'boolean', + }, + [OptionKeys.Parameter]: { + description: + 'Whether to enforce type annotations for parameters of functions and methods.', + type: 'boolean', + }, + [OptionKeys.PropertyDeclaration]: { + description: + 'Whether to enforce type annotations for properties of interfaces and types.', + type: 'boolean', + }, + [OptionKeys.VariableDeclaration]: { + description: + 'Whether to enforce type annotations for variable declarations, excluding array and object destructuring.', + type: 'boolean', + }, + [OptionKeys.VariableDeclarationIgnoreFunction]: { + description: + 'Whether to ignore variable declarations for non-arrow and arrow functions.', + type: 'boolean', + }, }, }, ], diff --git a/packages/eslint-plugin/tests/docs-eslint-output-snapshots/max-params.shot b/packages/eslint-plugin/tests/docs-eslint-output-snapshots/max-params.shot new file mode 100644 index 000000000000..9ab894b8a858 --- /dev/null +++ b/packages/eslint-plugin/tests/docs-eslint-output-snapshots/max-params.shot @@ -0,0 +1,22 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Validating rule docs max-params.mdx code examples ESLint output 1`] = ` +"Incorrect +Options: { "countVoidThis": false, "max": 1 } + +function hasNoThis(this: void, first: string, second: string) { +~~~~~~~~~~~~~~~~~~ Function 'hasNoThis' has too many parameters (2). Maximum allowed is 1. + // ... +} +" +`; + +exports[`Validating rule docs max-params.mdx code examples ESLint output 2`] = ` +"Correct +Options: { "countVoidThis": false, "max": 1 } + +function hasNoThis(this: void, first: string) { + // ... +} +" +`; diff --git a/packages/eslint-plugin/tests/schema-snapshots/ban-ts-comment.shot b/packages/eslint-plugin/tests/schema-snapshots/ban-ts-comment.shot index a39ac4e59b3b..c6e35698c0d9 100644 --- a/packages/eslint-plugin/tests/schema-snapshots/ban-ts-comment.shot +++ b/packages/eslint-plugin/tests/schema-snapshots/ban-ts-comment.shot @@ -33,6 +33,7 @@ exports[`Rule schemas should be convertible to TS types for documentation purpos "properties": { "minimumDescriptionLength": { "default": 3, + "description": "A minimum character length for descriptions when \`allow-with-description\` is enabled.", "type": "number" }, "ts-check": { @@ -68,6 +69,7 @@ type Options = [ 'ts-expect-error'?: DirectiveConfigSchema; 'ts-ignore'?: DirectiveConfigSchema; 'ts-nocheck'?: DirectiveConfigSchema; + /** A minimum character length for descriptions when \`allow-with-description\` is enabled. */ minimumDescriptionLength?: number; }, ]; diff --git a/packages/eslint-plugin/tests/schema-snapshots/consistent-type-assertions.shot b/packages/eslint-plugin/tests/schema-snapshots/consistent-type-assertions.shot index b50dc807a9ba..5a7b31771041 100644 --- a/packages/eslint-plugin/tests/schema-snapshots/consistent-type-assertions.shot +++ b/packages/eslint-plugin/tests/schema-snapshots/consistent-type-assertions.shot @@ -11,6 +11,7 @@ exports[`Rule schemas should be convertible to TS types for documentation purpos "additionalProperties": false, "properties": { "assertionStyle": { + "description": "The expected assertion style to enforce.", "enum": ["never"], "type": "string" } @@ -22,10 +23,12 @@ exports[`Rule schemas should be convertible to TS types for documentation purpos "additionalProperties": false, "properties": { "assertionStyle": { + "description": "The expected assertion style to enforce.", "enum": ["angle-bracket", "as"], "type": "string" }, "objectLiteralTypeAssertions": { + "description": "Whether to always prefer type declarations for object literals used as variable initializers, rather than type assertions.", "enum": ["allow", "allow-as-parameter", "never"], "type": "string" } @@ -42,11 +45,22 @@ exports[`Rule schemas should be convertible to TS types for documentation purpos type Options = [ | { - assertionStyle: 'angle-bracket' | 'as'; - objectLiteralTypeAssertions?: 'allow' | 'allow-as-parameter' | 'never'; + /** The expected assertion style to enforce. */ + assertionStyle: + | 'as' + /** The expected assertion style to enforce. */ + | 'angle-bracket'; + /** Whether to always prefer type declarations for object literals used as variable initializers, rather than type assertions. */ + objectLiteralTypeAssertions?: + | 'allow-as-parameter' + | 'never' + /** Whether to always prefer type declarations for object literals used as variable initializers, rather than type assertions. */ + | 'allow'; } | { - assertionStyle: 'never'; + /** The expected assertion style to enforce. */ + assertionStyle: /** The expected assertion style to enforce. */ + 'never'; }, ]; " diff --git a/packages/eslint-plugin/tests/schema-snapshots/consistent-type-exports.shot b/packages/eslint-plugin/tests/schema-snapshots/consistent-type-exports.shot index 1ad2d9511949..2da93e73dfad 100644 --- a/packages/eslint-plugin/tests/schema-snapshots/consistent-type-exports.shot +++ b/packages/eslint-plugin/tests/schema-snapshots/consistent-type-exports.shot @@ -9,6 +9,7 @@ exports[`Rule schemas should be convertible to TS types for documentation purpos "additionalProperties": false, "properties": { "fixMixedExportsWithInlineTypeSpecifier": { + "description": "Whether the rule will autofix \\"mixed\\" export cases using TS inline type specifiers.", "type": "boolean" } }, @@ -21,6 +22,7 @@ exports[`Rule schemas should be convertible to TS types for documentation purpos type Options = [ { + /** Whether the rule will autofix "mixed" export cases using TS inline type specifiers. */ fixMixedExportsWithInlineTypeSpecifier?: boolean; }, ]; diff --git a/packages/eslint-plugin/tests/schema-snapshots/consistent-type-imports.shot b/packages/eslint-plugin/tests/schema-snapshots/consistent-type-imports.shot index 7164fbdd3672..09ce1afb5b2a 100644 --- a/packages/eslint-plugin/tests/schema-snapshots/consistent-type-imports.shot +++ b/packages/eslint-plugin/tests/schema-snapshots/consistent-type-imports.shot @@ -9,13 +9,16 @@ exports[`Rule schemas should be convertible to TS types for documentation purpos "additionalProperties": false, "properties": { "disallowTypeAnnotations": { + "description": "Whether to disallow type imports in type annotations (\`import()\`).", "type": "boolean" }, "fixStyle": { + "description": "The expected type modifier to be added when an import is detected as used only in the type position.", "enum": ["inline-type-imports", "separate-type-imports"], "type": "string" }, "prefer": { + "description": "The expected import kind for type-only imports.", "enum": ["no-type-imports", "type-imports"], "type": "string" } @@ -29,9 +32,18 @@ exports[`Rule schemas should be convertible to TS types for documentation purpos type Options = [ { + /** Whether to disallow type imports in type annotations (\`import()\`). */ disallowTypeAnnotations?: boolean; - fixStyle?: 'inline-type-imports' | 'separate-type-imports'; - prefer?: 'no-type-imports' | 'type-imports'; + /** The expected type modifier to be added when an import is detected as used only in the type position. */ + fixStyle?: + | 'separate-type-imports' + /** The expected type modifier to be added when an import is detected as used only in the type position. */ + | 'inline-type-imports'; + /** The expected import kind for type-only imports. */ + prefer?: + | 'type-imports' + /** The expected import kind for type-only imports. */ + | 'no-type-imports'; }, ]; " diff --git a/packages/eslint-plugin/tests/schema-snapshots/dot-notation.shot b/packages/eslint-plugin/tests/schema-snapshots/dot-notation.shot index 73c0dcdad74b..2017f266c262 100644 --- a/packages/eslint-plugin/tests/schema-snapshots/dot-notation.shot +++ b/packages/eslint-plugin/tests/schema-snapshots/dot-notation.shot @@ -10,22 +10,27 @@ exports[`Rule schemas should be convertible to TS types for documentation purpos "properties": { "allowIndexSignaturePropertyAccess": { "default": false, + "description": "Whether to allow accessing properties matching an index signature with array notation.", "type": "boolean" }, "allowKeywords": { "default": true, + "description": "Whether to allow keywords such as [\\"class\\"]\`.", "type": "boolean" }, "allowPattern": { "default": "", + "description": "Regular expression of names to allow.", "type": "string" }, "allowPrivateClassPropertyAccess": { "default": false, + "description": "Whether to allow accessing class members marked as \`private\` with array notation.", "type": "boolean" }, "allowProtectedClassPropertyAccess": { "default": false, + "description": "Whether to allow accessing class members marked as \`protected\` with array notation.", "type": "boolean" } }, @@ -38,10 +43,15 @@ exports[`Rule schemas should be convertible to TS types for documentation purpos type Options = [ { + /** Whether to allow accessing properties matching an index signature with array notation. */ allowIndexSignaturePropertyAccess?: boolean; + /** Whether to allow keywords such as ["class"]\`. */ allowKeywords?: boolean; + /** Regular expression of names to allow. */ allowPattern?: string; + /** Whether to allow accessing class members marked as \`private\` with array notation. */ allowPrivateClassPropertyAccess?: boolean; + /** Whether to allow accessing class members marked as \`protected\` with array notation. */ allowProtectedClassPropertyAccess?: boolean; }, ]; diff --git a/packages/eslint-plugin/tests/schema-snapshots/explicit-member-accessibility.shot b/packages/eslint-plugin/tests/schema-snapshots/explicit-member-accessibility.shot index 5a33d7fca21f..38813f579a5e 100644 --- a/packages/eslint-plugin/tests/schema-snapshots/explicit-member-accessibility.shot +++ b/packages/eslint-plugin/tests/schema-snapshots/explicit-member-accessibility.shot @@ -33,6 +33,7 @@ exports[`Rule schemas should be convertible to TS types for documentation purpos "$ref": "#/items/0/$defs/accessibilityLevel" }, "ignoredMethodNames": { + "description": "Specific method names that may be ignored.", "items": { "type": "string" }, @@ -78,6 +79,7 @@ type AccessibilityLevel = type Options = [ { accessibility?: AccessibilityLevel; + /** Specific method names that may be ignored. */ ignoredMethodNames?: string[]; overrides?: { accessors?: AccessibilityLevel; diff --git a/packages/eslint-plugin/tests/schema-snapshots/max-params.shot b/packages/eslint-plugin/tests/schema-snapshots/max-params.shot index 646c1287dfae..ed1a2fa62a4d 100644 --- a/packages/eslint-plugin/tests/schema-snapshots/max-params.shot +++ b/packages/eslint-plugin/tests/schema-snapshots/max-params.shot @@ -9,13 +9,16 @@ exports[`Rule schemas should be convertible to TS types for documentation purpos "additionalProperties": false, "properties": { "countVoidThis": { + "description": "Whether to count a \`this\` declaration when the type is \`void\`.", "type": "boolean" }, "max": { + "description": "A maximum number of parameters in function definitions.", "minimum": 0, "type": "integer" }, "maximum": { + "description": "(deprecated) A maximum number of parameters in function definitions.", "minimum": 0, "type": "integer" } @@ -29,8 +32,11 @@ exports[`Rule schemas should be convertible to TS types for documentation purpos type Options = [ { + /** Whether to count a \`this\` declaration when the type is \`void\`. */ countVoidThis?: boolean; + /** A maximum number of parameters in function definitions. */ max?: number; + /** (deprecated) A maximum number of parameters in function definitions. */ maximum?: number; }, ]; diff --git a/packages/eslint-plugin/tests/schema-snapshots/no-base-to-string.shot b/packages/eslint-plugin/tests/schema-snapshots/no-base-to-string.shot index af652bc7e381..08776052d51f 100644 --- a/packages/eslint-plugin/tests/schema-snapshots/no-base-to-string.shot +++ b/packages/eslint-plugin/tests/schema-snapshots/no-base-to-string.shot @@ -9,6 +9,7 @@ exports[`Rule schemas should be convertible to TS types for documentation purpos "additionalProperties": false, "properties": { "ignoredTypeNames": { + "description": "Stringified regular expressions of type names to ignore.", "items": { "type": "string" }, @@ -24,6 +25,7 @@ exports[`Rule schemas should be convertible to TS types for documentation purpos type Options = [ { + /** Stringified regular expressions of type names to ignore. */ ignoredTypeNames?: string[]; }, ]; diff --git a/packages/eslint-plugin/tests/schema-snapshots/no-confusing-void-expression.shot b/packages/eslint-plugin/tests/schema-snapshots/no-confusing-void-expression.shot index b7481d1000ce..33d620951ee6 100644 --- a/packages/eslint-plugin/tests/schema-snapshots/no-confusing-void-expression.shot +++ b/packages/eslint-plugin/tests/schema-snapshots/no-confusing-void-expression.shot @@ -9,9 +9,11 @@ exports[`Rule schemas should be convertible to TS types for documentation purpos "additionalProperties": false, "properties": { "ignoreArrowShorthand": { + "description": "Whether to ignore \\"shorthand\\" \`() =>\` arrow functions: those without \`{ ... }\` braces.", "type": "boolean" }, "ignoreVoidOperator": { + "description": "Whether to ignore returns that start with the \`void\` operator.", "type": "boolean" } }, @@ -24,7 +26,9 @@ exports[`Rule schemas should be convertible to TS types for documentation purpos type Options = [ { + /** Whether to ignore "shorthand" \`() =>\` arrow functions: those without \`{ ... }\` braces. */ ignoreArrowShorthand?: boolean; + /** Whether to ignore returns that start with the \`void\` operator. */ ignoreVoidOperator?: boolean; }, ]; diff --git a/packages/eslint-plugin/tests/schema-snapshots/no-duplicate-type-constituents.shot b/packages/eslint-plugin/tests/schema-snapshots/no-duplicate-type-constituents.shot index d111b2e37297..d3e7832f1846 100644 --- a/packages/eslint-plugin/tests/schema-snapshots/no-duplicate-type-constituents.shot +++ b/packages/eslint-plugin/tests/schema-snapshots/no-duplicate-type-constituents.shot @@ -9,9 +9,11 @@ exports[`Rule schemas should be convertible to TS types for documentation purpos "additionalProperties": false, "properties": { "ignoreIntersections": { + "description": "Whether to ignore \`&\` intersections.", "type": "boolean" }, "ignoreUnions": { + "description": "Whether to ignore \`|\` unions.", "type": "boolean" } }, @@ -24,7 +26,9 @@ exports[`Rule schemas should be convertible to TS types for documentation purpos type Options = [ { + /** Whether to ignore \`&\` intersections. */ ignoreIntersections?: boolean; + /** Whether to ignore \`|\` unions. */ ignoreUnions?: boolean; }, ]; diff --git a/packages/eslint-plugin/tests/schema-snapshots/no-empty-function.shot b/packages/eslint-plugin/tests/schema-snapshots/no-empty-function.shot index c7660d3ec1ea..3bba08942345 100644 --- a/packages/eslint-plugin/tests/schema-snapshots/no-empty-function.shot +++ b/packages/eslint-plugin/tests/schema-snapshots/no-empty-function.shot @@ -9,6 +9,7 @@ exports[`Rule schemas should be convertible to TS types for documentation purpos "additionalProperties": false, "properties": { "allow": { + "description": "Locations and kinds of functions that are allowed to be empty.", "items": { "enum": [ "arrowFunctions", @@ -41,6 +42,7 @@ exports[`Rule schemas should be convertible to TS types for documentation purpos type Options = [ { + /** Locations and kinds of functions that are allowed to be empty. */ allow?: ( | 'arrowFunctions' | 'asyncFunctions' diff --git a/packages/eslint-plugin/tests/schema-snapshots/no-empty-interface.shot b/packages/eslint-plugin/tests/schema-snapshots/no-empty-interface.shot index fa4dbf83d2c6..0b7f9461781f 100644 --- a/packages/eslint-plugin/tests/schema-snapshots/no-empty-interface.shot +++ b/packages/eslint-plugin/tests/schema-snapshots/no-empty-interface.shot @@ -9,6 +9,7 @@ exports[`Rule schemas should be convertible to TS types for documentation purpos "additionalProperties": false, "properties": { "allowSingleExtends": { + "description": "Whether to allow empty interfaces that extend a single other interface.", "type": "boolean" } }, @@ -21,6 +22,7 @@ exports[`Rule schemas should be convertible to TS types for documentation purpos type Options = [ { + /** Whether to allow empty interfaces that extend a single other interface. */ allowSingleExtends?: boolean; }, ]; diff --git a/packages/eslint-plugin/tests/schema-snapshots/no-empty-object-type.shot b/packages/eslint-plugin/tests/schema-snapshots/no-empty-object-type.shot index 084d86820ca7..766c7f445205 100644 --- a/packages/eslint-plugin/tests/schema-snapshots/no-empty-object-type.shot +++ b/packages/eslint-plugin/tests/schema-snapshots/no-empty-object-type.shot @@ -9,14 +9,17 @@ exports[`Rule schemas should be convertible to TS types for documentation purpos "additionalProperties": false, "properties": { "allowInterfaces": { + "description": "Whether to allow empty interfaces.", "enum": ["always", "never", "with-single-extends"], "type": "string" }, "allowObjectTypes": { + "description": "Whether to allow empty object type literals.", "enum": ["always", "never"], "type": "string" }, "allowWithName": { + "description": "A stringified regular expression to allow interfaces and object type aliases with the configured name.", "type": "string" } }, @@ -29,8 +32,18 @@ exports[`Rule schemas should be convertible to TS types for documentation purpos type Options = [ { - allowInterfaces?: 'always' | 'never' | 'with-single-extends'; - allowObjectTypes?: 'always' | 'never'; + /** Whether to allow empty interfaces. */ + allowInterfaces?: + | 'never' + | 'with-single-extends' + /** Whether to allow empty interfaces. */ + | 'always'; + /** Whether to allow empty object type literals. */ + allowObjectTypes?: + | 'never' + /** Whether to allow empty object type literals. */ + | 'always'; + /** A stringified regular expression to allow interfaces and object type aliases with the configured name. */ allowWithName?: string; }, ]; diff --git a/packages/eslint-plugin/tests/schema-snapshots/no-floating-promises.shot b/packages/eslint-plugin/tests/schema-snapshots/no-floating-promises.shot index 10adf9eed25d..f93997a991f4 100644 --- a/packages/eslint-plugin/tests/schema-snapshots/no-floating-promises.shot +++ b/packages/eslint-plugin/tests/schema-snapshots/no-floating-promises.shot @@ -9,6 +9,7 @@ exports[`Rule schemas should be convertible to TS types for documentation purpos "additionalProperties": false, "properties": { "allowForKnownSafeCalls": { + "description": "Type specifiers of functions whose calls are safe to float.", "items": { "oneOf": [ { @@ -103,6 +104,7 @@ exports[`Rule schemas should be convertible to TS types for documentation purpos "type": "array" }, "allowForKnownSafePromises": { + "description": "Type specifiers that are known to be safe to float.", "items": { "oneOf": [ { @@ -218,6 +220,7 @@ exports[`Rule schemas should be convertible to TS types for documentation purpos type Options = [ { + /** Type specifiers of functions whose calls are safe to float. */ allowForKnownSafeCalls?: ( | { from: 'file'; @@ -235,6 +238,7 @@ type Options = [ } | string )[]; + /** Type specifiers that are known to be safe to float. */ allowForKnownSafePromises?: ( | { from: 'file'; diff --git a/packages/eslint-plugin/tests/schema-snapshots/no-inferrable-types.shot b/packages/eslint-plugin/tests/schema-snapshots/no-inferrable-types.shot index c913653a0078..79d257c7a52f 100644 --- a/packages/eslint-plugin/tests/schema-snapshots/no-inferrable-types.shot +++ b/packages/eslint-plugin/tests/schema-snapshots/no-inferrable-types.shot @@ -9,9 +9,11 @@ exports[`Rule schemas should be convertible to TS types for documentation purpos "additionalProperties": false, "properties": { "ignoreParameters": { + "description": "Whether to ignore function parameters.", "type": "boolean" }, "ignoreProperties": { + "description": "Whether to ignore class properties.", "type": "boolean" } }, @@ -24,7 +26,9 @@ exports[`Rule schemas should be convertible to TS types for documentation purpos type Options = [ { + /** Whether to ignore function parameters. */ ignoreParameters?: boolean; + /** Whether to ignore class properties. */ ignoreProperties?: boolean; }, ]; diff --git a/packages/eslint-plugin/tests/schema-snapshots/no-invalid-void-type.shot b/packages/eslint-plugin/tests/schema-snapshots/no-invalid-void-type.shot index a6d271f1a0f4..a02fca83275d 100644 --- a/packages/eslint-plugin/tests/schema-snapshots/no-invalid-void-type.shot +++ b/packages/eslint-plugin/tests/schema-snapshots/no-invalid-void-type.shot @@ -9,9 +9,11 @@ exports[`Rule schemas should be convertible to TS types for documentation purpos "additionalProperties": false, "properties": { "allowAsThisParameter": { + "description": "Whether a \`this\` parameter of a function may be \`void\`.", "type": "boolean" }, "allowInGenericTypeArguments": { + "description": "Whether \`void\` can be used as a valid value for generic type parameters.", "oneOf": [ { "type": "boolean" @@ -35,8 +37,13 @@ exports[`Rule schemas should be convertible to TS types for documentation purpos type Options = [ { + /** Whether a \`this\` parameter of a function may be \`void\`. */ allowAsThisParameter?: boolean; - allowInGenericTypeArguments?: [string, ...string[]] | boolean; + /** Whether \`void\` can be used as a valid value for generic type parameters. */ + allowInGenericTypeArguments?: + | [string, ...string[]] + /** Whether \`void\` can be used as a valid value for generic type parameters. */ + | boolean; }, ]; " diff --git a/packages/eslint-plugin/tests/schema-snapshots/no-magic-numbers.shot b/packages/eslint-plugin/tests/schema-snapshots/no-magic-numbers.shot index 5628d7b9927a..bb7c001fa6aa 100644 --- a/packages/eslint-plugin/tests/schema-snapshots/no-magic-numbers.shot +++ b/packages/eslint-plugin/tests/schema-snapshots/no-magic-numbers.shot @@ -44,15 +44,19 @@ exports[`Rule schemas should be convertible to TS types for documentation purpos "type": "boolean" }, "ignoreEnums": { + "description": "Whether enums used in TypeScript are considered okay.", "type": "boolean" }, "ignoreNumericLiteralTypes": { + "description": "Whether numbers used in TypeScript numeric literal types are considered okay.", "type": "boolean" }, "ignoreReadonlyClassProperties": { + "description": "Whether \`readonly\` class properties are considered okay.", "type": "boolean" }, "ignoreTypeIndexes": { + "description": "Whether numbers used to index types are okay.", "type": "boolean" } }, @@ -71,9 +75,13 @@ type Options = [ ignoreArrayIndexes?: boolean; ignoreClassFieldInitialValues?: boolean; ignoreDefaultValues?: boolean; + /** Whether enums used in TypeScript are considered okay. */ ignoreEnums?: boolean; + /** Whether numbers used in TypeScript numeric literal types are considered okay. */ ignoreNumericLiteralTypes?: boolean; + /** Whether \`readonly\` class properties are considered okay. */ ignoreReadonlyClassProperties?: boolean; + /** Whether numbers used to index types are okay. */ ignoreTypeIndexes?: boolean; }, ]; diff --git a/packages/eslint-plugin/tests/schema-snapshots/no-meaningless-void-operator.shot b/packages/eslint-plugin/tests/schema-snapshots/no-meaningless-void-operator.shot index 8f66e54f40de..eb8f091b2dda 100644 --- a/packages/eslint-plugin/tests/schema-snapshots/no-meaningless-void-operator.shot +++ b/packages/eslint-plugin/tests/schema-snapshots/no-meaningless-void-operator.shot @@ -10,6 +10,7 @@ exports[`Rule schemas should be convertible to TS types for documentation purpos "properties": { "checkNever": { "default": false, + "description": "Whether to suggest removing \`void\` when the argument has type \`never\`.", "type": "boolean" } }, @@ -22,6 +23,7 @@ exports[`Rule schemas should be convertible to TS types for documentation purpos type Options = [ { + /** Whether to suggest removing \`void\` when the argument has type \`never\`. */ checkNever?: boolean; }, ]; diff --git a/packages/eslint-plugin/tests/schema-snapshots/no-misused-promises.shot b/packages/eslint-plugin/tests/schema-snapshots/no-misused-promises.shot index 4cd7d094b174..e0d897012c0a 100644 --- a/packages/eslint-plugin/tests/schema-snapshots/no-misused-promises.shot +++ b/packages/eslint-plugin/tests/schema-snapshots/no-misused-promises.shot @@ -12,6 +12,7 @@ exports[`Rule schemas should be convertible to TS types for documentation purpos "type": "boolean" }, "checksSpreads": { + "description": "Whether to warn when \`...\` spreading a \`Promise\`.", "type": "boolean" }, "checksVoidReturn": { @@ -23,21 +24,27 @@ exports[`Rule schemas should be convertible to TS types for documentation purpos "additionalProperties": false, "properties": { "arguments": { + "description": "Disables checking an asynchronous function passed as argument where the parameter type expects a function that returns \`void\`.", "type": "boolean" }, "attributes": { + "description": "Disables checking an asynchronous function passed as a JSX attribute expected to be a function that returns \`void\`.", "type": "boolean" }, "inheritedMethods": { + "description": "Disables checking an asynchronous method in a type that extends or implements another type expecting that method to return \`void\`.", "type": "boolean" }, "properties": { + "description": "Disables checking an asynchronous function passed as an object property expected to be a function that returns \`void\`.", "type": "boolean" }, "returns": { + "description": "Disables checking an asynchronous function returned in a function whose return type is a function that returns \`void\`.", "type": "boolean" }, "variables": { + "description": "Disables checking an asynchronous function used as a variable whose return type is a function that returns \`void\`.", "type": "boolean" } }, @@ -56,14 +63,21 @@ exports[`Rule schemas should be convertible to TS types for documentation purpos type Options = [ { checksConditionals?: boolean; + /** Whether to warn when \`...\` spreading a \`Promise\`. */ checksSpreads?: boolean; checksVoidReturn?: | { + /** Disables checking an asynchronous function passed as argument where the parameter type expects a function that returns \`void\`. */ arguments?: boolean; + /** Disables checking an asynchronous function passed as a JSX attribute expected to be a function that returns \`void\`. */ attributes?: boolean; + /** Disables checking an asynchronous method in a type that extends or implements another type expecting that method to return \`void\`. */ inheritedMethods?: boolean; + /** Disables checking an asynchronous function passed as an object property expected to be a function that returns \`void\`. */ properties?: boolean; + /** Disables checking an asynchronous function returned in a function whose return type is a function that returns \`void\`. */ returns?: boolean; + /** Disables checking an asynchronous function used as a variable whose return type is a function that returns \`void\`. */ variables?: boolean; } | boolean; diff --git a/packages/eslint-plugin/tests/schema-snapshots/no-redeclare.shot b/packages/eslint-plugin/tests/schema-snapshots/no-redeclare.shot index 61f33831a071..878098ff2450 100644 --- a/packages/eslint-plugin/tests/schema-snapshots/no-redeclare.shot +++ b/packages/eslint-plugin/tests/schema-snapshots/no-redeclare.shot @@ -9,9 +9,11 @@ exports[`Rule schemas should be convertible to TS types for documentation purpos "additionalProperties": false, "properties": { "builtinGlobals": { + "description": "Whether to report shadowing of built-in global variables.", "type": "boolean" }, "ignoreDeclarationMerge": { + "description": "Whether to ignore declaration merges between certain TypeScript declaration types.", "type": "boolean" } }, @@ -24,7 +26,9 @@ exports[`Rule schemas should be convertible to TS types for documentation purpos type Options = [ { + /** Whether to report shadowing of built-in global variables. */ builtinGlobals?: boolean; + /** Whether to ignore declaration merges between certain TypeScript declaration types. */ ignoreDeclarationMerge?: boolean; }, ]; diff --git a/packages/eslint-plugin/tests/schema-snapshots/no-shadow.shot b/packages/eslint-plugin/tests/schema-snapshots/no-shadow.shot index 78b85fbadc0d..22a2dba566de 100644 --- a/packages/eslint-plugin/tests/schema-snapshots/no-shadow.shot +++ b/packages/eslint-plugin/tests/schema-snapshots/no-shadow.shot @@ -9,25 +9,31 @@ exports[`Rule schemas should be convertible to TS types for documentation purpos "additionalProperties": false, "properties": { "allow": { + "description": "Identifier names for which shadowing is allowed.", "items": { "type": "string" }, "type": "array" }, "builtinGlobals": { + "description": "Whether to report shadowing of built-in global variables.", "type": "boolean" }, "hoist": { + "description": "Whether to report shadowing before outer functions or variables are defined.", "enum": ["all", "functions", "never"], "type": "string" }, "ignoreFunctionTypeParameterNameValueShadow": { + "description": "Whether to ignore function parameters named the same as a variable.", "type": "boolean" }, "ignoreOnInitialization": { + "description": "Whether to ignore the variable initializers when the shadowed variable is presumably still unitialized.", "type": "boolean" }, "ignoreTypeValueShadow": { + "description": "Whether to ignore types named the same as a variable.", "type": "boolean" } }, @@ -40,11 +46,21 @@ exports[`Rule schemas should be convertible to TS types for documentation purpos type Options = [ { + /** Identifier names for which shadowing is allowed. */ allow?: string[]; + /** Whether to report shadowing of built-in global variables. */ builtinGlobals?: boolean; - hoist?: 'all' | 'functions' | 'never'; + /** Whether to report shadowing before outer functions or variables are defined. */ + hoist?: + | 'functions' + | 'never' + /** Whether to report shadowing before outer functions or variables are defined. */ + | 'all'; + /** Whether to ignore function parameters named the same as a variable. */ ignoreFunctionTypeParameterNameValueShadow?: boolean; + /** Whether to ignore the variable initializers when the shadowed variable is presumably still unitialized. */ ignoreOnInitialization?: boolean; + /** Whether to ignore types named the same as a variable. */ ignoreTypeValueShadow?: boolean; }, ]; diff --git a/packages/eslint-plugin/tests/schema-snapshots/no-unused-vars.shot b/packages/eslint-plugin/tests/schema-snapshots/no-unused-vars.shot index f7a81d300694..b9abdde2bab4 100644 --- a/packages/eslint-plugin/tests/schema-snapshots/no-unused-vars.shot +++ b/packages/eslint-plugin/tests/schema-snapshots/no-unused-vars.shot @@ -15,36 +15,46 @@ exports[`Rule schemas should be convertible to TS types for documentation purpos "additionalProperties": false, "properties": { "args": { + "description": "Whether to check all, some, or no arguments.", "enum": ["after-used", "all", "none"], "type": "string" }, "argsIgnorePattern": { + "description": "Regular expressions of argument names to not check for usage.", "type": "string" }, "caughtErrors": { + "description": "Whether to check catch block arguments.", "enum": ["all", "none"], "type": "string" }, "caughtErrorsIgnorePattern": { + "description": "Regular expressions of catch block argument names to not check for usage.", "type": "string" }, "destructuredArrayIgnorePattern": { + "description": "Regular expressions of destructured array variable names to not check for usage.", "type": "string" }, "ignoreClassWithStaticInitBlock": { + "description": "Whether to ignore classes with at least one static initialization block.", "type": "boolean" }, "ignoreRestSiblings": { + "description": "Whether to ignore sibling properties in \`...\` destructurings.", "type": "boolean" }, "reportUsedIgnorePattern": { + "description": "Whether to report variables that match any of the valid ignore pattern options if they have been used.", "type": "boolean" }, "vars": { + "description": "Whether to check all variables or only locally-declared variables.", "enum": ["all", "local"], "type": "string" }, "varsIgnorePattern": { + "description": "Regular expressions of variable names to not check for usage.", "type": "string" } }, @@ -61,15 +71,35 @@ type Options = [ | 'all' | 'local' | { - args?: 'after-used' | 'all' | 'none'; + /** Whether to check all, some, or no arguments. */ + args?: + | 'all' + | 'none' + /** Whether to check all, some, or no arguments. */ + | 'after-used'; + /** Regular expressions of argument names to not check for usage. */ argsIgnorePattern?: string; - caughtErrors?: 'all' | 'none'; + /** Whether to check catch block arguments. */ + caughtErrors?: + | 'none' + /** Whether to check catch block arguments. */ + | 'all'; + /** Regular expressions of catch block argument names to not check for usage. */ caughtErrorsIgnorePattern?: string; + /** Regular expressions of destructured array variable names to not check for usage. */ destructuredArrayIgnorePattern?: string; + /** Whether to ignore classes with at least one static initialization block. */ ignoreClassWithStaticInitBlock?: boolean; + /** Whether to ignore sibling properties in \`...\` destructurings. */ ignoreRestSiblings?: boolean; + /** Whether to report variables that match any of the valid ignore pattern options if they have been used. */ reportUsedIgnorePattern?: boolean; - vars?: 'all' | 'local'; + /** Whether to check all variables or only locally-declared variables. */ + vars?: + | 'local' + /** Whether to check all variables or only locally-declared variables. */ + | 'all'; + /** Regular expressions of variable names to not check for usage. */ varsIgnorePattern?: string; }, ]; diff --git a/packages/eslint-plugin/tests/schema-snapshots/no-use-before-define.shot b/packages/eslint-plugin/tests/schema-snapshots/no-use-before-define.shot index 624448da333f..a094b1776731 100644 --- a/packages/eslint-plugin/tests/schema-snapshots/no-use-before-define.shot +++ b/packages/eslint-plugin/tests/schema-snapshots/no-use-before-define.shot @@ -18,21 +18,27 @@ exports[`Rule schemas should be convertible to TS types for documentation purpos "type": "boolean" }, "classes": { + "description": "Whether to ignore references to class declarations.", "type": "boolean" }, "enums": { + "description": "Whether to check references to enums.", "type": "boolean" }, "functions": { + "description": "Whether to ignore references to function declarations.", "type": "boolean" }, "ignoreTypeReferences": { + "description": "Whether to ignore type references, such as in type annotations and assertions.", "type": "boolean" }, "typedefs": { + "description": "Whether to check references to types.", "type": "boolean" }, "variables": { + "description": "Whether to ignore references to variables.", "type": "boolean" } }, @@ -49,11 +55,17 @@ type Options = [ | 'nofunc' | { allowNamedExports?: boolean; + /** Whether to ignore references to class declarations. */ classes?: boolean; + /** Whether to check references to enums. */ enums?: boolean; + /** Whether to ignore references to function declarations. */ functions?: boolean; + /** Whether to ignore type references, such as in type annotations and assertions. */ ignoreTypeReferences?: boolean; + /** Whether to check references to types. */ typedefs?: boolean; + /** Whether to ignore references to variables. */ variables?: boolean; }, ]; diff --git a/packages/eslint-plugin/tests/schema-snapshots/only-throw-error.shot b/packages/eslint-plugin/tests/schema-snapshots/only-throw-error.shot index 370beb0d1bd8..05b6ae4af6b0 100644 --- a/packages/eslint-plugin/tests/schema-snapshots/only-throw-error.shot +++ b/packages/eslint-plugin/tests/schema-snapshots/only-throw-error.shot @@ -9,9 +9,11 @@ exports[`Rule schemas should be convertible to TS types for documentation purpos "additionalProperties": false, "properties": { "allowThrowingAny": { + "description": "Whether to always allow throwing values typed as \`any\`.", "type": "boolean" }, "allowThrowingUnknown": { + "description": "Whether to always allow throwing values typed as \`unknown\`.", "type": "boolean" } }, @@ -24,7 +26,9 @@ exports[`Rule schemas should be convertible to TS types for documentation purpos type Options = [ { + /** Whether to always allow throwing values typed as \`any\`. */ allowThrowingAny?: boolean; + /** Whether to always allow throwing values typed as \`unknown\`. */ allowThrowingUnknown?: boolean; }, ]; diff --git a/packages/eslint-plugin/tests/schema-snapshots/parameter-properties.shot b/packages/eslint-plugin/tests/schema-snapshots/parameter-properties.shot index 502e7b0387f2..73e2120ea8b3 100644 --- a/packages/eslint-plugin/tests/schema-snapshots/parameter-properties.shot +++ b/packages/eslint-plugin/tests/schema-snapshots/parameter-properties.shot @@ -23,12 +23,14 @@ exports[`Rule schemas should be convertible to TS types for documentation purpos "additionalProperties": false, "properties": { "allow": { + "description": "Whether to allow certain kinds of properties to be ignored.", "items": { "$ref": "#/items/0/$defs/modifier" }, "type": "array" }, "prefer": { + "description": "Whether to prefer class properties or parameter properties.", "enum": ["class-property", "parameter-property"], "type": "string" } @@ -51,8 +53,13 @@ type Modifier = type Options = [ { + /** Whether to allow certain kinds of properties to be ignored. */ allow?: Modifier[]; - prefer?: 'class-property' | 'parameter-property'; + /** Whether to prefer class properties or parameter properties. */ + prefer?: + | 'parameter-property' + /** Whether to prefer class properties or parameter properties. */ + | 'class-property'; }, ]; " diff --git a/packages/eslint-plugin/tests/schema-snapshots/prefer-literal-enum-member.shot b/packages/eslint-plugin/tests/schema-snapshots/prefer-literal-enum-member.shot index 9bbb15fe6ddb..227983ab267e 100644 --- a/packages/eslint-plugin/tests/schema-snapshots/prefer-literal-enum-member.shot +++ b/packages/eslint-plugin/tests/schema-snapshots/prefer-literal-enum-member.shot @@ -9,6 +9,7 @@ exports[`Rule schemas should be convertible to TS types for documentation purpos "additionalProperties": false, "properties": { "allowBitwiseExpressions": { + "description": "Whether to allow using bitwise expressions in enum initializers.", "type": "boolean" } }, @@ -21,6 +22,7 @@ exports[`Rule schemas should be convertible to TS types for documentation purpos type Options = [ { + /** Whether to allow using bitwise expressions in enum initializers. */ allowBitwiseExpressions?: boolean; }, ]; diff --git a/packages/eslint-plugin/tests/schema-snapshots/prefer-nullish-coalescing.shot b/packages/eslint-plugin/tests/schema-snapshots/prefer-nullish-coalescing.shot index 2a4fd6b7550e..7afce381e977 100644 --- a/packages/eslint-plugin/tests/schema-snapshots/prefer-nullish-coalescing.shot +++ b/packages/eslint-plugin/tests/schema-snapshots/prefer-nullish-coalescing.shot @@ -9,15 +9,19 @@ exports[`Rule schemas should be convertible to TS types for documentation purpos "additionalProperties": false, "properties": { "allowRuleToRunWithoutStrictNullChecksIKnowWhatIAmDoing": { + "description": "Unless this is set to \`true\`, the rule will error on every file whose \`tsconfig.json\` does _not_ have the \`strictNullChecks\` compiler option (or \`strict\`) set to \`true\`.", "type": "boolean" }, "ignoreConditionalTests": { + "description": "Whether to ignore cases that are located within a conditional test.", "type": "boolean" }, "ignoreMixedLogicalExpressions": { + "description": "Whether to ignore any logical or expressions that are part of a mixed logical expression (with \`&&\`).", "type": "boolean" }, "ignorePrimitives": { + "description": "Whether to ignore all (\`true\`) or some (an object with properties) primitive types.", "oneOf": [ { "properties": { @@ -43,6 +47,7 @@ exports[`Rule schemas should be convertible to TS types for documentation purpos ] }, "ignoreTernaryTests": { + "description": "Whether to ignore any ternary expressions that could be simplified by using the nullish coalescing operator.", "type": "boolean" } }, @@ -55,18 +60,24 @@ exports[`Rule schemas should be convertible to TS types for documentation purpos type Options = [ { + /** Unless this is set to \`true\`, the rule will error on every file whose \`tsconfig.json\` does _not_ have the \`strictNullChecks\` compiler option (or \`strict\`) set to \`true\`. */ allowRuleToRunWithoutStrictNullChecksIKnowWhatIAmDoing?: boolean; + /** Whether to ignore cases that are located within a conditional test. */ ignoreConditionalTests?: boolean; + /** Whether to ignore any logical or expressions that are part of a mixed logical expression (with \`&&\`). */ ignoreMixedLogicalExpressions?: boolean; + /** Whether to ignore all (\`true\`) or some (an object with properties) primitive types. */ ignorePrimitives?: + | true + /** Whether to ignore all (\`true\`) or some (an object with properties) primitive types. */ | { bigint?: boolean; boolean?: boolean; number?: boolean; string?: boolean; [k: string]: unknown; - } - | true; + }; + /** Whether to ignore any ternary expressions that could be simplified by using the nullish coalescing operator. */ ignoreTernaryTests?: boolean; }, ]; diff --git a/packages/eslint-plugin/tests/schema-snapshots/prefer-promise-reject-errors.shot b/packages/eslint-plugin/tests/schema-snapshots/prefer-promise-reject-errors.shot index fc04d11fd3f1..069c2ea65846 100644 --- a/packages/eslint-plugin/tests/schema-snapshots/prefer-promise-reject-errors.shot +++ b/packages/eslint-plugin/tests/schema-snapshots/prefer-promise-reject-errors.shot @@ -9,6 +9,7 @@ exports[`Rule schemas should be convertible to TS types for documentation purpos "additionalProperties": false, "properties": { "allowEmptyReject": { + "description": "Whether to allow calls to \`Promise.reject()\` with no arguments.", "type": "boolean" } }, @@ -21,6 +22,7 @@ exports[`Rule schemas should be convertible to TS types for documentation purpos type Options = [ { + /** Whether to allow calls to \`Promise.reject()\` with no arguments. */ allowEmptyReject?: boolean; }, ]; diff --git a/packages/eslint-plugin/tests/schema-snapshots/prefer-readonly-parameter-types.shot b/packages/eslint-plugin/tests/schema-snapshots/prefer-readonly-parameter-types.shot index 332e54184b30..6aef90b64a8b 100644 --- a/packages/eslint-plugin/tests/schema-snapshots/prefer-readonly-parameter-types.shot +++ b/packages/eslint-plugin/tests/schema-snapshots/prefer-readonly-parameter-types.shot @@ -9,6 +9,7 @@ exports[`Rule schemas should be convertible to TS types for documentation purpos "additionalProperties": false, "properties": { "allow": { + "description": "An array of type specifiers to ignore.", "items": { "oneOf": [ { @@ -103,12 +104,15 @@ exports[`Rule schemas should be convertible to TS types for documentation purpos "type": "array" }, "checkParameterProperties": { + "description": "Whether to check class parameter properties.", "type": "boolean" }, "ignoreInferredTypes": { + "description": "Whether to ignore parameters which don't explicitly specify a type.", "type": "boolean" }, "treatMethodsAsReadonly": { + "description": "Whether to treat all mutable methods as though they are readonly.", "type": "boolean" } }, @@ -121,6 +125,7 @@ exports[`Rule schemas should be convertible to TS types for documentation purpos type Options = [ { + /** An array of type specifiers to ignore. */ allow?: ( | { from: 'file'; @@ -138,8 +143,11 @@ type Options = [ } | string )[]; + /** Whether to check class parameter properties. */ checkParameterProperties?: boolean; + /** Whether to ignore parameters which don't explicitly specify a type. */ ignoreInferredTypes?: boolean; + /** Whether to treat all mutable methods as though they are readonly. */ treatMethodsAsReadonly?: boolean; }, ]; diff --git a/packages/eslint-plugin/tests/schema-snapshots/prefer-readonly.shot b/packages/eslint-plugin/tests/schema-snapshots/prefer-readonly.shot index 34e4a22204a9..aa6f21373b5c 100644 --- a/packages/eslint-plugin/tests/schema-snapshots/prefer-readonly.shot +++ b/packages/eslint-plugin/tests/schema-snapshots/prefer-readonly.shot @@ -9,6 +9,7 @@ exports[`Rule schemas should be convertible to TS types for documentation purpos "additionalProperties": false, "properties": { "onlyInlineLambdas": { + "description": "Whether to restrict checking only to members immediately assigned a lambda value.", "type": "boolean" } }, @@ -21,6 +22,7 @@ exports[`Rule schemas should be convertible to TS types for documentation purpos type Options = [ { + /** Whether to restrict checking only to members immediately assigned a lambda value. */ onlyInlineLambdas?: boolean; }, ]; diff --git a/packages/eslint-plugin/tests/schema-snapshots/promise-function-async.shot b/packages/eslint-plugin/tests/schema-snapshots/promise-function-async.shot index c073af42009a..323889a27a5d 100644 --- a/packages/eslint-plugin/tests/schema-snapshots/promise-function-async.shot +++ b/packages/eslint-plugin/tests/schema-snapshots/promise-function-async.shot @@ -20,15 +20,19 @@ exports[`Rule schemas should be convertible to TS types for documentation purpos "type": "array" }, "checkArrowFunctions": { + "description": "Whether to check arrow functions.", "type": "boolean" }, "checkFunctionDeclarations": { + "description": "Whether to check standalone function declarations.", "type": "boolean" }, "checkFunctionExpressions": { + "description": "Whether to check inline function expressions", "type": "boolean" }, "checkMethodDeclarations": { + "description": "Whether to check methods on classes and object literals.", "type": "boolean" } }, @@ -45,9 +49,13 @@ type Options = [ allowAny?: boolean; /** Any extra names of classes or interfaces to be considered Promises. */ allowedPromiseNames?: string[]; + /** Whether to check arrow functions. */ checkArrowFunctions?: boolean; + /** Whether to check standalone function declarations. */ checkFunctionDeclarations?: boolean; + /** Whether to check inline function expressions */ checkFunctionExpressions?: boolean; + /** Whether to check methods on classes and object literals. */ checkMethodDeclarations?: boolean; }, ]; diff --git a/packages/eslint-plugin/tests/schema-snapshots/return-await.shot b/packages/eslint-plugin/tests/schema-snapshots/return-await.shot index 7096730066db..1737782efd25 100644 --- a/packages/eslint-plugin/tests/schema-snapshots/return-await.shot +++ b/packages/eslint-plugin/tests/schema-snapshots/return-await.shot @@ -6,11 +6,27 @@ exports[`Rule schemas should be convertible to TS types for documentation purpos [ { - "enum": [ - "always", - "error-handling-correctness-only", - "in-try-catch", - "never" + "oneOf": [ + { + "description": "Requires that all returned promises be awaited.", + "enum": ["always"], + "type": "string" + }, + { + "description": "In error-handling contexts, the rule enforces that returned promises must be awaited. In ordinary contexts, the rule does not enforce any particular behavior around whether returned promises are awaited.", + "enum": ["error-handling-correctness-only"], + "type": "string" + }, + { + "description": "In error-handling contexts, the rule enforces that returned promises must be awaited. In ordinary contexts, the rule enforces that returned promises _must not_ be awaited.", + "enum": ["in-try-catch"], + "type": "string" + }, + { + "description": "Disallows awaiting any returned promises.", + "enum": ["never"], + "type": "string" + } ], "type": "string" } @@ -20,7 +36,14 @@ exports[`Rule schemas should be convertible to TS types for documentation purpos # TYPES: type Options = [ - 'always' | 'error-handling-correctness-only' | 'in-try-catch' | 'never', + /** Disallows awaiting any returned promises. */ + | 'never' + /** In error-handling contexts, the rule enforces that returned promises must be awaited. In ordinary contexts, the rule does not enforce any particular behavior around whether returned promises are awaited. */ + | 'error-handling-correctness-only' + /** In error-handling contexts, the rule enforces that returned promises must be awaited. In ordinary contexts, the rule enforces that returned promises _must not_ be awaited. */ + | 'in-try-catch' + /** Requires that all returned promises be awaited. */ + | 'always', ]; " `; diff --git a/packages/eslint-plugin/tests/schema-snapshots/strict-boolean-expressions.shot b/packages/eslint-plugin/tests/schema-snapshots/strict-boolean-expressions.shot index 140b7e556a48..5c52af177f3d 100644 --- a/packages/eslint-plugin/tests/schema-snapshots/strict-boolean-expressions.shot +++ b/packages/eslint-plugin/tests/schema-snapshots/strict-boolean-expressions.shot @@ -9,30 +9,38 @@ exports[`Rule schemas should be convertible to TS types for documentation purpos "additionalProperties": false, "properties": { "allowAny": { + "description": "Whether to allow \`any\` in a boolean context.", "type": "boolean" }, "allowNullableBoolean": { + "description": "Whether to allow nullable \`boolean\`s in a boolean context.", "type": "boolean" }, "allowNullableEnum": { + "description": "Whether to allow nullable \`enum\`s in a boolean context.", "type": "boolean" }, "allowNullableNumber": { + "description": "Whether to allow nullable \`number\`s in a boolean context.", "type": "boolean" }, "allowNullableObject": { + "description": "Whether to allow nullable \`object\`s in a boolean context.", "type": "boolean" }, "allowNullableString": { + "description": "Whether to allow nullable \`string\`s in a boolean context.", "type": "boolean" }, "allowNumber": { + "description": "Whether to allow \`number\` in a boolean context.", "type": "boolean" }, "allowRuleToRunWithoutStrictNullChecksIKnowWhatIAmDoing": { "type": "boolean" }, "allowString": { + "description": "Whether to allow \`string\` in a boolean context.", "type": "boolean" } }, @@ -45,14 +53,22 @@ exports[`Rule schemas should be convertible to TS types for documentation purpos type Options = [ { + /** Whether to allow \`any\` in a boolean context. */ allowAny?: boolean; + /** Whether to allow nullable \`boolean\`s in a boolean context. */ allowNullableBoolean?: boolean; + /** Whether to allow nullable \`enum\`s in a boolean context. */ allowNullableEnum?: boolean; + /** Whether to allow nullable \`number\`s in a boolean context. */ allowNullableNumber?: boolean; + /** Whether to allow nullable \`object\`s in a boolean context. */ allowNullableObject?: boolean; + /** Whether to allow nullable \`string\`s in a boolean context. */ allowNullableString?: boolean; + /** Whether to allow \`number\` in a boolean context. */ allowNumber?: boolean; allowRuleToRunWithoutStrictNullChecksIKnowWhatIAmDoing?: boolean; + /** Whether to allow \`string\` in a boolean context. */ allowString?: boolean; }, ]; diff --git a/packages/eslint-plugin/tests/schema-snapshots/triple-slash-reference.shot b/packages/eslint-plugin/tests/schema-snapshots/triple-slash-reference.shot index 330be71ffe18..96fc018138a5 100644 --- a/packages/eslint-plugin/tests/schema-snapshots/triple-slash-reference.shot +++ b/packages/eslint-plugin/tests/schema-snapshots/triple-slash-reference.shot @@ -9,14 +9,17 @@ exports[`Rule schemas should be convertible to TS types for documentation purpos "additionalProperties": false, "properties": { "lib": { + "description": "What to enforce for \`/// \` references.", "enum": ["always", "never"], "type": "string" }, "path": { + "description": "What to enforce for \`/// \` references.", "enum": ["always", "never"], "type": "string" }, "types": { + "description": "What to enforce for \`/// \` references.", "enum": ["always", "never", "prefer-import"], "type": "string" } @@ -30,9 +33,22 @@ exports[`Rule schemas should be convertible to TS types for documentation purpos type Options = [ { - lib?: 'always' | 'never'; - path?: 'always' | 'never'; - types?: 'always' | 'never' | 'prefer-import'; + /** What to enforce for \`/// \` references. */ + lib?: + | 'never' + /** What to enforce for \`/// \` references. */ + | 'always'; + /** What to enforce for \`/// \` references. */ + path?: + | 'never' + /** What to enforce for \`/// \` references. */ + | 'always'; + /** What to enforce for \`/// \` references. */ + types?: + | 'never' + | 'prefer-import' + /** What to enforce for \`/// \` references. */ + | 'always'; }, ]; " diff --git a/packages/eslint-plugin/tests/schema-snapshots/typedef.shot b/packages/eslint-plugin/tests/schema-snapshots/typedef.shot index e244ad4d80ca..b03a5d2644dc 100644 --- a/packages/eslint-plugin/tests/schema-snapshots/typedef.shot +++ b/packages/eslint-plugin/tests/schema-snapshots/typedef.shot @@ -9,27 +9,35 @@ exports[`Rule schemas should be convertible to TS types for documentation purpos "additionalProperties": false, "properties": { "arrayDestructuring": { + "description": "Whether to enforce type annotations on variables declared using array destructuring.", "type": "boolean" }, "arrowParameter": { + "description": "Whether to enforce type annotations for parameters of arrow functions.", "type": "boolean" }, "memberVariableDeclaration": { + "description": "Whether to enforce type annotations on member variables of classes.", "type": "boolean" }, "objectDestructuring": { + "description": "Whether to enforce type annotations on variables declared using object destructuring.", "type": "boolean" }, "parameter": { + "description": "Whether to enforce type annotations for parameters of functions and methods.", "type": "boolean" }, "propertyDeclaration": { + "description": "Whether to enforce type annotations for properties of interfaces and types.", "type": "boolean" }, "variableDeclaration": { + "description": "Whether to enforce type annotations for variable declarations, excluding array and object destructuring.", "type": "boolean" }, "variableDeclarationIgnoreFunction": { + "description": "Whether to ignore variable declarations for non-arrow and arrow functions.", "type": "boolean" } }, @@ -42,13 +50,21 @@ exports[`Rule schemas should be convertible to TS types for documentation purpos type Options = [ { + /** Whether to enforce type annotations on variables declared using array destructuring. */ arrayDestructuring?: boolean; + /** Whether to enforce type annotations for parameters of arrow functions. */ arrowParameter?: boolean; + /** Whether to enforce type annotations on member variables of classes. */ memberVariableDeclaration?: boolean; + /** Whether to enforce type annotations on variables declared using object destructuring. */ objectDestructuring?: boolean; + /** Whether to enforce type annotations for parameters of functions and methods. */ parameter?: boolean; + /** Whether to enforce type annotations for properties of interfaces and types. */ propertyDeclaration?: boolean; + /** Whether to enforce type annotations for variable declarations, excluding array and object destructuring. */ variableDeclaration?: boolean; + /** Whether to ignore variable declarations for non-arrow and arrow functions. */ variableDeclarationIgnoreFunction?: boolean; }, ];