Skip to content
This repository has been archived by the owner on Jan 25, 2024. It is now read-only.

Commit

Permalink
refactor(projects): refactor rule type
Browse files Browse the repository at this point in the history
  • Loading branch information
honghuangdc committed Dec 13, 2023
1 parent c2d7175 commit 3a3bce0
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 44 deletions.
5 changes: 1 addition & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,13 @@
}
},
"dependencies": {
"@antfu/eslint-define-config": "1.23.0-2",
"@antfu/install-pkg": "0.3.1",
"@eslint/eslintrc": "2.1.4",
"@eslint/js": "8.55.0",
"@typescript-eslint/eslint-plugin": "6.14.0",
"@typescript-eslint/parser": "6.14.0",
"eslint-config-prettier": "9.1.0",
"eslint-define-config": "2.0.0",
"eslint-parser-plain": "0.1.0",
"eslint-plugin-i": "2.29.0",
"eslint-plugin-n": "16.4.0",
Expand All @@ -120,9 +120,6 @@
"prompts": "2.4.2"
},
"devDependencies": {
"@eslint-types/import": "2.29.0-1",
"@eslint-types/typescript-eslint": "6.12.0",
"@eslint-types/unicorn": "49.0.0",
"@soybeanjs/cli": "1.0.0-beta.7",
"@toml-tools/parser": "1.0.0",
"@types/eslint": "8.44.8",
Expand Down
58 changes: 19 additions & 39 deletions pnpm-lock.yaml

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

37 changes: 37 additions & 0 deletions src/types/rule.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import type {
EslintRules,
FlatESLintConfigItem,
ImportRules,
MergeIntersection,
NRules,
ReactHooksRules,
ReactRules,
RuleConfig,
TypeScriptRules,
UnicornRules,
VueRules
} from '@antfu/eslint-define-config';
import type { Linter } from 'eslint';
import type { BuiltInParserName, LiteralUnion, RequiredOptions } from 'prettier';

export type PrettierCustomParser = 'astro' | 'svelte' | 'jsdoc-parser' | 'toml';

export interface PrettierOptions extends RequiredOptions {
parser: LiteralUnion<BuiltInParserName | PrettierCustomParser>;
}

type WrapRuleConfig<T extends { [key: string]: any }> = {
[K in keyof T]: T[K] extends RuleConfig ? T[K] : RuleConfig<T[K]>;
};

export type EslintFlatRules = WrapRuleConfig<
MergeIntersection<
EslintRules & ImportRules & NRules & UnicornRules & TypeScriptRules & VueRules & ReactRules & ReactHooksRules
>
>;

export type FlatConfigItem = Omit<FlatESLintConfigItem<EslintFlatRules, false>, 'plugins'> & {
plugins: Record<string, any>;
};

export type UserConfigItem = FlatConfigItem | Linter.FlatConfig;
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"@/*": ["./src/*"]
},
"resolveJsonModule": true,
"types": ["node", "@eslint-types/typescript-eslint", "@eslint-types/import", "@eslint-types/unicorn"],
"types": ["node"],
"strict": true,
"strictNullChecks": true,
"noUnusedLocals": true,
Expand Down

0 comments on commit 3a3bce0

Please sign in to comment.