@coderwyd/eslint-config 1.1.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -230
- package/dist/cli.cjs +66 -56
- package/dist/cli.js +66 -56
- package/dist/index.cjs +442 -539
- package/dist/index.d.cts +127 -147
- package/dist/index.d.ts +127 -147
- package/dist/index.js +442 -491
- package/package.json +40 -41
package/dist/index.d.cts
CHANGED
|
@@ -1,23 +1,25 @@
|
|
|
1
1
|
import { FlatGitignoreOptions } from 'eslint-config-flat-gitignore';
|
|
2
2
|
import { ParserOptions } from '@typescript-eslint/parser';
|
|
3
|
+
import { FlatESLintConfigItem, MergeIntersection, RenamePrefix, TypeScriptRules, VitestRules, NRules, Prefix, ReactHooksRules, ReactRules, JSDocRules, ImportRules, EslintRules, JsoncRules, VueRules, UnicornRules, EslintCommentsRules, RuleConfig } from '@antfu/eslint-define-config';
|
|
3
4
|
import { Linter } from 'eslint';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { RuleOptions } from '@eslint-types/typescript-eslint/types';
|
|
7
|
-
import { RuleOptions as RuleOptions$2 } from '@eslint-types/unicorn/types';
|
|
8
|
-
import { Rules as Rules$1 } from 'eslint-plugin-antfu';
|
|
9
|
-
import { UnprefixedRuleOptions, StylisticCustomizeOptions } from '@stylistic/eslint-plugin';
|
|
5
|
+
import { Rules } from 'eslint-plugin-antfu';
|
|
6
|
+
import { RequiredOptions, LiteralUnion, BuiltInParserName } from 'prettier';
|
|
10
7
|
|
|
8
|
+
type PrettierCustomParser = 'astro' | 'svelte' | 'toml';
|
|
9
|
+
type PrettierParser = BuiltInParserName | PrettierCustomParser;
|
|
10
|
+
interface PrettierOptions extends RequiredOptions {
|
|
11
|
+
parser: LiteralUnion<PrettierParser>;
|
|
12
|
+
}
|
|
13
|
+
type PartialPrettierExtendedOptions = Partial<PrettierOptions>;
|
|
11
14
|
type WrapRuleConfig<T extends {
|
|
12
15
|
[key: string]: any;
|
|
13
16
|
}> = {
|
|
14
17
|
[K in keyof T]: T[K] extends RuleConfig ? T[K] : RuleConfig<T[K]>;
|
|
15
18
|
};
|
|
16
|
-
type
|
|
17
|
-
type Rules = WrapRuleConfig<MergeIntersection<RenamePrefix<RuleOptions, '@typescript-eslint/', 'ts/'> & RenamePrefix<VitestRules, 'vitest/', 'test/'> & RenamePrefix<YmlRules, 'yml/', 'yaml/'> & RenamePrefix<NRules, 'n/', 'node/'> & Prefix<UnprefixedRuleOptions, 'style/'> & Prefix<Rules$1, 'antfu/'> & ReactHooksRules & ReactRules & RuleOptions$1 & ImportRules & EslintRules & JsoncRules & VueRules & RuleOptions$2 & EslintCommentsRules & {
|
|
19
|
+
type EslintFlatRules = WrapRuleConfig<MergeIntersection<RenamePrefix<TypeScriptRules, '@typescript-eslint/', 'ts/'> & RenamePrefix<VitestRules, 'vitest/', 'test/'> & RenamePrefix<NRules, 'n/', 'node/'> & Prefix<Rules, 'antfu/'> & ReactHooksRules & ReactRules & JSDocRules & ImportRules & EslintRules & JsoncRules & VueRules & UnicornRules & EslintCommentsRules & {
|
|
18
20
|
'test/no-only-tests': RuleConfig<[]>;
|
|
19
21
|
}>>;
|
|
20
|
-
type FlatConfigItem = Omit<FlatESLintConfigItem<
|
|
22
|
+
type FlatConfigItem = Omit<FlatESLintConfigItem<EslintFlatRules, false>, 'plugins'> & {
|
|
21
23
|
/**
|
|
22
24
|
* Custom name of each config item
|
|
23
25
|
*/
|
|
@@ -30,11 +32,42 @@ type FlatConfigItem = Omit<FlatESLintConfigItem<Rules, false>, 'plugins'> & {
|
|
|
30
32
|
plugins?: Record<string, any>;
|
|
31
33
|
};
|
|
32
34
|
type UserConfigItem = FlatConfigItem | Linter.FlatConfig;
|
|
33
|
-
|
|
35
|
+
|
|
36
|
+
type Awaitable<T> = T | Promise<T>;
|
|
37
|
+
type OptionsTypescript = (OptionsTypeScriptWithTypes & OptionsOverrides) | (OptionsTypeScriptParserOptions & OptionsOverrides);
|
|
38
|
+
interface OptionsFormatters {
|
|
39
|
+
/**
|
|
40
|
+
* Enable formatting support for CSS, Less, Sass, and SCSS.
|
|
41
|
+
*
|
|
42
|
+
* Currently only support Prettier.
|
|
43
|
+
*/
|
|
44
|
+
css?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Enable formatting support for HTML.
|
|
47
|
+
*
|
|
48
|
+
* Currently only support Prettier.
|
|
49
|
+
*/
|
|
50
|
+
html?: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Enable formatting support for Markdown.
|
|
53
|
+
*
|
|
54
|
+
* Support both Prettier.
|
|
55
|
+
*
|
|
56
|
+
* When set to `true`, it will use Prettier.
|
|
57
|
+
*/
|
|
58
|
+
markdown?: boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Enable formatting support for GraphQL.
|
|
61
|
+
*/
|
|
62
|
+
graphql?: boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Enable formatting support for Yaml.
|
|
65
|
+
*/
|
|
66
|
+
yaml?: boolean;
|
|
34
67
|
/**
|
|
35
|
-
*
|
|
68
|
+
* Enable formatting support for Toml.
|
|
36
69
|
*/
|
|
37
|
-
|
|
70
|
+
toml?: boolean;
|
|
38
71
|
}
|
|
39
72
|
interface OptionsComponentExts {
|
|
40
73
|
/**
|
|
@@ -50,6 +83,11 @@ interface OptionsTypeScriptParserOptions {
|
|
|
50
83
|
* Additional parser options for TypeScript.
|
|
51
84
|
*/
|
|
52
85
|
parserOptions?: Partial<ParserOptions>;
|
|
86
|
+
/**
|
|
87
|
+
* Glob patterns for files that should be type aware.
|
|
88
|
+
* @default ['**\/*.{ts,tsx}']
|
|
89
|
+
*/
|
|
90
|
+
filesTypeAware?: string[];
|
|
53
91
|
}
|
|
54
92
|
interface OptionsTypeScriptWithTypes {
|
|
55
93
|
/**
|
|
@@ -58,21 +96,10 @@ interface OptionsTypeScriptWithTypes {
|
|
|
58
96
|
*/
|
|
59
97
|
tsconfigPath?: string | string[];
|
|
60
98
|
}
|
|
61
|
-
interface OptionsHasTypeScript {
|
|
62
|
-
typescript?: boolean;
|
|
63
|
-
}
|
|
64
|
-
interface OptionsStylistic {
|
|
65
|
-
stylistic?: boolean | StylisticConfig;
|
|
66
|
-
}
|
|
67
|
-
interface StylisticConfig extends Pick<StylisticCustomizeOptions, 'indent' | 'quotes' | 'jsx' | 'semi'> {
|
|
68
|
-
}
|
|
69
99
|
interface OptionsOverrides {
|
|
70
100
|
overrides?: FlatConfigItem['rules'];
|
|
71
101
|
}
|
|
72
|
-
interface
|
|
73
|
-
isInEditor?: boolean;
|
|
74
|
-
}
|
|
75
|
-
interface OptionsUnoCSS {
|
|
102
|
+
interface OptionsUnoCSS extends OptionsOverrides {
|
|
76
103
|
/**
|
|
77
104
|
* Enable attributify support.
|
|
78
105
|
* @default true
|
|
@@ -84,7 +111,21 @@ interface OptionsUnoCSS {
|
|
|
84
111
|
*/
|
|
85
112
|
strict?: boolean;
|
|
86
113
|
}
|
|
114
|
+
interface OptionsVue extends OptionsOverrides {
|
|
115
|
+
/**
|
|
116
|
+
* The vue version
|
|
117
|
+
*
|
|
118
|
+
* @default 3
|
|
119
|
+
*/
|
|
120
|
+
version?: 2 | 3;
|
|
121
|
+
}
|
|
87
122
|
interface OptionsConfig extends OptionsComponentExts {
|
|
123
|
+
/**
|
|
124
|
+
* The current working directory
|
|
125
|
+
*
|
|
126
|
+
* @default process.cwd()
|
|
127
|
+
*/
|
|
128
|
+
cwd?: string;
|
|
88
129
|
/**
|
|
89
130
|
* Enable gitignore support.
|
|
90
131
|
*
|
|
@@ -94,6 +135,10 @@ interface OptionsConfig extends OptionsComponentExts {
|
|
|
94
135
|
* @default true
|
|
95
136
|
*/
|
|
96
137
|
gitignore?: boolean | FlatGitignoreOptions;
|
|
138
|
+
/**
|
|
139
|
+
* Core rules. Can't be disabled.
|
|
140
|
+
*/
|
|
141
|
+
javascript?: OptionsOverrides;
|
|
97
142
|
/**
|
|
98
143
|
* Enable TypeScript support.
|
|
99
144
|
*
|
|
@@ -101,51 +146,25 @@ interface OptionsConfig extends OptionsComponentExts {
|
|
|
101
146
|
*
|
|
102
147
|
* @default auto-detect based on the dependencies
|
|
103
148
|
*/
|
|
104
|
-
typescript?: boolean |
|
|
105
|
-
/**
|
|
106
|
-
* Enable JSX related rules.
|
|
107
|
-
*
|
|
108
|
-
* Currently only stylistic rules are included.
|
|
109
|
-
*
|
|
110
|
-
* @default true
|
|
111
|
-
*/
|
|
112
|
-
jsx?: boolean;
|
|
149
|
+
typescript?: boolean | OptionsTypescript;
|
|
113
150
|
/**
|
|
114
151
|
* Enable test support.
|
|
115
152
|
*
|
|
116
153
|
* @default true
|
|
117
154
|
*/
|
|
118
|
-
test?: boolean;
|
|
155
|
+
test?: boolean | OptionsOverrides;
|
|
119
156
|
/**
|
|
120
157
|
* Enable Vue support.
|
|
121
158
|
*
|
|
122
159
|
* @default auto-detect based on the dependencies
|
|
123
160
|
*/
|
|
124
|
-
vue?: boolean;
|
|
161
|
+
vue?: boolean | OptionsVue;
|
|
125
162
|
/**
|
|
126
163
|
* Enable JSONC support.
|
|
127
164
|
*
|
|
128
165
|
* @default true
|
|
129
166
|
*/
|
|
130
|
-
jsonc?: boolean;
|
|
131
|
-
/**
|
|
132
|
-
* Enable YAML support.
|
|
133
|
-
*
|
|
134
|
-
* @default true
|
|
135
|
-
*/
|
|
136
|
-
yaml?: boolean;
|
|
137
|
-
/**
|
|
138
|
-
* Enable Markdown support.
|
|
139
|
-
*
|
|
140
|
-
* @default true
|
|
141
|
-
*/
|
|
142
|
-
markdown?: boolean;
|
|
143
|
-
/**
|
|
144
|
-
* Enable stylistic rules.
|
|
145
|
-
*
|
|
146
|
-
* @default true
|
|
147
|
-
*/
|
|
148
|
-
stylistic?: boolean | StylisticConfig;
|
|
167
|
+
jsonc?: boolean | OptionsOverrides;
|
|
149
168
|
/**
|
|
150
169
|
* Enable react rules.
|
|
151
170
|
*
|
|
@@ -156,7 +175,16 @@ interface OptionsConfig extends OptionsComponentExts {
|
|
|
156
175
|
*
|
|
157
176
|
* @default false
|
|
158
177
|
*/
|
|
159
|
-
react?: boolean;
|
|
178
|
+
react?: boolean | OptionsOverrides;
|
|
179
|
+
/**
|
|
180
|
+
* Enable svelte rules.
|
|
181
|
+
*
|
|
182
|
+
* Requires installing:
|
|
183
|
+
* - `eslint-plugin-svelte`
|
|
184
|
+
*
|
|
185
|
+
* @default false
|
|
186
|
+
*/
|
|
187
|
+
svelte?: boolean | OptionsOverrides;
|
|
160
188
|
/**
|
|
161
189
|
* Enable unocss rules.
|
|
162
190
|
*
|
|
@@ -166,6 +194,46 @@ interface OptionsConfig extends OptionsComponentExts {
|
|
|
166
194
|
* @default false
|
|
167
195
|
*/
|
|
168
196
|
unocss?: boolean | OptionsUnoCSS;
|
|
197
|
+
/**
|
|
198
|
+
* Whether to use prettierrc
|
|
199
|
+
*
|
|
200
|
+
* If true, the rules in prettierrc will override the default rules
|
|
201
|
+
*
|
|
202
|
+
* @default true
|
|
203
|
+
*/
|
|
204
|
+
usePrettierrc?: boolean;
|
|
205
|
+
/**
|
|
206
|
+
* Use external formatters to format files.
|
|
207
|
+
*
|
|
208
|
+
* Requires installing:
|
|
209
|
+
* - `eslint-plugin-prettier`
|
|
210
|
+
*
|
|
211
|
+
* @default
|
|
212
|
+
* {
|
|
213
|
+
* "html": true,
|
|
214
|
+
* "css": true,
|
|
215
|
+
* "graphql": true,
|
|
216
|
+
* "markdown": true
|
|
217
|
+
* "yaml": true
|
|
218
|
+
* "toml": true
|
|
219
|
+
* }
|
|
220
|
+
*/
|
|
221
|
+
formatter?: OptionsFormatters;
|
|
222
|
+
/**
|
|
223
|
+
* Default prettier rules
|
|
224
|
+
*
|
|
225
|
+
* @default
|
|
226
|
+
* ```json
|
|
227
|
+
* {
|
|
228
|
+
* "arrowParens": "avoid",
|
|
229
|
+
* "htmlWhitespaceSensitivity": "ignore"
|
|
230
|
+
* "printWidth": 80,
|
|
231
|
+
* "semi": false,
|
|
232
|
+
* "singleQuote": true,
|
|
233
|
+
* }
|
|
234
|
+
* ```
|
|
235
|
+
*/
|
|
236
|
+
prettierRules?: PartialPrettierExtendedOptions;
|
|
169
237
|
/**
|
|
170
238
|
* Control to disable some rules in editors.
|
|
171
239
|
* @default auto-detect based on the process.env
|
|
@@ -173,6 +241,8 @@ interface OptionsConfig extends OptionsComponentExts {
|
|
|
173
241
|
isInEditor?: boolean;
|
|
174
242
|
/**
|
|
175
243
|
* Provide overrides for rules for each integration.
|
|
244
|
+
*
|
|
245
|
+
* @deprecated use `overrides` option in each integration key instead
|
|
176
246
|
*/
|
|
177
247
|
overrides?: {
|
|
178
248
|
javascript?: FlatConfigItem['rules'];
|
|
@@ -180,8 +250,6 @@ interface OptionsConfig extends OptionsComponentExts {
|
|
|
180
250
|
test?: FlatConfigItem['rules'];
|
|
181
251
|
vue?: FlatConfigItem['rules'];
|
|
182
252
|
jsonc?: FlatConfigItem['rules'];
|
|
183
|
-
markdown?: FlatConfigItem['rules'];
|
|
184
|
-
yaml?: FlatConfigItem['rules'];
|
|
185
253
|
react?: FlatConfigItem['rules'];
|
|
186
254
|
};
|
|
187
255
|
}
|
|
@@ -189,94 +257,6 @@ interface OptionsConfig extends OptionsComponentExts {
|
|
|
189
257
|
/**
|
|
190
258
|
* Construct an array of ESLint flat config items.
|
|
191
259
|
*/
|
|
192
|
-
declare function
|
|
193
|
-
|
|
194
|
-
declare function comments(): Promise<FlatConfigItem[]>;
|
|
195
|
-
|
|
196
|
-
declare function ignores(): Promise<FlatConfigItem[]>;
|
|
197
|
-
|
|
198
|
-
declare function imports(options?: OptionsStylistic): Promise<FlatConfigItem[]>;
|
|
199
|
-
|
|
200
|
-
declare function javascript(options?: OptionsIsInEditor & OptionsOverrides): Promise<FlatConfigItem[]>;
|
|
201
|
-
|
|
202
|
-
declare function jsdoc(options?: OptionsStylistic): Promise<FlatConfigItem[]>;
|
|
203
|
-
|
|
204
|
-
declare function jsonc(options?: OptionsFiles & OptionsStylistic & OptionsOverrides): Promise<FlatConfigItem[]>;
|
|
205
|
-
|
|
206
|
-
declare function markdown(options?: OptionsFiles & OptionsComponentExts & OptionsOverrides): Promise<FlatConfigItem[]>;
|
|
207
|
-
|
|
208
|
-
declare function node(): Promise<FlatConfigItem[]>;
|
|
209
|
-
|
|
210
|
-
/**
|
|
211
|
-
* Sort package.json
|
|
212
|
-
*
|
|
213
|
-
* Requires `jsonc` config
|
|
214
|
-
*/
|
|
215
|
-
declare function sortPackageJson(): Promise<FlatConfigItem[]>;
|
|
216
|
-
/**
|
|
217
|
-
* Sort tsconfig.json
|
|
218
|
-
*
|
|
219
|
-
* Requires `jsonc` config
|
|
220
|
-
*/
|
|
221
|
-
declare function sortTsconfig(): FlatConfigItem[];
|
|
222
|
-
|
|
223
|
-
declare function stylistic(options?: StylisticConfig): Promise<FlatConfigItem[]>;
|
|
224
|
-
|
|
225
|
-
declare function typescript(options?: OptionsFiles & OptionsComponentExts & OptionsOverrides & OptionsTypeScriptWithTypes & OptionsTypeScriptParserOptions): Promise<FlatConfigItem[]>;
|
|
226
|
-
|
|
227
|
-
declare function unicorn(): Promise<FlatConfigItem[]>;
|
|
228
|
-
|
|
229
|
-
declare function vue(options?: OptionsHasTypeScript & OptionsOverrides & OptionsStylistic & OptionsFiles): Promise<FlatConfigItem[]>;
|
|
230
|
-
|
|
231
|
-
declare function yaml(options?: OptionsOverrides & OptionsStylistic & OptionsFiles): Promise<FlatConfigItem[]>;
|
|
232
|
-
|
|
233
|
-
declare function test(options?: OptionsFiles & OptionsIsInEditor & OptionsOverrides): Promise<FlatConfigItem[]>;
|
|
234
|
-
|
|
235
|
-
/**
|
|
236
|
-
* Optional perfectionist plugin for props and items sorting.
|
|
237
|
-
*
|
|
238
|
-
* @see https://github.com/azat-io/eslint-plugin-perfectionist
|
|
239
|
-
*/
|
|
240
|
-
declare function perfectionist(): Promise<FlatConfigItem[]>;
|
|
241
|
-
|
|
242
|
-
declare function react(options?: OptionsHasTypeScript & OptionsOverrides & OptionsFiles): Promise<FlatConfigItem[]>;
|
|
243
|
-
|
|
244
|
-
declare function unocss(options?: OptionsUnoCSS): Promise<FlatConfigItem[]>;
|
|
245
|
-
|
|
246
|
-
declare const GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
|
|
247
|
-
declare const GLOB_SRC = "**/*.?([cm])[jt]s?(x)";
|
|
248
|
-
declare const GLOB_JS = "**/*.?([cm])js";
|
|
249
|
-
declare const GLOB_JSX = "**/*.?([cm])jsx";
|
|
250
|
-
declare const GLOB_TS = "**/*.?([cm])ts";
|
|
251
|
-
declare const GLOB_TSX = "**/*.?([cm])tsx";
|
|
252
|
-
declare const GLOB_STYLE = "**/*.{c,le,sc}ss";
|
|
253
|
-
declare const GLOB_CSS = "**/*.css";
|
|
254
|
-
declare const GLOB_LESS = "**/*.less";
|
|
255
|
-
declare const GLOB_SCSS = "**/*.scss";
|
|
256
|
-
declare const GLOB_JSON = "**/*.json";
|
|
257
|
-
declare const GLOB_JSON5 = "**/*.json5";
|
|
258
|
-
declare const GLOB_JSONC = "**/*.jsonc";
|
|
259
|
-
declare const GLOB_MARKDOWN = "**/*.md";
|
|
260
|
-
declare const GLOB_VUE = "**/*.vue";
|
|
261
|
-
declare const GLOB_YAML = "**/*.y?(a)ml";
|
|
262
|
-
declare const GLOB_HTML = "**/*.htm?(l)";
|
|
263
|
-
declare const GLOB_MARKDOWN_CODE = "**/*.md/**/*.?([cm])[jt]s?(x)";
|
|
264
|
-
declare const GLOB_TESTS: string[];
|
|
265
|
-
declare const GLOB_ALL_SRC: string[];
|
|
266
|
-
declare const GLOB_EXCLUDE: string[];
|
|
267
|
-
|
|
268
|
-
/**
|
|
269
|
-
* Combine array and non-array configs into a single array.
|
|
270
|
-
*/
|
|
271
|
-
declare function combine(...configs: Awaitable<UserConfigItem | UserConfigItem[]>[]): Promise<UserConfigItem[]>;
|
|
272
|
-
declare function renameRules(rules: Record<string, any>, from: string, to: string): {
|
|
273
|
-
[k: string]: any;
|
|
274
|
-
};
|
|
275
|
-
declare function getVueVersion(): number;
|
|
276
|
-
declare function toArray<T>(value: T | T[]): T[];
|
|
277
|
-
declare function interopDefault<T>(m: Awaitable<T>): Promise<T extends {
|
|
278
|
-
default: infer U;
|
|
279
|
-
} ? U : T>;
|
|
280
|
-
declare function ensurePackages(packages: string[]): Promise<void>;
|
|
260
|
+
declare function defineConfig(options?: OptionsConfig & FlatConfigItem, ...userConfigs: Awaitable<UserConfigItem | UserConfigItem[]>[]): Promise<UserConfigItem[]>;
|
|
281
261
|
|
|
282
|
-
export {
|
|
262
|
+
export { defineConfig };
|