Skip to content
This repository was archived by the owner on Mar 7, 2025. It is now read-only.

Commit 72f0ec1

Browse files
authored
feat: add eslint-plugin-eslint-comments (#163)
1 parent 87b27f1 commit 72f0ec1

16 files changed

+318
-1
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
"eslint-config-prettier": "~8.5.0",
6565
"eslint-gitignore": "~0.1.0",
6666
"eslint-plugin-deprecation": "~1.3.3",
67+
"eslint-plugin-eslint-comments": "~3.2.0",
6768
"eslint-plugin-import": "~2.26.0",
6869
"eslint-plugin-inclusive-language": "~2.2.0",
6970
"eslint-plugin-jsdoc": "~39.6.4",

pnpm-lock.yaml

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/generate-rule-files/src/plugins-map.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import * as eslint from 'eslint';
22
import * as eslintPluginDeprecation from 'eslint-plugin-deprecation';
33
// @ts-expect-error
4+
import eslintPluginEslintComments from 'eslint-plugin-eslint-comments';
5+
// @ts-expect-error
46
import * as eslintPluginImport from 'eslint-plugin-import';
57
// @ts-expect-error
68
import eslintPluginJSDoc from 'eslint-plugin-jsdoc';
@@ -50,14 +52,17 @@ export const PLUGIN_REGISTRY: Readonly<Record<string, Plugin>> = {
5052
name: 'Import',
5153
rules: (eslintPluginImport as Plugin).rules,
5254
},
55+
'eslint-comments': {
56+
name: 'EslintComments',
57+
rules: (eslintPluginEslintComments as Plugin).rules,
58+
},
5359
jsdoc: {
5460
name: 'JSDoc',
5561
prefix: 'jsdoc',
5662
rules: (eslintPluginJSDoc as Plugin).rules,
5763
},
5864
jsonc: {
5965
name: 'Jsonc',
60-
prefix: 'jsonc',
6166
rules:
6267
// @ts-expect-error: throw error when plugin successfully updated their type defs
6368
eslintPluginJsonc.rules as Plugin['rules'],
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/**
2+
* Eslint EslintComments extensions.
3+
*
4+
* @see [Eslint EslintComments extensions](https://mysticatea.github.io/eslint-plugin-eslint-comments/#%F0%9F%93%96-usage)
5+
*/
6+
export type EslintCommentsExtensions = 'plugin:eslint-comments/recommended';

src/config/extends/index.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { LiteralUnion } from '../../utility-types';
22
import type { EslintExtensions } from './eslint';
3+
import type { EslintCommentsExtensions } from './eslint-plugin-eslint-comment';
34
import type { ImportExtensions } from './eslint-plugin-import';
45
import type { JsdocExtensions } from './eslint-plugin-jsdoc';
56
import type { JsoncExtensions } from './eslint-plugin-jsonc';
@@ -19,6 +20,7 @@ import type { TypescriptEslintExtensions } from './typescript-eslint';
1920
* All known extensions.
2021
*/
2122
export type KnownExtensions = LiteralUnion<
23+
| EslintCommentsExtensions
2224
| EslintExtensions
2325
| ImportExtensions
2426
| IntlifyVueI18nExtensions
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import type { RuleConfig } from '../rule-config';
2+
3+
/**
4+
* Option.
5+
*/
6+
export interface DisableEnablePairOption {
7+
allowWholeFile?: boolean;
8+
}
9+
10+
/**
11+
* Options.
12+
*/
13+
export type DisableEnablePairOptions = [DisableEnablePairOption?];
14+
15+
/**
16+
* Require a `eslint-enable` comment for every `eslint-disable` comment.
17+
*
18+
* @see [disable-enable-pair](https://mysticatea.github.io/eslint-plugin-eslint-comments/rules/disable-enable-pair.html)
19+
*/
20+
export type DisableEnablePairRuleConfig = RuleConfig<DisableEnablePairOptions>;
21+
22+
/**
23+
* Require a `eslint-enable` comment for every `eslint-disable` comment.
24+
*
25+
* @see [disable-enable-pair](https://mysticatea.github.io/eslint-plugin-eslint-comments/rules/disable-enable-pair.html)
26+
*/
27+
export interface DisableEnablePairRule {
28+
/**
29+
* Require a `eslint-enable` comment for every `eslint-disable` comment.
30+
*
31+
* @see [disable-enable-pair](https://mysticatea.github.io/eslint-plugin-eslint-comments/rules/disable-enable-pair.html)
32+
*/
33+
'eslint-comments/disable-enable-pair': DisableEnablePairRuleConfig;
34+
}

src/rules/eslint-comments/index.d.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import type { DisableEnablePairRule } from './disable-enable-pair';
2+
import type { NoAggregatingEnableRule } from './no-aggregating-enable';
3+
import type { NoDuplicateDisableRule } from './no-duplicate-disable';
4+
import type { NoRestrictedDisableRule } from './no-restricted-disable';
5+
import type { NoUnlimitedDisableRule } from './no-unlimited-disable';
6+
import type { NoUnusedDisableRule } from './no-unused-disable';
7+
import type { NoUnusedEnableRule } from './no-unused-enable';
8+
import type { NoUseRule } from './no-use';
9+
import type { RequireDescriptionRule } from './require-description';
10+
11+
/**
12+
* All EslintComments rules.
13+
*/
14+
export type EslintCommentsRules = DisableEnablePairRule &
15+
NoAggregatingEnableRule &
16+
NoDuplicateDisableRule &
17+
NoRestrictedDisableRule &
18+
NoUnlimitedDisableRule &
19+
NoUnusedDisableRule &
20+
NoUnusedEnableRule &
21+
NoUseRule &
22+
RequireDescriptionRule;
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import type { RuleConfig } from '../rule-config';
2+
3+
/**
4+
* Disallow a `eslint-enable` comment for multiple `eslint-disable` comments.
5+
*
6+
* @see [no-aggregating-enable](https://mysticatea.github.io/eslint-plugin-eslint-comments/rules/no-aggregating-enable.html)
7+
*/
8+
export type NoAggregatingEnableRuleConfig = RuleConfig<[]>;
9+
10+
/**
11+
* Disallow a `eslint-enable` comment for multiple `eslint-disable` comments.
12+
*
13+
* @see [no-aggregating-enable](https://mysticatea.github.io/eslint-plugin-eslint-comments/rules/no-aggregating-enable.html)
14+
*/
15+
export interface NoAggregatingEnableRule {
16+
/**
17+
* Disallow a `eslint-enable` comment for multiple `eslint-disable` comments.
18+
*
19+
* @see [no-aggregating-enable](https://mysticatea.github.io/eslint-plugin-eslint-comments/rules/no-aggregating-enable.html)
20+
*/
21+
'eslint-comments/no-aggregating-enable': NoAggregatingEnableRuleConfig;
22+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import type { RuleConfig } from '../rule-config';
2+
3+
/**
4+
* Disallow duplicate `eslint-disable` comments.
5+
*
6+
* @see [no-duplicate-disable](https://mysticatea.github.io/eslint-plugin-eslint-comments/rules/no-duplicate-disable.html)
7+
*/
8+
export type NoDuplicateDisableRuleConfig = RuleConfig<[]>;
9+
10+
/**
11+
* Disallow duplicate `eslint-disable` comments.
12+
*
13+
* @see [no-duplicate-disable](https://mysticatea.github.io/eslint-plugin-eslint-comments/rules/no-duplicate-disable.html)
14+
*/
15+
export interface NoDuplicateDisableRule {
16+
/**
17+
* Disallow duplicate `eslint-disable` comments.
18+
*
19+
* @see [no-duplicate-disable](https://mysticatea.github.io/eslint-plugin-eslint-comments/rules/no-duplicate-disable.html)
20+
*/
21+
'eslint-comments/no-duplicate-disable': NoDuplicateDisableRuleConfig;
22+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import type { RuleConfig } from '../rule-config';
2+
3+
/**
4+
* Option.
5+
*/
6+
export type NoRestrictedDisableOption = string[];
7+
8+
/**
9+
* Options.
10+
*/
11+
export type NoRestrictedDisableOptions = NoRestrictedDisableOption;
12+
13+
/**
14+
* Disallow `eslint-disable` comments about specific rules.
15+
*
16+
* @see [no-restricted-disable](https://mysticatea.github.io/eslint-plugin-eslint-comments/rules/no-restricted-disable.html)
17+
*/
18+
export type NoRestrictedDisableRuleConfig =
19+
RuleConfig<NoRestrictedDisableOptions>;
20+
21+
/**
22+
* Disallow `eslint-disable` comments about specific rules.
23+
*
24+
* @see [no-restricted-disable](https://mysticatea.github.io/eslint-plugin-eslint-comments/rules/no-restricted-disable.html)
25+
*/
26+
export interface NoRestrictedDisableRule {
27+
/**
28+
* Disallow `eslint-disable` comments about specific rules.
29+
*
30+
* @see [no-restricted-disable](https://mysticatea.github.io/eslint-plugin-eslint-comments/rules/no-restricted-disable.html)
31+
*/
32+
'eslint-comments/no-restricted-disable': NoRestrictedDisableRuleConfig;
33+
}

0 commit comments

Comments
 (0)