@vinicunca/eslint-config 2.15.8 → 3.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/dist/index.cjs DELETED
@@ -1,2898 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
-
30
- // src/index.ts
31
- var src_exports = {};
32
- __export(src_exports, {
33
- GLOB_ALL_SRC: () => GLOB_ALL_SRC,
34
- GLOB_ASTRO: () => GLOB_ASTRO,
35
- GLOB_ASTRO_TS: () => GLOB_ASTRO_TS,
36
- GLOB_CSS: () => GLOB_CSS,
37
- GLOB_EXCLUDE: () => GLOB_EXCLUDE,
38
- GLOB_GRAPHQL: () => GLOB_GRAPHQL,
39
- GLOB_HTML: () => GLOB_HTML,
40
- GLOB_JS: () => GLOB_JS,
41
- GLOB_JSON: () => GLOB_JSON,
42
- GLOB_JSON5: () => GLOB_JSON5,
43
- GLOB_JSONC: () => GLOB_JSONC,
44
- GLOB_JSX: () => GLOB_JSX,
45
- GLOB_LESS: () => GLOB_LESS,
46
- GLOB_MARKDOWN: () => GLOB_MARKDOWN,
47
- GLOB_MARKDOWN_CODE: () => GLOB_MARKDOWN_CODE,
48
- GLOB_MARKDOWN_IN_MARKDOWN: () => GLOB_MARKDOWN_IN_MARKDOWN,
49
- GLOB_POSTCSS: () => GLOB_POSTCSS,
50
- GLOB_SCSS: () => GLOB_SCSS,
51
- GLOB_SRC: () => GLOB_SRC,
52
- GLOB_SRC_EXT: () => GLOB_SRC_EXT,
53
- GLOB_STYLE: () => GLOB_STYLE,
54
- GLOB_SVELTE: () => GLOB_SVELTE,
55
- GLOB_SVG: () => GLOB_SVG,
56
- GLOB_TESTS: () => GLOB_TESTS,
57
- GLOB_TOML: () => GLOB_TOML,
58
- GLOB_TS: () => GLOB_TS,
59
- GLOB_TSX: () => GLOB_TSX,
60
- GLOB_VUE: () => GLOB_VUE,
61
- GLOB_XML: () => GLOB_XML,
62
- GLOB_YAML: () => GLOB_YAML,
63
- STYLISTIC_CONFIG_DEFAULTS: () => STYLISTIC_CONFIG_DEFAULTS,
64
- astro: () => astro,
65
- combineConfigs: () => combineConfigs,
66
- command: () => command,
67
- comments: () => comments,
68
- defaultPluginRenaming: () => defaultPluginRenaming,
69
- ensurePackages: () => ensurePackages,
70
- formatters: () => formatters,
71
- ignores: () => ignores,
72
- imports: () => imports,
73
- interopDefault: () => interopDefault,
74
- isInEditorEnv: () => isInEditorEnv,
75
- isInGitHooksOrLintStaged: () => isInGitHooksOrLintStaged,
76
- isPackageInScope: () => isPackageInScope,
77
- javascript: () => javascript,
78
- jsdoc: () => jsdoc,
79
- jsonc: () => jsonc,
80
- jsx: () => jsx,
81
- markdown: () => markdown,
82
- node: () => node,
83
- parserPlain: () => parserPlain,
84
- perfectionist: () => perfectionist,
85
- pluginAntfu: () => import_eslint_plugin_antfu.default,
86
- pluginComments: () => import_eslint_plugin_eslint_comments.default,
87
- pluginImport: () => pluginImport,
88
- pluginNode: () => import_eslint_plugin_n.default,
89
- pluginPerfectionist: () => import_eslint_plugin_perfectionist.default,
90
- pluginSonar: () => import_eslint_plugin_sonarjs.default,
91
- pluginUnicorn: () => import_eslint_plugin_unicorn.default,
92
- pluginUnusedImports: () => import_eslint_plugin_unused_imports.default,
93
- react: () => react,
94
- regexp: () => regexp,
95
- renamePluginInConfigs: () => renamePluginInConfigs,
96
- renameRules: () => renameRules,
97
- solid: () => solid,
98
- sonar: () => sonar,
99
- sortPackageJson: () => sortPackageJson,
100
- sortTsconfig: () => sortTsconfig,
101
- stylistic: () => stylistic,
102
- svelte: () => svelte,
103
- test: () => test,
104
- toArray: () => toArray,
105
- toml: () => toml,
106
- typescript: () => typescript,
107
- unicorn: () => unicorn,
108
- unocss: () => unocss,
109
- vinicuncaESLint: () => vinicuncaESLint,
110
- vue: () => vue,
111
- yaml: () => yaml
112
- });
113
- module.exports = __toCommonJS(src_exports);
114
-
115
- // ../node_modules/.pnpm/tsup@8.3.5_jiti@2.4.2_postcss@8.5.1_tsx@4.19.2_typescript@5.7.3_yaml@2.7.0/node_modules/tsup/assets/cjs_shims.js
116
- var getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.src || new URL("main.js", document.baseURI).href;
117
- var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
118
-
119
- // ../node_modules/.pnpm/@vinicunca+perkakas@1.2.3/node_modules/@vinicunca/perkakas/dist/chunk-6AFNPQW2.js
120
- function r(o) {
121
- if (typeof o != "object" || o === null) return false;
122
- let e3 = Object.getPrototypeOf(o);
123
- return e3 === null || e3 === Object.prototype;
124
- }
125
-
126
- // ../node_modules/.pnpm/@vinicunca+perkakas@1.2.3/node_modules/@vinicunca/perkakas/dist/chunk-Q2HW4RVT.js
127
- function e(r2) {
128
- return typeof r2 == "number" && !Number.isNaN(r2);
129
- }
130
-
131
- // ../node_modules/.pnpm/@vinicunca+perkakas@1.2.3/node_modules/@vinicunca/perkakas/dist/chunk-AZUJCNUP.js
132
- function e2(o) {
133
- return typeof o == "boolean";
134
- }
135
-
136
- // src/base.ts
137
- var import_eslint_flat_config_utils = require("eslint-flat-config-utils");
138
- var import_local_pkg4 = require("local-pkg");
139
-
140
- // src/flags.ts
141
- var ERROR = "error";
142
- var OFF = "off";
143
- var WARN = "warn";
144
- var CONSISTENT = "consistent";
145
- var NEVER = "never";
146
- var ALWAYS = "always";
147
-
148
- // src/globs.ts
149
- var GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
150
- var GLOB_SRC = "**/*.?([cm])[jt]s?(x)";
151
- var GLOB_JS = "**/*.?([cm])js";
152
- var GLOB_JSX = "**/*.?([cm])jsx";
153
- var GLOB_TS = "**/*.?([cm])ts";
154
- var GLOB_TSX = "**/*.?([cm])tsx";
155
- var GLOB_STYLE = "**/*.{c,le,sc}ss";
156
- var GLOB_CSS = "**/*.css";
157
- var GLOB_POSTCSS = "**/*.{p,post}css";
158
- var GLOB_LESS = "**/*.less";
159
- var GLOB_SCSS = "**/*.scss";
160
- var GLOB_JSON = "**/*.json";
161
- var GLOB_JSON5 = "**/*.json5";
162
- var GLOB_JSONC = "**/*.jsonc";
163
- var GLOB_MARKDOWN = "**/*.md";
164
- var GLOB_MARKDOWN_IN_MARKDOWN = "**/*.md/*.md";
165
- var GLOB_SVELTE = "**/*.svelte";
166
- var GLOB_VUE = "**/*.vue";
167
- var GLOB_YAML = "**/*.y?(a)ml";
168
- var GLOB_TOML = "**/*.toml";
169
- var GLOB_XML = "**/*.xml";
170
- var GLOB_SVG = "**/*.svg";
171
- var GLOB_HTML = "**/*.htm?(l)";
172
- var GLOB_ASTRO = "**/*.astro";
173
- var GLOB_ASTRO_TS = "**/*.astro/*.ts";
174
- var GLOB_GRAPHQL = "**/*.{g,graph}ql";
175
- var GLOB_MARKDOWN_CODE = `${GLOB_MARKDOWN}/${GLOB_SRC}`;
176
- var GLOB_TESTS = [
177
- `**/__tests__/**/*.${GLOB_SRC_EXT}`,
178
- `**/*.spec.${GLOB_SRC_EXT}`,
179
- `**/*.test.${GLOB_SRC_EXT}`,
180
- `**/*.bench.${GLOB_SRC_EXT}`,
181
- `**/*.benchmark.${GLOB_SRC_EXT}`
182
- ];
183
- var GLOB_ALL_SRC = [
184
- GLOB_SRC,
185
- GLOB_STYLE,
186
- GLOB_JSON,
187
- GLOB_JSON5,
188
- GLOB_MARKDOWN,
189
- GLOB_SVELTE,
190
- GLOB_VUE,
191
- GLOB_YAML,
192
- GLOB_XML,
193
- GLOB_HTML
194
- ];
195
- var GLOB_EXCLUDE = [
196
- "**/node_modules",
197
- "**/dist",
198
- "**/package-lock.json",
199
- "**/yarn.lock",
200
- "**/pnpm-lock.yaml",
201
- "**/bun.lockb",
202
- "**/output",
203
- "**/coverage",
204
- "**/temp",
205
- "**/.temp",
206
- "**/tmp",
207
- "**/.tmp",
208
- "**/.history",
209
- "**/.vitepress/cache",
210
- "**/.nuxt",
211
- "**/.next",
212
- "**/.svelte-kit",
213
- "**/.vercel",
214
- "**/.changeset",
215
- "**/.idea",
216
- "**/.cache",
217
- "**/.output",
218
- "**/.vite-inspect",
219
- "**/.yarn",
220
- "**/vite.config.*.timestamp-*",
221
- "**/CHANGELOG*.md",
222
- "**/*.min.*",
223
- "**/LICENSE*",
224
- "**/__snapshots__",
225
- "**/auto-import?(s).d.ts",
226
- "**/components.d.ts"
227
- ];
228
-
229
- // src/utils.ts
230
- var import_local_pkg = require("local-pkg");
231
- var import_node_process = __toESM(require("process"), 1);
232
- var import_node_url = require("url");
233
- var scopeUrl = (0, import_node_url.fileURLToPath)(new URL(".", importMetaUrl));
234
- var isCwdInScope = (0, import_local_pkg.isPackageExists)("@vinicunca/eslint-config");
235
- var parserPlain = {
236
- meta: {
237
- name: "parser-plain"
238
- },
239
- parseForESLint: (code) => ({
240
- ast: {
241
- body: [],
242
- comments: [],
243
- loc: { end: code.length, start: 0 },
244
- range: [0, code.length],
245
- tokens: [],
246
- type: "Program"
247
- },
248
- scopeManager: null,
249
- services: { isPlain: true },
250
- visitorKeys: {
251
- Program: []
252
- }
253
- })
254
- };
255
- async function combineConfigs(...configs2) {
256
- const resolved = await Promise.all(configs2);
257
- return resolved.flat();
258
- }
259
- function renameRules(rules, map) {
260
- return Object.fromEntries(
261
- Object.entries(rules).map(([key, value]) => {
262
- for (const [from, to] of Object.entries(map)) {
263
- if (key.startsWith(`${from}/`)) {
264
- return [to + key.slice(from.length), value];
265
- }
266
- }
267
- return [key, value];
268
- })
269
- );
270
- }
271
- function renamePluginInConfigs(configs2, map) {
272
- return configs2.map((i) => {
273
- const clone = { ...i };
274
- if (clone.rules) {
275
- clone.rules = renameRules(clone.rules, map);
276
- }
277
- if (clone.plugins) {
278
- clone.plugins = Object.fromEntries(
279
- Object.entries(clone.plugins).map(([key, value]) => {
280
- if (key in map) {
281
- return [map[key], value];
282
- }
283
- return [key, value];
284
- })
285
- );
286
- }
287
- return clone;
288
- });
289
- }
290
- function toArray(value) {
291
- return Array.isArray(value) ? value : [value];
292
- }
293
- async function interopDefault(m) {
294
- const resolved = await m;
295
- return resolved.default || resolved;
296
- }
297
- function isPackageInScope(name) {
298
- return (0, import_local_pkg.isPackageExists)(name, { paths: [scopeUrl] });
299
- }
300
- async function ensurePackages(packages) {
301
- if (import_node_process.default.env.CI || import_node_process.default.stdout.isTTY === false || isCwdInScope === false) {
302
- return;
303
- }
304
- const nonExistingPackages = packages.filter((i) => i && !isPackageInScope(i));
305
- if (nonExistingPackages.length === 0) {
306
- return;
307
- }
308
- const p = await import("@clack/prompts");
309
- const result = await p.confirm({
310
- message: `${nonExistingPackages.length === 1 ? "Package is" : "Packages are"} required for this config: ${nonExistingPackages.join(", ")}. Do you want to install them?`
311
- });
312
- if (result) {
313
- await import("@antfu/install-pkg").then((i) => i.installPackage(nonExistingPackages, { dev: true }));
314
- }
315
- }
316
- function isInEditorEnv() {
317
- if (import_node_process.default.env.CI) {
318
- return false;
319
- }
320
- if (isInGitHooksOrLintStaged()) {
321
- return false;
322
- }
323
- return !!(import_node_process.default.env.VSCODE_PID || import_node_process.default.env.VSCODE_CWD || import_node_process.default.env.JETBRAINS_IDE || import_node_process.default.env.VIM || import_node_process.default.env.NVIM);
324
- }
325
- function isInGitHooksOrLintStaged() {
326
- return !!(import_node_process.default.env.GIT_PARAMS || import_node_process.default.env.VSCODE_GIT_COMMAND || import_node_process.default.env.npm_lifecycle_script?.startsWith("lint-staged"));
327
- }
328
-
329
- // src/configs/astro.ts
330
- async function astro(options = {}) {
331
- const {
332
- files = [GLOB_ASTRO],
333
- overrides = {},
334
- stylistic: stylistic2 = true
335
- } = options;
336
- const [
337
- pluginAstro,
338
- parserAstro,
339
- parserTs
340
- ] = await Promise.all([
341
- interopDefault(import("eslint-plugin-astro")),
342
- interopDefault(import("astro-eslint-parser")),
343
- interopDefault(import("@typescript-eslint/parser"))
344
- ]);
345
- return [
346
- {
347
- name: "vinicunca/astro/setup",
348
- plugins: {
349
- astro: pluginAstro
350
- }
351
- },
352
- {
353
- files,
354
- languageOptions: {
355
- globals: pluginAstro.environments.astro.globals,
356
- parser: parserAstro,
357
- parserOptions: {
358
- extraFileExtensions: [".astro"],
359
- parser: parserTs
360
- },
361
- sourceType: "module"
362
- },
363
- name: "vinicunca/astro/rules",
364
- processor: "astro/client-side-ts",
365
- rules: {
366
- // use recommended rules
367
- "astro/missing-client-only-directive-value": ERROR,
368
- "astro/no-conflict-set-directives": ERROR,
369
- "astro/no-deprecated-astro-canonicalurl": ERROR,
370
- "astro/no-deprecated-astro-fetchcontent": ERROR,
371
- "astro/no-deprecated-astro-resolve": ERROR,
372
- "astro/no-deprecated-getentrybyslug": ERROR,
373
- "astro/no-set-html-directive": OFF,
374
- "astro/no-unused-define-vars-in-style": ERROR,
375
- "astro/semi": OFF,
376
- "astro/valid-compile": ERROR,
377
- ...stylistic2 ? {
378
- "style/indent": OFF,
379
- "style/jsx-closing-tag-location": OFF,
380
- "style/jsx-one-expression-per-line": OFF,
381
- "style/no-multiple-empty-lines": OFF
382
- } : {},
383
- ...overrides
384
- }
385
- }
386
- ];
387
- }
388
-
389
- // src/configs/command.ts
390
- var import_config = __toESM(require("eslint-plugin-command/config"), 1);
391
- async function command() {
392
- return [
393
- {
394
- ...(0, import_config.default)(),
395
- name: "vinicunca/command/rules"
396
- }
397
- ];
398
- }
399
-
400
- // src/plugins.ts
401
- var import_eslint_plugin_eslint_comments = __toESM(require("@eslint-community/eslint-plugin-eslint-comments"), 1);
402
- var import_eslint_plugin_antfu = __toESM(require("eslint-plugin-antfu"), 1);
403
- var pluginImport = __toESM(require("eslint-plugin-import-x"), 1);
404
- var import_eslint_plugin_n = __toESM(require("eslint-plugin-n"), 1);
405
- var import_eslint_plugin_perfectionist = __toESM(require("eslint-plugin-perfectionist"), 1);
406
- var import_eslint_plugin_sonarjs = __toESM(require("eslint-plugin-sonarjs"), 1);
407
- var import_eslint_plugin_unicorn = __toESM(require("eslint-plugin-unicorn"), 1);
408
- var import_eslint_plugin_unused_imports = __toESM(require("eslint-plugin-unused-imports"), 1);
409
-
410
- // src/configs/comments.ts
411
- async function comments() {
412
- return [
413
- {
414
- name: "vinicunca/eslint-comments/rules",
415
- plugins: {
416
- "eslint-comments": import_eslint_plugin_eslint_comments.default
417
- },
418
- rules: {
419
- "eslint-comments/no-aggregating-enable": ERROR,
420
- "eslint-comments/no-duplicate-disable": ERROR,
421
- "eslint-comments/no-unlimited-disable": ERROR,
422
- "eslint-comments/no-unused-enable": ERROR
423
- }
424
- }
425
- ];
426
- }
427
-
428
- // src/configs/formatters.ts
429
- var import_local_pkg2 = require("local-pkg");
430
-
431
- // src/configs/stylistic.ts
432
- var STYLISTIC_CONFIG_DEFAULTS = {
433
- indent: 2,
434
- jsx: true,
435
- quotes: "single",
436
- semi: true
437
- };
438
- async function stylistic(options = {}) {
439
- const {
440
- indent,
441
- jsx: jsx2,
442
- overrides = {},
443
- quotes,
444
- semi
445
- } = {
446
- ...STYLISTIC_CONFIG_DEFAULTS,
447
- ...options
448
- };
449
- const pluginStylistic = await interopDefault(import("@stylistic/eslint-plugin"));
450
- const config = pluginStylistic.configs.customize({
451
- flat: true,
452
- indent,
453
- jsx: jsx2,
454
- pluginName: "style",
455
- quotes,
456
- semi
457
- });
458
- return [
459
- {
460
- name: "vinicunca/stylistic/rules",
461
- plugins: {
462
- antfu: import_eslint_plugin_antfu.default,
463
- style: pluginStylistic
464
- },
465
- rules: {
466
- ...config.rules,
467
- "antfu/consistent-chaining": ERROR,
468
- "antfu/consistent-list-newline": ERROR,
469
- "antfu/top-level-function": ERROR,
470
- "curly": [ERROR, "all"],
471
- "style/array-bracket-newline": [ERROR, CONSISTENT],
472
- "style/array-bracket-spacing": [ERROR, NEVER],
473
- "style/array-element-newline": [ERROR, CONSISTENT],
474
- "style/arrow-parens": [ERROR, ALWAYS],
475
- "style/brace-style": [ERROR],
476
- "style/func-call-spacing": [ERROR, NEVER],
477
- "style/member-delimiter-style": [ERROR],
478
- "style/object-curly-newline": [ERROR, { consistent: true, multiline: true }],
479
- "style/object-curly-spacing": [ERROR, ALWAYS],
480
- "style/object-property-newline": [ERROR, { allowMultiplePropertiesPerLine: true }],
481
- "style/operator-linebreak": [ERROR, "before"],
482
- "style/padded-blocks": [ERROR, { blocks: NEVER, classes: NEVER, switches: NEVER }],
483
- "style/quote-props": [ERROR, "consistent-as-needed"],
484
- "style/quotes": [ERROR, quotes],
485
- "style/rest-spread-spacing": [ERROR, NEVER],
486
- "style/semi": [ERROR, semi ? ALWAYS : NEVER],
487
- "style/semi-spacing": [ERROR, { after: true, before: false }],
488
- ...overrides
489
- }
490
- }
491
- ];
492
- }
493
-
494
- // src/configs/formatters.ts
495
- function mergePrettierOptions(options, overrides = {}) {
496
- return {
497
- ...options,
498
- ...overrides,
499
- plugins: [
500
- ...overrides.plugins || [],
501
- ...options.plugins || []
502
- ]
503
- };
504
- }
505
- async function formatters(options = {}, stylistic2 = {}) {
506
- if (options === true) {
507
- const isPrettierPluginXmlInScope = isPackageInScope("@prettier/plugin-xml");
508
- options = {
509
- astro: isPackageInScope("prettier-plugin-astro"),
510
- css: true,
511
- graphql: true,
512
- html: true,
513
- markdown: true,
514
- slidev: (0, import_local_pkg2.isPackageExists)("@slidev/cli"),
515
- svg: isPrettierPluginXmlInScope,
516
- xml: isPrettierPluginXmlInScope
517
- };
518
- }
519
- await ensurePackages([
520
- options.markdown && options.slidev ? "prettier-plugin-slidev" : void 0,
521
- options.astro ? "prettier-plugin-astro" : void 0,
522
- options.xml || options.svg ? "@prettier/plugin-xml" : void 0
523
- ]);
524
- if (options.slidev && options.markdown !== true && options.markdown !== "prettier") {
525
- throw new Error("`slidev` option only works when `markdown` is enabled with `prettier`");
526
- }
527
- const {
528
- indent,
529
- quotes,
530
- semi
531
- } = {
532
- ...STYLISTIC_CONFIG_DEFAULTS,
533
- ...stylistic2
534
- };
535
- const prettierOptions = Object.assign(
536
- {
537
- endOfLine: "auto",
538
- semi,
539
- singleQuote: quotes === "single",
540
- tabWidth: e(indent) ? indent : 2,
541
- trailingComma: "all",
542
- useTabs: indent === "tab"
543
- },
544
- options.prettierOptions || {}
545
- );
546
- const prettierXmlOptions = {
547
- xmlQuoteAttributes: "double",
548
- xmlSelfClosingSpace: true,
549
- xmlSortAttributesByKey: false,
550
- xmlWhitespaceSensitivity: "ignore"
551
- };
552
- const dprintOptions = Object.assign(
553
- {
554
- indentWidth: e(indent) ? indent : 2,
555
- quoteStyle: quotes === "single" ? "preferSingle" : "preferDouble",
556
- useTabs: indent === "tab"
557
- },
558
- options.dprintOptions || {}
559
- );
560
- const pluginFormat = await interopDefault(import("eslint-plugin-format"));
561
- const configs2 = [
562
- {
563
- name: "vinicunca/formatter/setup",
564
- plugins: {
565
- format: pluginFormat
566
- }
567
- }
568
- ];
569
- if (options.css) {
570
- configs2.push(
571
- {
572
- files: [GLOB_CSS, GLOB_POSTCSS],
573
- languageOptions: {
574
- parser: parserPlain
575
- },
576
- name: "vinicunca/formatter/css",
577
- rules: {
578
- "format/prettier": [
579
- ERROR,
580
- mergePrettierOptions(prettierOptions, {
581
- parser: "css"
582
- })
583
- ]
584
- }
585
- },
586
- {
587
- files: [GLOB_SCSS],
588
- languageOptions: {
589
- parser: parserPlain
590
- },
591
- name: "vinicunca/formatter/scss",
592
- rules: {
593
- "format/prettier": [
594
- ERROR,
595
- mergePrettierOptions(prettierOptions, {
596
- parser: "scss"
597
- })
598
- ]
599
- }
600
- },
601
- {
602
- files: [GLOB_LESS],
603
- languageOptions: {
604
- parser: parserPlain
605
- },
606
- name: "vinicunca/formatter/less",
607
- rules: {
608
- "format/prettier": [
609
- ERROR,
610
- mergePrettierOptions(prettierOptions, {
611
- parser: "less"
612
- })
613
- ]
614
- }
615
- }
616
- );
617
- }
618
- if (options.html) {
619
- configs2.push({
620
- files: ["**/*.html"],
621
- languageOptions: {
622
- parser: parserPlain
623
- },
624
- name: "vinicunca/formatter/html",
625
- rules: {
626
- "format/prettier": [
627
- ERROR,
628
- mergePrettierOptions(prettierOptions, {
629
- parser: "html"
630
- })
631
- ]
632
- }
633
- });
634
- }
635
- if (options.xml) {
636
- configs2.push({
637
- files: [GLOB_XML],
638
- languageOptions: {
639
- parser: parserPlain
640
- },
641
- name: "vinicunca/formatter/xml",
642
- rules: {
643
- "format/prettier": [
644
- ERROR,
645
- mergePrettierOptions({ ...prettierXmlOptions, ...prettierOptions }, {
646
- parser: "xml",
647
- plugins: [
648
- "@prettier/plugin-xml"
649
- ]
650
- })
651
- ]
652
- }
653
- });
654
- }
655
- if (options.svg) {
656
- configs2.push({
657
- files: [GLOB_SVG],
658
- languageOptions: {
659
- parser: parserPlain
660
- },
661
- name: "vinicunca/formatter/svg",
662
- rules: {
663
- "format/prettier": [
664
- ERROR,
665
- mergePrettierOptions({ ...prettierXmlOptions, ...prettierOptions }, {
666
- parser: "xml",
667
- plugins: [
668
- "@prettier/plugin-xml"
669
- ]
670
- })
671
- ]
672
- }
673
- });
674
- }
675
- if (options.markdown) {
676
- const formater = options.markdown === true ? "prettier" : options.markdown;
677
- let GLOB_SLIDEV;
678
- if (options.slidev) {
679
- GLOB_SLIDEV = options.slidev === true ? ["**/slides.md"] : options.slidev.files;
680
- } else {
681
- GLOB_SLIDEV = [];
682
- }
683
- configs2.push({
684
- files: [GLOB_MARKDOWN],
685
- ignores: GLOB_SLIDEV,
686
- languageOptions: {
687
- parser: parserPlain
688
- },
689
- name: "vinicunca/formatter/markdown",
690
- rules: {
691
- [`format/${formater}`]: [
692
- ERROR,
693
- formater === "prettier" ? mergePrettierOptions(prettierOptions, {
694
- embeddedLanguageFormatting: "off",
695
- parser: "markdown"
696
- }) : {
697
- ...dprintOptions,
698
- language: "markdown"
699
- }
700
- ]
701
- }
702
- });
703
- if (options.slidev) {
704
- configs2.push({
705
- files: GLOB_SLIDEV,
706
- languageOptions: {
707
- parser: parserPlain
708
- },
709
- name: "vinicunca/formatter/slidev",
710
- rules: {
711
- "format/prettier": [
712
- ERROR,
713
- mergePrettierOptions(prettierOptions, {
714
- embeddedLanguageFormatting: "off",
715
- parser: "slidev",
716
- plugins: [
717
- "prettier-plugin-slidev"
718
- ]
719
- })
720
- ]
721
- }
722
- });
723
- }
724
- }
725
- if (options.astro) {
726
- configs2.push({
727
- files: [GLOB_ASTRO],
728
- languageOptions: {
729
- parser: parserPlain
730
- },
731
- name: "vinicunca/formatter/astro",
732
- rules: {
733
- "format/prettier": [
734
- ERROR,
735
- mergePrettierOptions(prettierOptions, {
736
- parser: "astro",
737
- plugins: [
738
- "prettier-plugin-astro"
739
- ]
740
- })
741
- ]
742
- }
743
- });
744
- configs2.push({
745
- files: [GLOB_ASTRO, GLOB_ASTRO_TS],
746
- name: "vinicunca/formatter/astro/disables",
747
- rules: {
748
- "style/arrow-parens": OFF,
749
- "style/block-spacing": OFF,
750
- "style/comma-dangle": OFF,
751
- "style/indent": OFF,
752
- "style/no-multi-spaces": OFF,
753
- "style/quotes": OFF,
754
- "style/semi": OFF
755
- }
756
- });
757
- }
758
- if (options.graphql) {
759
- configs2.push({
760
- files: [GLOB_GRAPHQL],
761
- languageOptions: {
762
- parser: parserPlain
763
- },
764
- name: "vinicunca/formatter/graphql",
765
- rules: {
766
- "format/prettier": [
767
- ERROR,
768
- mergePrettierOptions(prettierOptions, {
769
- parser: "graphql"
770
- })
771
- ]
772
- }
773
- });
774
- }
775
- return configs2;
776
- }
777
-
778
- // src/configs/ignores.ts
779
- async function ignores(userIgnores = []) {
780
- return [
781
- {
782
- ignores: [
783
- ...GLOB_EXCLUDE,
784
- ...userIgnores
785
- ],
786
- name: "vinicunca/ignores"
787
- }
788
- ];
789
- }
790
-
791
- // src/configs/imports.ts
792
- async function imports(options = {}) {
793
- const {
794
- stylistic: stylistic2 = true
795
- } = options;
796
- return [
797
- {
798
- name: "vinicunca/imports/rules",
799
- plugins: {
800
- antfu: import_eslint_plugin_antfu.default,
801
- import: pluginImport
802
- },
803
- rules: {
804
- "antfu/import-dedupe": ERROR,
805
- "antfu/no-import-dist": ERROR,
806
- "antfu/no-import-node-modules-by-path": ERROR,
807
- "import/export": ERROR,
808
- "import/first": ERROR,
809
- "import/no-duplicates": ERROR,
810
- "import/no-mutable-exports": ERROR,
811
- "import/no-named-default": ERROR,
812
- "import/no-self-import": ERROR,
813
- "import/no-webpack-loader-syntax": ERROR,
814
- // Turned off to avoid conflicts with Perfectionist. https://eslint-plugin-perfectionist.azat.io/rules/sort-imports
815
- "import/order": OFF,
816
- ...stylistic2 ? {
817
- "import/newline-after-import": [ERROR, {
818
- count: 1,
819
- considerComments: true
820
- }]
821
- } : {}
822
- }
823
- },
824
- {
825
- files: ["**/bin/**/*", `**/bin.${GLOB_SRC_EXT}`],
826
- name: "vinicunca/imports/disables/bin",
827
- rules: {
828
- "antfu/no-import-dist": OFF,
829
- "antfu/no-import-node-modules-by-path": OFF
830
- }
831
- }
832
- ];
833
- }
834
-
835
- // src/configs/javascript.ts
836
- var import_globals = __toESM(require("globals"), 1);
837
- async function javascript(options = {}) {
838
- const {
839
- isInEditor = false,
840
- overrides = {}
841
- } = options;
842
- return [
843
- {
844
- languageOptions: {
845
- ecmaVersion: 2022,
846
- globals: {
847
- ...import_globals.default.browser,
848
- ...import_globals.default.es2021,
849
- ...import_globals.default.node,
850
- document: "readonly",
851
- navigator: "readonly",
852
- window: "readonly"
853
- },
854
- parserOptions: {
855
- ecmaFeatures: {
856
- jsx: true
857
- },
858
- ecmaVersion: 2022,
859
- sourceType: "module"
860
- },
861
- sourceType: "module"
862
- },
863
- linterOptions: {
864
- reportUnusedDisableDirectives: true
865
- },
866
- name: "vinicunca/javascript/setup"
867
- },
868
- {
869
- name: "vinicunca/javascript/rules",
870
- plugins: {
871
- "antfu": import_eslint_plugin_antfu.default,
872
- "unused-imports": import_eslint_plugin_unused_imports.default
873
- },
874
- rules: {
875
- "accessor-pairs": [ERROR, {
876
- enforceForClassMembers: true,
877
- setWithoutGet: true
878
- }],
879
- "array-callback-return": [ERROR, { checkForEach: true }],
880
- "block-scoped-var": ERROR,
881
- "camelcase": [ERROR, {
882
- allow: ["^UNSAFE_"],
883
- ignoreGlobals: true,
884
- properties: NEVER
885
- }],
886
- "constructor-super": ERROR,
887
- "default-case-last": ERROR,
888
- "dot-notation": [ERROR, { allowKeywords: true }],
889
- "eqeqeq": [ERROR, "smart"],
890
- "for-direction": ERROR,
891
- "new-cap": [ERROR, {
892
- capIsNew: false,
893
- properties: true
894
- }],
895
- "no-alert": WARN,
896
- "no-array-constructor": ERROR,
897
- "no-async-promise-executor": ERROR,
898
- "no-await-in-loop": ERROR,
899
- "no-caller": ERROR,
900
- "no-case-declarations": ERROR,
901
- "no-class-assign": ERROR,
902
- "no-compare-neg-zero": ERROR,
903
- "no-cond-assign": [ERROR, ALWAYS],
904
- "no-console": [ERROR, {
905
- allow: [WARN, ERROR]
906
- }],
907
- "no-const-assign": ERROR,
908
- "no-constant-binary-expression": ERROR,
909
- "no-constant-condition": [ERROR, {
910
- checkLoops: false
911
- }],
912
- "no-constructor-return": ERROR,
913
- "no-control-regex": ERROR,
914
- "no-debugger": ERROR,
915
- "no-delete-var": ERROR,
916
- "no-dupe-args": ERROR,
917
- "no-dupe-class-members": ERROR,
918
- "no-dupe-else-if": ERROR,
919
- "no-dupe-keys": ERROR,
920
- "no-duplicate-case": ERROR,
921
- "no-empty": [ERROR, {
922
- allowEmptyCatch: true
923
- }],
924
- "no-empty-character-class": ERROR,
925
- "no-empty-pattern": ERROR,
926
- "no-eval": ERROR,
927
- "no-ex-assign": ERROR,
928
- "no-extend-native": ERROR,
929
- "no-extra-bind": ERROR,
930
- "no-extra-boolean-cast": ERROR,
931
- "no-fallthrough": ERROR,
932
- "no-func-assign": ERROR,
933
- "no-global-assign": ERROR,
934
- "no-implied-eval": ERROR,
935
- "no-import-assign": ERROR,
936
- "no-invalid-regexp": ERROR,
937
- "no-invalid-this": ERROR,
938
- "no-irregular-whitespace": ERROR,
939
- "no-iterator": ERROR,
940
- "no-labels": ERROR,
941
- "no-lone-blocks": ERROR,
942
- "no-loss-of-precision": ERROR,
943
- "no-misleading-character-class": ERROR,
944
- "no-multi-str": ERROR,
945
- "no-nested-ternary": ERROR,
946
- "no-new": ERROR,
947
- "no-new-func": ERROR,
948
- "no-new-symbol": ERROR,
949
- "no-new-wrappers": ERROR,
950
- "no-obj-calls": ERROR,
951
- "no-object-constructor": ERROR,
952
- "no-octal": ERROR,
953
- "no-octal-escape": ERROR,
954
- "no-promise-executor-return": ERROR,
955
- "no-proto": ERROR,
956
- "no-prototype-builtins": ERROR,
957
- "no-redeclare": [ERROR, {
958
- builtinGlobals: false
959
- }],
960
- "no-regex-spaces": ERROR,
961
- "no-restricted-globals": [
962
- ERROR,
963
- {
964
- message: "Use `globalThis` instead.",
965
- name: "global"
966
- },
967
- {
968
- message: "Use `globalThis` instead.",
969
- name: "self"
970
- }
971
- ],
972
- "no-restricted-properties": [
973
- ERROR,
974
- {
975
- message: "Use `Object.getPrototypeOf` or `Object.setPrototypeOf` instead.",
976
- property: "__proto__"
977
- },
978
- {
979
- message: "Use `Object.defineProperty` instead.",
980
- property: "__defineGetter__"
981
- },
982
- {
983
- message: "Use `Object.defineProperty` instead.",
984
- property: "__defineSetter__"
985
- },
986
- {
987
- message: "Use `Object.getOwnPropertyDescriptor` instead.",
988
- property: "__lookupGetter__"
989
- },
990
- {
991
- message: "Use `Object.getOwnPropertyDescriptor` instead.",
992
- property: "__lookupSetter__"
993
- }
994
- ],
995
- "no-restricted-syntax": [
996
- ERROR,
997
- "ForInStatement",
998
- "TSEnumDeclaration[const=true]",
999
- "TSExportAssignment"
1000
- ],
1001
- "no-return-assign": [ERROR, ALWAYS],
1002
- "no-self-assign": [ERROR, {
1003
- props: true
1004
- }],
1005
- "no-self-compare": ERROR,
1006
- "no-sequences": ERROR,
1007
- "no-shadow-restricted-names": ERROR,
1008
- "no-sparse-arrays": ERROR,
1009
- "no-template-curly-in-string": ERROR,
1010
- "no-this-before-super": ERROR,
1011
- "no-throw-literal": ERROR,
1012
- "no-undef": ERROR,
1013
- "no-undef-init": ERROR,
1014
- "no-unexpected-multiline": ERROR,
1015
- "no-unmodified-loop-condition": ERROR,
1016
- "no-unneeded-ternary": [ERROR, {
1017
- defaultAssignment: false
1018
- }],
1019
- "no-unreachable": ERROR,
1020
- "no-unreachable-loop": ERROR,
1021
- "no-unsafe-finally": ERROR,
1022
- "no-unsafe-negation": ERROR,
1023
- "no-unused-expressions": [ERROR, {
1024
- allowShortCircuit: true,
1025
- allowTaggedTemplates: true,
1026
- allowTernary: true
1027
- }],
1028
- "no-unused-vars": [ERROR, {
1029
- args: "none",
1030
- caughtErrors: "none",
1031
- ignoreRestSiblings: true,
1032
- vars: "all"
1033
- }],
1034
- "no-use-before-define": [ERROR, {
1035
- classes: false,
1036
- functions: false,
1037
- variables: true
1038
- }],
1039
- "no-useless-backreference": ERROR,
1040
- "no-useless-call": ERROR,
1041
- "no-useless-catch": ERROR,
1042
- "no-useless-computed-key": ERROR,
1043
- "no-useless-constructor": ERROR,
1044
- "no-useless-rename": ERROR,
1045
- "no-useless-return": ERROR,
1046
- "no-var": ERROR,
1047
- "no-with": ERROR,
1048
- "object-shorthand": [ERROR, ALWAYS, {
1049
- avoidQuotes: true,
1050
- ignoreConstructors: false
1051
- }],
1052
- "one-var": [ERROR, {
1053
- initialized: NEVER
1054
- }],
1055
- "prefer-arrow-callback": [ERROR],
1056
- "prefer-const": [ERROR, {
1057
- destructuring: "all",
1058
- ignoreReadBeforeAssign: true
1059
- }],
1060
- "prefer-exponentiation-operator": ERROR,
1061
- "prefer-promise-reject-errors": ERROR,
1062
- "prefer-regex-literals": [ERROR, {
1063
- disallowRedundantWrapping: true
1064
- }],
1065
- "prefer-rest-params": ERROR,
1066
- "prefer-spread": ERROR,
1067
- "prefer-template": ERROR,
1068
- // Turned off to avoid conflicts with Perfectionist. https://eslint-plugin-perfectionist.azat.io/rules/sort-imports
1069
- "sort-imports": [OFF],
1070
- "symbol-description": ERROR,
1071
- "unicode-bom": [ERROR, NEVER],
1072
- "unused-imports/no-unused-imports": isInEditor ? OFF : ERROR,
1073
- "unused-imports/no-unused-vars": [WARN, {
1074
- args: "after-used",
1075
- argsIgnorePattern: "^_",
1076
- ignoreRestSiblings: true,
1077
- vars: "all",
1078
- varsIgnorePattern: "^_"
1079
- }],
1080
- "use-isnan": [ERROR, {
1081
- enforceForIndexOf: true,
1082
- enforceForSwitchCase: true
1083
- }],
1084
- "valid-typeof": [ERROR, {
1085
- requireStringLiterals: true
1086
- }],
1087
- "vars-on-top": ERROR,
1088
- "yoda": [ERROR, NEVER],
1089
- ...overrides
1090
- }
1091
- },
1092
- {
1093
- files: [`**/scripts/${GLOB_SRC}`, `**/cli.${GLOB_SRC_EXT}`],
1094
- name: "vinicunca/javascript/disables",
1095
- rules: {
1096
- "no-console": OFF
1097
- }
1098
- }
1099
- ];
1100
- }
1101
-
1102
- // src/configs/jsdoc.ts
1103
- async function jsdoc(options = {}) {
1104
- const {
1105
- stylistic: stylistic2 = true
1106
- } = options;
1107
- return [
1108
- {
1109
- name: "vinicunca/jsdoc/rules",
1110
- plugins: {
1111
- jsdoc: await interopDefault(import("eslint-plugin-jsdoc"))
1112
- },
1113
- rules: {
1114
- "jsdoc/check-access": WARN,
1115
- "jsdoc/check-alignment": WARN,
1116
- "jsdoc/check-param-names": WARN,
1117
- "jsdoc/check-property-names": WARN,
1118
- "jsdoc/check-types": WARN,
1119
- "jsdoc/empty-tags": WARN,
1120
- "jsdoc/implements-on-classes": WARN,
1121
- "jsdoc/multiline-blocks": WARN,
1122
- "jsdoc/no-defaults": WARN,
1123
- "jsdoc/no-multi-asterisks": WARN,
1124
- "jsdoc/no-types": WARN,
1125
- "jsdoc/require-param-name": WARN,
1126
- "jsdoc/require-property": WARN,
1127
- "jsdoc/require-property-description": WARN,
1128
- "jsdoc/require-property-name": WARN,
1129
- "jsdoc/require-returns-check": WARN,
1130
- "jsdoc/require-returns-description": WARN,
1131
- "jsdoc/require-yields-check": WARN,
1132
- "jsdoc/valid-types": WARN,
1133
- ...stylistic2 ? {
1134
- "jsdoc/check-alignment": WARN,
1135
- "jsdoc/multiline-blocks": WARN
1136
- } : {}
1137
- }
1138
- }
1139
- ];
1140
- }
1141
-
1142
- // src/configs/jsonc.ts
1143
- async function jsonc(options = {}) {
1144
- const {
1145
- files = [GLOB_JSON, GLOB_JSON5, GLOB_JSONC],
1146
- overrides = {},
1147
- stylistic: stylistic2 = true
1148
- } = options;
1149
- const {
1150
- indent = 2
1151
- } = e2(stylistic2) ? {} : stylistic2;
1152
- const [
1153
- pluginJsonc,
1154
- parserJsonc
1155
- ] = await Promise.all([
1156
- interopDefault(import("eslint-plugin-jsonc")),
1157
- interopDefault(import("jsonc-eslint-parser"))
1158
- ]);
1159
- return [
1160
- {
1161
- name: "vinicunca/jsonc/setup",
1162
- plugins: {
1163
- jsonc: pluginJsonc
1164
- }
1165
- },
1166
- {
1167
- files,
1168
- languageOptions: {
1169
- parser: parserJsonc
1170
- },
1171
- name: "vinicunca/jsonc/rules",
1172
- rules: {
1173
- "jsonc/no-bigint-literals": ERROR,
1174
- "jsonc/no-binary-expression": ERROR,
1175
- "jsonc/no-binary-numeric-literals": ERROR,
1176
- "jsonc/no-dupe-keys": ERROR,
1177
- "jsonc/no-escape-sequence-in-identifier": ERROR,
1178
- "jsonc/no-floating-decimal": ERROR,
1179
- "jsonc/no-hexadecimal-numeric-literals": ERROR,
1180
- "jsonc/no-infinity": ERROR,
1181
- "jsonc/no-multi-str": ERROR,
1182
- "jsonc/no-nan": ERROR,
1183
- "jsonc/no-number-props": ERROR,
1184
- "jsonc/no-numeric-separators": ERROR,
1185
- "jsonc/no-octal": ERROR,
1186
- "jsonc/no-octal-escape": ERROR,
1187
- "jsonc/no-octal-numeric-literals": ERROR,
1188
- "jsonc/no-parenthesized": ERROR,
1189
- "jsonc/no-plus-sign": ERROR,
1190
- "jsonc/no-regexp-literals": ERROR,
1191
- "jsonc/no-sparse-arrays": ERROR,
1192
- "jsonc/no-template-literals": ERROR,
1193
- "jsonc/no-undefined-value": ERROR,
1194
- "jsonc/no-unicode-codepoint-escapes": ERROR,
1195
- "jsonc/no-useless-escape": ERROR,
1196
- "jsonc/space-unary-ops": ERROR,
1197
- "jsonc/valid-json-number": ERROR,
1198
- "jsonc/vue-custom-block/no-parsing-error": ERROR,
1199
- ...stylistic2 ? {
1200
- "jsonc/array-bracket-spacing": [ERROR, NEVER],
1201
- "jsonc/comma-dangle": [ERROR, NEVER],
1202
- "jsonc/comma-style": [ERROR, "last"],
1203
- "jsonc/indent": [ERROR, indent],
1204
- "jsonc/key-spacing": [ERROR, { afterColon: true, beforeColon: false }],
1205
- "jsonc/object-curly-newline": [ERROR, { consistent: true, multiline: true }],
1206
- "jsonc/object-curly-spacing": [ERROR, "always"],
1207
- "jsonc/object-property-newline": [ERROR, { allowMultiplePropertiesPerLine: true }],
1208
- "jsonc/quote-props": ERROR,
1209
- "jsonc/quotes": ERROR
1210
- } : {},
1211
- ...overrides
1212
- }
1213
- }
1214
- ];
1215
- }
1216
-
1217
- // src/configs/jsx.ts
1218
- async function jsx() {
1219
- return [
1220
- {
1221
- files: [GLOB_JSX, GLOB_TSX],
1222
- languageOptions: {
1223
- parserOptions: {
1224
- ecmaFeatures: {
1225
- jsx: true
1226
- }
1227
- }
1228
- },
1229
- name: "vinicunca/jsx/setup"
1230
- }
1231
- ];
1232
- }
1233
-
1234
- // src/configs/markdown.ts
1235
- var import_eslint_merge_processors = require("eslint-merge-processors");
1236
- async function markdown(options = {}) {
1237
- const {
1238
- componentExts = [],
1239
- files = [GLOB_MARKDOWN],
1240
- overrides = {}
1241
- } = options;
1242
- const markdown2 = await interopDefault(import("@eslint/markdown"));
1243
- return [
1244
- {
1245
- name: "vinicunca/markdown/setup",
1246
- plugins: {
1247
- markdown: markdown2
1248
- }
1249
- },
1250
- {
1251
- files,
1252
- ignores: [GLOB_MARKDOWN_IN_MARKDOWN],
1253
- name: "vinicunca/markdown/processor",
1254
- /**
1255
- * `eslint-plugin-markdown` only creates virtual files for code blocks,
1256
- * but not the markdown file itself. We use `eslint-merge-processors` to
1257
- * add a pass-through processor for the markdown file itself.
1258
- */
1259
- processor: (0, import_eslint_merge_processors.mergeProcessors)([
1260
- markdown2.processors.markdown,
1261
- import_eslint_merge_processors.processorPassThrough
1262
- ])
1263
- },
1264
- {
1265
- files,
1266
- languageOptions: {
1267
- parser: parserPlain
1268
- },
1269
- name: "vinicunca/markdown/parser"
1270
- },
1271
- {
1272
- files: [
1273
- GLOB_MARKDOWN_CODE,
1274
- ...componentExts.map((ext) => `${GLOB_MARKDOWN}/**/*.${ext}`)
1275
- ],
1276
- languageOptions: {
1277
- parserOptions: {
1278
- ecmaFeatures: {
1279
- impliedStrict: true
1280
- }
1281
- }
1282
- },
1283
- name: "vinicunca/markdown/disables",
1284
- rules: {
1285
- "import/newline-after-import": OFF,
1286
- "no-alert": OFF,
1287
- "no-console": OFF,
1288
- "no-undef": OFF,
1289
- "no-unused-expressions": OFF,
1290
- "no-unused-vars": OFF,
1291
- "node/prefer-global/process": OFF,
1292
- "style/comma-dangle": OFF,
1293
- "style/eol-last": OFF,
1294
- "ts/consistent-type-imports": OFF,
1295
- "ts/no-namespace": OFF,
1296
- "ts/no-redeclare": OFF,
1297
- "ts/no-require-imports": OFF,
1298
- "ts/no-unused-vars": OFF,
1299
- "ts/no-use-before-define": OFF,
1300
- "ts/no-var-requires": OFF,
1301
- "unicode-bom": OFF,
1302
- "unused-imports/no-unused-imports": OFF,
1303
- "unused-imports/no-unused-vars": OFF,
1304
- ...overrides
1305
- }
1306
- }
1307
- ];
1308
- }
1309
-
1310
- // src/configs/node.ts
1311
- async function node() {
1312
- return [
1313
- {
1314
- name: "vinicunca/node/rules",
1315
- plugins: {
1316
- node: import_eslint_plugin_n.default
1317
- },
1318
- rules: {
1319
- "node/handle-callback-err": [ERROR, "^(err|error)$"],
1320
- "node/no-callback-literal": OFF,
1321
- "node/no-deprecated-api": ERROR,
1322
- "node/no-exports-assign": ERROR,
1323
- "node/no-new-require": ERROR,
1324
- "node/no-path-concat": ERROR,
1325
- "node/prefer-global/buffer": [ERROR, NEVER],
1326
- "node/prefer-global/process": [ERROR, NEVER],
1327
- "node/process-exit-as-throw": ERROR
1328
- }
1329
- }
1330
- ];
1331
- }
1332
-
1333
- // src/configs/perfectionist.ts
1334
- async function perfectionist() {
1335
- return [
1336
- {
1337
- name: "vinicunca/perfectionist/rules",
1338
- plugins: {
1339
- perfectionist: import_eslint_plugin_perfectionist.default
1340
- },
1341
- rules: {
1342
- "perfectionist/sort-exports": [
1343
- ERROR,
1344
- { order: "asc", type: "natural" }
1345
- ],
1346
- "perfectionist/sort-imports": [
1347
- ERROR,
1348
- {
1349
- groups: [
1350
- "type",
1351
- ["parent-type", "sibling-type", "index-type", "internal-type"],
1352
- "builtin",
1353
- "external",
1354
- "internal",
1355
- ["parent", "sibling", "index"],
1356
- "side-effect",
1357
- "object",
1358
- "unknown"
1359
- ],
1360
- newlinesBetween: "ignore",
1361
- order: "asc",
1362
- type: "natural"
1363
- }
1364
- ],
1365
- "perfectionist/sort-named-exports": [
1366
- ERROR,
1367
- { order: "asc", type: "natural" }
1368
- ],
1369
- "perfectionist/sort-named-imports": [
1370
- ERROR,
1371
- { order: "asc", type: "natural" }
1372
- ]
1373
- }
1374
- }
1375
- ];
1376
- }
1377
-
1378
- // src/configs/react.ts
1379
- var import_local_pkg3 = require("local-pkg");
1380
- var ReactRefreshAllowConstantExportPackages = [
1381
- "vite"
1382
- ];
1383
- var RemixPackages = [
1384
- "@remix-run/node",
1385
- "@remix-run/react",
1386
- "@remix-run/serve",
1387
- "@remix-run/dev"
1388
- ];
1389
- var NextJsPackages = [
1390
- "next"
1391
- ];
1392
- async function react(options = {}) {
1393
- const {
1394
- files = [GLOB_SRC],
1395
- filesTypeAware = [GLOB_TS, GLOB_TSX],
1396
- ignoresTypeAware = [
1397
- `${GLOB_MARKDOWN}/**`,
1398
- GLOB_ASTRO_TS
1399
- ],
1400
- overrides = {},
1401
- tsconfigPath
1402
- } = options;
1403
- const isTypeAware = !!tsconfigPath;
1404
- const typeAwareRules = {
1405
- "react/no-leaked-conditional-rendering": "warn"
1406
- };
1407
- const [
1408
- pluginReact,
1409
- pluginReactHooks,
1410
- pluginReactRefresh
1411
- ] = await Promise.all([
1412
- interopDefault(import("@eslint-react/eslint-plugin")),
1413
- interopDefault(import("eslint-plugin-react-hooks")),
1414
- interopDefault(import("eslint-plugin-react-refresh"))
1415
- ]);
1416
- const isAllowConstantExport = ReactRefreshAllowConstantExportPackages.some((i) => (0, import_local_pkg3.isPackageExists)(i));
1417
- const isUsingRemix = RemixPackages.some((i) => (0, import_local_pkg3.isPackageExists)(i));
1418
- const isUsingNext = NextJsPackages.some((i) => (0, import_local_pkg3.isPackageExists)(i));
1419
- const plugins = pluginReact.configs.all.plugins;
1420
- return [
1421
- {
1422
- name: "vinicunca/react/setup",
1423
- plugins: {
1424
- "react": plugins["@eslint-react"],
1425
- "react-dom": plugins["@eslint-react/dom"],
1426
- "react-hooks": pluginReactHooks,
1427
- "react-hooks-extra": plugins["@eslint-react/hooks-extra"],
1428
- "react-naming-convention": plugins["@eslint-react/naming-convention"],
1429
- "react-refresh": pluginReactRefresh
1430
- }
1431
- },
1432
- {
1433
- files,
1434
- languageOptions: {
1435
- parserOptions: {
1436
- ecmaFeatures: {
1437
- jsx: true
1438
- }
1439
- },
1440
- sourceType: "module"
1441
- },
1442
- name: "vinicunca/react/rules",
1443
- rules: {
1444
- // recommended rules from @eslint-react/dom
1445
- "react-dom/no-children-in-void-dom-elements": WARN,
1446
- "react-dom/no-dangerously-set-innerhtml": WARN,
1447
- "react-dom/no-dangerously-set-innerhtml-with-children": ERROR,
1448
- "react-dom/no-find-dom-node": ERROR,
1449
- "react-dom/no-missing-button-type": WARN,
1450
- "react-dom/no-missing-iframe-sandbox": WARN,
1451
- "react-dom/no-namespace": ERROR,
1452
- "react-dom/no-render-return-value": ERROR,
1453
- "react-dom/no-script-url": WARN,
1454
- "react-dom/no-unsafe-iframe-sandbox": WARN,
1455
- "react-dom/no-unsafe-target-blank": WARN,
1456
- // recommended rules react-hooks
1457
- "react-hooks/exhaustive-deps": WARN,
1458
- "react-hooks/rules-of-hooks": ERROR,
1459
- // react refresh
1460
- "react-refresh/only-export-components": [
1461
- WARN,
1462
- {
1463
- allowConstantExport: isAllowConstantExport,
1464
- allowExportNames: [
1465
- ...isUsingNext ? [
1466
- "config",
1467
- "generateStaticParams",
1468
- "metadata",
1469
- "generateMetadata",
1470
- "viewport",
1471
- "generateViewport"
1472
- ] : [],
1473
- ...isUsingRemix ? [
1474
- "meta",
1475
- "links",
1476
- "headers",
1477
- "loader",
1478
- "action"
1479
- ] : []
1480
- ]
1481
- }
1482
- ],
1483
- // recommended rules from @eslint-react
1484
- "react/ensure-forward-ref-using-ref": WARN,
1485
- "react/no-access-state-in-setstate": ERROR,
1486
- "react/no-array-index-key": WARN,
1487
- "react/no-children-count": WARN,
1488
- "react/no-children-for-each": WARN,
1489
- "react/no-children-map": WARN,
1490
- "react/no-children-only": WARN,
1491
- "react/no-children-prop": WARN,
1492
- "react/no-children-to-array": WARN,
1493
- "react/no-clone-element": WARN,
1494
- "react/no-comment-textnodes": WARN,
1495
- "react/no-component-will-mount": ERROR,
1496
- "react/no-component-will-receive-props": ERROR,
1497
- "react/no-component-will-update": ERROR,
1498
- "react/no-create-ref": ERROR,
1499
- "react/no-direct-mutation-state": ERROR,
1500
- "react/no-duplicate-key": ERROR,
1501
- "react/no-implicit-key": ERROR,
1502
- "react/no-missing-key": ERROR,
1503
- "react/no-nested-components": WARN,
1504
- "react/no-redundant-should-component-update": ERROR,
1505
- "react/no-set-state-in-component-did-mount": WARN,
1506
- "react/no-set-state-in-component-did-update": WARN,
1507
- "react/no-set-state-in-component-will-update": WARN,
1508
- "react/no-string-refs": ERROR,
1509
- "react/no-unsafe-component-will-mount": WARN,
1510
- "react/no-unsafe-component-will-receive-props": WARN,
1511
- "react/no-unsafe-component-will-update": WARN,
1512
- "react/no-unstable-context-value": ERROR,
1513
- "react/no-unstable-default-props": ERROR,
1514
- "react/no-unused-class-component-members": WARN,
1515
- "react/no-unused-state": WARN,
1516
- "react/no-useless-fragment": WARN,
1517
- "react/prefer-destructuring-assignment": WARN,
1518
- "react/prefer-shorthand-boolean": WARN,
1519
- "react/prefer-shorthand-fragment": WARN,
1520
- // overrides
1521
- ...overrides
1522
- }
1523
- },
1524
- ...isTypeAware ? [{
1525
- files: filesTypeAware,
1526
- ignores: ignoresTypeAware,
1527
- name: "antfu/react/type-aware-rules",
1528
- rules: {
1529
- ...typeAwareRules
1530
- }
1531
- }] : []
1532
- ];
1533
- }
1534
-
1535
- // src/configs/regexp.ts
1536
- var import_eslint_plugin_regexp = require("eslint-plugin-regexp");
1537
- async function regexp(options = {}) {
1538
- const config = import_eslint_plugin_regexp.configs["flat/recommended"];
1539
- const rules = {
1540
- ...config.rules
1541
- };
1542
- if (options.level === WARN) {
1543
- for (const key in rules) {
1544
- if (rules[key] === ERROR) {
1545
- rules[key] = WARN;
1546
- }
1547
- }
1548
- }
1549
- return [
1550
- {
1551
- ...config,
1552
- name: "vinicunca/regexp/rules",
1553
- rules: {
1554
- ...rules,
1555
- ...options.overrides
1556
- }
1557
- }
1558
- ];
1559
- }
1560
-
1561
- // src/configs/solid.ts
1562
- async function solid(options = {}) {
1563
- const {
1564
- files = [GLOB_JSX, GLOB_TSX],
1565
- overrides = {},
1566
- typescript: typescript2 = true
1567
- } = options;
1568
- const tsconfigPath = options?.tsconfigPath ? toArray(options.tsconfigPath) : void 0;
1569
- const isTypeAware = !!tsconfigPath;
1570
- const [
1571
- pluginSolid,
1572
- parserTs
1573
- ] = await Promise.all([
1574
- interopDefault(import("eslint-plugin-solid")),
1575
- interopDefault(import("@typescript-eslint/parser"))
1576
- ]);
1577
- return [
1578
- {
1579
- name: "vinicunca/solid/setup",
1580
- plugins: {
1581
- solid: pluginSolid
1582
- }
1583
- },
1584
- {
1585
- files,
1586
- languageOptions: {
1587
- parser: parserTs,
1588
- parserOptions: {
1589
- ecmaFeatures: {
1590
- jsx: true
1591
- },
1592
- ...isTypeAware ? { project: tsconfigPath } : {}
1593
- },
1594
- sourceType: "module"
1595
- },
1596
- name: "vinicunca/solid/rules",
1597
- rules: {
1598
- // reactivity
1599
- "solid/components-return-once": WARN,
1600
- "solid/event-handlers": [ERROR, {
1601
- // if true, don't warn on ambiguously named event handlers like `onclick` or `onchange`
1602
- ignoreCase: false,
1603
- // if true, warn when spreading event handlers onto JSX. Enable for Solid < v1.6.
1604
- warnOnSpread: false
1605
- }],
1606
- // these rules are mostly style suggestions
1607
- "solid/imports": ERROR,
1608
- // identifier usage is important
1609
- "solid/jsx-no-duplicate-props": ERROR,
1610
- "solid/jsx-no-script-url": ERROR,
1611
- "solid/jsx-no-undef": ERROR,
1612
- "solid/jsx-uses-vars": ERROR,
1613
- "solid/no-destructure": ERROR,
1614
- // security problems
1615
- "solid/no-innerhtml": [ERROR, { allowStatic: true }],
1616
- "solid/no-react-deps": ERROR,
1617
- "solid/no-react-specific-props": ERROR,
1618
- "solid/no-unknown-namespaces": ERROR,
1619
- "solid/prefer-for": ERROR,
1620
- "solid/reactivity": WARN,
1621
- "solid/self-closing-comp": ERROR,
1622
- "solid/style-prop": [ERROR, { styleProps: ["style", "css"] }],
1623
- ...typescript2 ? {
1624
- "solid/jsx-no-undef": [ERROR, { typescriptEnabled: true }],
1625
- "solid/no-unknown-namespaces": OFF
1626
- } : {},
1627
- // overrides
1628
- ...overrides
1629
- }
1630
- }
1631
- ];
1632
- }
1633
-
1634
- // src/configs/sonar.ts
1635
- async function sonar() {
1636
- return [
1637
- {
1638
- name: "vinicunca/sonar/rules",
1639
- plugins: {
1640
- sonar: import_eslint_plugin_sonarjs.default
1641
- },
1642
- rules: {
1643
- ...import_eslint_plugin_sonarjs.default.configs.recommended.rules,
1644
- "sonar/todo-tag": OFF,
1645
- "sonar/pseudo-random": OFF,
1646
- "sonar/slow-regex": OFF,
1647
- "sonar/cognitive-complexity": OFF,
1648
- "sonar/no-unused-vars": OFF
1649
- }
1650
- }
1651
- ];
1652
- }
1653
-
1654
- // src/configs/sort-package-json.ts
1655
- async function sortPackageJson() {
1656
- return [
1657
- {
1658
- files: ["**/package.json"],
1659
- name: "vinicunca/sort/package-json",
1660
- rules: {
1661
- "jsonc/sort-array-values": [
1662
- ERROR,
1663
- {
1664
- order: { type: "asc" },
1665
- pathPattern: "^files$"
1666
- }
1667
- ],
1668
- "jsonc/sort-keys": [
1669
- ERROR,
1670
- {
1671
- order: [
1672
- "publisher",
1673
- "name",
1674
- "displayName",
1675
- "type",
1676
- "version",
1677
- "private",
1678
- "packageManager",
1679
- "description",
1680
- "author",
1681
- "contributors",
1682
- "license",
1683
- "funding",
1684
- "homepage",
1685
- "repository",
1686
- "bugs",
1687
- "keywords",
1688
- "categories",
1689
- "sideEffects",
1690
- "exports",
1691
- "main",
1692
- "module",
1693
- "unpkg",
1694
- "jsdelivr",
1695
- "types",
1696
- "typesVersions",
1697
- "bin",
1698
- "icon",
1699
- "files",
1700
- "engines",
1701
- "activationEvents",
1702
- "contributes",
1703
- "scripts",
1704
- "peerDependencies",
1705
- "peerDependenciesMeta",
1706
- "dependencies",
1707
- "optionalDependencies",
1708
- "devDependencies",
1709
- "pnpm",
1710
- "overrides",
1711
- "resolutions",
1712
- "husky",
1713
- "simple-git-hooks",
1714
- "lint-staged",
1715
- "eslintConfig"
1716
- ],
1717
- pathPattern: "^$"
1718
- },
1719
- {
1720
- order: { type: "asc" },
1721
- pathPattern: "^(?:dev|peer|optional|bundled)?[Dd]ependencies$"
1722
- },
1723
- {
1724
- order: { type: "asc" },
1725
- pathPattern: "^resolutions$"
1726
- },
1727
- {
1728
- order: { type: "asc" },
1729
- pathPattern: "^pnpm.overrides$"
1730
- },
1731
- {
1732
- order: [
1733
- "types",
1734
- "import",
1735
- "require",
1736
- "default"
1737
- ],
1738
- pathPattern: "^exports.*$"
1739
- },
1740
- {
1741
- order: [
1742
- // client hooks only
1743
- "pre-commit",
1744
- "prepare-commit-msg",
1745
- "commit-msg",
1746
- "post-commit",
1747
- "pre-rebase",
1748
- "post-rewrite",
1749
- "post-checkout",
1750
- "post-merge",
1751
- "pre-push",
1752
- "pre-auto-gc"
1753
- ],
1754
- pathPattern: "^(?:gitHooks|husky|simple-git-hooks)$"
1755
- }
1756
- ]
1757
- }
1758
- }
1759
- ];
1760
- }
1761
- function sortTsconfig() {
1762
- return [
1763
- {
1764
- files: ["**/tsconfig.json", "**/tsconfig.*.json"],
1765
- name: "vinicunca/sort/tsconfig",
1766
- rules: {
1767
- "jsonc/sort-keys": [
1768
- ERROR,
1769
- {
1770
- order: [
1771
- "extends",
1772
- "compilerOptions",
1773
- "references",
1774
- "files",
1775
- "include",
1776
- "exclude"
1777
- ],
1778
- pathPattern: "^$"
1779
- },
1780
- {
1781
- order: [
1782
- /* Projects */
1783
- "incremental",
1784
- "composite",
1785
- "tsBuildInfoFile",
1786
- "disableSourceOfProjectReferenceRedirect",
1787
- "disableSolutionSearching",
1788
- "disableReferencedProjectLoad",
1789
- /* Language and Environment */
1790
- "target",
1791
- "jsx",
1792
- "jsxFactory",
1793
- "jsxFragmentFactory",
1794
- "jsxImportSource",
1795
- "lib",
1796
- "moduleDetection",
1797
- "noLib",
1798
- "reactNamespace",
1799
- "useDefineForClassFields",
1800
- "emitDecoratorMetadata",
1801
- "experimentalDecorators",
1802
- /* Modules */
1803
- "baseUrl",
1804
- "rootDir",
1805
- "rootDirs",
1806
- "customConditions",
1807
- "module",
1808
- "moduleResolution",
1809
- "moduleSuffixes",
1810
- "noResolve",
1811
- "paths",
1812
- "resolveJsonModule",
1813
- "resolvePackageJsonExports",
1814
- "resolvePackageJsonImports",
1815
- "typeRoots",
1816
- "types",
1817
- "allowArbitraryExtensions",
1818
- "allowImportingTsExtensions",
1819
- "allowUmdGlobalAccess",
1820
- /* JavaScript Support */
1821
- "allowJs",
1822
- "checkJs",
1823
- "maxNodeModuleJsDepth",
1824
- /* Type Checking */
1825
- "strict",
1826
- "strictBindCallApply",
1827
- "strictFunctionTypes",
1828
- "strictNullChecks",
1829
- "strictPropertyInitialization",
1830
- "allowUnreachableCode",
1831
- "allowUnusedLabels",
1832
- "alwaysStrict",
1833
- "exactOptionalPropertyTypes",
1834
- "noFallthroughCasesInSwitch",
1835
- "noImplicitAny",
1836
- "noImplicitOverride",
1837
- "noImplicitReturns",
1838
- "noImplicitThis",
1839
- "noPropertyAccessFromIndexSignature",
1840
- "noUncheckedIndexedAccess",
1841
- "noUnusedLocals",
1842
- "noUnusedParameters",
1843
- "useUnknownInCatchVariables",
1844
- /* Emit */
1845
- "declaration",
1846
- "declarationDir",
1847
- "declarationMap",
1848
- "downlevelIteration",
1849
- "emitBOM",
1850
- "emitDeclarationOnly",
1851
- "importHelpers",
1852
- "importsNotUsedAsValues",
1853
- "inlineSourceMap",
1854
- "inlineSources",
1855
- "mapRoot",
1856
- "newLine",
1857
- "noEmit",
1858
- "noEmitHelpers",
1859
- "noEmitOnError",
1860
- "outDir",
1861
- "outFile",
1862
- "preserveConstEnums",
1863
- "preserveValueImports",
1864
- "removeComments",
1865
- "sourceMap",
1866
- "sourceRoot",
1867
- "stripInternal",
1868
- /* Interop Constraints */
1869
- "allowSyntheticDefaultImports",
1870
- "esModuleInterop",
1871
- "forceConsistentCasingInFileNames",
1872
- "isolatedModules",
1873
- "preserveSymlinks",
1874
- "verbatimModuleSyntax",
1875
- /* Completeness */
1876
- "skipDefaultLibCheck",
1877
- "skipLibCheck"
1878
- ],
1879
- pathPattern: "^compilerOptions$"
1880
- }
1881
- ]
1882
- }
1883
- }
1884
- ];
1885
- }
1886
-
1887
- // src/configs/svelte.ts
1888
- async function svelte(options = {}) {
1889
- const {
1890
- files = [GLOB_SVELTE],
1891
- overrides = {},
1892
- stylistic: stylistic2 = true
1893
- } = options;
1894
- const {
1895
- indent = 2,
1896
- quotes = "single"
1897
- } = e2(stylistic2) ? {} : stylistic2;
1898
- const [
1899
- pluginSvelte,
1900
- parserSvelte
1901
- ] = await Promise.all([
1902
- interopDefault(import("eslint-plugin-svelte")),
1903
- interopDefault(import("svelte-eslint-parser"))
1904
- ]);
1905
- return [
1906
- {
1907
- name: "vinicunca/svelte/setup",
1908
- plugins: {
1909
- svelte: pluginSvelte
1910
- }
1911
- },
1912
- {
1913
- files,
1914
- languageOptions: {
1915
- parser: parserSvelte,
1916
- parserOptions: {
1917
- extraFileExtensions: [".svelte"],
1918
- parser: options.typescript ? await interopDefault(import("@typescript-eslint/parser")) : null
1919
- }
1920
- },
1921
- name: "vinicunca/svelte/rules",
1922
- processor: pluginSvelte.processors[".svelte"],
1923
- rules: {
1924
- "import/no-mutable-exports": OFF,
1925
- "no-undef": OFF,
1926
- // incompatible with most recent (attribute-form) generic types RFC
1927
- "no-unused-vars": [ERROR, {
1928
- args: "none",
1929
- caughtErrors: "none",
1930
- ignoreRestSiblings: true,
1931
- vars: "all",
1932
- varsIgnorePattern: "^(\\$\\$Props$|\\$\\$Events$|\\$\\$Slots$)"
1933
- }],
1934
- "svelte/comment-directive": ERROR,
1935
- "svelte/no-at-debug-tags": "warn",
1936
- "svelte/no-at-html-tags": ERROR,
1937
- "svelte/no-dupe-else-if-blocks": ERROR,
1938
- "svelte/no-dupe-style-properties": ERROR,
1939
- "svelte/no-dupe-use-directives": ERROR,
1940
- "svelte/no-dynamic-slot-name": ERROR,
1941
- "svelte/no-export-load-in-svelte-module-in-kit-pages": ERROR,
1942
- "svelte/no-inner-declarations": ERROR,
1943
- "svelte/no-not-function-handler": ERROR,
1944
- "svelte/no-object-in-text-mustaches": ERROR,
1945
- "svelte/no-reactive-functions": ERROR,
1946
- "svelte/no-reactive-literals": ERROR,
1947
- "svelte/no-shorthand-style-property-overrides": ERROR,
1948
- "svelte/no-unknown-style-directive-property": ERROR,
1949
- "svelte/no-unused-svelte-ignore": ERROR,
1950
- "svelte/no-useless-mustaches": ERROR,
1951
- "svelte/require-store-callbacks-use-set-param": ERROR,
1952
- "svelte/system": ERROR,
1953
- "svelte/valid-each-key": ERROR,
1954
- "unused-imports/no-unused-vars": [
1955
- ERROR,
1956
- {
1957
- args: "after-used",
1958
- argsIgnorePattern: "^_",
1959
- vars: "all",
1960
- varsIgnorePattern: "^(_|\\$\\$Props$|\\$\\$Events$|\\$\\$Slots$)"
1961
- }
1962
- ],
1963
- ...stylistic2 ? {
1964
- "style/indent": OFF,
1965
- // superseded by svelte/indent
1966
- "style/no-trailing-spaces": OFF,
1967
- // superseded by svelte/no-trailing-spaces
1968
- "svelte/derived-has-same-inputs-outputs": ERROR,
1969
- "svelte/html-closing-bracket-spacing": ERROR,
1970
- // quotes only supports single and double quotes but in options we have backtick as well
1971
- "svelte/html-quotes": [ERROR, { prefer: quotes }],
1972
- "svelte/indent": [ERROR, { alignAttributesVertically: true, indent }],
1973
- "svelte/mustache-spacing": ERROR,
1974
- "svelte/no-spaces-around-equal-signs-in-attribute": ERROR,
1975
- "svelte/no-trailing-spaces": ERROR,
1976
- "svelte/spaced-html-comment": ERROR
1977
- } : {},
1978
- ...overrides
1979
- }
1980
- }
1981
- ];
1982
- }
1983
-
1984
- // src/configs/test.ts
1985
- var _pluginTest;
1986
- async function test(options = {}) {
1987
- const {
1988
- files = GLOB_TESTS,
1989
- isInEditor = false,
1990
- overrides = {}
1991
- } = options;
1992
- const [
1993
- pluginVitest,
1994
- pluginNoOnlyTests
1995
- ] = await Promise.all([
1996
- interopDefault(import("@vitest/eslint-plugin")),
1997
- // @ts-expect-error missing types
1998
- interopDefault(import("eslint-plugin-no-only-tests"))
1999
- ]);
2000
- _pluginTest = _pluginTest || {
2001
- ...pluginVitest,
2002
- rules: {
2003
- ...pluginVitest.rules,
2004
- // extend `test/no-only-tests` rule
2005
- ...pluginNoOnlyTests.rules
2006
- }
2007
- };
2008
- return [
2009
- {
2010
- name: "vinicunca/test/setup",
2011
- plugins: {
2012
- test: _pluginTest
2013
- }
2014
- },
2015
- {
2016
- files,
2017
- name: "vinicunca/test/rules",
2018
- rules: {
2019
- "node/prefer-global/process": OFF,
2020
- "sonar/no-duplicate-string": OFF,
2021
- "test/consistent-test-it": [ERROR, { fn: "it", withinDescribe: "it" }],
2022
- "test/no-identical-title": ERROR,
2023
- "test/no-only-tests": isInEditor ? OFF : ERROR,
2024
- "test/prefer-hooks-in-order": ERROR,
2025
- "test/prefer-lowercase-title": ERROR,
2026
- ...overrides
2027
- }
2028
- }
2029
- ];
2030
- }
2031
-
2032
- // src/configs/toml.ts
2033
- async function toml(options = {}) {
2034
- const {
2035
- files = [GLOB_TOML],
2036
- overrides = {},
2037
- stylistic: stylistic2 = true
2038
- } = options;
2039
- const {
2040
- indent = 2
2041
- } = e2(stylistic2) ? {} : stylistic2;
2042
- const [
2043
- pluginToml,
2044
- parserToml
2045
- ] = await Promise.all([
2046
- interopDefault(import("eslint-plugin-toml")),
2047
- interopDefault(import("toml-eslint-parser"))
2048
- ]);
2049
- return [
2050
- {
2051
- name: "vinicunca/toml/setup",
2052
- plugins: {
2053
- toml: pluginToml
2054
- }
2055
- },
2056
- {
2057
- files,
2058
- languageOptions: {
2059
- parser: parserToml
2060
- },
2061
- name: "vinicunca/toml/rules",
2062
- rules: {
2063
- "style/spaced-comment": OFF,
2064
- "toml/comma-style": ERROR,
2065
- "toml/keys-order": ERROR,
2066
- "toml/no-space-dots": ERROR,
2067
- "toml/no-unreadable-number-separator": ERROR,
2068
- "toml/precision-of-fractional-seconds": ERROR,
2069
- "toml/precision-of-integer": ERROR,
2070
- "toml/tables-order": ERROR,
2071
- "toml/vue-custom-block/no-parsing-error": ERROR,
2072
- ...stylistic2 ? {
2073
- "toml/array-bracket-newline": ERROR,
2074
- "toml/array-bracket-spacing": ERROR,
2075
- "toml/array-element-newline": ERROR,
2076
- "toml/indent": [ERROR, indent === "tab" ? 2 : indent],
2077
- "toml/inline-table-curly-spacing": ERROR,
2078
- "toml/key-spacing": ERROR,
2079
- "toml/padding-line-between-pairs": ERROR,
2080
- "toml/padding-line-between-tables": ERROR,
2081
- "toml/quoted-keys": ERROR,
2082
- "toml/spaced-comment": ERROR,
2083
- "toml/table-bracket-spacing": ERROR
2084
- } : {},
2085
- ...overrides
2086
- }
2087
- }
2088
- ];
2089
- }
2090
-
2091
- // src/configs/typescript.ts
2092
- var import_node_process2 = __toESM(require("process"), 1);
2093
- async function typescript(options = {}) {
2094
- const {
2095
- componentExts = [],
2096
- overrides = {},
2097
- overridesTypeAware = {},
2098
- parserOptions = {},
2099
- type = "app"
2100
- } = options ?? {};
2101
- const files = options.files ?? [
2102
- GLOB_TS,
2103
- GLOB_TSX,
2104
- ...componentExts.map((ext) => `**/*.${ext}`)
2105
- ];
2106
- const filesTypeAware = options.filesTypeAware ?? [GLOB_TS, GLOB_TSX];
2107
- const ignoresTypeAware = options.ignoresTypeAware ?? [
2108
- `${GLOB_MARKDOWN}/**`,
2109
- GLOB_ASTRO_TS
2110
- ];
2111
- const tsconfigPath = options?.tsconfigPath ? options.tsconfigPath : void 0;
2112
- const isTypeAware = !!tsconfigPath;
2113
- const typeAwareRules = {
2114
- "dot-notation": OFF,
2115
- "no-implied-eval": OFF,
2116
- "ts/await-thenable": ERROR,
2117
- "ts/dot-notation": [ERROR, { allowKeywords: true }],
2118
- "ts/no-floating-promises": ERROR,
2119
- "ts/no-for-in-array": ERROR,
2120
- "ts/no-implied-eval": ERROR,
2121
- // Temporary turning it off due to performance
2122
- "ts/no-misused-promises": OFF,
2123
- "ts/no-unnecessary-type-assertion": ERROR,
2124
- "ts/no-unsafe-argument": ERROR,
2125
- "ts/no-unsafe-assignment": ERROR,
2126
- "ts/no-unsafe-call": ERROR,
2127
- "ts/no-unsafe-member-access": ERROR,
2128
- "ts/no-unsafe-return": ERROR,
2129
- "ts/promise-function-async": ERROR,
2130
- "ts/restrict-plus-operands": ERROR,
2131
- "ts/restrict-template-expressions": ERROR,
2132
- "ts/return-await": [ERROR, "in-try-catch"],
2133
- "ts/strict-boolean-expressions": [ERROR, { allowNullableBoolean: true, allowNullableObject: true }],
2134
- "ts/switch-exhaustiveness-check": ERROR,
2135
- "ts/unbound-method": ERROR
2136
- };
2137
- const [
2138
- pluginTs,
2139
- parserTs
2140
- ] = await Promise.all([
2141
- interopDefault(import("@typescript-eslint/eslint-plugin")),
2142
- interopDefault(import("@typescript-eslint/parser"))
2143
- ]);
2144
- function makeParser({ files: files2, ignores: ignores2, typeAware }) {
2145
- return {
2146
- files: files2,
2147
- ...ignores2 ? { ignores: ignores2 } : {},
2148
- languageOptions: {
2149
- parser: parserTs,
2150
- parserOptions: {
2151
- extraFileExtensions: componentExts.map((ext) => `.${ext}`),
2152
- sourceType: "module",
2153
- ...typeAware ? {
2154
- projectService: {
2155
- allowDefaultProject: ["./*.js"],
2156
- defaultProject: tsconfigPath
2157
- },
2158
- tsconfigRootDir: import_node_process2.default.cwd()
2159
- } : {},
2160
- ...parserOptions
2161
- }
2162
- },
2163
- name: `vinicunca/typescript/${typeAware ? "type-aware-parser" : "parser"}`
2164
- };
2165
- }
2166
- return [
2167
- {
2168
- // Install the plugins without globs, so they can be configured separately.
2169
- name: "vinicunca/typescript/setup",
2170
- plugins: {
2171
- antfu: import_eslint_plugin_antfu.default,
2172
- ts: pluginTs
2173
- }
2174
- },
2175
- // assign type-aware parser for type-aware files and type-unaware parser for the rest
2176
- ...isTypeAware ? [
2177
- makeParser({ files: filesTypeAware, ignores: ignoresTypeAware, typeAware: true }),
2178
- makeParser({ files, ignores: filesTypeAware, typeAware: false })
2179
- ] : [
2180
- makeParser({ files, typeAware: false })
2181
- ],
2182
- {
2183
- files,
2184
- name: "vinicunca/typescript/rules",
2185
- rules: {
2186
- ...renameRules(
2187
- pluginTs.configs["eslint-recommended"].overrides[0].rules,
2188
- { "@typescript-eslint": "ts" }
2189
- ),
2190
- ...renameRules(
2191
- pluginTs.configs.strict.rules,
2192
- { "@typescript-eslint": "ts" }
2193
- ),
2194
- "no-dupe-class-members": OFF,
2195
- "no-invalid-this": OFF,
2196
- "no-loss-of-precision": OFF,
2197
- "no-redeclare": OFF,
2198
- "no-unused-vars": OFF,
2199
- "no-use-before-define": OFF,
2200
- "no-useless-constructor": OFF,
2201
- "ts/array-type": [ERROR, { default: "generic" }],
2202
- "ts/ban-ts-comment": [ERROR, { "ts-expect-error": "allow-with-description" }],
2203
- "ts/consistent-type-definitions": [ERROR, "interface"],
2204
- "ts/consistent-type-imports": [ERROR, { disallowTypeAnnotations: false, prefer: "type-imports" }],
2205
- "ts/explicit-member-accessibility": OFF,
2206
- "ts/explicit-module-boundary-types": OFF,
2207
- // https://www.totaltypescript.com/method-shorthand-syntax-considered-harmful
2208
- "ts/method-signature-style": [ERROR, "property"],
2209
- "ts/naming-convention": OFF,
2210
- "ts/no-dupe-class-members": ERROR,
2211
- "ts/no-empty-function": OFF,
2212
- "ts/no-empty-interface": OFF,
2213
- "ts/no-empty-object-type": [ERROR, { allowInterfaces: "always" }],
2214
- "ts/no-explicit-any": OFF,
2215
- "ts/no-import-type-side-effects": ERROR,
2216
- "ts/no-invalid-this": ERROR,
2217
- "ts/no-invalid-void-type": OFF,
2218
- "ts/no-loss-of-precision": ERROR,
2219
- "ts/no-non-null-assertion": OFF,
2220
- "ts/no-redeclare": ERROR,
2221
- "ts/no-require-imports": ERROR,
2222
- "ts/no-unused-vars": [ERROR, {
2223
- argsIgnorePattern: "^_",
2224
- destructuredArrayIgnorePattern: "^_",
2225
- ignoreRestSiblings: true,
2226
- varsIgnorePattern: "^_"
2227
- }],
2228
- "ts/no-use-before-define": [ERROR, { classes: false, functions: false, variables: true }],
2229
- "ts/parameter-properties": OFF,
2230
- "ts/prefer-ts-expect-error": ERROR,
2231
- "ts/triple-slash-reference": OFF,
2232
- ...type === "lib" ? {
2233
- "ts/explicit-function-return-type": [ERROR, {
2234
- allowExpressions: true,
2235
- allowHigherOrderFunctions: true,
2236
- allowIIFEs: true
2237
- }]
2238
- } : {},
2239
- ...overrides
2240
- }
2241
- },
2242
- ...isTypeAware ? [{
2243
- files: filesTypeAware,
2244
- ignores: ignoresTypeAware,
2245
- name: "vinicunca/typescript/rules-type-aware",
2246
- rules: {
2247
- ...typeAwareRules,
2248
- ...overridesTypeAware
2249
- }
2250
- }] : [],
2251
- {
2252
- files: ["**/*.d.?([cm])ts"],
2253
- name: "vinicunca/typescript/disables/dts",
2254
- rules: {
2255
- "eslint-comments/no-unlimited-disable": OFF,
2256
- "import/no-duplicates": OFF,
2257
- "no-restricted-syntax": OFF,
2258
- "unused-imports/no-unused-vars": OFF
2259
- }
2260
- },
2261
- {
2262
- files: ["**/*.{test,spec}.ts?(x)"],
2263
- name: "vinicunca/typescript/disables/tests",
2264
- rules: {
2265
- "no-unused-expressions": OFF
2266
- }
2267
- },
2268
- {
2269
- files: ["**/*.js", "**/*.cjs"],
2270
- name: "vinicunca/typescript/disables/javascript",
2271
- rules: {
2272
- "ts/no-require-imports": OFF,
2273
- "ts/no-var-requires": OFF
2274
- }
2275
- }
2276
- ];
2277
- }
2278
-
2279
- // src/configs/unicorn.ts
2280
- async function unicorn(options = {}) {
2281
- return [
2282
- {
2283
- name: "vinicunca/unicorn/rules",
2284
- plugins: {
2285
- unicorn: import_eslint_plugin_unicorn.default
2286
- },
2287
- rules: {
2288
- ...options.allRecommended ? import_eslint_plugin_unicorn.default.configs["flat/recommended"].rules : {
2289
- "unicorn/error-message": ERROR,
2290
- "unicorn/escape-case": ERROR,
2291
- "unicorn/no-instanceof-array": ERROR,
2292
- "unicorn/no-new-array": ERROR,
2293
- "unicorn/no-new-buffer": ERROR,
2294
- "unicorn/number-literal-case": ERROR,
2295
- "unicorn/prefer-dom-node-text-content": ERROR,
2296
- "unicorn/prefer-includes": ERROR,
2297
- "unicorn/prefer-node-protocol": ERROR,
2298
- "unicorn/prefer-number-properties": ERROR,
2299
- "unicorn/prefer-string-starts-ends-with": ERROR,
2300
- "unicorn/prefer-type-error": ERROR,
2301
- "unicorn/throw-new-error": ERROR
2302
- }
2303
- }
2304
- }
2305
- ];
2306
- }
2307
-
2308
- // src/configs/unocss.ts
2309
- async function unocss(options = {}) {
2310
- const {
2311
- attributify = false,
2312
- strict = false
2313
- } = options;
2314
- const [
2315
- pluginUnoCSS
2316
- ] = await Promise.all([
2317
- interopDefault(import("@unocss/eslint-plugin"))
2318
- ]);
2319
- return [
2320
- {
2321
- name: "vinicunca/unocss",
2322
- plugins: {
2323
- unocss: pluginUnoCSS
2324
- },
2325
- rules: {
2326
- "unocss/order": WARN,
2327
- ...attributify ? {
2328
- "unocss/order-attributify": WARN
2329
- } : {},
2330
- ...strict ? {
2331
- "unocss/blocklist": ERROR
2332
- } : {}
2333
- }
2334
- }
2335
- ];
2336
- }
2337
-
2338
- // src/configs/vue.ts
2339
- var import_eslint_merge_processors2 = require("eslint-merge-processors");
2340
- async function vue(options = {}) {
2341
- const {
2342
- files = [GLOB_VUE],
2343
- overrides = {},
2344
- stylistic: stylistic2 = true
2345
- } = options;
2346
- const sfcBlocks = options.sfcBlocks === true ? {} : options.sfcBlocks ?? {};
2347
- const {
2348
- indent = 2
2349
- } = e2(stylistic2) ? {} : stylistic2;
2350
- const [
2351
- pluginVue,
2352
- parserVue,
2353
- processorVueBlocks
2354
- ] = await Promise.all([
2355
- interopDefault(import("eslint-plugin-vue")),
2356
- interopDefault(import("vue-eslint-parser")),
2357
- interopDefault(import("eslint-processor-vue-blocks"))
2358
- ]);
2359
- return [
2360
- {
2361
- name: "vinicunca/vue/setup",
2362
- plugins: {
2363
- vue: pluginVue
2364
- },
2365
- // This allows Vue plugin to work with auto imports
2366
- // https://github.com/vuejs/eslint-plugin-vue/pull/2422
2367
- languageOptions: {
2368
- globals: {
2369
- computed: "readonly",
2370
- defineEmits: "readonly",
2371
- defineExpose: "readonly",
2372
- defineProps: "readonly",
2373
- onMounted: "readonly",
2374
- onUnmounted: "readonly",
2375
- reactive: "readonly",
2376
- ref: "readonly",
2377
- shallowReactive: "readonly",
2378
- shallowRef: "readonly",
2379
- toRef: "readonly",
2380
- toRefs: "readonly",
2381
- watch: "readonly",
2382
- watchEffect: "readonly"
2383
- }
2384
- }
2385
- },
2386
- {
2387
- files,
2388
- languageOptions: {
2389
- parser: parserVue,
2390
- parserOptions: {
2391
- ecmaFeatures: {
2392
- jsx: true
2393
- },
2394
- extraFileExtensions: [".vue"],
2395
- parser: options.typescript ? await interopDefault(import("@typescript-eslint/parser")) : null,
2396
- sourceType: "module"
2397
- }
2398
- },
2399
- name: "vinicunca/vue/rules",
2400
- processor: sfcBlocks === false ? pluginVue.processors[".vue"] : (0, import_eslint_merge_processors2.mergeProcessors)([
2401
- pluginVue.processors[".vue"],
2402
- processorVueBlocks({
2403
- ...sfcBlocks,
2404
- blocks: {
2405
- styles: true,
2406
- ...sfcBlocks.blocks
2407
- }
2408
- })
2409
- ]),
2410
- rules: {
2411
- ...pluginVue.configs.base.rules,
2412
- ...pluginVue.configs["vue3-essential"].rules,
2413
- ...pluginVue.configs["vue3-strongly-recommended"].rules,
2414
- ...pluginVue.configs["vue3-recommended"].rules,
2415
- "node/prefer-global/process": OFF,
2416
- "vue/block-order": [ERROR, {
2417
- order: ["script", "template", "style"]
2418
- }],
2419
- "vue/component-name-in-template-casing": [ERROR, "PascalCase"],
2420
- "vue/component-options-name-casing": [ERROR, "PascalCase"],
2421
- "vue/custom-event-name-casing": [ERROR, "camelCase"],
2422
- "vue/define-macros-order": [ERROR, {
2423
- order: ["defineOptions", "defineProps", "defineEmits", "defineSlots"]
2424
- }],
2425
- "vue/dot-location": [ERROR, "property"],
2426
- "vue/dot-notation": [ERROR, { allowKeywords: true }],
2427
- "vue/eqeqeq": [ERROR, "smart"],
2428
- "vue/html-indent": [ERROR, indent],
2429
- "vue/max-attributes-per-line": [ERROR],
2430
- "vue/multi-word-component-names": OFF,
2431
- "vue/no-constant-condition": WARN,
2432
- "vue/no-dupe-keys": OFF,
2433
- "vue/no-empty-pattern": ERROR,
2434
- "vue/no-extra-parens": [ERROR, "functions"],
2435
- "vue/no-irregular-whitespace": ERROR,
2436
- "vue/no-loss-of-precision": ERROR,
2437
- "vue/no-restricted-syntax": [
2438
- ERROR,
2439
- "DebuggerStatement",
2440
- "LabeledStatement",
2441
- "WithStatement"
2442
- ],
2443
- "vue/no-restricted-v-bind": [ERROR, "/^v-/"],
2444
- // reactivity transform
2445
- "vue/no-setup-props-reactivity-loss": OFF,
2446
- "vue/no-sparse-arrays": ERROR,
2447
- "vue/no-unused-refs": ERROR,
2448
- "vue/no-useless-v-bind": ERROR,
2449
- "vue/no-v-html": OFF,
2450
- "vue/no-v-text-v-html-on-component": OFF,
2451
- "vue/object-shorthand": [ERROR, ALWAYS, {
2452
- avoidQuotes: true,
2453
- ignoreConstructors: false
2454
- }],
2455
- "vue/prefer-import-from-vue": OFF,
2456
- "vue/prefer-separate-static-class": ERROR,
2457
- "vue/prefer-template": ERROR,
2458
- "vue/require-default-prop": OFF,
2459
- "vue/require-prop-types": OFF,
2460
- "vue/space-infix-ops": ERROR,
2461
- "vue/space-unary-ops": [ERROR, {
2462
- nonwords: false,
2463
- words: true
2464
- }],
2465
- ...stylistic2 ? {
2466
- "vue/array-bracket-spacing": [ERROR, NEVER],
2467
- "vue/arrow-spacing": [ERROR, {
2468
- after: true,
2469
- before: true
2470
- }],
2471
- "vue/block-spacing": [ERROR, ALWAYS],
2472
- "vue/block-tag-newline": [ERROR, {
2473
- multiline: ALWAYS,
2474
- singleline: ALWAYS
2475
- }],
2476
- "vue/brace-style": [ERROR, "stroustrup", { allowSingleLine: true }],
2477
- "vue/comma-dangle": [ERROR, "always-multiline"],
2478
- "vue/comma-spacing": [ERROR, {
2479
- after: true,
2480
- before: false
2481
- }],
2482
- "vue/comma-style": [ERROR, "last"],
2483
- "vue/html-comment-content-spacing": [ERROR, ALWAYS, {
2484
- exceptions: ["-"]
2485
- }],
2486
- "vue/key-spacing": [ERROR, {
2487
- afterColon: true,
2488
- beforeColon: false
2489
- }],
2490
- "vue/keyword-spacing": [ERROR, {
2491
- after: true,
2492
- before: true
2493
- }],
2494
- "vue/object-curly-newline": [ERROR, { consistent: true, multiline: true }],
2495
- "vue/object-curly-spacing": [ERROR, ALWAYS],
2496
- "vue/object-property-newline": [ERROR, { allowMultiplePropertiesPerLine: true }],
2497
- "vue/operator-linebreak": [ERROR, "before"],
2498
- "vue/padding-line-between-blocks": [ERROR, ALWAYS],
2499
- "vue/quote-props": [ERROR, "consistent-as-needed"],
2500
- "vue/space-in-parens": [ERROR, NEVER],
2501
- "vue/template-curly-spacing": ERROR
2502
- } : {},
2503
- ...overrides
2504
- }
2505
- }
2506
- ];
2507
- }
2508
-
2509
- // src/configs/yaml.ts
2510
- async function yaml(options = {}) {
2511
- const {
2512
- files = [GLOB_YAML],
2513
- overrides = {},
2514
- stylistic: stylistic2 = true
2515
- } = options;
2516
- const {
2517
- indent = 2,
2518
- quotes = "single"
2519
- } = e2(stylistic2) ? {} : stylistic2;
2520
- const [
2521
- pluginYaml,
2522
- parserYaml
2523
- ] = await Promise.all([
2524
- interopDefault(import("eslint-plugin-yml")),
2525
- interopDefault(import("yaml-eslint-parser"))
2526
- ]);
2527
- return [
2528
- {
2529
- name: "vinicunca/yaml/setup",
2530
- plugins: {
2531
- yaml: pluginYaml
2532
- }
2533
- },
2534
- {
2535
- files,
2536
- languageOptions: {
2537
- parser: parserYaml
2538
- },
2539
- name: "vinicunca/yaml/rules",
2540
- rules: {
2541
- "style/spaced-comment": OFF,
2542
- "yaml/block-mapping": ERROR,
2543
- "yaml/block-sequence": ERROR,
2544
- "yaml/no-empty-key": ERROR,
2545
- "yaml/no-empty-sequence-entry": ERROR,
2546
- "yaml/no-irregular-whitespace": ERROR,
2547
- "yaml/plain-scalar": ERROR,
2548
- "yaml/vue-custom-block/no-parsing-error": ERROR,
2549
- ...stylistic2 ? {
2550
- "yaml/block-mapping-question-indicator-newline": ERROR,
2551
- "yaml/block-sequence-hyphen-indicator-newline": ERROR,
2552
- "yaml/flow-mapping-curly-newline": ERROR,
2553
- "yaml/flow-mapping-curly-spacing": ERROR,
2554
- "yaml/flow-sequence-bracket-newline": ERROR,
2555
- "yaml/flow-sequence-bracket-spacing": ERROR,
2556
- "yaml/indent": [ERROR, indent === "tab" ? 2 : indent],
2557
- "yaml/key-spacing": ERROR,
2558
- "yaml/no-tab-indent": ERROR,
2559
- "yaml/quotes": [ERROR, { avoidEscape: true, prefer: quotes === "backtick" ? "single" : quotes }],
2560
- "yaml/spaced-comment": ERROR
2561
- } : {},
2562
- ...overrides
2563
- }
2564
- },
2565
- {
2566
- files: ["pnpm-workspace.yaml"],
2567
- rules: {
2568
- "yaml/sort-keys": ERROR
2569
- }
2570
- }
2571
- ];
2572
- }
2573
-
2574
- // src/base.ts
2575
- var flatConfigProps = [
2576
- "name",
2577
- "languageOptions",
2578
- "linterOptions",
2579
- "processor",
2580
- "plugins",
2581
- "rules",
2582
- "settings"
2583
- ];
2584
- var VuePackages = [
2585
- "vue",
2586
- "nuxt",
2587
- "vitepress",
2588
- "@slidev/cli"
2589
- ];
2590
- var defaultPluginRenaming = {
2591
- "@eslint-react": "react",
2592
- "@eslint-react/dom": "react-dom",
2593
- "@eslint-react/hooks-extra": "react-hooks-extra",
2594
- "@eslint-react/naming-convention": "react-naming-convention",
2595
- "@stylistic": "style",
2596
- "@typescript-eslint": "ts",
2597
- "import-x": "import",
2598
- "n": "node",
2599
- "sonarjs": "sonar",
2600
- "vitest": "test",
2601
- "yml": "yaml"
2602
- };
2603
- function vinicuncaESLint(options = {}, ...userConfigs) {
2604
- const {
2605
- astro: enableAstro = false,
2606
- autoRenamePlugins = true,
2607
- componentExts = [],
2608
- gitignore: enableGitignore = true,
2609
- jsx: enableJsx = true,
2610
- react: enableReact = false,
2611
- regexp: enableRegexp = true,
2612
- solid: enableSolid = false,
2613
- svelte: enableSvelte = false,
2614
- typescript: enableTypeScript = (0, import_local_pkg4.isPackageExists)("typescript"),
2615
- unicorn: enableUnicorn = true,
2616
- unocss: enableUnoCSS = false,
2617
- vue: enableVue = VuePackages.some((i) => (0, import_local_pkg4.isPackageExists)(i))
2618
- } = options;
2619
- let isInEditor = options.isInEditor;
2620
- if (isInEditor == null) {
2621
- isInEditor = isInEditorEnv();
2622
- if (isInEditor) {
2623
- console.log("[@vinicunca/eslint-config] Detected running in editor, some rules are disabled.");
2624
- }
2625
- }
2626
- let stylisticOptions = {};
2627
- if (options.stylistic === false) {
2628
- stylisticOptions = false;
2629
- } else if (r(options.stylistic)) {
2630
- stylisticOptions = options.stylistic;
2631
- } else {
2632
- stylisticOptions = {};
2633
- }
2634
- if (stylisticOptions && !("jsx" in stylisticOptions)) {
2635
- stylisticOptions.jsx = enableJsx;
2636
- }
2637
- const configs2 = [];
2638
- if (enableGitignore) {
2639
- if (!e2(enableGitignore)) {
2640
- configs2.push(interopDefault(import("eslint-config-flat-gitignore")).then((r2) => [r2({
2641
- name: "vinicunca/gitignore",
2642
- ...enableGitignore
2643
- })]));
2644
- } else {
2645
- configs2.push(interopDefault(import("eslint-config-flat-gitignore")).then((r2) => [r2({
2646
- name: "vinicunca/gitignore",
2647
- strict: false
2648
- })]));
2649
- }
2650
- }
2651
- const typescriptOptions = resolveSubOptions(options, "typescript");
2652
- const tsconfigPath = "tsconfigPath" in typescriptOptions ? typescriptOptions.tsconfigPath : void 0;
2653
- configs2.push(
2654
- ignores(options.ignores),
2655
- javascript({
2656
- isInEditor,
2657
- overrides: getOverrides(options, "javascript")
2658
- }),
2659
- comments(),
2660
- node(),
2661
- jsdoc({
2662
- stylistic: stylisticOptions
2663
- }),
2664
- imports({
2665
- stylistic: stylisticOptions
2666
- }),
2667
- command(),
2668
- perfectionist(),
2669
- sonar()
2670
- );
2671
- if (enableUnicorn) {
2672
- configs2.push(
2673
- unicorn(enableUnicorn === true ? {} : enableUnicorn)
2674
- );
2675
- }
2676
- if (enableVue) {
2677
- componentExts.push("vue");
2678
- }
2679
- if (enableJsx) {
2680
- configs2.push(jsx());
2681
- }
2682
- if (enableTypeScript) {
2683
- configs2.push(typescript({
2684
- ...typescriptOptions,
2685
- componentExts,
2686
- overrides: getOverrides(options, "typescript"),
2687
- type: options.type
2688
- }));
2689
- }
2690
- if (stylisticOptions) {
2691
- configs2.push(stylistic({
2692
- ...stylisticOptions,
2693
- overrides: getOverrides(options, "stylistic")
2694
- }));
2695
- }
2696
- if (enableRegexp) {
2697
- configs2.push(regexp(e2(enableRegexp) ? {} : enableRegexp));
2698
- }
2699
- if (options.test ?? true) {
2700
- configs2.push(test({
2701
- isInEditor,
2702
- overrides: getOverrides(options, "test")
2703
- }));
2704
- }
2705
- if (enableVue) {
2706
- configs2.push(vue({
2707
- ...resolveSubOptions(options, "vue"),
2708
- overrides: getOverrides(options, "vue"),
2709
- stylistic: stylisticOptions,
2710
- typescript: !!enableTypeScript
2711
- }));
2712
- }
2713
- if (enableReact) {
2714
- configs2.push(react({
2715
- ...typescriptOptions,
2716
- overrides: getOverrides(options, "react"),
2717
- tsconfigPath
2718
- }));
2719
- }
2720
- if (enableSolid) {
2721
- configs2.push(solid({
2722
- overrides: getOverrides(options, "solid"),
2723
- tsconfigPath,
2724
- typescript: !!enableTypeScript
2725
- }));
2726
- }
2727
- if (enableSvelte) {
2728
- configs2.push(svelte({
2729
- overrides: getOverrides(options, "svelte"),
2730
- stylistic: stylisticOptions,
2731
- typescript: !!enableTypeScript
2732
- }));
2733
- }
2734
- if (enableUnoCSS) {
2735
- configs2.push(unocss({
2736
- ...resolveSubOptions(options, "unocss"),
2737
- overrides: getOverrides(options, "unocss")
2738
- }));
2739
- }
2740
- if (enableAstro) {
2741
- configs2.push(astro({
2742
- overrides: getOverrides(options, "astro"),
2743
- stylistic: stylisticOptions
2744
- }));
2745
- }
2746
- if (options.jsonc ?? true) {
2747
- configs2.push(
2748
- jsonc({
2749
- overrides: getOverrides(options, "jsonc"),
2750
- stylistic: stylisticOptions
2751
- }),
2752
- sortPackageJson(),
2753
- sortTsconfig()
2754
- );
2755
- }
2756
- if (options.yaml ?? true) {
2757
- configs2.push(yaml({
2758
- overrides: getOverrides(options, "yaml"),
2759
- stylistic: stylisticOptions
2760
- }));
2761
- }
2762
- if (options.toml ?? true) {
2763
- configs2.push(toml({
2764
- overrides: getOverrides(options, "toml"),
2765
- stylistic: stylisticOptions
2766
- }));
2767
- }
2768
- if (options.markdown ?? true) {
2769
- configs2.push(
2770
- markdown(
2771
- {
2772
- componentExts,
2773
- overrides: getOverrides(options, "markdown")
2774
- }
2775
- )
2776
- );
2777
- }
2778
- if (options.formatters) {
2779
- configs2.push(formatters(
2780
- options.formatters,
2781
- e2(stylisticOptions) ? {} : stylisticOptions
2782
- ));
2783
- }
2784
- if ("files" in options) {
2785
- throw new Error('[@vinicunca/eslint-config] The first argument should not contain the "files" property as the options are supposed to be global. Place it in the second or later config instead.');
2786
- }
2787
- const fusedConfig = flatConfigProps.reduce((acc, key) => {
2788
- if (key in options) {
2789
- acc[key] = options[key];
2790
- }
2791
- ;
2792
- return acc;
2793
- }, {});
2794
- if (Object.keys(fusedConfig).length) {
2795
- configs2.push([fusedConfig]);
2796
- }
2797
- ;
2798
- let composer = new import_eslint_flat_config_utils.FlatConfigComposer();
2799
- composer = composer.append(
2800
- ...configs2,
2801
- ...userConfigs
2802
- );
2803
- if (autoRenamePlugins) {
2804
- composer = composer.renamePlugins(defaultPluginRenaming);
2805
- }
2806
- return composer;
2807
- }
2808
- function getOverrides(options, key) {
2809
- const sub = resolveSubOptions(options, key);
2810
- return {
2811
- ..."overrides" in sub ? sub.overrides : {}
2812
- };
2813
- }
2814
- function resolveSubOptions(options, key) {
2815
- return e2(options[key]) ? {} : options[key] || {};
2816
- }
2817
- // Annotate the CommonJS export names for ESM import in node:
2818
- 0 && (module.exports = {
2819
- GLOB_ALL_SRC,
2820
- GLOB_ASTRO,
2821
- GLOB_ASTRO_TS,
2822
- GLOB_CSS,
2823
- GLOB_EXCLUDE,
2824
- GLOB_GRAPHQL,
2825
- GLOB_HTML,
2826
- GLOB_JS,
2827
- GLOB_JSON,
2828
- GLOB_JSON5,
2829
- GLOB_JSONC,
2830
- GLOB_JSX,
2831
- GLOB_LESS,
2832
- GLOB_MARKDOWN,
2833
- GLOB_MARKDOWN_CODE,
2834
- GLOB_MARKDOWN_IN_MARKDOWN,
2835
- GLOB_POSTCSS,
2836
- GLOB_SCSS,
2837
- GLOB_SRC,
2838
- GLOB_SRC_EXT,
2839
- GLOB_STYLE,
2840
- GLOB_SVELTE,
2841
- GLOB_SVG,
2842
- GLOB_TESTS,
2843
- GLOB_TOML,
2844
- GLOB_TS,
2845
- GLOB_TSX,
2846
- GLOB_VUE,
2847
- GLOB_XML,
2848
- GLOB_YAML,
2849
- STYLISTIC_CONFIG_DEFAULTS,
2850
- astro,
2851
- combineConfigs,
2852
- command,
2853
- comments,
2854
- defaultPluginRenaming,
2855
- ensurePackages,
2856
- formatters,
2857
- ignores,
2858
- imports,
2859
- interopDefault,
2860
- isInEditorEnv,
2861
- isInGitHooksOrLintStaged,
2862
- isPackageInScope,
2863
- javascript,
2864
- jsdoc,
2865
- jsonc,
2866
- jsx,
2867
- markdown,
2868
- node,
2869
- parserPlain,
2870
- perfectionist,
2871
- pluginAntfu,
2872
- pluginComments,
2873
- pluginImport,
2874
- pluginNode,
2875
- pluginPerfectionist,
2876
- pluginSonar,
2877
- pluginUnicorn,
2878
- pluginUnusedImports,
2879
- react,
2880
- regexp,
2881
- renamePluginInConfigs,
2882
- renameRules,
2883
- solid,
2884
- sonar,
2885
- sortPackageJson,
2886
- sortTsconfig,
2887
- stylistic,
2888
- svelte,
2889
- test,
2890
- toArray,
2891
- toml,
2892
- typescript,
2893
- unicorn,
2894
- unocss,
2895
- vinicuncaESLint,
2896
- vue,
2897
- yaml
2898
- });