Programming Search⌘K

TypeScript lints

The lint rules of TypeScript, with what each one finds. This page has 128 cards.

Require consistently using either T[] or Array<T> for arrays. @typescript-eslint/array-type

It is in the stylistic configuration. ESLint can fix the code that it reports. Its rule type is suggestion.

Code
@typescript-eslint/array-type
Message
Array type using '{}<{}>' is forbidden. Use '{}{}[]' instead.
Message
Array type using '{}<{}>' is forbidden. Use '{}{}' instead.
Message
Array type using '{}<{}>' is forbidden for simple types. Use '{}{}[]' instead.
Message
Array type using '{}<{}>' is forbidden for simple types. Use '{}{}' instead.
Message
Array type using '{}{}[]' is forbidden. Use '{}<{}>' instead.
Message
Array type using '{}{}[]' is forbidden for non-simple types. Use '{}<{}>' instead.

Source: github.com, typescript-eslint.io. JSON record. This entry is a card. Help write this page.

Disallow awaiting a value that is not a Thenable. @typescript-eslint/await-thenable

It is in the recommended configuration. It needs type information. It gives suggestions that an editor can apply. Its rule type is problem.

Code
@typescript-eslint/await-thenable
Message
Unexpected `await` of a non-Promise (non-"Thenable") value.
Message
Unexpected `await using` of a value that is not async disposable.
Message
Convert to an ordinary `for...of` loop.
Message
Unexpected `for await...of` of a value that is not async iterable.
Message
Unexpected iterable of non-Promise (non-"Thenable") values passed to promise aggregator.
Message
Remove unnecessary `await`.

Source: github.com, typescript-eslint.io. JSON record. This entry is a card. Help write this page.

Disallow @ts-<directive> comments or require descriptions after directives. @typescript-eslint/ban-ts-comment

It gives suggestions that an editor can apply. Its rule type is problem.

Code
@typescript-eslint/ban-ts-comment
Message
Replace "@ts-ignore" with "@ts-expect-error".
Message
Do not use "@ts-{}" because it alters compilation errors.
Message
The description for the "@ts-{}" directive must match the {} format.
Message
Include a description after the "@ts-{}" directive to explain why the @ts-{} is necessary. The description must be {} characters or longer.
Message
Use "@ts-expect-error" instead of "@ts-ignore", as "@ts-ignore" will do nothing if the following line is error-free.

Source: github.com, typescript-eslint.io. JSON record. This entry is a card. Help write this page.

Enforce that literals on classes are exposed in a consistent style. @typescript-eslint/class-literal-property-style

It is in the stylistic configuration. It gives suggestions that an editor can apply. Its rule type is problem.

Code
@typescript-eslint/class-literal-property-style
Message
Literals should be exposed using readonly fields.
Message
Replace the literals with readonly fields.
Message
Literals should be exposed using getters.
Message
Replace the literals with getters.

Source: github.com, typescript-eslint.io. JSON record. This entry is a card. Help write this page.

Enforce specifying generic type arguments on type annotation or constructor name of a constructor call. @typescript-eslint/consistent-generic-constructors

It is in the stylistic configuration. ESLint can fix the code that it reports. Its rule type is suggestion.

Code
@typescript-eslint/consistent-generic-constructors
Message
The generic type arguments should be specified as part of the constructor type arguments.
Message
The generic type arguments should be specified as part of the type annotation.

Source: github.com, typescript-eslint.io. JSON record. This entry is a card. Help write this page.

Require or disallow the Record type. @typescript-eslint/consistent-indexed-object-style

It is in the stylistic configuration. ESLint can fix the code that it reports. Its rule type is suggestion.

Code
@typescript-eslint/consistent-indexed-object-style
Message
An index signature is preferred over a record.
Message
Change into an index signature instead of a record.
Message
A record is preferred over an index signature.
Message
Change into a record instead of an index signature.

Source: github.com, typescript-eslint.io. JSON record. This entry is a card. Help write this page.

Enforce consistent usage of type assertions. @typescript-eslint/consistent-type-assertions

It is in the stylistic configuration. ESLint can fix the code that it reports. Its rule type is suggestion.

