@vinicunca/eslint-config 2.0.13 → 2.1.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
@@ -6,6 +6,8 @@ import { UnprefixedRuleOptions, StylisticCustomizeOptions } from '@stylistic/esl
6
6
  import { ParserOptions } from '@typescript-eslint/parser';
7
7
  import { Rules as Rules$1 } from '@vinicunca/eslint-plugin-vinicunca';
8
8
  export { default as pluginVinicunca } from '@vinicunca/eslint-plugin-vinicunca';
9
+ import { Linter } from 'eslint';
10
+ import { Options } from 'eslint-processor-vue-blocks';
9
11
  export { default as pluginComments } from 'eslint-plugin-eslint-comments';
10
12
  import * as eslintPluginI from 'eslint-plugin-i';
11
13
  export { eslintPluginI as pluginImport };
@@ -14,6 +16,105 @@ export { default as pluginPerfectionist } from 'eslint-plugin-perfectionist';
14
16
  export { default as pluginUnicorn } from 'eslint-plugin-unicorn';
15
17
  export { default as pluginUnusedImports } from 'eslint-plugin-unused-imports';
16
18
 
19
+ /**
20
+ * Vendor types from Prettier so we don't rely on the dependency.
21
+ */
22
+ type VendoredPrettierOptions = Partial<VendoredPrettierOptionsRequired>;
23
+ interface VendoredPrettierOptionsRequired {
24
+ /**
25
+ * Include parentheses around a sole arrow function parameter.
26
+ * @default "always"
27
+ */
28
+ arrowParens: 'always' | 'avoid';
29
+ /**
30
+ * Put the `>` of a multi-line HTML (HTML, JSX, Vue, Angular) element at the end of the last line instead of being
31
+ * alone on the next line (does not apply to self closing elements).
32
+ */
33
+ bracketSameLine: boolean;
34
+ /**
35
+ * Print spaces between brackets in object literals.
36
+ */
37
+ bracketSpacing: boolean;
38
+ /**
39
+ * Which end of line characters to apply.
40
+ * @default "lf"
41
+ */
42
+ endOfLine: 'auto' | 'cr' | 'crlf' | 'lf';
43
+ /**
44
+ * How to handle whitespaces in HTML.
45
+ * @default "css"
46
+ */
47
+ htmlWhitespaceSensitivity: 'css' | 'ignore' | 'strict';
48
+ /**
49
+ * Put the `>` of a multi-line JSX element at the end of the last line instead of being alone on the next line.
50
+ * @deprecated use bracketSameLine instead
51
+ */
52
+ jsxBracketSameLine: boolean;
53
+ /**
54
+ * Use single quotes in JSX.
55
+ */
56
+ jsxSingleQuote: boolean;
57
+ /**
58
+ * Provide ability to support new languages to prettier.
59
+ */
60
+ plugins: Array<any | string>;
61
+ /**
62
+ * Specify the line length that the printer will wrap on.
63
+ * @default 120
64
+ */
65
+ printWidth: number;
66
+ /**
67
+ * By default, Prettier will wrap markdown text as-is since some services use a linebreak-sensitive renderer.
68
+ * In some cases you may want to rely on editor/viewer soft wrapping instead, so this option allows you to opt out.
69
+ * @default "preserve"
70
+ */
71
+ proseWrap: 'always' | 'never' | 'preserve';
72
+ /**
73
+ * Change when properties in objects are quoted.
74
+ * @default "as-needed"
75
+ */
76
+ quoteProps: 'as-needed' | 'consistent' | 'preserve';
77
+ /**
78
+ * Format only a segment of a file.
79
+ * @default Number.POSITIVE_INFINITY
80
+ */
81
+ rangeEnd: number;
82
+ /**
83
+ * Format only a segment of a file.
84
+ */
85
+ rangeStart: number;
86
+ /**
87
+ * Print semicolons at the ends of statements.
88
+ */
89
+ semi: boolean;
90
+ /**
91
+ * Enforce single attribute per line in HTML, Vue and JSX.
92
+ * @default false
93
+ */
94
+ singleAttributePerLine: boolean;
95
+ /**
96
+ * Use single quotes instead of double quotes.
97
+ */
98
+ singleQuote: boolean;
99
+ /**
100
+ * Specify the number of spaces per indentation-level.
101
+ */
102
+ tabWidth: number;
103
+ /**
104
+ * Print trailing commas wherever possible.
105
+ */
106
+ trailingComma: 'all' | 'es5' | 'none';
107
+ /**
108
+ * Indent lines with tabs instead of spaces
109
+ */
110
+ useTabs?: boolean;
111
+ /**
112
+ * Whether or not to indent the code inside <script> and <style> tags in Vue files.
113
+ * @default false
114
+ */
115
+ vueIndentScriptAndStyle: boolean;
116
+ }
117
+
17
118
  type WrapRuleConfig<T extends {
18
119
  [key: string]: any;
19
120
  }> = {
@@ -25,7 +126,7 @@ type Rules = WrapRuleConfig<MergeIntersection<RenamePrefix<RuleOptions, '@typesc
25
126
  }>>;
