@curev/eslint-config 0.3.6 → 0.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/index.d.cts CHANGED
@@ -1,516 +1,9 @@
1
- import { RuleConfig, MergeIntersection, RenamePrefix, VitestRules, YmlRules, NRules, Prefix, ReactHooksRules, ReactRules, ImportRules, EslintRules, JsoncRules, VueRules, EslintCommentsRules, FlatESLintConfigItem } from '@antfu/eslint-define-config';
2
- import { Rules as Rules$1 } from '@curev/eslint-plugin';
3
- import { RuleOptions as RuleOptions$1 } from '@eslint-types/jsdoc/types';
4
- import { RuleOptions } from '@eslint-types/typescript-eslint/types';
5
- import { RuleOptions as RuleOptions$2 } from '@eslint-types/unicorn/types';
6
- import { UnprefixedRuleOptions, StylisticCustomizeOptions } from '@stylistic/eslint-plugin';
7
- import { ParserOptions } from '@typescript-eslint/parser';
1
+ import * as _antfu_eslint_config from '@antfu/eslint-config';
2
+ import { OptionsConfig, TypedFlatConfigItem } from '@antfu/eslint-config';
8
3
  import { Linter } from 'eslint';
9
- import { FlatGitignoreOptions } from 'eslint-config-flat-gitignore';
10
- import { Options } from 'eslint-processor-vue-blocks';
4
+ import { Awaitable, FlatConfigComposer } from 'eslint-flat-config-utils';
11
5
 
12
- /**
13
- * Vendor types from Prettier so we don't rely on the dependency.
14
- */
15
- type VendoredPrettierOptions = Partial<VendoredPrettierOptionsRequired>;
16
- interface VendoredPrettierOptionsRequired {
17
- /**
18
- * Include parentheses around a sole arrow function parameter.
19
- * @default "always"
20
- */
21
- arrowParens: "always" | "avoid";
22
- /**
23
- * Put the `>` of a multi-line HTML (HTML, JSX, Vue, Angular) element at the end of the last line instead of being
24
- * alone on the next line (does not apply to self closing elements).
25
- */
26
- bracketSameLine: boolean;
27
- /**
28
- * Print spaces between brackets in object literals.
29
- */
30
- bracketSpacing: boolean;
31
- /**
32
- * Which end of line characters to apply.
33
- * @default "lf"
34
- */
35
- endOfLine: "auto" | "cr" | "crlf" | "lf";
36
- /**
37
- * How to handle whitespaces in HTML.
38
- * @default "css"
39
- */
40
- htmlWhitespaceSensitivity: "css" | "ignore" | "strict";
41
- /**
42
- * Put the `>` of a multi-line JSX element at the end of the last line instead of being alone on the next line.
43
- * @deprecated use bracketSameLine instead
44
- */
45
- jsxBracketSameLine: boolean;
46
- /**
47
- * Use single quotes in JSX.
48
- */
49
- jsxSingleQuote: boolean;
50
- /**
51
- * Provide ability to support new languages to prettier.
52
- */
53
- plugins: Array<any | string>;
54
- /**
55
- * Specify the line length that the printer will wrap on.
56
- * @default 120
57
- */
58
- printWidth: 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
- * Change when properties in objects are quoted.
67
- * @default "as-needed"
68
- */
69
- quoteProps: "as-needed" | "consistent" | "preserve";
70
- /**
71
- * Format only a segment of a file.
72
- * @default Number.POSITIVE_INFINITY
73
- */
74
- rangeEnd: number;
75
- /**
76
- * Format only a segment of a file.
77
- */
78
- rangeStart: number;
79
- /**
80
- * Print semicolons at the ends of statements.
81
- */
82
- semi: boolean;
83
- /**
84
- * Enforce single attribute per line in HTML, Vue and JSX.
85
- * @default false
86
- */
87
- singleAttributePerLine: boolean;
88
- /**
89
- * Use single quotes instead of double quotes.
90
- */
91
- singleQuote: boolean;
92
- /**
93
- * Specify the number of spaces per indentation-level.
94
- */
95
- tabWidth: number;
96
- /**
97
- * Print trailing commas wherever possible.
98
- */
99
- trailingComma: "all" | "es5" | "none";
100
- /**
101
- * Indent lines with tabs instead of spaces
102
- */
103
- useTabs?: boolean;
104
- /**
105
- * Whether or not to indent the code inside <script> and <style> tags in Vue files.
106
- * @default false
107
- */
108
- vueIndentScriptAndStyle: boolean;
109
- }
6
+ type CurevOptions = OptionsConfig & Omit<TypedFlatConfigItem, "files">;
7
+ declare function curev(options?: CurevOptions, ...userConfigs: Awaitable<TypedFlatConfigItem | TypedFlatConfigItem[] | FlatConfigComposer<any, any> | Linter.Config[]>[]): FlatConfigComposer<TypedFlatConfigItem, _antfu_eslint_config.ConfigNames>;
110
8
 