Code
@typescript-eslint/consistent-type-assertions
Message
Use 'as {}' instead of '<{}>'.
Message
Do not use any type assertions.
Message
Use const x: {} = [ ... ] instead.
Message
Use const x = [ ... ] satisfies {} instead.
Message
Use const x: {} = { ... } instead.
Message
Use const x = { ... } satisfies {} instead.

Source: github.com, typescript-eslint.io. JSON record. This entry is a card. Help write this page.

Enforce consistent usage of type exports. @typescript-eslint/consistent-type-exports

It needs type information. ESLint can fix the code that it reports. Its rule type is suggestion.

Code
@typescript-eslint/consistent-type-exports
Message
Type exports {} are not values and should be exported using `export type`.
Message
Type export {} is not a value and should be exported using `export type`.
Message
All exports in the declaration are only used as types. Use `export type`.

Source: github.com, typescript-eslint.io. JSON record. This entry is a card. Help write this page.

Enforce consistent usage of type imports. @typescript-eslint/consistent-type-imports

ESLint can fix the code that it reports. Its rule type is suggestion.

Code
@typescript-eslint/consistent-type-imports
Message
Use an `import` instead of an `import type`.
Message
`import()` type annotations are forbidden.
Message
Imports {} are only used as type.
Message
All imports in the declaration are only used as types. Use `import type`.

Source: github.com, typescript-eslint.io. JSON record. This entry is a card. Help write this page.

Require explicit return and argument types on exported functions' and classes' public class methods. @typescript-eslint/explicit-module-boundary-types

Its rule type is problem.

Code
@typescript-eslint/explicit-module-boundary-types
Message
Argument '{}' should be typed with a non-any type.
Message
{} argument should be typed with a non-any type.
Message
Argument '{}' should be typed.
Message
{} argument should be typed.
Message
Missing return type on function.

Source: github.com, typescript-eslint.io. JSON record. This entry is a card. Help write this page.

Enforce using a particular method signature syntax. @typescript-eslint/method-signature-style

ESLint can fix the code that it reports. Its rule type is suggestion.

Code
@typescript-eslint/method-signature-style
Message
Convert to a method signature. This removes the `readonly` modifier, allowing the member to be reassigned.
Message
Shorthand method signature is forbidden. Use a function property instead.
Message
Function property signature is forbidden. Use a method shorthand instead.

Source: github.com, typescript-eslint.io. JSON record. This entry is a card. Help write this page.

Enforce naming conventions for everything across a codebase. @typescript-eslint/naming-convention

It needs type information. Its rule type is suggestion.

Code
@typescript-eslint/naming-convention
Message
{} name `{}` must match one of the following formats: {}
Message
{} name `{}` trimmed as `{}` must match one of the following formats: {}
Message
{} name `{}` must have one of the following {}es: {}
Message
{} name `{}` must have {} {} underscore(s).
Message
{} name `{}` must {} the RegExp: {}
Message
{} name `{}` must not have a {} underscore.

Source: github.com, typescript-eslint.io. JSON record. This entry is a card. Help write this page.

Require .toString() and .toLocaleString() to only be called on objects which provide useful information when stringified. @typescript-eslint/no-base-to-string

It is in the recommended configuration. It needs type information. Its rule type is suggestion.

Code
@typescript-eslint/no-base-to-string
Message
Using `join()` for {} {} use Object's default stringification format ('[object Object]') when stringified.
Message
'{}' {} use Object's default stringification format ('[object Object]') when stringified.

Source: github.com, typescript-eslint.io. JSON record. This entry is a card. Help write this page.

Disallow non-null assertion in locations that may be confusing. @typescript-eslint/no-confusing-non-null-assertion

It is in the stylistic configuration. It gives suggestions that an editor can apply. Its rule type is problem.

Code
@typescript-eslint/no-confusing-non-null-assertion
Message
Confusing combination of non-null assertion and assignment like `a! = b`, which looks very similar to `a != b`.
Message
Confusing combination of non-null assertion and equality test like `a! == b`, which looks very similar to `a !== b`.
Message
Confusing combination of non-null assertion and `{}` operator like `a! {} b`, which might be misinterpreted as `!(a {} b)`.
Message
Remove unnecessary non-null assertion (!) in assignment left-hand side.
Message
Remove unnecessary non-null assertion (!) in equality test.
Message
Remove possibly unnecessary non-null assertion (!) in the left operand of the `{}` operator.