26
127
  type FlatConfigItem = Omit<FlatESLintConfigItem<Rules, false>, 'plugins'> & {
27
128
  /**
28
- * The name of the configuration object.
129
+ * Custom name of each config item
29
130
  */
30
131
  name?: string;
31
132
  /**
@@ -35,12 +136,67 @@ type FlatConfigItem = Omit<FlatESLintConfigItem<Rules, false>, 'plugins'> & {
35
136
  */
36
137
  plugins?: Record<string, any>;
37
138
  };
139
+ type UserConfigItem = FlatConfigItem | Linter.FlatConfig;
38
140
  interface OptionsFiles {
39
141
  /**
40
142
  * Override the `files` option to provide custom globs.
41
143
  */
42
144
  files?: string[];
43
145
  }
146
+ interface OptionsVue extends OptionsOverrides {
147
+ /**
148
+ * Create virtual files for Vue SFC blocks to enable linting.
149
+ *
150
+ * @see https://github.com/antfu/eslint-processor-vue-blocks
151
+ * @default true
152
+ */
153
+ sfcBlocks?: Options | boolean;
154
+ /**
155
+ * Vue version. Apply different rules set from `eslint-plugin-vue`.
156
+ *
157
+ * @default 3
158
+ */
159
+ vueVersion?: 2 | 3;
160
+ }
161
+ type OptionsTypescript = (OptionsTypeScriptParserOptions & OptionsOverrides) | (OptionsTypeScriptWithTypes & OptionsOverrides);
162
+ interface OptionsFormatters {
163
+ /**
164
+ * Enable formatting support for CSS, Less, Sass, and SCSS.
165
+ *
166
+ * Currently only support Prettier.
167
+ */
168
+ css?: 'prettier' | boolean;
169
+ /**
170
+ * Custom options for dprint.
171
+ *
172
+ * By default it's controlled by our own config.
173
+ */
174
+ dprintOptions?: boolean;
175
+ /**
176
+ * Enable formatting support for GraphQL.
177
+ */
178
+ graphql?: 'prettier' | boolean;
179
+ /**
180
+ * Enable formatting support for HTML.
181
+ *
182
+ * Currently only support Prettier.
183
+ */
184
+ html?: 'prettier' | boolean;
185
+ /**
186
+ * Enable formatting support for Markdown.
187
+ *
188
+ * Support both Prettier and dprint.
189
+ *
190
+ * When set to `true`, it will use Prettier.
191
+ */
192
+ markdown?: 'dprint' | 'prettier' | boolean;
193
+ /**
194
+ * Custom options for Prettier.
195
+ *
196
+ * By default it's controlled by our own config.
197
+ */
198
+ prettierOptions?: VendoredPrettierOptions;
199
+ }
44
200
  interface OptionsComponentExts {
45
201
  /**
46
202
  * Additional extensions for components.
@@ -51,20 +207,25 @@ interface OptionsComponentExts {
51
207
  componentExts?: string[];
52
208
  }
53
209
  interface OptionsTypeScriptParserOptions {
210
+ /**
211
+ * Glob patterns for files that should be type aware.
212
+ * @default ['**\/*.{ts,tsx}']
213
+ */
214
+ filesTypeAware?: string[];
54
215
  /**
55
216
  * Additional parser options for TypeScript.
56
217
  */
57
218
  parserOptions?: Partial<ParserOptions>;
58
219
  }
