@eienjs/eslint-config 1.2.2 → 1.4.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/dist/cli/constants.js +74 -0
- package/dist/cli/constants_generated.js +13 -0
- package/dist/cli/index.d.ts +1 -1
- package/dist/cli/index.js +3 -268
- package/dist/cli/run.js +77 -0
- package/dist/cli/stages/update_eslint_files.js +39 -0
- package/dist/cli/stages/update_package_json.js +46 -0
- package/dist/cli/stages/update_vscode_settings.js +30 -0
- package/dist/cli/utils.js +23 -0
- package/dist/configs/adonisjs.d.ts +6 -0
- package/dist/configs/adonisjs.js +115 -0
- package/dist/configs/astro.d.ts +6 -0
- package/dist/configs/astro.js +52 -0
- package/dist/configs/command.d.ts +6 -0
- package/dist/configs/command.js +12 -0
- package/dist/configs/comments.d.ts +6 -0
- package/dist/configs/comments.js +19 -0
- package/dist/configs/disables.d.ts +6 -0
- package/dist/configs/disables.js +85 -0
- package/dist/configs/formatters.d.ts +6 -0
- package/dist/configs/formatters.js +134 -0
- package/dist/configs/ignores.d.ts +6 -0
- package/dist/configs/ignores.js +12 -0
- package/dist/configs/imports.d.ts +6 -0
- package/dist/configs/imports.js +28 -0
- package/dist/configs/index.d.ts +25 -95
- package/dist/configs/index.js +25 -1
- package/dist/configs/javascript.d.ts +6 -0
- package/dist/configs/javascript.js +289 -0
- package/dist/configs/jsdoc.d.ts +6 -0
- package/dist/configs/jsdoc.js +34 -0
- package/dist/configs/jsonc.d.ts +6 -0
- package/dist/configs/jsonc.js +71 -0
- package/dist/configs/markdown.d.ts +6 -0
- package/dist/configs/markdown.js +67 -0
- package/dist/configs/node.d.ts +6 -0
- package/dist/configs/node.js +22 -0
- package/dist/configs/nuxt.d.ts +6 -0
- package/dist/configs/nuxt.js +137 -0
- package/dist/configs/perfectionist.d.ts +12 -0
- package/dist/configs/perfectionist.js +56 -0
- package/dist/configs/pnpm.d.ts +6 -0
- package/dist/configs/pnpm.js +33 -0
- package/dist/configs/regexp.d.ts +6 -0
- package/dist/configs/regexp.js +21 -0
- package/dist/configs/sort.d.ts +18 -0
- package/dist/configs/sort.js +239 -0
- package/dist/configs/stylistic.d.ts +8 -0
- package/dist/configs/stylistic.js +76 -0
- package/dist/configs/test.d.ts +6 -0
- package/dist/configs/test.js +42 -0
- package/dist/configs/toml.d.ts +6 -0
- package/dist/configs/toml.js +45 -0
- package/dist/configs/typescript.d.ts +6 -0
- package/dist/configs/typescript.js +237 -0
- package/dist/configs/unicorn.d.ts +6 -0
- package/dist/configs/unicorn.js +42 -0
- package/dist/configs/vue.d.ts +6 -0
- package/dist/configs/vue.js +206 -0
- package/dist/configs/yaml.d.ts +6 -0
- package/dist/configs/yaml.js +83 -0
- package/dist/factory.d.ts +17 -0
- package/dist/factory.js +161 -0
- package/dist/globs.d.ts +32 -0
- package/dist/globs.js +89 -0
- package/dist/index.d.ts +6 -86
- package/dist/index.js +3 -133
- package/dist/package.js +5 -0
- package/dist/plugins.js +9 -0
- package/dist/{types-ClRJcxpY.d.ts → typegen.d.ts} +446 -747
- package/dist/types.d.ts +426 -0
- package/dist/utils.d.ts +42 -0
- package/dist/utils.js +62 -0
- package/dist/vendored/prettier_types.d.ts +121 -0
- package/package.json +45 -33
- package/dist/configs-D_4UWxl6.js +0 -2192
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,426 @@
|
|
|
1
|
+
import { ConfigNames, RuleOptions } from "./typegen.js";
|
|
2
|
+
import { VendoredPrettierOptions } from "./vendored/prettier_types.js";
|
|
3
|
+
import { StylisticCustomizeOptions } from "@stylistic/eslint-plugin";
|
|
4
|
+
import { ParserOptions } from "@typescript-eslint/parser";
|
|
5
|
+
import { FlatGitignoreOptions } from "eslint-config-flat-gitignore";
|
|
6
|
+
import { Options } from "eslint-processor-vue-blocks";
|
|
7
|
+
import { Linter } from "eslint";
|
|
8
|
+
|
|
9
|
+
//#region src/types.d.ts
|
|
10
|
+
type Awaitable<T> = T | Promise<T>;
|
|
11
|
+
type Rules = Record<string, Linter.RuleEntry | undefined> & RuleOptions;
|
|
12
|
+
/**
|
|
13
|
+
* An updated version of ESLint's `Linter.Config`, which provides autocompletion
|
|
14
|
+
* for `rules` and relaxes type limitations for `plugins` and `rules`, because
|
|
15
|
+
* many plugins still lack proper type definitions.
|
|
16
|
+
*/
|
|
17
|
+
type TypedFlatConfigItem = Omit<Linter.Config, 'plugins' | 'rules'> & {
|
|
18
|
+
/**
|
|
19
|
+
* An object containing a name-value mapping of plugin names to plugin objects.
|
|
20
|
+
* When `files` is specified, these plugins are only available to the matching files.
|
|
21
|
+
*
|
|
22
|
+
* @see [Using plugins in your configuration](https://eslint.org/docs/latest/user-guide/configuring/configuration-files-new#using-plugins-in-your-configuration)
|
|
23
|
+
*/
|
|
24
|
+
plugins?: Record<string, unknown>;
|
|
25
|
+
/**
|
|
26
|
+
* An object containing the configured rules. When `files` or `ignores` are
|
|
27
|
+
* specified, these rule configurations are only available to the matching files.
|
|
28
|
+
*/
|
|
29
|
+
rules?: Rules;
|
|
30
|
+
};
|
|
31
|
+
interface OptionsErasableSyntaxOnly {
|
|
32
|
+
/**
|
|
33
|
+
* Enable/disable erasable syntax only rules for enums.
|
|
34
|
+
*
|
|
35
|
+
* @default true when `erableSyntaxOnly` is enabled
|
|
36
|
+
*/
|
|
37
|
+
enums?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Enable/disable erasable syntax only rules for parameter properties.
|
|
40
|
+
*
|
|
41
|
+
* @default true when `erableSyntaxOnly` is enabled
|
|
42
|
+
*/
|
|
43
|
+
parameterProperties?: boolean;
|
|
44
|
+
}
|
|
45
|
+
interface OptionsNuxt extends OptionsOverrides {
|
|
46
|
+
/**
|
|
47
|
+
* Version of Nuxt
|
|
48
|
+
*
|
|
49
|
+
* @default 4
|
|
50
|
+
*/
|
|
51
|
+
version?: 3 | 4;
|
|
52
|
+
/**
|
|
53
|
+
* Sort keys in nuxt.config to maintain a consistent order
|
|
54
|
+
*
|
|
55
|
+
* @default true when `stylistic` is enabled
|
|
56
|
+
*/
|
|
57
|
+
sortConfigKeys?: boolean;
|
|
58
|
+
dirs?: {
|
|
59
|
+
/**
|
|
60
|
+
* Nuxt source directory
|
|
61
|
+
*/
|
|
62
|
+
src?: string[];
|
|
63
|
+
/**
|
|
64
|
+
* Root directory for nuxt project
|
|
65
|
+
*/
|
|
66
|
+
root?: string[];
|
|
67
|
+
/**
|
|
68
|
+
* Directory for pages
|
|
69
|
+
*/
|
|
70
|
+
pages?: string[];
|
|
71
|
+
/**
|
|
72
|
+
* Directory for layouts
|
|
73
|
+
*/
|
|
74
|
+
layouts?: string[];
|
|
75
|
+
/**
|
|
76
|
+
* Directory for components
|
|
77
|
+
*/
|
|
78
|
+
components?: string[];
|
|
79
|
+
/**
|
|
80
|
+
* Directory for components with prefix
|
|
81
|
+
* Ignore `vue/multi-word-component-names`
|
|
82
|
+
*/
|
|
83
|
+
componentsPrefixed?: string[];
|
|
84
|
+
/**
|
|
85
|
+
* Directory for composobles
|
|
86
|
+
*/
|
|
87
|
+
composables?: string[];
|
|
88
|
+
/**
|
|
89
|
+
* Directory for plugins
|
|
90
|
+
*/
|
|
91
|
+
plugins?: string[];
|
|
92
|
+
/**
|
|
93
|
+
* Directory for modules
|
|
94
|
+
*/
|
|
95
|
+
modules?: string[];
|
|
96
|
+
/**
|
|
97
|
+
* Directory for middleware
|
|
98
|
+
*/
|
|
99
|
+
middleware?: string[];
|
|
100
|
+
/**
|
|
101
|
+
* Directory for server
|
|
102
|
+
*/
|
|
103
|
+
servers?: string[];
|
|
104
|
+
/**
|
|
105
|
+
* Directory for utils
|
|
106
|
+
*/
|
|
107
|
+
utils?: string[];
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
interface OptionsAdonisJS extends OptionsOverrides {
|
|
111
|
+
/**
|
|
112
|
+
* Override the `dirs` option to provide custom directories of adonisjs app.
|
|
113
|
+
*/
|
|
114
|
+
dirs?: {
|
|
115
|
+
root?: string;
|
|
116
|
+
bin?: string;
|
|
117
|
+
controllers?: string;
|
|
118
|
+
exceptions?: string;
|
|
119
|
+
models?: string;
|
|
120
|
+
mails?: string;
|
|
121
|
+
services?: string;
|
|
122
|
+
listeners?: string;
|
|
123
|
+
events?: string;
|
|
124
|
+
middleware?: string;
|
|
125
|
+
validators?: string;
|
|
126
|
+
providers?: string;
|
|
127
|
+
policies?: string;
|
|
128
|
+
abilities?: string;
|
|
129
|
+
database?: string;
|
|
130
|
+
start?: string;
|
|
131
|
+
tests?: string;
|
|
132
|
+
config?: string;
|
|
133
|
+
commands?: string;
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
interface OptionsVue extends OptionsOverrides {
|
|
137
|
+
/**
|
|
138
|
+
* Create virtual files for Vue SFC blocks to enable linting.
|
|
139
|
+
*
|
|
140
|
+
* @see https://github.com/antfu/eslint-processor-vue-blocks
|
|
141
|
+
* @default true
|
|
142
|
+
*/
|
|
143
|
+
sfcBlocks?: boolean | Options;
|
|
144
|
+
/**
|
|
145
|
+
* Only check registered components in template casing.
|
|
146
|
+
*
|
|
147
|
+
* @default false
|
|
148
|
+
*/
|
|
149
|
+
componentNameInTemplateCasingOnlyRegistered?: boolean;
|
|
150
|
+
/**
|
|
151
|
+
* Ignored components in template casing.
|
|
152
|
+
*
|
|
153
|
+
* @default []
|
|
154
|
+
*/
|
|
155
|
+
componentNameInTemplateCasingIgnores?: string[];
|
|
156
|
+
/**
|
|
157
|
+
* Global components in template casing.
|
|
158
|
+
*
|
|
159
|
+
* @default []
|
|
160
|
+
*/
|
|
161
|
+
componentNameInTemplateCasingGlobals?: string[];
|
|
162
|
+
}
|
|
163
|
+
type OptionsTypescript = (OptionsTypeScriptWithTypes & OptionsOverrides & OptionsTypescriptWithErasableSyntaxOnly) | (OptionsTypeScriptParserOptions & OptionsOverrides & OptionsTypescriptWithErasableSyntaxOnly);
|
|
164
|
+
interface OptionsFormatters {
|
|
165
|
+
/**
|
|
166
|
+
* Enable formatting support for CSS, Less, Sass, and SCSS.
|
|
167
|
+
*
|
|
168
|
+
* Currently only support Prettier.
|
|
169
|
+
*/
|
|
170
|
+
css?: 'prettier' | boolean;
|
|
171
|
+
/**
|
|
172
|
+
* Enable formatting support for HTML.
|
|
173
|
+
*
|
|
174
|
+
* Currently only support Prettier.
|
|
175
|
+
*/
|
|
176
|
+
html?: 'prettier' | boolean;
|
|
177
|
+
/**
|
|
178
|
+
* Enable formatting support for XML.
|
|
179
|
+
*
|
|
180
|
+
* Currently only support Prettier.
|
|
181
|
+
*/
|
|
182
|
+
xml?: 'prettier' | boolean;
|
|
183
|
+
/**
|
|
184
|
+
* Enable formatting support for SVG.
|
|
185
|
+
*
|
|
186
|
+
* Currently only support Prettier.
|
|
187
|
+
*/
|
|
188
|
+
svg?: 'prettier' | boolean;
|
|
189
|
+
/**
|
|
190
|
+
* Enable formatting support for Markdown.
|
|
191
|
+
*
|
|
192
|
+
* Support both Prettier and dprint.
|
|
193
|
+
*
|
|
194
|
+
* When set to `true`, it will use Prettier.
|
|
195
|
+
*/
|
|
196
|
+
markdown?: 'prettier' | boolean;
|
|
197
|
+
/**
|
|
198
|
+
* Custom options for Prettier.
|
|
199
|
+
*
|
|
200
|
+
* By default it's controlled by our own config.
|
|
201
|
+
*/
|
|
202
|
+
prettierOptions?: VendoredPrettierOptions;
|
|
203
|
+
/**
|
|
204
|
+
* Enable formatting support for Astro.
|
|
205
|
+
*
|
|
206
|
+
* Currently only support Prettier.
|
|
207
|
+
*/
|
|
208
|
+
astro?: 'prettier' | boolean;
|
|
209
|
+
}
|
|
210
|
+
interface OptionsComponentExts {
|
|
211
|
+
/**
|
|
212
|
+
* Additional extensions for components.
|
|
213
|
+
*
|
|
214
|
+
* @example ['vue']
|
|
215
|
+
* @default []
|
|
216
|
+
*/
|
|
217
|
+
componentExts?: string[];
|
|
218
|
+
}
|
|
219
|
+
interface OptionsTypeScriptParserOptions {
|
|
220
|
+
/**
|
|
221
|
+
* Additional parser options for TypeScript.
|
|
222
|
+
*/
|
|
223
|
+
parserOptions?: Partial<ParserOptions>;
|
|
224
|
+
/**
|
|
225
|
+
* Glob patterns for files that should be type aware.
|
|
226
|
+
* @default ['**\/*.{ts,tsx}']
|
|
227
|
+
*/
|
|
228
|
+
filesTypeAware?: string[];
|
|
229
|
+
/**
|
|
230
|
+
* Glob patterns for files that should not be type aware.
|
|
231
|
+
* @default ['**\/*.md\/**', '**\/*.astro/*.ts']
|
|
232
|
+
*/
|
|
233
|
+
ignoresTypeAware?: string[];
|
|
234
|
+
}
|
|
235
|
+
interface OptionsTypescriptWithErasableSyntaxOnly {
|
|
236
|
+
/**
|
|
237
|
+
* Enable erasable syntax only rules.
|
|
238
|
+
*
|
|
239
|
+
* @default false
|
|
240
|
+
*/
|
|
241
|
+
erasableSyntaxOnly?: boolean | OptionsErasableSyntaxOnly;
|
|
242
|
+
}
|
|
243
|
+
interface OptionsTypeScriptWithTypes {
|
|
244
|
+
/**
|
|
245
|
+
* When this options is provided, type aware rules will be enabled.
|
|
246
|
+
* @see https://typescript-eslint.io/linting/typed-linting/
|
|
247
|
+
*/
|
|
248
|
+
tsconfigPath?: string;
|
|
249
|
+
/**
|
|
250
|
+
* Override type aware rules.
|
|
251
|
+
*/
|
|
252
|
+
overridesTypeAware?: TypedFlatConfigItem['rules'];
|
|
253
|
+
}
|
|
254
|
+
interface OptionsHasTypeScript {
|
|
255
|
+
typescript?: boolean;
|
|
256
|
+
}
|
|
257
|
+
interface OptionsStylistic {
|
|
258
|
+
stylistic?: boolean | StylisticConfig;
|
|
259
|
+
}
|
|
260
|
+
interface StylisticConfig extends Pick<StylisticCustomizeOptions, 'indent' | 'quotes'> {
|
|
261
|
+
maxLineLength?: number;
|
|
262
|
+
}
|
|
263
|
+
interface OptionsOverrides {
|
|
264
|
+
overrides?: TypedFlatConfigItem['rules'];
|
|
265
|
+
}
|
|
266
|
+
interface OptionsFiles {
|
|
267
|
+
/**
|
|
268
|
+
* Override the `files` option to provide custom globs.
|
|
269
|
+
*/
|
|
270
|
+
files?: string[];
|
|
271
|
+
}
|
|
272
|
+
interface OptionsRegExp {
|
|
273
|
+
/**
|
|
274
|
+
* Override rulelevels
|
|
275
|
+
*/
|
|
276
|
+
level?: 'error' | 'warn';
|
|
277
|
+
}
|
|
278
|
+
interface OptionsIsInEditor {
|
|
279
|
+
isInEditor?: boolean;
|
|
280
|
+
}
|
|
281
|
+
interface OptionsConfig extends OptionsComponentExts {
|
|
282
|
+
/**
|
|
283
|
+
* Enable gitignore support.
|
|
284
|
+
*
|
|
285
|
+
* Passing an object to configure the options.
|
|
286
|
+
*
|
|
287
|
+
* @see https://github.com/antfu/eslint-config-flat-gitignore
|
|
288
|
+
* @default true
|
|
289
|
+
*/
|
|
290
|
+
gitignore?: boolean | FlatGitignoreOptions;
|
|
291
|
+
/**
|
|
292
|
+
* Core rules. Can't be disabled.
|
|
293
|
+
*/
|
|
294
|
+
javascript?: OptionsOverrides;
|
|
295
|
+
/**
|
|
296
|
+
* Enable TypeScript support.
|
|
297
|
+
*
|
|
298
|
+
* Passing an object to enable TypeScript Language Server support.
|
|
299
|
+
*
|
|
300
|
+
* @default auto-detect based on the dependencies
|
|
301
|
+
*/
|
|
302
|
+
typescript?: boolean | OptionsTypescript;
|
|
303
|
+
/**
|
|
304
|
+
* Options for eslint-plugin-unicorn.
|
|
305
|
+
*
|
|
306
|
+
* @default true
|
|
307
|
+
*/
|
|
308
|
+
unicorn?: boolean | OptionsOverrides;
|
|
309
|
+
/**
|
|
310
|
+
* Options for eslint-plugin-import-lite.
|
|
311
|
+
*
|
|
312
|
+
* @default true
|
|
313
|
+
*/
|
|
314
|
+
imports?: boolean | OptionsOverrides;
|
|
315
|
+
/**
|
|
316
|
+
* Enable test support.
|
|
317
|
+
*
|
|
318
|
+
* @default true
|
|
319
|
+
*/
|
|
320
|
+
test?: boolean | OptionsOverrides;
|
|
321
|
+
/**
|
|
322
|
+
* Enable Vue support.
|
|
323
|
+
*
|
|
324
|
+
* @default auto-detect based on the dependencies
|
|
325
|
+
*/
|
|
326
|
+
vue?: boolean | OptionsVue;
|
|
327
|
+
/**
|
|
328
|
+
* Enable JSONC support.
|
|
329
|
+
*
|
|
330
|
+
* @default true
|
|
331
|
+
*/
|
|
332
|
+
jsonc?: boolean | OptionsOverrides;
|
|
333
|
+
/**
|
|
334
|
+
* Enable YAML support.
|
|
335
|
+
*
|
|
336
|
+
* @default true
|
|
337
|
+
*/
|
|
338
|
+
yaml?: boolean | OptionsOverrides;
|
|
339
|
+
/**
|
|
340
|
+
* Enable TOML support.
|
|
341
|
+
*
|
|
342
|
+
* @default true
|
|
343
|
+
*/
|
|
344
|
+
toml?: boolean | OptionsOverrides;
|
|
345
|
+
/**
|
|
346
|
+
* Enable ASTRO support.
|
|
347
|
+
*
|
|
348
|
+
* Requires installing:
|
|
349
|
+
* - `eslint-plugin-astro`
|
|
350
|
+
*
|
|
351
|
+
* Requires installing for formatting .astro:
|
|
352
|
+
* - `prettier-plugin-astro`
|
|
353
|
+
*
|
|
354
|
+
* @default false
|
|
355
|
+
*/
|
|
356
|
+
astro?: boolean | OptionsOverrides;
|
|
357
|
+
/**
|
|
358
|
+
* Enable linting for **code snippets** in Markdown.
|
|
359
|
+
*
|
|
360
|
+
* For formatting Markdown content, enable also `formatters.markdown`.
|
|
361
|
+
*
|
|
362
|
+
* @default true
|
|
363
|
+
*/
|
|
364
|
+
markdown?: boolean | OptionsOverrides;
|
|
365
|
+
/**
|
|
366
|
+
* Enable stylistic rules.
|
|
367
|
+
*
|
|
368
|
+
* @see https://eslint.style/
|
|
369
|
+
* @default true
|
|
370
|
+
*/
|
|
371
|
+
stylistic?: boolean | (StylisticConfig & OptionsOverrides);
|
|
372
|
+
/**
|
|
373
|
+
* Enable regexp rules.
|
|
374
|
+
*
|
|
375
|
+
* @see https://ota-meshi.github.io/eslint-plugin-regexp/
|
|
376
|
+
* @default true
|
|
377
|
+
*/
|
|
378
|
+
regexp?: boolean | (OptionsRegExp & OptionsOverrides);
|
|
379
|
+
/**
|
|
380
|
+
* Enable pnpm (workspace/catalogs) support.
|
|
381
|
+
*
|
|
382
|
+
* Currently it's disabled by default, as it's still experimental.
|
|
383
|
+
* In the future it will be smartly enabled based on the project usage.
|
|
384
|
+
*
|
|
385
|
+
* @see https://github.com/antfu/pnpm-workspace-utils
|
|
386
|
+
* @experimental
|
|
387
|
+
* @default false
|
|
388
|
+
*/
|
|
389
|
+
pnpm?: boolean;
|
|
390
|
+
/**
|
|
391
|
+
* Use external formatters to format files.
|
|
392
|
+
*
|
|
393
|
+
* Requires installing:
|
|
394
|
+
* - `eslint-plugin-format`
|
|
395
|
+
*
|
|
396
|
+
* When set to `true`, it will enable all formatters.
|
|
397
|
+
*
|
|
398
|
+
* @default false
|
|
399
|
+
*/
|
|
400
|
+
formatters?: boolean | OptionsFormatters;
|
|
401
|
+
/**
|
|
402
|
+
* Control to disable some rules in editors.
|
|
403
|
+
* @default auto-detect based on the process.env
|
|
404
|
+
*/
|
|
405
|
+
isInEditor?: boolean;
|
|
406
|
+
/**
|
|
407
|
+
* Enable AdonisJS support.
|
|
408
|
+
*
|
|
409
|
+
* Requires installing:
|
|
410
|
+
* - `@adonisjs/eslint-plugin`
|
|
411
|
+
*
|
|
412
|
+
* @default false
|
|
413
|
+
*/
|
|
414
|
+
adonisjs?: boolean | OptionsAdonisJS;
|
|
415
|
+
/**
|
|
416
|
+
* Enable Nuxt support.
|
|
417
|
+
*
|
|
418
|
+
* Requires installing:
|
|
419
|
+
* - `@nuxt/eslint-plugin`
|
|
420
|
+
*
|
|
421
|
+
* @default false
|
|
422
|
+
*/
|
|
423
|
+
nuxt?: boolean | OptionsNuxt;
|
|
424
|
+
}
|
|
425
|
+
//#endregion
|
|
426
|
+
export { Awaitable, OptionsAdonisJS, OptionsComponentExts, OptionsConfig, OptionsErasableSyntaxOnly, OptionsFiles, OptionsFormatters, OptionsHasTypeScript, OptionsIsInEditor, OptionsNuxt, OptionsOverrides, OptionsRegExp, OptionsStylistic, OptionsTypeScriptParserOptions, OptionsTypeScriptWithTypes, OptionsTypescript, OptionsTypescriptWithErasableSyntaxOnly, OptionsVue, Rules, StylisticConfig, TypedFlatConfigItem };
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Awaitable, TypedFlatConfigItem } from "./types.js";
|
|
2
|
+
|
|
3
|
+
//#region src/utils.d.ts
|
|
4
|
+
declare const parserPlain: {
|
|
5
|
+
meta: {
|
|
6
|
+
name: string;
|
|
7
|
+
};
|
|
8
|
+
parseForESLint: (code: string) => {
|
|
9
|
+
ast: {
|
|
10
|
+
body: never[];
|
|
11
|
+
comments: never[];
|
|
12
|
+
loc: {
|
|
13
|
+
end: number;
|
|
14
|
+
start: number;
|
|
15
|
+
};
|
|
16
|
+
range: number[];
|
|
17
|
+
tokens: never[];
|
|
18
|
+
type: string;
|
|
19
|
+
};
|
|
20
|
+
scopeManager: null;
|
|
21
|
+
services: {
|
|
22
|
+
isPlain: boolean;
|
|
23
|
+
};
|
|
24
|
+
visitorKeys: {
|
|
25
|
+
Program: never[];
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Combine array and non-array configs into a single array.
|
|
31
|
+
*/
|
|
32
|
+
declare function combine(...configs: Awaitable<TypedFlatConfigItem | TypedFlatConfigItem[]>[]): Promise<TypedFlatConfigItem[]>;
|
|
33
|
+
declare function toArray<T>(value: T | T[]): T[];
|
|
34
|
+
declare function interopDefault<T>(m: Awaitable<T>): Promise<T extends {
|
|
35
|
+
default: infer U;
|
|
36
|
+
} ? U : T>;
|
|
37
|
+
declare function isPackageInScope(name: string): boolean;
|
|
38
|
+
declare function ensurePackages(packages: (string | undefined)[]): Promise<void>;
|
|
39
|
+
declare function isInEditorEnv(): boolean;
|
|
40
|
+
declare function isInGitHooksOrLintStaged(): boolean;
|
|
41
|
+
//#endregion
|
|
42
|
+
export { combine, ensurePackages, interopDefault, isInEditorEnv, isInGitHooksOrLintStaged, isPackageInScope, parserPlain, toArray };
|
package/dist/utils.js
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { isPackageExists } from "local-pkg";
|
|
2
|
+
import process from "node:process";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
|
|
5
|
+
//#region src/utils.ts
|
|
6
|
+
const scopeUrl = fileURLToPath(new URL(".", import.meta.url));
|
|
7
|
+
const isCwdInScope = isPackageExists("@eienjs/eslint-config");
|
|
8
|
+
const parserPlain = {
|
|
9
|
+
meta: { name: "parser-plain" },
|
|
10
|
+
parseForESLint: (code) => ({
|
|
11
|
+
ast: {
|
|
12
|
+
body: [],
|
|
13
|
+
comments: [],
|
|
14
|
+
loc: {
|
|
15
|
+
end: code.length,
|
|
16
|
+
start: 0
|
|
17
|
+
},
|
|
18
|
+
range: [0, code.length],
|
|
19
|
+
tokens: [],
|
|
20
|
+
type: "Program"
|
|
21
|
+
},
|
|
22
|
+
scopeManager: null,
|
|
23
|
+
services: { isPlain: true },
|
|
24
|
+
visitorKeys: { Program: [] }
|
|
25
|
+
})
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Combine array and non-array configs into a single array.
|
|
29
|
+
*/
|
|
30
|
+
async function combine(...configs) {
|
|
31
|
+
return (await Promise.all(configs)).flat();
|
|
32
|
+
}
|
|
33
|
+
function toArray(value) {
|
|
34
|
+
return Array.isArray(value) ? value : [value];
|
|
35
|
+
}
|
|
36
|
+
async function interopDefault(m) {
|
|
37
|
+
const resolved = await m;
|
|
38
|
+
return resolved.default || resolved;
|
|
39
|
+
}
|
|
40
|
+
function isPackageInScope(name) {
|
|
41
|
+
return isPackageExists(name, { paths: [scopeUrl] });
|
|
42
|
+
}
|
|
43
|
+
async function ensurePackages(packages) {
|
|
44
|
+
if (process.env.CI || !process.stdout.isTTY || !isCwdInScope) return;
|
|
45
|
+
const nonExistingPackages = packages.filter((i) => i && !isPackageInScope(i));
|
|
46
|
+
if (nonExistingPackages.length === 0) return;
|
|
47
|
+
const p = await import("@clack/prompts");
|
|
48
|
+
const packagesMissing = nonExistingPackages.join(", ");
|
|
49
|
+
const packagesMissingPlural = nonExistingPackages.length === 1 ? "Package is" : "Packages are";
|
|
50
|
+
if (await p.confirm({ message: `${packagesMissingPlural} required for this config: ${packagesMissing}. Do you want to install them?` })) await import("@antfu/install-pkg").then(async (i) => i.installPackage(nonExistingPackages, { dev: true }));
|
|
51
|
+
}
|
|
52
|
+
function isInEditorEnv() {
|
|
53
|
+
if (process.env.CI) return false;
|
|
54
|
+
if (isInGitHooksOrLintStaged()) return false;
|
|
55
|
+
return Boolean(process.env.VSCODE_PID || process.env.VSCODE_CWD || process.env.JETBRAINS_IDE || process.env.VIM || process.env.NVIM);
|
|
56
|
+
}
|
|
57
|
+
function isInGitHooksOrLintStaged() {
|
|
58
|
+
return Boolean(process.env.GIT_PARAMS || process.env.VSCODE_GIT_COMMAND || process.env.npm_lifecycle_script?.startsWith("lint-staged"));
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
//#endregion
|
|
62
|
+
export { combine, ensurePackages, interopDefault, isInEditorEnv, isInGitHooksOrLintStaged, isPackageInScope, parserPlain, toArray };
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
//#region src/vendored/prettier_types.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Vendor types from Prettier so we don't rely on the dependency.
|
|
4
|
+
*/
|
|
5
|
+
type VendoredPrettierOptions = Partial<VendoredPrettierOptionsRequired>;
|
|
6
|
+
interface VendoredPrettierOptionsRequired {
|
|
7
|
+
/**
|
|
8
|
+
* Specify the line length that the printer will wrap on.
|
|
9
|
+
* @default 120
|
|
10
|
+
*/
|
|
11
|
+
printWidth: number;
|
|
12
|
+
/**
|
|
13
|
+
* Specify the number of spaces per indentation-level.
|
|
14
|
+
*/
|
|
15
|
+
tabWidth: number;
|
|
16
|
+
/**
|
|
17
|
+
* Indent lines with tabs instead of spaces
|
|
18
|
+
*/
|
|
19
|
+
useTabs?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Print semicolons at the ends of statements.
|
|
22
|
+
*/
|
|
23
|
+
semi: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Use single quotes instead of double quotes.
|
|
26
|
+
*/
|
|
27
|
+
singleQuote: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Use single quotes in JSX.
|
|
30
|
+
*/
|
|
31
|
+
jsxSingleQuote: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Print trailing commas wherever possible.
|
|
34
|
+
*/
|
|
35
|
+
trailingComma: 'none' | 'es5' | 'all';
|
|
36
|
+
/**
|
|
37
|
+
* Print spaces between brackets in object literals.
|
|
38
|
+
*/
|
|
39
|
+
bracketSpacing: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Put the `>` of a multi-line HTML (HTML, XML, JSX, Vue, Angular) element at the end of the last line instead of being
|
|
42
|
+
* alone on the next line (does not apply to self closing elements).
|
|
43
|
+
*/
|
|
44
|
+
bracketSameLine: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Put the `>` of a multi-line JSX element at the end of the last line instead of being alone on the next line.
|
|
47
|
+
* @deprecated use bracketSameLine instead
|
|
48
|
+
*/
|
|
49
|
+
jsxBracketSameLine: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Format only a segment of a file.
|
|
52
|
+
*/
|
|
53
|
+
rangeStart: number;
|
|
54
|
+
/**
|
|
55
|
+
* Format only a segment of a file.
|
|
56
|
+
* @default Number.POSITIVE_INFINITY
|
|
57
|
+
*/
|
|
58
|
+
rangeEnd: number;
|
|
59
|
+
/**
|
|
60
|
+
* By default, Prettier will wrap markdown text as-is since some services use a linebreak-sensitive renderer.
|
|
61
|
+
* In some cases you may want to rely on editor/viewer soft wrapping instead, so this option allows you to opt out.
|
|
62
|
+
* @default "preserve"
|
|
63
|
+
*/
|
|
64
|
+
proseWrap: 'always' | 'never' | 'preserve';
|
|
65
|
+
/**
|
|
66
|
+
* Include parentheses around a sole arrow function parameter.
|
|
67
|
+
* @default "always"
|
|
68
|
+
*/
|
|
69
|
+
arrowParens: 'avoid' | 'always';
|
|
70
|
+
/**
|
|
71
|
+
* Provide ability to support new languages to prettier.
|
|
72
|
+
*/
|
|
73
|
+
plugins: unknown[];
|
|
74
|
+
/**
|
|
75
|
+
* How to handle whitespaces in HTML.
|
|
76
|
+
* @default "css"
|
|
77
|
+
*/
|
|
78
|
+
htmlWhitespaceSensitivity: 'css' | 'strict' | 'ignore';
|
|
79
|
+
/**
|
|
80
|
+
* Which end of line characters to apply.
|
|
81
|
+
* @default "lf"
|
|
82
|
+
*/
|
|
83
|
+
endOfLine: 'auto' | 'lf' | 'crlf' | 'cr';
|
|
84
|
+
/**
|
|
85
|
+
* Change when properties in objects are quoted.
|
|
86
|
+
* @default "as-needed"
|
|
87
|
+
*/
|
|
88
|
+
quoteProps: 'as-needed' | 'consistent' | 'preserve';
|
|
89
|
+
/**
|
|
90
|
+
* Whether or not to indent the code inside <script> and <style> tags in Vue files.
|
|
91
|
+
* @default false
|
|
92
|
+
*/
|
|
93
|
+
vueIndentScriptAndStyle: boolean;
|
|
94
|
+
/**
|
|
95
|
+
* Enforce single attribute per line in HTML, XML, Vue and JSX.
|
|
96
|
+
* @default false
|
|
97
|
+
*/
|
|
98
|
+
singleAttributePerLine: boolean;
|
|
99
|
+
/**
|
|
100
|
+
* How to handle whitespaces in XML.
|
|
101
|
+
* @default "preserve"
|
|
102
|
+
*/
|
|
103
|
+
xmlQuoteAttributes: 'single' | 'double' | 'preserve';
|
|
104
|
+
/**
|
|
105
|
+
* Whether to put a space inside the brackets of self-closing XML elements.
|
|
106
|
+
* @default true
|
|
107
|
+
*/
|
|
108
|
+
xmlSelfClosingSpace: boolean;
|
|
109
|
+
/**
|
|
110
|
+
* Whether to sort attributes by key in XML elements.
|
|
111
|
+
* @default false
|
|
112
|
+
*/
|
|
113
|
+
xmlSortAttributesByKey: boolean;
|
|
114
|
+
/**
|
|
115
|
+
* How to handle whitespaces in XML.
|
|
116
|
+
* @default "ignore"
|
|
117
|
+
*/
|
|
118
|
+
xmlWhitespaceSensitivity: 'ignore' | 'strict' | 'preserve';
|
|
119
|
+
}
|
|
120
|
+
//#endregion
|
|
121
|
+
export { VendoredPrettierOptions };
|