Source: github.com, typescript-eslint.io. JSON record. This entry is a card. Help write this page.

Disallow duplicate constituents of union or intersection types. @typescript-eslint/no-duplicate-type-constituents

It is in the recommended configuration. It needs type information. ESLint can fix the code that it reports. Its rule type is suggestion.

Code
@typescript-eslint/no-duplicate-type-constituents
Message
{} type constituent is duplicated with {}.
Message
Explicit undefined is unnecessary on an optional parameter.

Source: github.com, typescript-eslint.io. JSON record. This entry is a card. Help write this page.

Disallow accidentally using the "empty object" type. @typescript-eslint/no-empty-object-type

It is in the recommended configuration. It gives suggestions that an editor can apply. Its rule type is suggestion.

Code
@typescript-eslint/no-empty-object-type
Message
An interface declaring no members is equivalent to its supertype.
Message
Replace empty interface with `{}`.
Message
Replace empty interface with a type alias.
Message
Replace `{}` with `{}`.

Source: github.com, typescript-eslint.io. JSON record. This entry is a card. Help write this page.

Disallow the any type. @typescript-eslint/no-explicit-any

It is in the recommended configuration. ESLint can fix the code that it reports. Its rule type is suggestion.

Code
@typescript-eslint/no-explicit-any
Message
Use `never` instead, this is useful when instantiating generic type parameters that you don't need to know the type of.
Message
Use `PropertyKey` instead, this is more explicit than `keyof any`.
Message
Use `unknown` instead, this will force you to explicitly, and safely assert the type is correct.
Message
Unexpected any. Specify a different type.

Source: github.com, typescript-eslint.io. JSON record. This entry is a card. Help write this page.

Disallow iterating over an array with a for-in loop. @typescript-eslint/no-for-in-array

It is in the recommended configuration. It needs type information. Its rule type is problem.

Code
@typescript-eslint/no-for-in-array
Message
For-in loops over arrays skips holes, returns indices as strings, and may visit the prototype chain or other enumerable properties. Use a more robust iteration method such as for-of or array.forEach instead.

Source: github.com, typescript-eslint.io. JSON record. This entry is a card. Help write this page.

Enforce the use of top-level import type qualifier when an import only has specifiers with inline type qualifiers. @typescript-eslint/no-import-type-side-effects

ESLint can fix the code that it reports. Its rule type is problem.

Code
@typescript-eslint/no-import-type-side-effects
Message
TypeScript will only remove the inline type specifiers which will leave behind a side effect import at runtime. Convert this to a top-level type qualifier to properly remove the entire import.

Source: github.com, typescript-eslint.io. JSON record. This entry is a card. Help write this page.

Disallow void type outside of generic or return types. @typescript-eslint/no-invalid-void-type

It is in the strict configuration. Its rule type is problem.

Code
@typescript-eslint/no-invalid-void-type
Message
{} may not have void as a type argument.
Message
void is only valid as a return type.
Message
void is only valid as a return type or generic type argument.
Message
void is only valid as return type or type of `this` parameter.
Message
void is only valid as a return type or generic type argument or the type of a `this` parameter.
Message
void is not valid as a constituent in a union type

Source: github.com, typescript-eslint.io. JSON record. This entry is a card. Help write this page.

Disallow the void operator except when used to discard a value. @typescript-eslint/no-meaningless-void-operator

It is in the strict configuration. It needs type information. ESLint can fix the code that it reports. Its rule type is suggestion.

Code
@typescript-eslint/no-meaningless-void-operator
Message
void operator is useless here; it should only discard a call's return value
Message
void operator shouldn't be used on {}; it should convey that a return value is being ignored
Message
Remove 'void'

Source: github.com, typescript-eslint.io. JSON record. This entry is a card. Help write this page.

