@rotki/eslint-config 1.1.2 → 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.
@@ -0,0 +1,523 @@
1
+ import { RuleConfig, FlatESLintConfigItem, MergeIntersection, Prefix, RenamePrefix, VitestRules, YmlRules, NRules, ImportRules, EslintRules, JsoncRules, VueRules, EslintCommentsRules } from '@antfu/eslint-define-config';
2
+ import { FlatGitignoreOptions } from 'eslint-config-flat-gitignore';
3
+ import { ParserOptions } from '@typescript-eslint/parser';
4
+ import { Options } from 'eslint-processor-vue-blocks';
5
+ import { Linter } from 'eslint';
6
+ import { RuleOptions } from '@eslint-types/typescript-eslint/types';
7
+ import { RuleOptions as RuleOptions$1 } from '@eslint-types/unicorn/types';
8
+ import { Rules as Rules$1 } from 'eslint-plugin-antfu';
9
+ export { default as pluginAntfu } from 'eslint-plugin-antfu';
10
+ import { StylisticCustomizeOptions, UnprefixedRuleOptions } from '@stylistic/eslint-plugin';
11
+ export { default as pluginComments } from 'eslint-plugin-eslint-comments';
12
+ import * as eslintPluginI from 'eslint-plugin-i';
13
+ export { eslintPluginI as pluginImport };
14
+ export { default as pluginNode } from 'eslint-plugin-n';
15
+ export { default as pluginUnicorn } from 'eslint-plugin-unicorn';
16
+ export { default as pluginUnusedImports } from 'eslint-plugin-unused-imports';
17
+ export { default as pluginPerfectionist } from 'eslint-plugin-perfectionist';
18
+
19
+ type ValidVLostConfiguration = [
20
+ {
21
+ allowModifiers?: boolean;
22
+ }
23
+ ];
24
+ interface VuetifyRules {
25
+ 'vue/valid-v-slot': RuleConfig<ValidVLostConfiguration>;
26
+ 'vuetify/no-deprecated-classes': RuleConfig<[]>;
27
+ 'vuetify/no-deprecated-colors': RuleConfig<[]>;
28
+ 'vuetify/no-deprecated-components': RuleConfig<[]>;
29
+ 'vuetify/no-deprecated-events': RuleConfig<[]>;
30
+ 'vuetify/no-deprecated-props': RuleConfig<[]>;
31
+ 'vuetify/no-deprecated-slots': RuleConfig<[]>;
32
+ 'vuetify/grid-unknown-attributes': RuleConfig<[]>;
33
+ }
34
+
35
+ interface VueI18nRules {
36
+ 'key-format-style': RuleConfig<['camelCase' | 'kebab-case' | 'snake_case', {
37
+ 'allowArray'?: boolean;
38
+ 'splitByDots'?: boolean;
39
+ }]>;
40
+ 'no-deprecated-i18n-component': RuleConfig<[]>;
41
+ 'no-deprecated-i18n-place-attr': RuleConfig<[]>;
42
+ 'no-deprecated-i18n-places-prop': RuleConfig<[]>;
43
+ 'no-duplicate-keys-in-locale': RuleConfig<[{
44
+ 'ignoreI18nBlock'?: boolean;
45
+ }]>;
46
+ 'no-dynamic-keys': RuleConfig<[]>;
47
+ 'no-html-messages': RuleConfig<[]>;
48
+ 'no-i18n-t-path-prop': RuleConfig<[]>;
49
+ 'no-missing-keys': RuleConfig<[]>;
50
+ 'no-missing-keys-in-other-locales': RuleConfig<[{
51
+ 'ignoreLocales'?: string[];
52
+ }]>;
53
+ 'no-raw-text': RuleConfig<[
54
+ {
55
+ 'attributes'?: Record<string, string[]>;
56
+ 'ignoreNodes'?: string[];
57
+ 'ignorePattern'?: string;
58
+ 'ignoreText'?: string[];
59
+ }
60
+ ]>;
61
+ 'no-unknown-locale': RuleConfig<[
62
+ {
63
+ 'locales'?: string[];
64
+ 'disableRFC5646'?: boolean;
65
+ }
66
+ ]>;
67
+ 'no-unused-keys': RuleConfig<[
68
+ {
69
+ 'src'?: string;
70
+ 'extensions'?: string[];
71
+ 'ignores'?: string[];
72
+ 'enableFix'?: boolean;
73
+ }
74
+ ]>;
75
+ 'no-v-html': RuleConfig<[]>;
76
+ 'prefer-linked-key-with-paren': RuleConfig<[]>;
77
+ 'prefer-sfc-lang-attr': RuleConfig<[]>;
78
+ 'sfc-locale-attr': RuleConfig<['always' | 'never']>;
79
+ 'valid-message-syntax': RuleConfig<[]>;
80
+ }
81
+
82
+ /**
83
+ * Vendor types from Prettier so we don't rely on the dependency.
84
+ */
85
+ type VendoredPrettierOptions = Partial<VendoredPrettierOptionsRequired>;
86
+ interface VendoredPrettierOptionsRequired {
87
+ /**
88
+ * Specify the line length that the printer will wrap on.
89
+ * @default 120
90
+ */
91
+ printWidth: number;
92
+ /**
93
+ * Specify the number of spaces per indentation-level.
94
+ */
95
+ tabWidth: number;
96
+ /**
97
+ * Indent lines with tabs instead of spaces
98
+ */
99
+ useTabs?: boolean;
100
+ /**
101
+ * Print semicolons at the ends of statements.
102
+ */
103
+ semi: boolean;
104
+ /**
105
+ * Use single quotes instead of double quotes.
106
+ */
107
+ singleQuote: boolean;
108
+ /**
109
+ * Use single quotes in JSX.
110
+ */
111
+ jsxSingleQuote: boolean;
112
+ /**
113
+ * Print trailing commas wherever possible.
114
+ */
115
+ trailingComma: 'none' | 'es5' | 'all';
116
+ /**
117
+ * Print spaces between brackets in object literals.
118
+ */
119
+ bracketSpacing: boolean;
120
+ /**
121
+ * Put the `>` of a multi-line HTML (HTML, JSX, Vue, Angular) element at the end of the last line instead of being
122
+ * alone on the next line (does not apply to self closing elements).
123
+ */
124
+ bracketSameLine: boolean;
125
+ /**
126
+ * Put the `>` of a multi-line JSX element at the end of the last line instead of being alone on the next line.
127
+ * @deprecated use bracketSameLine instead
128
+ */
129
+ jsxBracketSameLine: boolean;
130
+ /**
131
+ * Format only a segment of a file.
132
+ */
133
+ rangeStart: number;
134
+ /**
135
+ * Format only a segment of a file.
136
+ * @default Number.POSITIVE_INFINITY
137
+ */
138
+ rangeEnd: number;
139
+ /**
140
+ * By default, Prettier will wrap markdown text as-is since some services use a linebreak-sensitive renderer.
141
+ * In some cases you may want to rely on editor/viewer soft wrapping instead, so this option allows you to opt out.
142
+ * @default "preserve"
143
+ */
144
+ proseWrap: 'always' | 'never' | 'preserve';
145
+ /**
146
+ * Include parentheses around a sole arrow function parameter.
147
+ * @default "always"
148
+ */
149
+ arrowParens: 'avoid' | 'always';
150
+ /**
151
+ * Provide ability to support new languages to prettier.
152
+ */
153
+ plugins: Array<string | any>;
154
+ /**
155
+ * How to handle whitespaces in HTML.
156
+ * @default "css"
157
+ */
158
+ htmlWhitespaceSensitivity: 'css' | 'strict' | 'ignore';
159
+ /**
160
+ * Which end of line characters to apply.
161
+ * @default "lf"
162
+ */
163
+ endOfLine: 'auto' | 'lf' | 'crlf' | 'cr';
164
+ /**
165
+ * Change when properties in objects are quoted.
166
+ * @default "as-needed"
167
+ */
168
+ quoteProps: 'as-needed' | 'consistent' | 'preserve';
169
+ /**
170
+ * Whether or not to indent the code inside <script> and <style> tags in Vue files.
171
+ * @default false
172
+ */
173
+ vueIndentScriptAndStyle: boolean;
174
+ /**
175
+ * Enforce single attribute per line in HTML, Vue and JSX.
176
+ * @default false
177
+ */
178
+ singleAttributePerLine: boolean;
179
+ }
180
+
181
+ type WrapRuleConfig<T extends {
182
+ [key: string]: any;
183
+ }> = {
184
+ [K in keyof T]: T[K] extends RuleConfig ? T[K] : RuleConfig<T[K]>;
185
+ };
186
+ type Awaitable<T> = T | Promise<T>;
187
+ type Rules = WrapRuleConfig<MergeIntersection<Prefix<RuleOptions, '@typescript-eslint/'> & RenamePrefix<VitestRules, 'vitest/', 'test/'> & RenamePrefix<YmlRules, 'yml/', 'yaml/'> & RenamePrefix<NRules, 'n/', 'node/'> & Prefix<UnprefixedRuleOptions, '@stylestic'> & Prefix<Rules$1, 'antfu/'> & ImportRules & EslintRules & JsoncRules & VueRules & RuleOptions$1 & EslintCommentsRules & {
188
+ 'test/no-only-tests': RuleConfig<[]>;
189
+ } & {
190
+ 'cypress/no-assigning-return-values': RuleConfig<[]>;
191
+ 'cypress/no-unnecessary-waiting': RuleConfig<[]>;
192
+ 'cypress/assertion-before-screenshot': RuleConfig<[]>;
193
+ 'cypress/no-force': RuleConfig<[]>;
194
+ 'cypress/no-async-tests': RuleConfig<[]>;
195
+ 'cypress/no-pause': RuleConfig<[]>;
196
+ } & {
197
+ '@rotki/no-deprecated-classes': RuleConfig<[]>;
198
+ } & VuetifyRules & Prefix<VueI18nRules, '@intlify/vue-i18n/'>>>;
199
+ type FlatConfigItem = Omit<FlatESLintConfigItem<Rules, false>, 'plugins'> & {
200
+ plugins?: Record<string, any>;
201
+ };
202
+ type UserConfigItem = FlatConfigItem | Linter.FlatConfig;
203
+ type OptionsTypescript = (OptionsTypeScriptWithTypes & OptionsOverrides) | (OptionsTypeScriptParserOptions & OptionsOverrides);
204
+ interface OptionsFormatters {
205
+ /**
206
+ * Enable formatting support for CSS, Less, Sass, and SCSS.
207
+ *
208
+ * Currently only support Prettier.
209
+ */
210
+ css?: 'prettier' | boolean;
211
+ /**
212
+ * Enable formatting support for HTML.
213
+ *
214
+ * Currently only support Prettier.
215
+ */
216
+ html?: 'prettier' | boolean;
217
+ /**
218
+ * Enable formatting support for Markdown.
219
+ *
220
+ * Support both Prettier and dprint.
221
+ *
222
+ * When set to `true`, it will use Prettier.
223
+ */
224
+ markdown?: 'prettier' | 'dprint' | boolean;
225
+ /**
226
+ * Custom options for Prettier.
227
+ *
228
+ * By default it's controlled by our own config.
229
+ */
230
+ prettierOptions?: VendoredPrettierOptions;
231
+ /**
232
+ * Custom options for dprint.
233
+ *
234
+ * By default it's controlled by our own config.
235
+ */
236
+ dprintOptions?: boolean;
237
+ }
238
+ interface OptionsFiles {
239
+ /**
240
+ * Override the `files` option to provide custom globs.
241
+ */
242
+ files?: string[];
243
+ }
244
+ interface OptionsVue extends OptionsOverrides {
245
+ /**
246
+ * Create virtual files for Vue SFC blocks to enable linting.
247
+ *
248
+ * @see https://github.com/antfu/eslint-processor-vue-blocks
249
+ * @default true
250
+ */
251
+ sfcBlocks?: boolean | Options;
252
+ /**
253
+ * Vue version. Apply different rules set from `eslint-plugin-vue`.
254
+ *
255
+ * @default 3
256
+ */
257
+ vueVersion?: 2 | 3;
258
+ }
259
+ interface OptionsCypress extends OptionsOverrides {
260
+ testDirectory?: string;
261
+ }
262
+ interface OptionsVueI18n extends OptionsOverrides {
263
+ /**
264
+ * The source directory where of the project where vue-i18n is setup.
265
+ */
266
+ src?: string;
267
+ /**
268
+ * The locales directory under the source directory
269
+ *
270
+ * @default locales
271
+ */
272
+ localesDirectory?: string;
273
+ /**
274
+ * Patterns that will be ignored by @intlify/vue-i18n/no-unused-keys.
275
+ */
276
+ ignores?: string[];
277
+ }
278
+ interface OptionsOverrides {
279
+ overrides?: FlatConfigItem['rules'];
280
+ }
281
+ interface OptionsComponentExts {
282
+ /**
283
+ * Additional extensions for components.
284
+ *
285
+ * @example ['vue']
286
+ * @default []
287
+ */
288
+ componentExts?: string[];
289
+ }
290
+ interface OptionsTypeScriptParserOptions {
291
+ /**
292
+ * Additional parser options for TypeScript.
293
+ */
294
+ parserOptions?: Partial<ParserOptions>;
295
+ /**
296
+ * Glob patterns for files that should be type aware.
297
+ * @default ['**\/*.{ts,tsx}']
298
+ */
299
+ filesTypeAware?: string[];
300
+ }
301
+ interface OptionsTypeScriptWithTypes {
302
+ /**
303
+ * When this options is provided, type aware rules will be enabled.
304
+ * @see https://typescript-eslint.io/linting/typed-linting/
305
+ */
306
+ tsconfigPath?: string | string[];
307
+ }
308
+ interface OptionsHasTypeScript {
309
+ typescript?: boolean;
310
+ }
311
+ interface OptionsStylistic {
312
+ stylistic?: boolean | StylisticConfig;
313
+ }
314
+ interface StylisticConfig extends Pick<StylisticCustomizeOptions, 'indent' | 'quotes' | 'jsx' | 'semi'> {
315
+ }
316
+ interface OptionsIsInEditor {
317
+ isInEditor?: boolean;
318
+ }
319
+ interface OptionsConfig extends OptionsComponentExts {
320
+ /**
321
+ * Enable gitignore support.
322
+ *
323
+ * Passing an object to configure the options.
324
+ *
325
+ * @see https://github.com/antfu/eslint-config-flat-gitignore
326
+ * @default true
327
+ */
328
+ gitignore?: boolean | FlatGitignoreOptions;
329
+ /**
330
+ * Core rules. Can't be disabled.
331
+ */
332
+ javascript?: OptionsOverrides;
333
+ /**
334
+ * Enable TypeScript support.
335
+ *
336
+ * Passing an object to enable TypeScript Language Server support.
337
+ *
338
+ * @default auto-detect based on the dependencies
339
+ */
340
+ typescript?: boolean | OptionsTypescript;
341
+ /**
342
+ * Enable JSX related rules.
343
+ *
344
+ * Currently only stylistic rules are included.
345
+ *
346
+ * @default true
347
+ */
348
+ jsx?: boolean;
349
+ /**
350
+ * Enable test support.
351
+ *
352
+ * @default true
353
+ */
354
+ test?: boolean | OptionsOverrides;
355
+ /**
356
+ * Enable Vue support.
357
+ *
358
+ * @default auto-detect based on the dependencies
359
+ */
360
+ vue?: boolean | OptionsVue;
361
+ /**
362
+ * Enable JSONC support.
363
+ *
364
+ * @default true
365
+ */
366
+ jsonc?: boolean | OptionsOverrides;
367
+ /**
368
+ * Enable YAML support.
369
+ *
370
+ * @default true
371
+ */
372
+ yaml?: boolean | OptionsOverrides;
373
+ /**
374
+ * Enable linting for **code snippets** in Markdown.
375
+ *
376
+ * For formatting Markdown content, enable also `formatters.markdown`.
377
+ *
378
+ * @default true
379
+ */
380
+ markdown?: boolean | OptionsOverrides;
381
+ /**
382
+ * Enable stylistic rules.
383
+ *
384
+ * @default true
385
+ */
386
+ stylistic?: boolean | StylisticConfig;
387
+ /**
388
+ * Use external formatters to format files.
389
+ *
390
+ * Requires installing:
391
+ * - `eslint-plugin-format`
392
+ *
393
+ * When set to `true`, it will enable all formatters.
394
+ *
395
+ * @default false
396
+ */
397
+ formatters?: boolean | OptionsFormatters;
398
+ /**
399
+ * Enable cypress test linting
400
+ * Requires installing:
401
+ * - `eslint-plugin-cypress`
402
+ *
403
+ * When set to `true` it will run on the whole project
404
+ *
405
+ * @default false
406
+ */
407
+ cypress?: boolean | OptionsCypress;
408
+ /**
409
+ * Enable rotki linting
410
+ * Requires installing:
411
+ * - `@rotki/eslint-plugin`
412
+ *
413
+ *
414
+ * @default false
415
+ */
416
+ rotki?: boolean;
417
+ /**
418
+ * Enable vuetify linting support.
419
+ * Requires installing:
420
+ * - `eslint-plugin-vuetify`
421
+ *
422
+ *
423
+ * @default false
424
+ */
425
+ vuetify?: boolean | OptionsOverrides;
426
+ /**
427
+ * Enable vue-i18n linting support.
428
+ * Requires installing:
429
+ * - `eslint-plugin-vuetify`
430
+ *
431
+ *
432
+ * @default false
433
+ */
434
+ vueI18n?: boolean | OptionsVueI18n;
435
+ /**
436
+ * Control to disable some rules in editors.
437
+ * @default auto-detect based on the process.env
438
+ */
439
+ isInEditor?: boolean;
440
+ }
441
+
442
+ /**
443
+ * Construct an array of ESLint flat config items.
444
+ */
445
+ declare function rotki(options?: OptionsConfig & FlatConfigItem, ...userConfigs: Awaitable<UserConfigItem | UserConfigItem[]>[]): Promise<UserConfigItem[]>;
446
+
447
+ declare function comments(): FlatConfigItem[];
448
+
449
+ declare function cypress(options?: OptionsOverrides & OptionsFiles & OptionsHasTypeScript & OptionsCypress): Promise<FlatConfigItem[]>;
450
+
451
+ declare function formatters(options?: OptionsFormatters | true, stylistic?: StylisticConfig): Promise<FlatConfigItem[]>;
452
+
453
+ declare function ignores(): FlatConfigItem[];
454
+
455
+ declare function imports(options?: OptionsStylistic): FlatConfigItem[];
456
+
457
+ declare function javascript(options?: OptionsIsInEditor & OptionsOverrides): FlatConfigItem[];
458
+
459
+ declare function jsonc(options?: OptionsFiles & OptionsStylistic & OptionsOverrides): Promise<FlatConfigItem[]>;
460
+
461
+ declare function markdown(options?: OptionsFiles & OptionsComponentExts & OptionsOverrides): Promise<FlatConfigItem[]>;
462
+
463
+ declare function node(): FlatConfigItem[];
464
+
465
+ /**
466
+ * Perfectionist plugin for props and items sorting.
467
+ *
468
+ * @see https://github.com/azat-io/eslint-plugin-perfectionist
469
+ */
470
+ declare function perfectionist(): FlatConfigItem[];
471
+
472
+ declare function rotkiPlugin(options?: OptionsOverrides & OptionsHasTypeScript & OptionsFiles): Promise<FlatConfigItem[]>;
473
+
474
+ declare function sortPackageJson(): FlatConfigItem[];
475
+ declare function sortTsconfig(): FlatConfigItem[];
476
+
477
+ declare const StylisticConfigDefaults: StylisticConfig;
478
+ declare function stylistic(options?: StylisticConfig & OptionsOverrides): Promise<FlatConfigItem[]>;
479
+
480
+ declare function test(options?: OptionsFiles & OptionsIsInEditor & OptionsOverrides): Promise<FlatConfigItem[]>;
481
+
482
+ declare function typescript(options?: OptionsFiles & OptionsComponentExts & OptionsOverrides & OptionsTypeScriptWithTypes & OptionsTypeScriptParserOptions & OptionsIsInEditor): Promise<FlatConfigItem[]>;
483
+
484
+ declare function unicorn(): FlatConfigItem[];
485
+
486
+ declare function vue(options?: OptionsVue & OptionsHasTypeScript & OptionsOverrides & OptionsStylistic & OptionsFiles): Promise<FlatConfigItem[]>;
487
+
488
+ declare function vueI18n(options?: OptionsHasTypeScript & OptionsIsInEditor & OptionsFiles & OptionsVueI18n): Promise<FlatConfigItem[]>;
489
+
490
+ declare function vuetify(options?: OptionsOverrides & OptionsHasTypeScript & OptionsFiles): Promise<FlatConfigItem[]>;
491
+
492
+ declare function yaml(options?: OptionsOverrides & OptionsStylistic & OptionsFiles): Promise<FlatConfigItem[]>;
493
+
494
+ declare const GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
495
+ declare const GLOB_SRC = "**/*.?([cm])[jt]s?(x)";
496
+ declare const GLOB_JS = "**/*.?([cm])js";
497
+ declare const GLOB_JSX = "**/*.?([cm])jsx";
498
+ declare const GLOB_TS = "**/*.?([cm])ts";
499
+ declare const GLOB_TSX = "**/*.?([cm])tsx";
500
+ declare const GLOB_STYLE = "**/*.{c,le,sc}ss";
501
+ declare const GLOB_CSS = "**/*.css";
502
+ declare const GLOB_POSTCSS = "**/*.{p,post}css";
503
+ declare const GLOB_LESS = "**/*.less";
504
+ declare const GLOB_SCSS = "**/*.scss";
505
+ declare const GLOB_JSON = "**/*.json";
506
+ declare const GLOB_JSON5 = "**/*.json5";
507
+ declare const GLOB_JSONC = "**/*.jsonc";
508
+ declare const GLOB_MARKDOWN = "**/*.md";
509
+ declare const GLOB_MARKDOWN_IN_MARKDOWN = "**/*.md/*.md";
510
+ declare const GLOB_VUE = "**/*.vue";
511
+ declare const GLOB_YAML = "**/*.y?(a)ml";
512
+ declare const GLOB_HTML = "**/*.htm?(l)";
513
+ declare const GLOB_MARKDOWN_CODE = "**/*.md/**/*.?([cm])[jt]s?(x)";
514
+ declare const GLOB_CYPRESS = "**/*.cy.?([cm])[jt]s?(x)";
515
+ declare const GLOB_TESTS: string[];
516
+ declare const GLOB_ALL_SRC: string[];
517
+ declare const GLOB_NODE_MODULES: "**/node_modules";
518
+ declare const GLOB_DIST: "**/dist";
519
+ declare const GLOB_LIB: "**/lib";
520
+ declare const GLOB_LOCKFILE: string[];
521
+ declare const GLOB_EXCLUDE: string[];
522
+
523
+ export { GLOB_ALL_SRC, GLOB_CSS, GLOB_CYPRESS, GLOB_DIST, GLOB_EXCLUDE, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_LIB, GLOB_LOCKFILE, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_MARKDOWN_IN_MARKDOWN, GLOB_NODE_MODULES, GLOB_POSTCSS, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_TESTS, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_YAML, StylisticConfigDefaults, comments, cypress, rotki as default, formatters, ignores, imports, javascript, jsonc, markdown, node, perfectionist, rotkiPlugin, sortPackageJson, sortTsconfig, stylistic, test, typescript, unicorn, vue, vueI18n, vuetify, yaml };