diff --git a/.changeset/grumpy-waves-warn.md b/.changeset/grumpy-waves-warn.md new file mode 100644 index 000000000..62fbd9e95 --- /dev/null +++ b/.changeset/grumpy-waves-warn.md @@ -0,0 +1,5 @@ +--- +"eslint-plugin-regexp": minor +--- + +Improved compatibility of type information with typescript-eslint in config. diff --git a/lib/configs/rules/all.ts b/lib/configs/rules/all.ts index a3a6b2dda..1757ab937 100644 --- a/lib/configs/rules/all.ts +++ b/lib/configs/rules/all.ts @@ -1,7 +1,8 @@ import { rules as ruleLint } from "../../all-rules" +import type { SeverityString } from "../../types" import { rules as recommendedRules } from "./recommended" -const all: Record = {} +const all: Record = {} for (const rule of ruleLint) { all[rule.meta.docs.ruleId] = "error" } diff --git a/lib/configs/rules/recommended.ts b/lib/configs/rules/recommended.ts index a3da7e800..d0871e96f 100644 --- a/lib/configs/rules/recommended.ts +++ b/lib/configs/rules/recommended.ts @@ -1,4 +1,6 @@ -export const rules = { +import type { SeverityString } from "../../types" + +export const rules: Record = { // ESLint core rules "no-control-regex": "error", "no-misleading-character-class": "error", diff --git a/lib/types.ts b/lib/types.ts index 32adf711f..5a43742e3 100644 --- a/lib/types.ts +++ b/lib/types.ts @@ -13,6 +13,8 @@ export type RuleCategory = | "Best Practices" | "Stylistic Issues" +export type SeverityString = "error" | "warn" | "off" + export interface RuleMetaData { docs: { description: string @@ -21,7 +23,7 @@ export interface RuleMetaData { url: string ruleId: string ruleName: string - default?: "error" | "warn" + default?: Exclude } messages: { [messageId: string]: string } fixable?: "code" | "whitespace" @@ -42,7 +44,7 @@ export interface PartialRuleMetaData { description: string category: RuleCategory recommended: boolean - default?: "error" | "warn" + default?: Exclude } messages: { [messageId: string]: string } fixable?: "code" | "whitespace" diff --git a/tools/update-rulesets.ts b/tools/update-rulesets.ts index b14cf10c1..dbc3a6979 100644 --- a/tools/update-rulesets.ts +++ b/tools/update-rulesets.ts @@ -14,7 +14,9 @@ const coreRules = [ // "require-unicode-regexp", // modern ] -const content = `export const rules = { +const content = `import type { SeverityString } from "../../types" + +export const rules: Record = { // ESLint core rules ${coreRules.map((ruleName) => `"${ruleName}": "error"`).join(",\n ")}, // The ESLint rule will report fewer cases than our rule