Skip to content

Commit

Permalink
feat: add eslint-plugin-eslint-comments (#163)
Browse files Browse the repository at this point in the history
  • Loading branch information
Shinigami92 committed Jan 2, 2023
1 parent 87b27f1 commit 72f0ec1
Show file tree
Hide file tree
Showing 16 changed files with 318 additions and 1 deletion.
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -64,6 +64,7 @@
"eslint-config-prettier": "~8.5.0",
"eslint-gitignore": "~0.1.0",
"eslint-plugin-deprecation": "~1.3.3",
"eslint-plugin-eslint-comments": "~3.2.0",
"eslint-plugin-import": "~2.26.0",
"eslint-plugin-inclusive-language": "~2.2.0",
"eslint-plugin-jsdoc": "~39.6.4",
Expand Down
13 changes: 13 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion scripts/generate-rule-files/src/plugins-map.ts
@@ -1,6 +1,8 @@
import * as eslint from 'eslint';
import * as eslintPluginDeprecation from 'eslint-plugin-deprecation';
// @ts-expect-error
import eslintPluginEslintComments from 'eslint-plugin-eslint-comments';
// @ts-expect-error
import * as eslintPluginImport from 'eslint-plugin-import';
// @ts-expect-error
import eslintPluginJSDoc from 'eslint-plugin-jsdoc';
Expand Down Expand Up @@ -50,14 +52,17 @@ export const PLUGIN_REGISTRY: Readonly<Record<string, Plugin>> = {
name: 'Import',
rules: (eslintPluginImport as Plugin).rules,
},
'eslint-comments': {
name: 'EslintComments',
rules: (eslintPluginEslintComments as Plugin).rules,
},
jsdoc: {
name: 'JSDoc',
prefix: 'jsdoc',
rules: (eslintPluginJSDoc as Plugin).rules,
},
jsonc: {
name: 'Jsonc',
prefix: 'jsonc',
rules:
// @ts-expect-error: throw error when plugin successfully updated their type defs
eslintPluginJsonc.rules as Plugin['rules'],
Expand Down
6 changes: 6 additions & 0 deletions src/config/extends/eslint-plugin-eslint-comment.d.ts
@@ -0,0 +1,6 @@
/**
* Eslint EslintComments extensions.
*
* @see [Eslint EslintComments extensions](https://mysticatea.github.io/eslint-plugin-eslint-comments/#%F0%9F%93%96-usage)
*/
export type EslintCommentsExtensions = 'plugin:eslint-comments/recommended';
2 changes: 2 additions & 0 deletions src/config/extends/index.d.ts
@@ -1,5 +1,6 @@
import type { LiteralUnion } from '../../utility-types';
import type { EslintExtensions } from './eslint';
import type { EslintCommentsExtensions } from './eslint-plugin-eslint-comment';
import type { ImportExtensions } from './eslint-plugin-import';
import type { JsdocExtensions } from './eslint-plugin-jsdoc';
import type { JsoncExtensions } from './eslint-plugin-jsonc';
Expand All @@ -19,6 +20,7 @@ import type { TypescriptEslintExtensions } from './typescript-eslint';
* All known extensions.
*/
export type KnownExtensions = LiteralUnion<
| EslintCommentsExtensions
| EslintExtensions
| ImportExtensions
| IntlifyVueI18nExtensions
Expand Down
34 changes: 34 additions & 0 deletions src/rules/eslint-comments/disable-enable-pair.d.ts
@@ -0,0 +1,34 @@
import type { RuleConfig } from '../rule-config';

/**
* Option.
*/
export interface DisableEnablePairOption {
allowWholeFile?: boolean;
}

/**
* Options.
*/
export type DisableEnablePairOptions = [DisableEnablePairOption?];

/**
* Require a `eslint-enable` comment for every `eslint-disable` comment.
*
* @see [disable-enable-pair](https://mysticatea.github.io/eslint-plugin-eslint-comments/rules/disable-enable-pair.html)
*/
export type DisableEnablePairRuleConfig = RuleConfig<DisableEnablePairOptions>;

/**
* Require a `eslint-enable` comment for every `eslint-disable` comment.
*
* @see [disable-enable-pair](https://mysticatea.github.io/eslint-plugin-eslint-comments/rules/disable-enable-pair.html)
*/
export interface DisableEnablePairRule {
/**
* Require a `eslint-enable` comment for every `eslint-disable` comment.
*
* @see [disable-enable-pair](https://mysticatea.github.io/eslint-plugin-eslint-comments/rules/disable-enable-pair.html)
*/
'eslint-comments/disable-enable-pair': DisableEnablePairRuleConfig;
}
22 changes: 22 additions & 0 deletions src/rules/eslint-comments/index.d.ts
@@ -0,0 +1,22 @@
import type { DisableEnablePairRule } from './disable-enable-pair';
import type { NoAggregatingEnableRule } from './no-aggregating-enable';
import type { NoDuplicateDisableRule } from './no-duplicate-disable';
import type { NoRestrictedDisableRule } from './no-restricted-disable';
import type { NoUnlimitedDisableRule } from './no-unlimited-disable';
import type { NoUnusedDisableRule } from './no-unused-disable';
import type { NoUnusedEnableRule } from './no-unused-enable';
import type { NoUseRule } from './no-use';
import type { RequireDescriptionRule } from './require-description';

/**
* All EslintComments rules.
*/
export type EslintCommentsRules = DisableEnablePairRule &
NoAggregatingEnableRule &
NoDuplicateDisableRule &
NoRestrictedDisableRule &
NoUnlimitedDisableRule &
NoUnusedDisableRule &
NoUnusedEnableRule &
NoUseRule &
RequireDescriptionRule;
22 changes: 22 additions & 0 deletions src/rules/eslint-comments/no-aggregating-enable.d.ts
@@ -0,0 +1,22 @@
import type { RuleConfig } from '../rule-config';

/**
* Disallow a `eslint-enable` comment for multiple `eslint-disable` comments.
*
* @see [no-aggregating-enable](https://mysticatea.github.io/eslint-plugin-eslint-comments/rules/no-aggregating-enable.html)
*/
export type NoAggregatingEnableRuleConfig = RuleConfig<[]>;

/**
* Disallow a `eslint-enable` comment for multiple `eslint-disable` comments.
*
* @see [no-aggregating-enable](https://mysticatea.github.io/eslint-plugin-eslint-comments/rules/no-aggregating-enable.html)
*/
export interface NoAggregatingEnableRule {
/**
* Disallow a `eslint-enable` comment for multiple `eslint-disable` comments.
*
* @see [no-aggregating-enable](https://mysticatea.github.io/eslint-plugin-eslint-comments/rules/no-aggregating-enable.html)
*/
'eslint-comments/no-aggregating-enable': NoAggregatingEnableRuleConfig;
}
22 changes: 22 additions & 0 deletions src/rules/eslint-comments/no-duplicate-disable.d.ts
@@ -0,0 +1,22 @@
import type { RuleConfig } from '../rule-config';

/**
* Disallow duplicate `eslint-disable` comments.
*
* @see [no-duplicate-disable](https://mysticatea.github.io/eslint-plugin-eslint-comments/rules/no-duplicate-disable.html)
*/
export type NoDuplicateDisableRuleConfig = RuleConfig<[]>;

/**
* Disallow duplicate `eslint-disable` comments.
*
* @see [no-duplicate-disable](https://mysticatea.github.io/eslint-plugin-eslint-comments/rules/no-duplicate-disable.html)
*/
export interface NoDuplicateDisableRule {
/**
* Disallow duplicate `eslint-disable` comments.
*
* @see [no-duplicate-disable](https://mysticatea.github.io/eslint-plugin-eslint-comments/rules/no-duplicate-disable.html)
*/
'eslint-comments/no-duplicate-disable': NoDuplicateDisableRuleConfig;
}
33 changes: 33 additions & 0 deletions src/rules/eslint-comments/no-restricted-disable.d.ts
@@ -0,0 +1,33 @@
import type { RuleConfig } from '../rule-config';

/**
* Option.
*/
export type NoRestrictedDisableOption = string[];

/**
* Options.
*/
export type NoRestrictedDisableOptions = NoRestrictedDisableOption;

/**
* Disallow `eslint-disable` comments about specific rules.
*
* @see [no-restricted-disable](https://mysticatea.github.io/eslint-plugin-eslint-comments/rules/no-restricted-disable.html)
*/
export type NoRestrictedDisableRuleConfig =
RuleConfig<NoRestrictedDisableOptions>;

/**
* Disallow `eslint-disable` comments about specific rules.
*
* @see [no-restricted-disable](https://mysticatea.github.io/eslint-plugin-eslint-comments/rules/no-restricted-disable.html)
*/
export interface NoRestrictedDisableRule {
/**
* Disallow `eslint-disable` comments about specific rules.
*
* @see [no-restricted-disable](https://mysticatea.github.io/eslint-plugin-eslint-comments/rules/no-restricted-disable.html)
*/
'eslint-comments/no-restricted-disable': NoRestrictedDisableRuleConfig;
}
22 changes: 22 additions & 0 deletions src/rules/eslint-comments/no-unlimited-disable.d.ts
@@ -0,0 +1,22 @@
import type { RuleConfig } from '../rule-config';

/**
* Disallow `eslint-disable` comments without rule names.
*
* @see [no-unlimited-disable](https://mysticatea.github.io/eslint-plugin-eslint-comments/rules/no-unlimited-disable.html)
*/
export type NoUnlimitedDisableRuleConfig = RuleConfig<[]>;

/**
* Disallow `eslint-disable` comments without rule names.
*
* @see [no-unlimited-disable](https://mysticatea.github.io/eslint-plugin-eslint-comments/rules/no-unlimited-disable.html)
*/
export interface NoUnlimitedDisableRule {
/**
* Disallow `eslint-disable` comments without rule names.
*
* @see [no-unlimited-disable](https://mysticatea.github.io/eslint-plugin-eslint-comments/rules/no-unlimited-disable.html)
*/
'eslint-comments/no-unlimited-disable': NoUnlimitedDisableRuleConfig;
}
22 changes: 22 additions & 0 deletions src/rules/eslint-comments/no-unused-disable.d.ts
@@ -0,0 +1,22 @@
import type { RuleConfig } from '../rule-config';

/**
* Disallow unused `eslint-disable` comments.
*
* @see [no-unused-disable](https://mysticatea.github.io/eslint-plugin-eslint-comments/rules/no-unused-disable.html)
*/
export type NoUnusedDisableRuleConfig = RuleConfig<[]>;

/**
* Disallow unused `eslint-disable` comments.
*
* @see [no-unused-disable](https://mysticatea.github.io/eslint-plugin-eslint-comments/rules/no-unused-disable.html)
*/
export interface NoUnusedDisableRule {
/**
* Disallow unused `eslint-disable` comments.
*
* @see [no-unused-disable](https://mysticatea.github.io/eslint-plugin-eslint-comments/rules/no-unused-disable.html)
*/
'eslint-comments/no-unused-disable': NoUnusedDisableRuleConfig;
}
22 changes: 22 additions & 0 deletions src/rules/eslint-comments/no-unused-enable.d.ts
@@ -0,0 +1,22 @@
import type { RuleConfig } from '../rule-config';

/**
* Disallow unused `eslint-enable` comments.
*
* @see [no-unused-enable](https://mysticatea.github.io/eslint-plugin-eslint-comments/rules/no-unused-enable.html)
*/
export type NoUnusedEnableRuleConfig = RuleConfig<[]>;

/**
* Disallow unused `eslint-enable` comments.
*
* @see [no-unused-enable](https://mysticatea.github.io/eslint-plugin-eslint-comments/rules/no-unused-enable.html)
*/
export interface NoUnusedEnableRule {
/**
* Disallow unused `eslint-enable` comments.
*
* @see [no-unused-enable](https://mysticatea.github.io/eslint-plugin-eslint-comments/rules/no-unused-enable.html)
*/
'eslint-comments/no-unused-enable': NoUnusedEnableRuleConfig;
}
44 changes: 44 additions & 0 deletions src/rules/eslint-comments/no-use.d.ts
@@ -0,0 +1,44 @@
import type { RuleConfig } from '../rule-config';

/**
* Option.
*/
export interface NoUseOption {
allow?: (
| 'eslint'
| 'eslint-disable'
| 'eslint-disable-line'
| 'eslint-disable-next-line'
| 'eslint-enable'
| 'eslint-env'
| 'exported'
| 'global'
| 'globals'
)[];
}

/**
* Options.
*/
export type NoUseOptions = [NoUseOption?];

/**
* Disallow ESLint directive-comments.
*
* @see [no-use](https://mysticatea.github.io/eslint-plugin-eslint-comments/rules/no-use.html)
*/
export type NoUseRuleConfig = RuleConfig<NoUseOptions>;

/**
* Disallow ESLint directive-comments.
*
* @see [no-use](https://mysticatea.github.io/eslint-plugin-eslint-comments/rules/no-use.html)
*/
export interface NoUseRule {
/**
* Disallow ESLint directive-comments.
*
* @see [no-use](https://mysticatea.github.io/eslint-plugin-eslint-comments/rules/no-use.html)
*/
'eslint-comments/no-use': NoUseRuleConfig;
}
45 changes: 45 additions & 0 deletions src/rules/eslint-comments/require-description.d.ts
@@ -0,0 +1,45 @@
import type { RuleConfig } from '../rule-config';

/**
* Option.
*/
export interface RequireDescriptionOption {
ignore?: (
| 'eslint'
| 'eslint-disable'
| 'eslint-disable-line'
| 'eslint-disable-next-line'
| 'eslint-enable'
| 'eslint-env'
| 'exported'
| 'global'
| 'globals'
)[];
}

/**
* Options.
*/
export type RequireDescriptionOptions = [RequireDescriptionOption?];

/**
* Require include descriptions in ESLint directive-comments.
*
* @see [require-description](https://mysticatea.github.io/eslint-plugin-eslint-comments/rules/require-description.html)
*/
export type RequireDescriptionRuleConfig =
RuleConfig<RequireDescriptionOptions>;

/**
* Require include descriptions in ESLint directive-comments.
*
* @see [require-description](https://mysticatea.github.io/eslint-plugin-eslint-comments/rules/require-description.html)
*/
export interface RequireDescriptionRule {
/**
* Require include descriptions in ESLint directive-comments.
*
* @see [require-description](https://mysticatea.github.io/eslint-plugin-eslint-comments/rules/require-description.html)
*/
'eslint-comments/require-description': RequireDescriptionRuleConfig;
}

0 comments on commit 72f0ec1

Please sign in to comment.