111
- type WrapRuleConfig<T extends {
112
- [key: string]: any;
113
- }> = {
114
- [K in keyof T]: T[K] extends RuleConfig ? T[K] : RuleConfig<T[K]>;
115
- };
116
- type Awaitable<T> = Promise<T> | T;
117
- 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, "curev/"> & ReactHooksRules & ReactRules & RuleOptions$1 & ImportRules & EslintRules & JsoncRules & VueRules & RuleOptions$2 & EslintCommentsRules & {
118
- "test/no-only-tests": RuleConfig<[]>;
119
- }>>;
120
- type FlatConfigItem = Omit<FlatESLintConfigItem<Rules, false>, "plugins"> & {
121
- /**
122
- * Custom name of each config item
123
- */
124
- name?: string;
125
- /**
126
- * An object containing a name-value mapping of plugin names to plugin objects. When `files` is specified, these plugins are only available to the matching files.
127
- *
128
- * @see [Using plugins in your configuration](https://eslint.org/docs/latest/user-guide/configuring/configuration-files-new#using-plugins-in-your-configuration)
129
- */
130
- plugins?: Record<string, any>;
131
- };
132
- type UserConfigItem = FlatConfigItem | Linter.FlatConfig;
133
- interface OptionsFiles {
134
- /**
135
- * Override the `files` option to provide custom globs.
136
- */
137
- files?: string[];
138
- }
139
- interface OptionsVue extends OptionsOverrides {
140
- /**
141
- * Create virtual files for Vue SFC blocks to enable linting.
142
- *
143
- * @see https://github.com/antfu/eslint-processor-vue-blocks
144
- * @default true
145
- */
146
- sfcBlocks?: Options | boolean;
147
- /**
148
- * Vue version. Apply different rules set from `eslint-plugin-vue`.
149
- *
150
- * @default 3
151
- */
152
- vueVersion?: 2 | 3;
153
- }
154
- type OptionsTypescript = (OptionsTypeScriptParserOptions & OptionsOverrides) | (OptionsTypeScriptWithTypes & OptionsOverrides);
155
- interface OptionsFormatters {
156
- /**
157
- * Enable formatting support for CSS, Less, Sass, and SCSS.
158
- *
159
- * Currently only support Prettier.
160
- */
161
- css?: "prettier" | boolean;
162
- /**
163
- * Custom options for dprint.
164
- *
165
- * By default it's controlled by our own config.
166
- */
167
- dprintOptions?: boolean;
168
- /**
169
- * Enable formatting support for GraphQL.
170
- */
171
- graphql?: "prettier" | boolean;
172
- /**
173
- * Enable formatting support for HTML.
174
- *
175
- * Currently only support Prettier.
176
- */
177
- html?: "prettier" | boolean;
178
- /**
179
- * Enable formatting support for Markdown.
180
- *
181
- * Support both Prettier and dprint.
182
- *
183
- * When set to `true`, it will use Prettier.
184
- */
185
- markdown?: "dprint" | "prettier" | boolean;
186
- /**
187
- * Custom options for Prettier.
188
- *
189
- * By default it's controlled by our own config.
190
- */
191
- prettierOptions?: VendoredPrettierOptions;
192
- }
193
- interface OptionsComponentExts {
194
- /**
195
- * Additional extensions for components.
196
- *
197
- * @example ['vue']
198
- * @default []
199
- */
200
- componentExts?: string[];
201
- }
202
- interface OptionsTypeScriptParserOptions {
203
- /**
204
- * Glob patterns for files that should be type aware.
205
- * @default ['**\/*.{ts,tsx}']
206
- */
207
- filesTypeAware?: string[];
208
- /**
209
- * Additional parser options for TypeScript.
210
- */
211
- parserOptions?: Partial<ParserOptions>;
212
- }
213
- interface OptionsTypeScriptWithTypes {
214
- /**
215
- * When this options is provided, type aware rules will be enabled.
216
- * @see https://typescript-eslint.io/linting/typed-linting/
217
- */
218
- tsconfigPath?: string | string[];
219
- }
220
- interface OptionsHasTypeScript {
221
- typescript?: boolean;
222
- }
223
- interface OptionsStylistic {
224
- stylistic?: StylisticConfig | boolean;
225
- }
226
- interface StylisticConfig extends StylisticCustomizeOptions {
227
- }
228
- interface OptionsOverrides {
229
- overrides?: FlatConfigItem["rules"];
230
- }
231
- interface OptionsIsInEditor {
232
- isInEditor?: boolean;
233
- }
234
- interface OptionsUnoCSS extends OptionsOverrides {
235
- /**
236
- * Enable attributify support.
237
- * @default true
238
- */
239
- attributify?: boolean;
240
- /**
241
- * Enable strict mode by throwing errors about blocklisted classes.
242
- * @default false
243
- */
244
- strict?: boolean;
245
- }
246
- interface OptionsConfig extends OptionsComponentExts {
247
- /**
248
- * Use external formatters to format files.
249
- *
250
- * Requires installing:
251
- * - `eslint-plugin-format`
252
- *
253
- * When set to `true`, it will enable all formatters.
254
- *
255
- * @default false
256
- */
257
- formatters?: OptionsFormatters | boolean;
258
- /**
259
- * Enable gitignore support.
260
- *
261
- * Passing an object to configure the options.
262
- *
263
- * @see https://github.com/antfu/eslint-config-flat-gitignore
264
- * @default true
265
- */
266
- gitignore?: FlatGitignoreOptions | boolean;
267
- /**
268
- * Control to disable some rules in editors.
269
- * @default auto-detect based on the process.env
270
- */
271
- isInEditor?: boolean;
272
- /**
273
- * Core rules. Can't be disabled.
274
- */
275
- javascript?: OptionsOverrides;
276
- /**
277
- * Enable JSONC support.
278
- *
279
- * @default true
280
- */
281
- jsonc?: OptionsOverrides | boolean;
282
- /**
283
- * Enable JSX related rules.
284
- *
285
- * Currently only stylistic rules are included.
286
- *
287
- * @default true
288
- */
289
- jsx?: boolean;
290
- /**
291
- * Enable linting for **code snippets** in Markdown.
292
- *
293
- * For formatting Markdown content, enable also `formatters.markdown`.
294
- *
295
- * @default true
296
- */
297
- markdown?: OptionsOverrides | boolean;
298
- /**
299
- * Provide overrides for rules for each integration.
300
- *
301
- * @deprecated use `overrides` option in each integration key instead
302
- */
303
- overrides?: {
304
- javascript?: FlatConfigItem["rules"];
305
- jsonc?: FlatConfigItem["rules"];
306
- markdown?: FlatConfigItem["rules"];
307
- react?: FlatConfigItem["rules"];
308
- stylistic?: FlatConfigItem["rules"];
309
- svelte?: FlatConfigItem["rules"];
310
- test?: FlatConfigItem["rules"];
311
- toml?: FlatConfigItem["rules"];
312
- typescript?: FlatConfigItem["rules"];
313
- vue?: FlatConfigItem["rules"];
314
- yaml?: FlatConfigItem["rules"];
315
- };
316
- /**
317
- * Enable react rules.
318
- *
319
- * Requires installing:
320
- * - `eslint-plugin-react`
321
- * - `eslint-plugin-react-hooks`
322
- * - `eslint-plugin-react-refresh`
323
- *
324
- * @default false
325
- */
326
- react?: OptionsOverrides | boolean;
327
- /**
328
- * Enable stylistic rules.
329
- *
330
- * @default true
331
- */
332
- stylistic?: (StylisticConfig & OptionsOverrides) | boolean;
333
- /**
334
- * Enable svelte rules.
335
- *
336
- * Requires installing:
337
- * - `eslint-plugin-svelte`
338
- *
339
- * @default false
340
- */
341
- svelte?: boolean;
342
- /**
343
- * Enable test support.
344
- *
345
- * @default true
346
- */
347
- test?: OptionsOverrides | boolean;
348
- /**
349
- * Enable TOML support.
350
- *
351
- * @default true
352
- */
353
- toml?: OptionsOverrides | boolean;
354
- /**
355
- * Enable TypeScript support.
356
- *
357
- * Passing an object to enable TypeScript Language Server support.
358
- *
359
- * @default auto-detect based on the dependencies
360
- */
361
- typescript?: OptionsTypescript | boolean;
362
- /**
363
- * Enable unocss rules.
364
- *
365
- * Requires installing:
366
- * - `@unocss/eslint-plugin`
367
- *
368
- * @default false
369
- */
370
- unocss?: OptionsUnoCSS | boolean;
371
- /**
372
- * Enable Vue support.
373
- *
374
- * @default auto-detect based on the dependencies
375
- */
376
- vue?: OptionsVue | boolean;
377
- /**
378
- * Enable YAML support.
379
- *
380
- * @default true
381
- */
382
- yaml?: OptionsOverrides | boolean;
383
- }
384
-
385
- /**
386
- * Construct an array of ESLint flat config items.
387
- */
388
- declare function curev(options?: OptionsConfig & FlatConfigItem, ...userConfigs: Awaitable<UserConfigItem | UserConfigItem[]>[]): Promise<UserConfigItem[]>;
389
- type ResolvedOptions<T> = T extends boolean ? never : NonNullable<T>;
390
- declare function resolveSubOptions<K extends keyof OptionsConfig>(options: OptionsConfig, key: K): ResolvedOptions<OptionsConfig[K]>;
391
- declare function getOverrides<K extends keyof OptionsConfig>(options: OptionsConfig, key: K): any;
392
-
393
- declare function comments(): Promise<FlatConfigItem[]>;
394
-
395
- declare function ignores(): Promise<FlatConfigItem[]>;
396
-
397
- declare function imports(options?: OptionsStylistic): Promise<FlatConfigItem[]>;
398
-
399
- declare function javascript(options?: OptionsIsInEditor & OptionsOverrides): Promise<FlatConfigItem[]>;
400
-
401
- declare function jsdoc(options?: OptionsStylistic): Promise<FlatConfigItem[]>;
402
-
403
- declare function jsonc(options?: OptionsFiles & OptionsStylistic & OptionsOverrides): Promise<FlatConfigItem[]>;
404
-
405
- declare function markdown(options?: OptionsFiles & OptionsComponentExts & OptionsOverrides): Promise<FlatConfigItem[]>;
406
-
407
- declare function node(): Promise<FlatConfigItem[]>;
408
-
409
- /**
410
- * Optional perfectionist plugin for props and items sorting.
411
- *
412
- * @see https://github.com/azat-io/eslint-plugin-perfectionist
413
- */
414
- declare function perfectionist(): Promise<FlatConfigItem[]>;
415
-
416
- declare function formatters(options?: OptionsFormatters | true, stylistic?: StylisticConfig): Promise<FlatConfigItem[]>;
417
-
418
- declare function react(options?: OptionsHasTypeScript & OptionsOverrides & OptionsFiles): Promise<FlatConfigItem[]>;
419
-
420
- /**
421
- * Sort package.json
422
- *
423
- * Requires `jsonc` config
424
- */
425
- declare function sortPackageJson(): Promise<FlatConfigItem[]>;
426
- /**
427
- * Sort tsconfig.json
428
- *
429
- * Requires `jsonc` config
430
- */
431
- declare function sortTsconfig(): FlatConfigItem[];
432
-
433
- declare const StylisticConfigDefaults: StylisticConfig;
434
- declare function stylistic(options?: StylisticConfig & OptionsOverrides): Promise<FlatConfigItem[]>;
435
-
436
- declare function svelte(options?: OptionsHasTypeScript & OptionsOverrides & OptionsStylistic & OptionsFiles): Promise<FlatConfigItem[]>;
437
-
438
- declare function test(options?: OptionsFiles & OptionsIsInEditor & OptionsOverrides): Promise<FlatConfigItem[]>;
439
-
440
- declare function typescript(options?: OptionsFiles & OptionsComponentExts & OptionsOverrides & OptionsTypeScriptWithTypes & OptionsTypeScriptParserOptions): Promise<FlatConfigItem[]>;
441
-
442
- declare function unicorn(): Promise<FlatConfigItem[]>;
443
-
444
- declare function unocss(options?: OptionsUnoCSS): Promise<FlatConfigItem[]>;
445
-
446
- declare function vue(options?: OptionsVue & OptionsHasTypeScript & OptionsOverrides & OptionsStylistic & OptionsFiles): Promise<FlatConfigItem[]>;
447
-
448
- declare function yaml(options?: OptionsOverrides & OptionsStylistic & OptionsFiles): Promise<FlatConfigItem[]>;
449
-
450
- declare function toml(options?: OptionsOverrides & OptionsStylistic & OptionsFiles): Promise<FlatConfigItem[]>;
451
-
452
- declare const GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
453
- declare const GLOB_SRC = "**/*.?([cm])[jt]s?(x)";
454
- declare const GLOB_JS = "**/*.?([cm])js";
455
- declare const GLOB_JSX = "**/*.?([cm])jsx";
456
- declare const GLOB_TS = "**/*.?([cm])ts";
457
- declare const GLOB_TSX = "**/*.?([cm])tsx";
458
- declare const GLOB_STYLE = "**/*.{c,le,sc}ss";
459
- declare const GLOB_CSS = "**/*.css";
460
- declare const GLOB_POSTCSS = "**/*.{p,post}css";
461
- declare const GLOB_LESS = "**/*.less";
462
- declare const GLOB_SCSS = "**/*.scss";
463
- declare const GLOB_JSON = "**/*.json";
464
- declare const GLOB_JSON5 = "**/*.json5";
465
- declare const GLOB_JSONC = "**/*.jsonc";
466
- declare const GLOB_MARKDOWN = "**/*.md";
467
- declare const GLOB_MARKDOWN_IN_MARKDOWN = "**/*.md/*.md";
468
- declare const GLOB_SVELTE = "**/*.svelte";
469
- declare const GLOB_VUE = "**/*.vue";
470
- declare const GLOB_YAML = "**/*.y?(a)ml";
471
- declare const GLOB_TOML = "**/*.toml";
472
- declare const GLOB_HTML = "**/*.htm?(l)";
473
- declare const GLOB_MARKDOWN_CODE = "**/*.md/**/*.?([cm])[jt]s?(x)";
474
- declare const GLOB_TESTS: string[];
475
- declare const GLOB_ALL_SRC: string[];
476
- declare const GLOB_EXCLUDE: string[];
477
-
478
- declare const parserPlain: {
479
- meta: {
480
- name: string;
481
- };
482
- parseForESLint: (code: string) => {
483
- ast: {
484
- body: never[];
485
- comments: never[];
486
- loc: {
487
- end: number;
488
- start: number;
489
- };
490
- range: number[];
491
- tokens: never[];
492
- type: string;
493
- };
494
- scopeManager: null;
495
- services: {
496
- isPlain: boolean;
497
- };
498
- visitorKeys: {
499
- Program: never[];
500
- };
501
- };
502
- };
503
- /**
504
- * Combine array and non-array configs into a single array.
505
- */
506
- declare function combine(...configs: Awaitable<UserConfigItem | UserConfigItem[]>[]): Promise<UserConfigItem[]>;
507
- declare function renameRules(rules: Record<string, any>, from: string, to: string): {
508
- [k: string]: any;
509
- };
510
- declare function toArray<T>(value: T | T[]): T[];
511
- declare function interopDefault<T>(m: Awaitable<T>): Promise<T extends {
512
- default: infer U;
513
- } ? U : T>;
514
- declare function ensurePackages(packages: string[]): Promise<void>;
515
-
516
- export { type Awaitable, type FlatConfigItem, GLOB_ALL_SRC, GLOB_CSS, GLOB_EXCLUDE, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_MARKDOWN_IN_MARKDOWN, GLOB_POSTCSS, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_SVELTE, GLOB_TESTS, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_YAML, type OptionsComponentExts, type OptionsConfig, type OptionsFiles, type OptionsFormatters, type OptionsHasTypeScript, type OptionsIsInEditor, type OptionsOverrides, type OptionsStylistic, type OptionsTypeScriptParserOptions, type OptionsTypeScriptWithTypes, type OptionsTypescript, type OptionsUnoCSS, type OptionsVue, type ResolvedOptions, type Rules, type StylisticConfig, StylisticConfigDefaults, type UserConfigItem, type WrapRuleConfig, combine, comments, curev, curev as default, ensurePackages, formatters, getOverrides, ignores, imports, interopDefault, javascript, jsdoc, jsonc, markdown, node, parserPlain, perfectionist, react, renameRules, resolveSubOptions, sortPackageJson, sortTsconfig, stylistic, svelte, test, toArray, toml, typescript, unicorn, unocss, vue, yaml };
9
+ export { type CurevOptions, curev, curev as default };