Disallow Promises in places not designed to handle them. @typescript-eslint/no-misused-promises

It is in the recommended configuration. It needs type information. Its rule type is problem.

Code
@typescript-eslint/no-misused-promises
Message
Expected non-Promise value in a boolean conditional.
Message
Expected a non-Promise value to be returned.
Message
Expected a non-Promise value to be spread in an object.
Message
Promise returned in function argument where a void return was expected.
Message
Promise-returning function provided to attribute where a void return was expected.
Message
Promise-returning method provided where a void return was expected by extended/implemented type '{}'.

Source: github.com, typescript-eslint.io. JSON record. This entry is a card. Help write this page.

Disallow using the spread operator when it might cause unexpected behavior. @typescript-eslint/no-misused-spread

It is in the strict configuration. It needs type information. It gives suggestions that an editor can apply. Its rule type is problem.

Code
@typescript-eslint/no-misused-spread
Message
Add await operator.
Message
Using the spread operator on an array in an object will result in a list of indices.
Message
Using the spread operator on class declarations will spread only their static properties, and will lose their class prototype.
Message
Using the spread operator on class instances will lose their class prototype.
Message
Using the spread operator on a function without additional properties can cause unexpected behavior. Did you forget to call the function?
Message
Using the spread operator on an Iterable in an object can cause unexpected behavior.

Source: github.com, typescript-eslint.io. JSON record. This entry is a card. Help write this page.

Disallow non-null assertions in the left operand of a nullish coalescing operator. @typescript-eslint/no-non-null-asserted-nullish-coalescing

It is in the strict configuration. It gives suggestions that an editor can apply. Its rule type is problem.

Code
@typescript-eslint/no-non-null-asserted-nullish-coalescing
Message
The nullish coalescing operator is designed to handle undefined and null - using a non-null assertion is not needed.
Message
Remove the non-null assertion.

Source: github.com, typescript-eslint.io. JSON record. This entry is a card. Help write this page.

Disallow non-null assertions after an optional chain expression. @typescript-eslint/no-non-null-asserted-optional-chain

It is in the recommended configuration. It gives suggestions that an editor can apply. Its rule type is problem.

Code
@typescript-eslint/no-non-null-asserted-optional-chain
Message
Optional chain expressions can return undefined by design - using a non-null assertion is unsafe and wrong.
Message
You should remove the non-null assertion.

Source: github.com, typescript-eslint.io. JSON record. This entry is a card. Help write this page.

Disallow non-null assertions using the ! postfix operator. @typescript-eslint/no-non-null-assertion

It is in the strict configuration. It gives suggestions that an editor can apply. Its rule type is problem.

Code
@typescript-eslint/no-non-null-assertion
Message
Forbidden non-null assertion.
Message
Consider using the optional chain operator `?.` instead. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator.

Source: github.com, typescript-eslint.io. JSON record. This entry is a card. Help write this page.

Disallow variable declarations from shadowing variables declared in the outer scope. @typescript-eslint/no-shadow

Its rule type is suggestion.

Code
@typescript-eslint/no-shadow
Message
Enum members are added to the enum scope, so references to '{}' in enum member initializers resolve to this member instead of the declaration in the upper scope on line {} column {}.
Message
'{}' is already declared in the upper scope on line {} column {}.
Message
'{}' is already a global variable.

Source: github.com, typescript-eslint.io. JSON record. This entry is a card. Help write this page.

Disallow unnecessary equality comparisons against boolean literals. @typescript-eslint/no-unnecessary-boolean-literal-compare

It is in the strict configuration. It needs type information. ESLint can fix the code that it reports. Its rule type is suggestion.

Code
@typescript-eslint/no-unnecessary-boolean-literal-compare
Message
This expression unnecessarily compares a nullable boolean value to false instead of using the ?? operator to provide a default.
Message
This expression unnecessarily compares a nullable boolean value to true instead of using it directly.
Message
This expression unnecessarily compares a nullable boolean value to true instead of negating it.
Message
This expression unnecessarily compares a boolean value to a boolean instead of using it directly.
Message
This expression unnecessarily compares a boolean value to a boolean instead of negating it.
Message
This rule requires the `strictNullChecks` compiler option to be turned on to function correctly.

