Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

docs(eslint-plugin): [ban-ts-comment] include descriptionFormat#5283

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Merged
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 31 additions & 4 deletionspackages/eslint-plugin/docs/rules/ban-ts-comment.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -22,11 +22,16 @@ By default, only `@ts-check` is allowed, as it enables rather than suppresses er
The configuration looks like this:

```ts
type DirectiveConfig =
| boolean
| 'allow-with-description'
| { descriptionFormat: string };

interface Options {
'ts-expect-error'?:boolean | 'allow-with-description';
'ts-ignore'?:boolean | 'allow-with-description';
'ts-nocheck'?:boolean | 'allow-with-description';
'ts-check'?:boolean | 'allow-with-description';
'ts-expect-error'?:DirectiveConfig;
'ts-ignore'?:DirectiveConfig;
'ts-nocheck'?:DirectiveConfig;
'ts-check'?:DirectiveConfig;
minimumDescriptionLength?: number;
}

Expand DownExpand Up@@ -105,6 +110,28 @@ if (false) {
}
```

### `descriptionFormat`

For each directive type, you can specify a custom format in the form of a regular expression. Only description that matches the pattern will be allowed.

For example, with `{ 'ts-expect-error': { descriptionFormat: '^: TS\\d+ because .+$' } }`:

<!--tabs-->

#### ❌ Incorrect

```ts
// @ts-expect-error: the library definition is wrong
const a = doSomething('hello');
```

#### ✅ Correct

```ts
// @ts-expect-error: TS1234 because the library definition is wrong
const a = doSomething('hello');
```

### `minimumDescriptionLength`

Use `minimumDescriptionLength` to set a minimum length for descriptions when using the `allow-with-description` option for a directive.
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp