diff --git a/scripts/typegen.ts b/scripts/typegen.ts index 27dd66b7..96c1a797 100644 --- a/scripts/typegen.ts +++ b/scripts/typegen.ts @@ -1,5 +1,6 @@ import fs from "node:fs/promises"; +import { type Linter } from "eslint"; import { flatConfigsToRulesDTS } from "eslint-typegen/core"; import { @@ -30,7 +31,7 @@ import { } from "../src/configs"; import { combine } from "../src/utils"; -const configs = await combine( +const configs = (await combine( comments(), formatters({}, {}), functional({}), @@ -55,7 +56,7 @@ const configs = await combine( unocss({}), vue({}), yaml({}), -); +)) as Linter.FlatConfig[]; const dts = await flatConfigsToRulesDTS(configs, { includeAugmentation: false, diff --git a/src/configs/comments.ts b/src/configs/comments.ts index 3717030b..d8e403e7 100644 --- a/src/configs/comments.ts +++ b/src/configs/comments.ts @@ -12,17 +12,14 @@ export async function comments(): Promise { { name: "rs:comments", plugins: { - "eslint-comments": pluginComments, + comments: pluginComments, }, rules: { - "eslint-comments/no-aggregating-enable": "error", - "eslint-comments/no-duplicate-disable": "error", - "eslint-comments/no-unlimited-disable": "error", - "eslint-comments/no-unused-enable": "error", - "eslint-comments/disable-enable-pair": [ - "error", - { allowWholeFile: true }, - ], + "comments/no-aggregating-enable": "error", + "comments/no-duplicate-disable": "error", + "comments/no-unlimited-disable": "error", + "comments/no-unused-enable": "error", + "comments/disable-enable-pair": ["error", { allowWholeFile: true }], }, }, ]; diff --git a/src/configs/functional.ts b/src/configs/functional.ts index 51ee17f7..e2e407f4 100644 --- a/src/configs/functional.ts +++ b/src/configs/functional.ts @@ -1,4 +1,3 @@ -import { GLOB_TS } from "../globs"; import { type FlatConfigItem, type OptionsFunctional, @@ -8,6 +7,8 @@ import { } from "../types"; import { loadPackages } from "../utils"; +import { defaultFilesTypesAware } from "./typescript"; + export async function functional( options: Readonly< OptionsFunctional & @@ -19,7 +20,7 @@ export async function functional( const { overrides = {}, stylistic = true, - filesTypeAware = [GLOB_TS], + filesTypeAware = defaultFilesTypesAware, functionalEnforcement = "none", } = options; diff --git a/src/configs/typescript.ts b/src/configs/typescript.ts index cc49ddd5..83164fdd 100644 --- a/src/configs/typescript.ts +++ b/src/configs/typescript.ts @@ -22,6 +22,8 @@ import { } from "../types"; import { loadPackages, toArray } from "../utils"; +export const defaultFilesTypesAware = [GLOB_TS, GLOB_TSX, GLOB_DTS]; + export async function typescript( options: Readonly< OptionsFiles & @@ -44,11 +46,7 @@ export async function typescript( ...componentExts.map((ext) => `**/*.${ext}`), ]; - const filesTypeAware = options.filesTypeAware ?? [ - GLOB_TS, - GLOB_TSX, - GLOB_DTS, - ]; + const filesTypeAware = options.filesTypeAware ?? defaultFilesTypesAware; const tsconfigPath = options.tsconfig === undefined ? undefined @@ -64,13 +62,13 @@ export async function typescript( function makeParser( typeAware: boolean, - files: Readonly, - ignores?: Readonly, + files: string[], + ignores: string[] = [], ): FlatConfigItem { return { name: `rs:typescript:${typeAware ? "type-aware-parser" : "parser"}`, - files: [...files], - ...(ignores === undefined ? {} : { ignores: [...ignores] }), + files, + ignores, languageOptions: { parser: parserTs, parserOptions: { @@ -450,15 +448,15 @@ export async function typescript( }, }, { + name: "rs:typescript:rules-non-type-aware", files, ignores: filesTypeAware, - name: "rs:typescript:rules-non-type-aware", rules: ((pluginTs.configs?.["disable-type-checked"] as Linter.FlatConfig) .rules ?? {}) as NonNullable, }, { - files: GLOB_TESTS, name: "rs:typescript:tests-overrides", + files: GLOB_TESTS, rules: { "ts/no-unused-expressions": "off", "ts/consistent-type-definitions": "off",