Source: github.com, typescript-eslint.io. JSON record. This entry is a card. Help write this page.

Disallow conditionals where the type is always truthy or always falsy. @typescript-eslint/no-unnecessary-condition

It is in the strict configuration. It needs type information. It gives suggestions that an editor can apply. Its rule type is suggestion.

Code
@typescript-eslint/no-unnecessary-condition
Message
Unnecessary conditional, value is always falsy.
Message
This callback should return a conditional, but return is always falsy.
Message
Unnecessary conditional, left-hand side of `??` operator is always `null` or `undefined`.
Message
Unnecessary conditional, value is always truthy.
Message
This callback should return a conditional, but return is always truthy.
Message
Unnecessary conditional, comparison is always {}, since `{} {} {}` is {}.

Source: github.com, typescript-eslint.io. JSON record. This entry is a card. Help write this page.

Disallow type assertions that do not change the type of an expression. @typescript-eslint/no-unnecessary-type-assertion

It is in the recommended configuration. It needs type information. ESLint can fix the code that it reports. Its rule type is suggestion.

Code
@typescript-eslint/no-unnecessary-type-assertion
Message
The type arguments for this generic call may be inferred from the assertion. Specify them explicitly instead.
Message
This assertion is unnecessary since the receiver accepts the original type of the expression.
Message
This assertion is unnecessary since it does not change the type of the expression.

Source: github.com, typescript-eslint.io. JSON record. This entry is a card. Help write this page.

Disallow conversion idioms when they do not change the type or value of the expression. @typescript-eslint/no-unnecessary-type-conversion

It is in the strict configuration. It needs type information. It gives suggestions that an editor can apply. Its rule type is suggestion.

Code
@typescript-eslint/no-unnecessary-type-conversion
Message
Remove the type conversion.
Message
Instead, assert that the value satisfies the {} type.
Message
{} does not change the type or value of the {}.

Source: github.com, typescript-eslint.io. JSON record. This entry is a card. Help write this page.

Disallow type parameters that aren't used multiple times. @typescript-eslint/no-unnecessary-type-parameters

It is in the strict configuration. It needs type information. It gives suggestions that an editor can apply. Its rule type is problem.

Code
@typescript-eslint/no-unnecessary-type-parameters
Message
Replace all usages of type parameter with its constraint.
Message
Type parameter {} is {} in the {} signature.

Source: github.com, typescript-eslint.io. JSON record. This entry is a card. Help write this page.

Disallow calling a function with a value with type any. @typescript-eslint/no-unsafe-argument

It is in the recommended configuration. It needs type information. Its rule type is problem.

Code
@typescript-eslint/no-unsafe-argument
Message
Unsafe argument of type {} assigned to a parameter of type {}.
Message
Unsafe spread of an {} array type.
Message
Unsafe spread of an {} type.
Message
Unsafe spread of a tuple type. The argument is {} and is assigned to a parameter of type {}.

Source: github.com, typescript-eslint.io. JSON record. This entry is a card. Help write this page.

Disallow assigning a value with type any to variables and properties. @typescript-eslint/no-unsafe-assignment

It is in the recommended configuration. It needs type information. Its rule type is problem.

Code
@typescript-eslint/no-unsafe-assignment
Message
Unsafe assignment of an {} value.
Message
Unsafe array destructuring of an {} array value.
Message
Unsafe array destructuring of a tuple element with an {} value.
Message
Unsafe spread of an {} value in an array.
Message
Unsafe assignment of type {} to a variable of type {}.
Message
Unsafe object destructuring of a property with an {} value.

Source: github.com, typescript-eslint.io. JSON record. This entry is a card. Help write this page.

Disallow calling a value with type any. @typescript-eslint/no-unsafe-call

It is in the recommended configuration. It needs type information. Its rule type is problem.

Code
@typescript-eslint/no-unsafe-call
Message
Unsafe call of a type that could not be resolved.
Message
Unsafe call of a `this` type that could not be resolved.
Message
Unsafe construction of a type that could not be resolved.
Message
Unsafe use of a template tag whose type could not be resolved.
Message
Unsafe call of {} typed value.
Message
Unsafe construction of {} typed value.