59
- interface OptionsHasTypeScript {
60
- typescript?: OptionsConfig['typescript'];
61
- }
62
220
  interface OptionsTypeScriptWithTypes {
63
221
  /**
64
222
  * When this options is provided, type aware rules will be enabled.
65
223
  * @see https://typescript-eslint.io/linting/typed-linting/
66
224
  */
67
- tsconfigPath?: string[];
225
+ tsconfigPath?: string | string[];
226
+ }
227
+ interface OptionsHasTypeScript {
228
+ typescript?: boolean;
68
229
  }
69
230
  interface OptionsStylistic {
70
231
  stylistic?: StylisticConfig | boolean;
@@ -77,7 +238,7 @@ interface OptionsOverrides {
77
238
  interface OptionsIsInEditor {
78
239
  isInEditor?: boolean;
79
240
  }
80
- interface OptionsUnoCSS {
241
+ interface OptionsUnoCSS extends OptionsOverrides {
81
242
  /**
82
243
  * Enable attributify support.
83
244
  * @default true
@@ -95,6 +256,17 @@ interface OptionsIgnores {
95
256
  replace?: boolean;
96
257
  }
97
258
  interface OptionsConfig extends OptionsComponentExts {
259
+ /**
260
+ * Use external formatters to format files.
261
+ *
262
+ * Requires installing:
263
+ * - `eslint-plugin-format`
264
+ *
265
+ * When set to `true`, it will enable all formatters.
266
+ *
267
+ * @default false
268
+ */
269
+ formatters?: OptionsFormatters | boolean;
98
270
  /**
99
271
  * Additional options for the ignore rules.
100
272
  */
@@ -104,12 +276,16 @@ interface OptionsConfig extends OptionsComponentExts {
104
276
  * @default auto-detect based on the process.env
105
277
  */
106
278
  isInEditor?: boolean;
279
+ /**
280
+ * Core rules. Can't be disabled.
281
+ */
282
+ javascript?: OptionsOverrides;
107
283
  /**
108
284
  * Enable JSONC support.
109
285
  *
110
286
  * @default true
111
287
  */
112
- jsonc?: boolean;
288
+ jsonc?: OptionsOverrides | boolean;
113
289
  /**
114
290
  * Enable JSX related rules.
115
291
  *
@@ -119,31 +295,20 @@ interface OptionsConfig extends OptionsComponentExts {
119
295
  */
120
296
  jsx?: boolean;
121
297
  /**
122
- * Enable Markdown support.
298
+ * Enable linting for **code snippets** in Markdown.
299
+ *
300
+ * For formatting Markdown content, enable also `formatters.markdown`.
123
301
  *
124
302
  * @default true
125
303
  */
126
- markdown?: boolean;
127
- /**
128
- * Provide overrides for rules for each integration.
129
- */
130
- overrides?: {
131
- javascript?: FlatConfigItem['rules'];
132
- jsonc?: FlatConfigItem['rules'];
133
- markdown?: FlatConfigItem['rules'];
134
- react?: FlatConfigItem['rules'];
135
- test?: FlatConfigItem['rules'];
136
- typescript?: FlatConfigItem['rules'];
137
- vue?: FlatConfigItem['rules'];
138
- yaml?: FlatConfigItem['rules'];
139
- };
304
+ markdown?: OptionsOverrides | boolean;
140
305
  /**
141
306
  * Enable react support.
142
307
  * In This plugin, react is not supported as a first class citizen. 😎
143
308
  *
144
309
  * @default false
145
310
  */
146
- react?: boolean;
311
+ react?: OptionsOverrides | boolean;
147
312
  /**
148
313
  * Enable stylistic rules.
149
314
  *
@@ -155,7 +320,7 @@ interface OptionsConfig extends OptionsComponentExts {
155
320
  *
156
321
  * @default true
157
322
  */
158
- test?: boolean;
323
+ test?: OptionsOverrides | boolean;
159
324
  /**
160
325
  * Enable TypeScript support.
161
326
  *
@@ -163,9 +328,7 @@ interface OptionsConfig extends OptionsComponentExts {
163
328
  *
164
329
  * @default auto-detect based on the dependencies
165
330
  */
166
- typescript?: OptionsTypeScriptWithTypes & OptionsTypeScriptParserOptions & {
167
- enabled?: boolean;
168
- };
331
+ typescript?: OptionsTypescript | boolean;
169
332
  /**
170
333
  * Enable unocss rules.
171
334
  *
@@ -180,19 +343,16 @@ interface OptionsConfig extends OptionsComponentExts {
180
343
  *
181
344
  * @default auto-detect based on the dependencies
182
345
  */
183
- vue?: boolean;
346
+ vue?: OptionsVue | boolean;
184
347
  /**
185
348
  * Enable YAML support.
186
349
  *
187
350
  * @default true
188
351
  */
189
- yaml?: boolean;
352
+ yaml?: OptionsOverrides | boolean;
190
353
  }
191
354
 
192
- declare function vinicuncaESLint({ options, userConfigs }?: {
193
- options?: OptionsConfig & FlatConfigItem;
194
- userConfigs?: Awaitable<FlatConfigItem | FlatConfigItem[]>[];
195
- }): Promise<FlatConfigItem[]>;
355
+ declare function vinicuncaESLint(options?: OptionsConfig & FlatConfigItem, ...userConfigs: Awaitable<UserConfigItem | UserConfigItem[]>[]): Promise<UserConfigItem[]>;
196
356
 
197
357
  declare function comments(): Promise<FlatConfigItem[]>;
198
358
 
@@ -202,7 +362,7 @@ declare function imports(): Promise<FlatConfigItem[]>;
202
362
 
203
363
  declare function javascript(options?: OptionsIsInEditor & OptionsOverrides): Promise<FlatConfigItem[]>;
204
364
 
205
- declare function jsdoc(): Promise<FlatConfigItem[]>;
365
+ declare function jsdoc(options?: OptionsStylistic): Promise<FlatConfigItem[]>;
206
366
 
207
367
  declare function jsonc(options?: OptionsFiles & OptionsStylistic & OptionsOverrides): Promise<FlatConfigItem[]>;
208
368
 
@@ -225,46 +385,80 @@ declare function sortPackageJson(): Promise<FlatConfigItem[]>;
225
385
  */
226
386
  declare function sortTsconfig(): FlatConfigItem[];
227
387
 
228
- declare function stylistic(options?: StylisticConfig): Promise<FlatConfigItem[]>;
388
+ declare const STYLISTIC_CONFIG_DEFAULTS: StylisticConfig;
389
+ declare function stylistic(options?: StylisticConfig & OptionsOverrides): Promise<FlatConfigItem[]>;
229
390
 
230
391
  declare function test(options?: OptionsFiles & OptionsIsInEditor & OptionsOverrides): Promise<FlatConfigItem[]>;
231
392
 
232
393
  declare function typescript(options?: OptionsFiles & OptionsComponentExts & OptionsOverrides & OptionsTypeScriptWithTypes & OptionsTypeScriptParserOptions): Promise<FlatConfigItem[]>;
233
394
 
234
- declare function unicorn(options?: OptionsOverrides): Promise<FlatConfigItem[]>;
395
+ declare function unicorn(): Promise<FlatConfigItem[]>;
235
396
 
236
397
  declare function unocss(options?: OptionsUnoCSS): Promise<FlatConfigItem[]>;
237
398
 
238
- declare function vue(options?: OptionsHasTypeScript & OptionsOverrides & OptionsStylistic & OptionsFiles): Promise<FlatConfigItem[]>;
399
+ declare function vue(options?: OptionsVue & OptionsHasTypeScript & OptionsOverrides & OptionsStylistic & OptionsFiles): Promise<FlatConfigItem[]>;
239
400
 
240
401
  declare function yaml(options?: OptionsOverrides & OptionsStylistic & OptionsFiles): Promise<FlatConfigItem[]>;
241
402
 
242
403
  /**
243
404
  * Combine array and non-array configs into a single array.
244
405
  */
245
- declare function combineConfigs(...configs: Awaitable<FlatConfigItem | FlatConfigItem[]>[]): Promise<FlatConfigItem[]>;
406
+ declare function combineConfigs(...configs: Awaitable<UserConfigItem | UserConfigItem[]>[]): Promise<UserConfigItem[]>;
246
407
  declare function renameRules(rules: Record<string, any>, from: string, to: string): {
247
408
  [k: string]: any;
248
409
  };
249
410
  declare function interopDefault<T>(m: Awaitable<T>): Promise<T extends {
250
411
  default: infer U;
251
412
  } ? U : T>;
413
+ declare const parserPlain: {
414
+ meta: {
415
+ name: string;
416
+ };
417
+ parseForESLint: (code: string) => {
418
+ ast: {
419
+ body: never[];
420
+ comments: never[];
421
+ loc: {
422
+ end: number;
423
+ start: number;
424
+ };
425
+ range: number[];
426
+ tokens: never[];
427
+ type: string;
428
+ };
429
+ scopeManager: null;
430
+ services: {
431
+ isPlain: boolean;
432
+ };
433
+ visitorKeys: {
434
+ Program: never[];
435
+ };
436
+ };
437
+ };
438
+ declare function toArray<T>(value: T | T[]): T[];
252
439
 
440
+ declare const GLOB_SRC = "**/*.?([cm])[jt]s?(x)";
441
+ declare const GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
253
442
  declare const GLOB_JS = "**/*.?([cm])js";
254
443
  declare const GLOB_JSX = "**/*.?([cm])jsx";
255
444
  declare const GLOB_TS = "**/*.?([cm])ts";
256
445
  declare const GLOB_TSX = "**/*.?([cm])tsx";
257
- declare const GLOB_EXCLUDE: string[];
258
- declare const GLOB_SRC = "**/*.?([cm])[jt]s?(x)";
259
- declare const GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
260
- declare const GLOB_TESTS: string[];
261
- declare const GLOB_VUE = "**/*.vue";
446
+ declare const GLOB_STYLE = "**/*.{c,le,sc}ss";
447
+ declare const GLOB_CSS = "**/*.css";
448
+ declare const GLOB_POSTCSS = "**/*.{p,post}css";
449
+ declare const GLOB_LESS = "**/*.less";
450
+ declare const GLOB_SCSS = "**/*.scss";
262
451
  declare const GLOB_JSON = "**/*.json";
263
452
  declare const GLOB_JSON5 = "**/*.json5";
264
453
  declare const GLOB_JSONC = "**/*.jsonc";
265
- declare const GLOB_YAML = "**/*.y?(a)ml";
266
454
  declare const GLOB_MARKDOWN = "**/*.md";
267
455
  declare const GLOB_MARKDOWN_IN_MARKDOWN = "**/*.md/*.md";
456
+ declare const GLOB_VUE = "**/*.vue";
457
+ declare const GLOB_YAML = "**/*.y?(a)ml";
458
+ declare const GLOB_HTML = "**/*.htm?(l)";
268
459
  declare const GLOB_MARKDOWN_CODE = "**/*.md/**/*.?([cm])[jt]s?(x)";
460
+ declare const GLOB_TESTS: string[];
461
+ declare const GLOB_ALL_SRC: string[];
462
+ declare const GLOB_EXCLUDE: string[];
269
463
 
270
- export { type Awaitable, type FlatConfigItem, GLOB_EXCLUDE, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_MARKDOWN_IN_MARKDOWN, GLOB_SRC, GLOB_SRC_EXT, GLOB_TESTS, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_YAML, type OptionsComponentExts, type OptionsConfig, type OptionsFiles, type OptionsHasTypeScript, type OptionsIgnores, type OptionsIsInEditor, type OptionsOverrides, type OptionsStylistic, type OptionsTypeScriptParserOptions, type OptionsTypeScriptWithTypes, type OptionsUnoCSS, type Rules, type StylisticConfig, type WrapRuleConfig, combineConfigs, comments, ignores, imports, interopDefault, javascript, jsdoc, jsonc, markdown, node, react, renameRules, sortPackageJson, sortTsconfig, stylistic, test, typescript, unicorn, unocss, vinicuncaESLint, vue, yaml };
464
+ 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_TESTS, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_YAML, type OptionsComponentExts, type OptionsConfig, type OptionsFiles, type OptionsFormatters, type OptionsHasTypeScript, type OptionsIgnores, type OptionsIsInEditor, type OptionsOverrides, type OptionsStylistic, type OptionsTypeScriptParserOptions, type OptionsTypeScriptWithTypes, type OptionsTypescript, type OptionsUnoCSS, type OptionsVue, type Rules, STYLISTIC_CONFIG_DEFAULTS, type StylisticConfig, type UserConfigItem, type WrapRuleConfig, combineConfigs, comments, ignores, imports, interopDefault, javascript, jsdoc, jsonc, markdown, node, parserPlain, react, renameRules, sortPackageJson, sortTsconfig, stylistic, test, toArray, typescript, unicorn, unocss, vinicuncaESLint, vue, yaml };