@@ -161,7 +161,7 @@ Pro Tip: For larger codebases you may want to consider splitting our linting int
| [`@typescript-eslint/prefer-reduce-type-parameter`](./docs/rules/prefer-reduce-type-parameter.md) | Prefer using type parameter when calling `Array#reduce` instead of casting | | :wrench: | :thought_balloon: |
| [`@typescript-eslint/prefer-regexp-exec`](./docs/rules/prefer-regexp-exec.md) | Enforce that `RegExp#exec` is used instead of `String#match` if no global flag is provided | :heavy_check_mark: | | :thought_balloon: |
| [`@typescript-eslint/prefer-string-starts-ends-with`](./docs/rules/prefer-string-starts-ends-with.md) | Enforce the use of `String#startsWith` and `String#endsWith` instead of other equivalent methods of checking substrings | | :wrench: | :thought_balloon: |
| [`@typescript-eslint/prefer-ts-expect-error`](./docs/rules/prefer-ts-expect-error.md) | Recommends using `// @ts-expect-error` over `// @ts-ignore` | | :wrench: | |
| [`@typescript-eslint/prefer-ts-expect-error`](./docs/rules/prefer-ts-expect-error.md) | Recommends using `@ts-expect-error` over `@ts-ignore` | | :wrench: | |
| [`@typescript-eslint/promise-function-async`](./docs/rules/promise-function-async.md) | Requires any function or method that returns a Promise to be marked async | | | :thought_balloon: |
| [`@typescript-eslint/require-array-sort-compare`](./docs/rules/require-array-sort-compare.md) | Requires `Array#sort` calls to always provide a `compareFunction` | | | :thought_balloon: |
| [`@typescript-eslint/restrict-plus-operands`](./docs/rules/restrict-plus-operands.md) | When adding two variables, operands must both be of type number or of type string | :heavy_check_mark: | | :thought_balloon: |
#Recommends using `// @ts-expect-error` over `// @ts-ignore` (`prefer-ts-expect-error`)
#Recommends using `@ts-expect-error` over `@ts-ignore` (`prefer-ts-expect-error`)
TypeScript allows you to suppress all errors on a line by placing a single-line comment starting with `@ts-ignore` immediately before the erroring line.
TypeScript allows you to suppress all errors on a line by placing a single-line comment or a comment block line starting with `@ts-ignore` immediately before the erroring line.
While powerful, there is no way to know if a `@ts-ignore` is actually suppressing an error without manually investigating what happens when the `@ts-ignore` is removed.
This means its easy for `@ts-ignore`s to be forgotten about, and remain in code even after the error they were suppressing is fixed.
@@ -20,6 +20,15 @@ Examples of **incorrect** code for this rule:
// @ts-ignore
const str:string=1;
/**
* Explaining comment
*
* @ts-ignore */
const multiLine:number='value';
/** @ts-ignore */
const block:string=1;
const isOptionEnabled = (key:string):boolean=> {
// @ts-ignore: if key isn't in globalOptions it'll be undefined which is false
return!!globalOptions[key];
@@ -32,6 +41,15 @@ Examples of **correct** code for this rule:
// @ts-expect-error
const str:string=1;
/**
* Explaining comment
*
* @ts-expect-error */
const multiLine:number='value';
/** @ts-expect-error */
const block:string=1;
const isOptionEnabled = (key:string):boolean=> {
// @ts-expect-error: if key isn't in globalOptions it'll be undefined which is false