Source: github.com, typescript-eslint.io. JSON record. This entry is a card. Help write this page.

Disallow assigning non-instance values to class instance typed locations. @typescript-eslint/no-unsafe-class-instance-assignment

It is in the strict configuration. It needs type information. Its rule type is problem.

Code
@typescript-eslint/no-unsafe-class-instance-assignment
Message
This value is used where an instance of class `{}` is expected, but was not created by its constructor.
Message
This object literal is used where an instance of class `{}` is expected.

Source: github.com, typescript-eslint.io. JSON record. This entry is a card. Help write this page.

Disallow assigning non-enum values to enum typed locations. @typescript-eslint/no-unsafe-enum-assignment

It is in the strict configuration. It needs type information. Its rule type is problem.

Code
@typescript-eslint/no-unsafe-enum-assignment
Message
The computed key used here does not have a shared enum type with the expected enum {}.
Message
The argument passed here does not have a shared enum type with the expected enum {}.
Message
The value asserted here does not have a shared enum type with the expected enum {}.
Message
The value assigned here does not have a shared enum type with the expected enum {}.
Message
This mutation can produce a value outside of the expected enum {}.
Message
The value returned here does not have a shared enum type with the expected enum {}.

Source: github.com, typescript-eslint.io. JSON record. This entry is a card. Help write this page.

Disallow comparing an enum value with a non-enum value. @typescript-eslint/no-unsafe-enum-comparison

It is in the recommended configuration. It needs type information. It gives suggestions that an editor can apply. Its rule type is suggestion.

Code
@typescript-eslint/no-unsafe-enum-comparison
Message
The case statement does not have a shared enum type with the switch predicate.
Message
The two values in this comparison do not have a shared enum type.
Message
Replace with an enum value comparison.

Source: github.com, typescript-eslint.io. JSON record. This entry is a card. Help write this page.

Disallow member access on a value with type any. @typescript-eslint/no-unsafe-member-access

It is in the recommended configuration. It needs type information. Its rule type is problem.

Code
@typescript-eslint/no-unsafe-member-access
Message
The type of computed name {} cannot be resolved.
Message
Unsafe member access {} on a type that cannot be resolved.
Message
Computed name {} resolves to an `any` value.
Message
Unsafe member access {} on an `any` value.

Source: github.com, typescript-eslint.io. JSON record. This entry is a card. Help write this page.

Disallow type assertions that narrow a type. @typescript-eslint/no-unsafe-type-assertion

It needs type information. Its rule type is problem.

Code
@typescript-eslint/no-unsafe-type-assertion
Message
Unsafe assertion from {} detected: consider using type guards or a safer assertion.
Message
Unsafe assertion to {} detected: consider using a more specific type to ensure safety.
Message
Unsafe type assertion: '{}' could be instantiated with an arbitrary type which could be unrelated to the original type.
Message
Unsafe type assertion: type '{}' is more narrow than the original type.
Message
Unsafe type assertion: the original type is assignable to the constraint of type '{}', but '{}' could be instantiated with a different subtype of its constraint.

Source: github.com, typescript-eslint.io. JSON record. This entry is a card. Help write this page.

Disallow unused variables. @typescript-eslint/no-unused-vars

It is in the recommended configuration. ESLint can fix the code that it reports. Its rule type is problem.

Code
@typescript-eslint/no-unused-vars
Message
Remove unused import declaration.
Message
Remove unused variable "{}".
Message
'{}' is {} but never used{}.
Message
'{}' is marked as ignored but is used{}.
Message
'{}' is {} but only used as a type{}.

Source: github.com, typescript-eslint.io. JSON record. This entry is a card. Help write this page.

Disallow default values that will never be used. @typescript-eslint/no-useless-default-assignment

It is in the strict configuration. It needs type information. It gives suggestions that an editor can apply. Its rule type is suggestion.

Code
@typescript-eslint/no-useless-default-assignment
Message
This rule requires the `strictNullChecks` compiler option to be turned on to function correctly.
Message
Using `= undefined` to make a parameter optional adds unnecessary runtime logic.
Message
Remove the default value.
Message
Default value is useless because the {} is not optional.
Message
Default value is useless because it is undefined. Optional {}s are already undefined by default.
Message
Use the `?` optional syntax instead.

Source: github.com, typescript-eslint.io. JSON record. This entry is a card. Help write this page.

Enforce the use of as const over literal type. @typescript-eslint/prefer-as-const

It is in the recommended configuration. ESLint can fix the code that it reports. Its rule type is suggestion.

Code
@typescript-eslint/prefer-as-const
Message
Expected a `const` instead of a literal type assertion.
Message
Expected a `const` assertion instead of a literal type annotation.
Message
You should use `as const` instead of type annotation.

Source: github.com, typescript-eslint.io. JSON record. This entry is a card. Help write this page.

Enforce the use of Array.prototype.find() over Array.prototype.filter() followed by [0] when looking for a single result. @typescript-eslint/prefer-find

It is in the stylistic configuration. It needs type information. It gives suggestions that an editor can apply. Its rule type is suggestion.

Code
@typescript-eslint/prefer-find
Message
Prefer .find(...) instead of .filter(...)[0].
Message
Use .find(...) instead of .filter(...)[0].

Source: github.com, typescript-eslint.io. JSON record. This entry is a card. Help write this page.

Enforce using function types instead of interfaces with call signatures. @typescript-eslint/prefer-function-type

It is in the stylistic configuration. ESLint can fix the code that it reports. Its rule type is suggestion.

Code
@typescript-eslint/prefer-function-type
Message
{} only has a call signature, you should use a function type instead.
Message
`this` refers to the function type '{}', did you intend to use a generic `this` parameter like `<Self>(this: Self, ...) => Self` instead?

Source: github.com, typescript-eslint.io. JSON record. This entry is a card. Help write this page.

Enforce using the nullish coalescing operator instead of logical assignments or chaining. @typescript-eslint/prefer-nullish-coalescing

It is in the stylistic configuration. It needs type information. It gives suggestions that an editor can apply. Its rule type is suggestion.

Code
@typescript-eslint/prefer-nullish-coalescing
Message
This rule requires the `strictNullChecks` compiler option to be turned on to function correctly.
Message
Prefer using nullish coalescing operator (`??{}`) instead of an assignment expression, as it is simpler to read.
Message
Prefer using nullish coalescing operator (`??{}`) instead of a logical {} (`||{}`), as it is a safer operator.
Message
Prefer using nullish coalescing operator (`??{}`) instead of a ternary expression, as it is simpler to read.
Message
Fix to nullish coalescing operator (`??{}`).

Source: github.com, typescript-eslint.io. JSON record. This entry is a card. Help write this page.

Enforce using concise optional chain expressions instead of chained logical ands, negated logical ors, or empty objects. @typescript-eslint/prefer-optional-chain

It is in the stylistic configuration. It needs type information. ESLint can fix the code that it reports. Its rule type is suggestion.

Code
@typescript-eslint/prefer-optional-chain
Message
Change to an optional chain.
Message
Prefer using an optional chain expression instead, as it's more concise and easier to read.

Source: github.com, typescript-eslint.io. JSON record. This entry is a card. Help write this page.

Enforce using type parameter when calling Array#reduce instead of using a type assertion. @typescript-eslint/prefer-reduce-type-parameter

It is in the strict configuration. It needs type information. ESLint can fix the code that it reports. Its rule type is problem.

Code
@typescript-eslint/prefer-reduce-type-parameter
Message
Unnecessary assertion: Array#reduce accepts a type parameter for the default value.

Source: github.com, typescript-eslint.io. JSON record. This entry is a card. Help write this page.

Enforce using String#startsWith and String#endsWith over other equivalent methods of checking substrings. @typescript-eslint/prefer-string-starts-ends-with

It is in the stylistic configuration. It needs type information. ESLint can fix the code that it reports. Its rule type is suggestion.

Code
@typescript-eslint/prefer-string-starts-ends-with
Message
Use the 'String#endsWith' method instead.
Message
Use 'String#startsWith' method instead.

Source: github.com, typescript-eslint.io. JSON record. This entry is a card. Help write this page.

Require any function or method that returns a Promise to be marked async. @typescript-eslint/promise-function-async

It needs type information. ESLint can fix the code that it reports. Its rule type is suggestion.

Code
@typescript-eslint/promise-function-async
Message
Functions that return promises must be async.
Message
Functions that return promises must be async. Consider adding an explicit return type annotation if the function is intended to return a union of promise and non-promise types.

Source: github.com, typescript-eslint.io. JSON record. This entry is a card. Help write this page.

Require both operands of addition to be the same type and be bigint, number, or string. @typescript-eslint/restrict-plus-operands

It needs type information. Its rule type is problem.

Code
@typescript-eslint/restrict-plus-operands
Message
Numeric '+' operations must either be both bigints or both numbers. Got `{}` + `{}`.
Message
Invalid operand for a '+' operation. Operands must each be a number or {}. Got `{}`.
Message
Operands of '+' operations must be a number or {}. Got `{}` + `{}`.

Source: github.com, typescript-eslint.io. JSON record. This entry is a card. Help write this page.

Enforce consistent awaiting of returned promises. @typescript-eslint/return-await

It needs type information. ESLint can fix the code that it reports. Its rule type is problem.

Code
@typescript-eslint/return-await
Message
Returning an awaited promise is not allowed in this context.
Message
Remove `await` before the expression. Use caution as this may impact control flow.
Message
Returning an awaited value that is not a promise is not allowed.
Message
Returning an awaited promise is required in this context.
Message
Add `await` before the expression. Use caution as this may impact control flow.

Source: github.com, typescript-eslint.io. JSON record. This entry is a card. Help write this page.

Disallow certain types in boolean expressions. @typescript-eslint/strict-boolean-expressions

It needs type information. It gives suggestions that an editor can apply. Its rule type is suggestion.

Code
@typescript-eslint/strict-boolean-expressions
Message
Explicitly convert value to a boolean (`Boolean(value)`)
Message
Change condition to check array's length (`value.length > 0`)
Message
Change condition to check array's length (`value.length === 0`)
Message
Change condition to check for empty string (`value !== ""`)
Message
Change condition to check if false (`value === false`)
Message
Change condition to check for NaN (`!Number.isNaN(value)`)

Source: github.com, typescript-eslint.io. JSON record. This entry is a card. Help write this page.

Disallow passing a value-returning function in a position accepting a void function. @typescript-eslint/strict-void-return

It needs type information. It gives suggestions that an editor can apply. Its rule type is problem.

Code
@typescript-eslint/strict-void-return
Message
Async function used in a context where a void function is expected.
Message
Value-returning function used in a context where a void function is expected.
Message
Value returned in a context where a void return is expected.
Message
Add a void operator to discard the return value.
Message
Wrap the function body in an async IIFE.

Source: github.com, typescript-eslint.io. JSON record. This entry is a card. Help write this page.

Require switch-case statements to be exhaustive. @typescript-eslint/switch-exhaustiveness-check

It needs type information. It gives suggestions that an editor can apply. Its rule type is suggestion.

Code
@typescript-eslint/switch-exhaustiveness-check
Message
Add branches for missing cases.
Message
The switch statement is exhaustive, so the default case is unnecessary.
Message
Switch is not exhaustive. Cases not matched: {}

Source: github.com, typescript-eslint.io. JSON record. This entry is a card. Help write this page.

Enforce typing arguments in Promise rejection callbacks as unknown. @typescript-eslint/use-unknown-in-catch-callback-variable

It is in the strict configuration. It needs type information. It gives suggestions that an editor can apply. Its rule type is suggestion.

Code
@typescript-eslint/use-unknown-in-catch-callback-variable
Message
Add an explicit `: [unknown]` type annotation to the rejection callback rest variable.
Message
Add an explicit `: unknown` type annotation to the rejection callback variable.
Message
Change existing type annotation to `: [unknown]`.
Message
Change existing type annotation to `: unknown`.

Source: github.com, typescript-eslint.io. JSON record. This entry is a card. Help write this page.