@vinicunca/eslint-config 2.7.8 → 2.8.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.js CHANGED
@@ -1,18 +1,23 @@
1
- // ../node_modules/.pnpm/@vinicunca+perkakas@1.0.4/node_modules/@vinicunca/perkakas/dist/chunk-HLL46USD.js
2
- function r(e2) {
3
- if (typeof e2 != "object" || e2 === null) return false;
4
- let o = Object.getPrototypeOf(e2);
1
+ // ../node_modules/.pnpm/@vinicunca+perkakas@1.0.5/node_modules/@vinicunca/perkakas/dist/chunk-HLL46USD.js
2
+ function r(e3) {
3
+ if (typeof e3 != "object" || e3 === null) return false;
4
+ let o = Object.getPrototypeOf(e3);
5
5
  return o === null || o === Object.prototype;
6
6
  }
7
7
 
8
- // ../node_modules/.pnpm/@vinicunca+perkakas@1.0.4/node_modules/@vinicunca/perkakas/dist/chunk-AZUJCNUP.js
8
+ // ../node_modules/.pnpm/@vinicunca+perkakas@1.0.5/node_modules/@vinicunca/perkakas/dist/chunk-AZUJCNUP.js
9
9
  function e(o) {
10
10
  return typeof o == "boolean";
11
11
  }
12
12
 
13
+ // ../node_modules/.pnpm/@vinicunca+perkakas@1.0.5/node_modules/@vinicunca/perkakas/dist/chunk-Q2HW4RVT.js
14
+ function e2(r2) {
15
+ return typeof r2 == "number" && !Number.isNaN(r2);
16
+ }
17
+
13
18
  // src/base.ts
14
19
  import { FlatConfigComposer } from "eslint-flat-config-utils";
15
- import { isPackageExists } from "local-pkg";
20
+ import { isPackageExists as isPackageExists4 } from "local-pkg";
16
21
 
17
22
  // src/flags.ts
18
23
  var ERROR = "error";
@@ -22,37 +27,9 @@ var CONSISTENT = "consistent";
22
27
  var NEVER = "never";
23
28
  var ALWAYS = "always";
24
29
 
25
- // src/plugins.ts
26
- import { default as default2 } from "eslint-plugin-antfu";
27
- import { default as default3 } from "eslint-plugin-eslint-comments";
28
- import * as pluginImport from "eslint-plugin-import-x";
29
- import { default as default4 } from "eslint-plugin-n";
30
- import { default as default5 } from "eslint-plugin-perfectionist";
31
- import { default as default6 } from "eslint-plugin-sonarjs";
32
- import { default as default7 } from "eslint-plugin-unicorn";
33
- import { default as default8 } from "eslint-plugin-unused-imports";
34
-
35
- // src/configs/comments.ts
36
- async function comments() {
37
- return [
38
- {
39
- name: "vinicunca/eslint-comments",
40
- plugins: {
41
- "eslint-comments": default3
42
- },
43
- rules: {
44
- "eslint-comments/no-aggregating-enable": ERROR,
45
- "eslint-comments/no-duplicate-disable": ERROR,
46
- "eslint-comments/no-unlimited-disable": ERROR,
47
- "eslint-comments/no-unused-enable": ERROR
48
- }
49
- }
50
- ];
51
- }
52
-
53
30
  // src/globs.ts
54
- var GLOB_SRC = "**/*.?([cm])[jt]s?(x)";
55
31
  var GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
32
+ var GLOB_SRC = "**/*.?([cm])[jt]s?(x)";
56
33
  var GLOB_JS = "**/*.?([cm])js";
57
34
  var GLOB_JSX = "**/*.?([cm])jsx";
58
35
  var GLOB_TS = "**/*.?([cm])ts";
@@ -67,9 +44,16 @@ var GLOB_JSON5 = "**/*.json5";
67
44
  var GLOB_JSONC = "**/*.jsonc";
68
45
  var GLOB_MARKDOWN = "**/*.md";
69
46
  var GLOB_MARKDOWN_IN_MARKDOWN = "**/*.md/*.md";
47
+ var GLOB_SVELTE = "**/*.svelte";
70
48
  var GLOB_VUE = "**/*.vue";
71
49
  var GLOB_YAML = "**/*.y?(a)ml";
50
+ var GLOB_TOML = "**/*.toml";
51
+ var GLOB_XML = "**/*.xml";
52
+ var GLOB_SVG = "**/*.svg";
72
53
  var GLOB_HTML = "**/*.htm?(l)";
54
+ var GLOB_ASTRO = "**/*.astro";
55
+ var GLOB_ASTRO_TS = "**/*.astro/*.ts";
56
+ var GLOB_GRAPHQL = "**/*.{g,graph}ql";
73
57
  var GLOB_MARKDOWN_CODE = `${GLOB_MARKDOWN}/${GLOB_SRC}`;
74
58
  var GLOB_TESTS = [
75
59
  `**/__tests__/**/*.${GLOB_SRC_EXT}`,
@@ -84,8 +68,10 @@ var GLOB_ALL_SRC = [
84
68
  GLOB_JSON,
85
69
  GLOB_JSON5,
86
70
  GLOB_MARKDOWN,
71
+ GLOB_SVELTE,
87
72
  GLOB_VUE,
88
73
  GLOB_YAML,
74
+ GLOB_XML,
89
75
  GLOB_HTML
90
76
  ];
91
77
  var GLOB_EXCLUDE = [
@@ -105,6 +91,7 @@ var GLOB_EXCLUDE = [
105
91
  "**/.vitepress/cache",
106
92
  "**/.nuxt",
107
93
  "**/.next",
94
+ "**/.svelte-kit",
108
95
  "**/.vercel",
109
96
  "**/.changeset",
110
97
  "**/.idea",
@@ -122,7 +109,31 @@ var GLOB_EXCLUDE = [
122
109
  ];
123
110
 
124
111
  // src/utils.ts
112
+ import { isPackageExists } from "local-pkg";
125
113
  import process from "node:process";
114
+ import { fileURLToPath } from "node:url";
115
+ var scopeUrl = fileURLToPath(new URL(".", import.meta.url));
116
+ var isCwdInScope = isPackageExists("@vinicunca/eslint-config");
117
+ var parserPlain = {
118
+ meta: {
119
+ name: "parser-plain"
120
+ },
121
+ parseForESLint: (code) => ({
122
+ ast: {
123
+ body: [],
124
+ comments: [],
125
+ loc: { end: code.length, start: 0 },
126
+ range: [0, code.length],
127
+ tokens: [],
128
+ type: "Program"
129
+ },
130
+ scopeManager: null,
131
+ services: { isPlain: true },
132
+ visitorKeys: {
133
+ Program: []
134
+ }
135
+ })
136
+ };
126
137
  async function combineConfigs(...configs2) {
127
138
  const resolved = await Promise.all(configs2);
128
139
  return resolved.flat();
@@ -158,36 +169,149 @@ function renamePluginInConfigs(configs2, map) {
158
169
  return clone;
159
170
  });
160
171
  }
172
+ function toArray(value) {
173
+ return Array.isArray(value) ? value : [value];
174
+ }
161
175
  async function interopDefault(m) {
162
176
  const resolved = await m;
163
177
  return resolved.default || resolved;
164
178
  }
165
- var parserPlain = {
166
- meta: {
167
- name: "parser-plain"
168
- },
169
- parseForESLint: (code) => ({
170
- ast: {
171
- body: [],
172
- comments: [],
173
- loc: { end: code.length, start: 0 },
174
- range: [0, code.length],
175
- tokens: [],
176
- type: "Program"
179
+ function isPackageInScope(name) {
180
+ return isPackageExists(name, { paths: [scopeUrl] });
181
+ }
182
+ async function ensurePackages(packages) {
183
+ if (process.env.CI || process.stdout.isTTY === false || isCwdInScope === false) {
184
+ return;
185
+ }
186
+ const nonExistingPackages = packages.filter((i) => i && !isPackageInScope(i));
187
+ if (nonExistingPackages.length === 0) {
188
+ return;
189
+ }
190
+ const p = await import("@clack/prompts");
191
+ const result = await p.confirm({
192
+ message: `${nonExistingPackages.length === 1 ? "Package is" : "Packages are"} required for this config: ${nonExistingPackages.join(", ")}. Do you want to install them?`
193
+ });
194
+ if (result) {
195
+ await import("@antfu/install-pkg").then((i) => i.installPackage(nonExistingPackages, { dev: true }));
196
+ }
197
+ }
198
+ function isInEditorEnv() {
199
+ if (process.env.CI) {
200
+ return false;
201
+ }
202
+ if (isInGitHooksOrLintStaged()) {
203
+ return false;
204
+ }
205
+ return !!(process.env.VSCODE_PID || process.env.VSCODE_CWD || process.env.JETBRAINS_IDE || process.env.VIM || process.env.NVIM);
206
+ }
207
+ function isInGitHooksOrLintStaged() {
208
+ return !!(process.env.GIT_PARAMS || process.env.VSCODE_GIT_COMMAND || process.env.npm_lifecycle_script?.startsWith("lint-staged"));
209
+ }
210
+
211
+ // src/configs/astro.ts
212
+ async function astro(options = {}) {
213
+ const {
214
+ files = [GLOB_ASTRO],
215
+ overrides = {},
216
+ stylistic: stylistic2 = true
217
+ } = options;
218
+ const [
219
+ pluginAstro,
220
+ parserAstro,
221
+ parserTs
222
+ ] = await Promise.all([
223
+ interopDefault(import("eslint-plugin-astro")),
224
+ interopDefault(import("astro-eslint-parser")),
225
+ interopDefault(import("@typescript-eslint/parser"))
226
+ ]);
227
+ return [
228
+ {
229
+ name: "vinicunca/astro/setup",
230
+ plugins: {
231
+ astro: pluginAstro
232
+ }
177
233
  },
178
- scopeManager: null,
179
- services: { isPlain: true },
180
- visitorKeys: {
181
- Program: []
234
+ {
235
+ files,
236
+ languageOptions: {
237
+ globals: pluginAstro.environments.astro.globals,
238
+ parser: parserAstro,
239
+ parserOptions: {
240
+ extraFileExtensions: [".astro"],
241
+ parser: parserTs
242
+ },
243
+ sourceType: "module"
244
+ },
245
+ name: "vinicunca/astro/rules",
246
+ processor: "astro/client-side-ts",
247
+ rules: {
248
+ // use recommended rules
249
+ "astro/missing-client-only-directive-value": ERROR,
250
+ "astro/no-conflict-set-directives": ERROR,
251
+ "astro/no-deprecated-astro-canonicalurl": ERROR,
252
+ "astro/no-deprecated-astro-fetchcontent": ERROR,
253
+ "astro/no-deprecated-astro-resolve": ERROR,
254
+ "astro/no-deprecated-getentrybyslug": ERROR,
255
+ "astro/no-set-html-directive": OFF,
256
+ "astro/no-unused-define-vars-in-style": ERROR,
257
+ "astro/semi": OFF,
258
+ "astro/valid-compile": ERROR,
259
+ ...stylistic2 ? {
260
+ "style/indent": OFF,
261
+ "style/jsx-closing-tag-location": OFF,
262
+ "style/jsx-indent": OFF,
263
+ "style/jsx-one-expression-per-line": OFF,
264
+ "style/no-multiple-empty-lines": OFF
265
+ } : {},
266
+ ...overrides
267
+ }
182
268
  }
183
- })
184
- };
185
- function isInEditorEnv() {
186
- return !!((process.env.VSCODE_PID || process.env.VSCODE_CWD || process.env.JETBRAINS_IDE || process.env.VIM || process.env.NVIM) && !process.env.CI);
269
+ ];
270
+ }
271
+
272
+ // src/configs/command.ts
273
+ import createCommand from "eslint-plugin-command/config";
274
+ async function command() {
275
+ return [
276
+ {
277
+ ...createCommand(),
278
+ name: "vinicunca/command/rules"
279
+ }
280
+ ];
281
+ }
282
+
283
+ // src/plugins.ts
284
+ import { default as default2 } from "@eslint-community/eslint-plugin-eslint-comments";
285
+ import { default as default3 } from "eslint-plugin-antfu";
286
+ import * as pluginImport from "eslint-plugin-import-x";
287
+ import { default as default4 } from "eslint-plugin-n";
288
+ import { default as default5 } from "eslint-plugin-perfectionist";
289
+ import { default as default6 } from "eslint-plugin-sonarjs";
290
+ import { default as default7 } from "eslint-plugin-unicorn";
291
+ import { default as default8 } from "eslint-plugin-unused-imports";
292
+
293
+ // src/configs/comments.ts
294
+ async function comments() {
295
+ return [
296
+ {
297
+ name: "vinicunca/eslint-comments/rules",
298
+ plugins: {
299
+ "eslint-comments": default2
300
+ },
301
+ rules: {
302
+ "eslint-comments/no-aggregating-enable": ERROR,
303
+ "eslint-comments/no-duplicate-disable": ERROR,
304
+ "eslint-comments/no-unlimited-disable": ERROR,
305
+ "eslint-comments/no-unused-enable": ERROR
306
+ }
307
+ }
308
+ ];
187
309
  }
188
310
 
311
+ // src/configs/formatters.ts
312
+ import { isPackageExists as isPackageExists2 } from "local-pkg";
313
+
189
314
  // src/configs/stylistic.ts
190
- var STR_PARENS_NEW_LINE = "parens-new-line";
191
315
  var STYLISTIC_CONFIG_DEFAULTS = {
192
316
  indent: 2,
193
317
  jsx: true,
@@ -218,13 +342,13 @@ async function stylistic(options = {}) {
218
342
  {
219
343
  name: "vinicunca/stylistic/rules",
220
344
  plugins: {
221
- antfu: default2,
345
+ antfu: default3,
222
346
  style: pluginStylistic
223
347
  },
224
348
  rules: {
225
349
  ...config.rules,
226
- "antfu/consistent-list-newline": "error",
227
- "antfu/top-level-function": "error",
350
+ "antfu/consistent-list-newline": ERROR,
351
+ "antfu/top-level-function": ERROR,
228
352
  "curly": [ERROR, "all"],
229
353
  "style/array-bracket-newline": [ERROR, CONSISTENT],
230
354
  "style/array-bracket-spacing": [ERROR, NEVER],
@@ -232,46 +356,6 @@ async function stylistic(options = {}) {
232
356
  "style/arrow-parens": [ERROR, ALWAYS],
233
357
  "style/brace-style": [ERROR],
234
358
  "style/func-call-spacing": [ERROR, NEVER],
235
- "style/jsx-child-element-spacing": OFF,
236
- "style/jsx-closing-bracket-location": [ERROR, "line-aligned"],
237
- "style/jsx-closing-tag-location": ERROR,
238
- "style/jsx-curly-brace-presence": [ERROR, { children: NEVER, props: NEVER }],
239
- "style/jsx-curly-newline": [ERROR, {
240
- multiline: "consistent",
241
- singleline: "consistent"
242
- }],
243
- "style/jsx-curly-spacing": [ERROR, {
244
- children: true,
245
- spacing: {
246
- objectLiterals: NEVER
247
- },
248
- when: "always"
249
- }],
250
- "style/jsx-equals-spacing": [ERROR, NEVER],
251
- "style/jsx-first-prop-new-line": [ERROR, "multiline-multiprop"],
252
- "style/jsx-indent": [ERROR, 2],
253
- "style/jsx-indent-props": [ERROR, 2],
254
- "style/jsx-max-props-per-line": [ERROR, { maximum: 1, when: "multiline" }],
255
- "style/jsx-newline": ERROR,
256
- "style/jsx-one-expression-per-line": [ERROR, { allow: "single-child" }],
257
- "style/jsx-props-no-multi-spaces": ERROR,
258
- // Turned off to avoid conflicts with Perfectionist. https://eslint-plugin-perfectionist.azat.io/rules/sort-jsx-props
259
- "style/jsx-sort-props": [OFF],
260
- "style/jsx-tag-spacing": [ERROR, {
261
- afterOpening: NEVER,
262
- beforeClosing: NEVER,
263
- beforeSelfClosing: "always",
264
- closingSlash: NEVER
265
- }],
266
- "style/jsx-wrap-multilines": [ERROR, {
267
- arrow: STR_PARENS_NEW_LINE,
268
- assignment: STR_PARENS_NEW_LINE,
269
- condition: STR_PARENS_NEW_LINE,
270
- declaration: STR_PARENS_NEW_LINE,
271
- logical: STR_PARENS_NEW_LINE,
272
- prop: STR_PARENS_NEW_LINE,
273
- return: STR_PARENS_NEW_LINE
274
- }],
275
359
  "style/member-delimiter-style": [ERROR],
276
360
  "style/object-curly-newline": [ERROR, { consistent: true, multiline: true }],
277
361
  "style/object-curly-spacing": [ERROR, ALWAYS],
@@ -292,13 +376,27 @@ async function stylistic(options = {}) {
292
376
  // src/configs/formatters.ts
293
377
  async function formatters(options = {}, stylistic2 = {}) {
294
378
  if (options === true) {
379
+ const isPrettierPluginXmlInScope = isPackageInScope("@prettier/plugin-xml");
295
380
  options = {
381
+ astro: isPackageInScope("prettier-plugin-astro"),
296
382
  css: true,
297
383
  graphql: true,
298
384
  html: true,
299
- markdown: true
385
+ markdown: true,
386
+ slidev: isPackageExists2("@slidev/cli"),
387
+ svg: isPrettierPluginXmlInScope,
388
+ xml: isPrettierPluginXmlInScope
300
389
  };
301
390
  }
391
+ await ensurePackages([
392
+ "eslint-plugin-format",
393
+ options.markdown && options.slidev ? "prettier-plugin-slidev" : void 0,
394
+ options.astro ? "prettier-plugin-astro" : void 0,
395
+ options.xml || options.svg ? "@prettier/plugin-xml" : void 0
396
+ ]);
397
+ if (options.slidev && options.markdown !== true && options.markdown !== "prettier") {
398
+ throw new Error("`slidev` option only works when `markdown` is enabled with `prettier`");
399
+ }
302
400
  const {
303
401
  indent,
304
402
  quotes,
@@ -312,15 +410,21 @@ async function formatters(options = {}, stylistic2 = {}) {
312
410
  endOfLine: "auto",
313
411
  semi,
314
412
  singleQuote: quotes === "single",
315
- tabWidth: typeof indent === "number" ? indent : 2,
413
+ tabWidth: e2(indent) ? indent : 2,
316
414
  trailingComma: "all",
317
415
  useTabs: indent === "tab"
318
416
  },
319
417
  options.prettierOptions || {}
320
418
  );
419
+ const prettierXmlOptions = {
420
+ xmlQuoteAttributes: "double",
421
+ xmlSelfClosingSpace: true,
422
+ xmlSortAttributesByKey: false,
423
+ xmlWhitespaceSensitivity: "ignore"
424
+ };
321
425
  const dprintOptions = Object.assign(
322
426
  {
323
- indentWidth: typeof indent === "number" ? indent : 2,
427
+ indentWidth: e2(indent) ? indent : 2,
324
428
  quoteStyle: quotes === "single" ? "preferSingle" : "preferDouble",
325
429
  useTabs: indent === "tab"
326
430
  },
@@ -345,7 +449,7 @@ async function formatters(options = {}, stylistic2 = {}) {
345
449
  name: "vinicunca/formatter/css",
346
450
  rules: {
347
451
  "format/prettier": [
348
- "error",
452
+ ERROR,
349
453
  {
350
454
  ...prettierOptions,
351
455
  parser: "css"
@@ -361,7 +465,7 @@ async function formatters(options = {}, stylistic2 = {}) {
361
465
  name: "vinicunca/formatter/scss",
362
466
  rules: {
363
467
  "format/prettier": [
364
- "error",
468
+ ERROR,
365
469
  {
366
470
  ...prettierOptions,
367
471
  parser: "scss"
@@ -377,7 +481,7 @@ async function formatters(options = {}, stylistic2 = {}) {
377
481
  name: "vinicunca/formatter/less",
378
482
  rules: {
379
483
  "format/prettier": [
380
- "error",
484
+ ERROR,
381
485
  {
382
486
  ...prettierOptions,
383
487
  parser: "less"
@@ -396,7 +500,7 @@ async function formatters(options = {}, stylistic2 = {}) {
396
500
  name: "vinicunca/formatter/html",
397
501
  rules: {
398
502
  "format/prettier": [
399
- "error",
503
+ ERROR,
400
504
  {
401
505
  ...prettierOptions,
402
506
  parser: "html"
@@ -405,21 +509,72 @@ async function formatters(options = {}, stylistic2 = {}) {
405
509
  }
406
510
  });
407
511
  }
512
+ if (options.xml) {
513
+ configs2.push({
514
+ files: [GLOB_XML],
515
+ languageOptions: {
516
+ parser: parserPlain
517
+ },
518
+ name: "antfu/formatter/xml",
519
+ rules: {
520
+ "format/prettier": [
521
+ ERROR,
522
+ {
523
+ ...prettierXmlOptions,
524
+ ...prettierOptions,
525
+ parser: "xml",
526
+ plugins: [
527
+ "@prettier/plugin-xml"
528
+ ]
529
+ }
530
+ ]
531
+ }
532
+ });
533
+ }
534
+ if (options.svg) {
535
+ configs2.push({
536
+ files: [GLOB_SVG],
537
+ languageOptions: {
538
+ parser: parserPlain
539
+ },
540
+ name: "antfu/formatter/svg",
541
+ rules: {
542
+ "format/prettier": [
543
+ ERROR,
544
+ {
545
+ ...prettierXmlOptions,
546
+ ...prettierOptions,
547
+ parser: "xml",
548
+ plugins: [
549
+ "@prettier/plugin-xml"
550
+ ]
551
+ }
552
+ ]
553
+ }
554
+ });
555
+ }
408
556
  if (options.markdown) {
409
557
  const formater = options.markdown === true ? "prettier" : options.markdown;
558
+ let GLOB_SLIDEV;
559
+ if (options.slidev) {
560
+ GLOB_SLIDEV = options.slidev === true ? ["**/slides.md"] : options.slidev.files;
561
+ } else {
562
+ GLOB_SLIDEV = [];
563
+ }
410
564
  configs2.push({
411
565
  files: [GLOB_MARKDOWN],
566
+ ignores: GLOB_SLIDEV,
412
567
  languageOptions: {
413
568
  parser: parserPlain
414
569
  },
415
570
  name: "vinicunca/formatter/markdown",
416
571
  rules: {
417
572
  [`format/${formater}`]: [
418
- "error",
573
+ ERROR,
419
574
  formater === "prettier" ? {
420
575
  printWidth: 120,
421
576
  ...prettierOptions,
422
- embeddedLanguageFormatting: "off",
577
+ embeddedLanguageFormatting: OFF,
423
578
  parser: "markdown"
424
579
  } : {
425
580
  ...dprintOptions,
@@ -428,17 +583,73 @@ async function formatters(options = {}, stylistic2 = {}) {
428
583
  ]
429
584
  }
430
585
  });
586
+ if (options.slidev) {
587
+ configs2.push({
588
+ files: GLOB_SLIDEV,
589
+ languageOptions: {
590
+ parser: parserPlain
591
+ },
592
+ name: "vinicunca/formatter/slidev",
593
+ rules: {
594
+ "format/prettier": [
595
+ ERROR,
596
+ {
597
+ ...prettierOptions,
598
+ embeddedLanguageFormatting: "off",
599
+ parser: "slidev",
600
+ plugins: [
601
+ "prettier-plugin-slidev"
602
+ ]
603
+ }
604
+ ]
605
+ }
606
+ });
607
+ }
608
+ }
609
+ if (options.astro) {
610
+ configs2.push({
611
+ files: [GLOB_ASTRO],
612
+ languageOptions: {
613
+ parser: parserPlain
614
+ },
615
+ name: "vinicunca/formatter/astro",
616
+ rules: {
617
+ "format/prettier": [
618
+ ERROR,
619
+ {
620
+ ...prettierOptions,
621
+ parser: "astro",
622
+ plugins: [
623
+ "prettier-plugin-astro"
624
+ ]
625
+ }
626
+ ]
627
+ }
628
+ });
629
+ configs2.push({
630
+ files: [GLOB_ASTRO, GLOB_ASTRO_TS],
631
+ name: "vinicunca/formatter/astro/disables",
632
+ rules: {
633
+ "style/arrow-parens": OFF,
634
+ "style/block-spacing": OFF,
635
+ "style/comma-dangle": OFF,
636
+ "style/indent": OFF,
637
+ "style/no-multi-spaces": OFF,
638
+ "style/quotes": OFF,
639
+ "style/semi": OFF
640
+ }
641
+ });
431
642
  }
432
643
  if (options.graphql) {
433
644
  configs2.push({
434
- files: ["**/*.graphql"],
645
+ files: [GLOB_GRAPHQL],
435
646
  languageOptions: {
436
647
  parser: parserPlain
437
648
  },
438
649
  name: "vinicunca/formatter/graphql",
439
650
  rules: {
440
651
  "format/prettier": [
441
- "error",
652
+ ERROR,
442
653
  {
443
654
  ...prettierOptions,
444
655
  parser: "graphql"
@@ -460,28 +671,44 @@ async function ignores() {
460
671
  }
461
672
 
462
673
  // src/configs/imports.ts
463
- async function imports() {
674
+ async function imports(options = {}) {
675
+ const {
676
+ stylistic: stylistic2 = true
677
+ } = options;
464
678
  return [
465
679
  {
466
680
  name: "vinicunca/imports/rules",
467
681
  plugins: {
468
- antfu: default2,
682
+ antfu: default3,
469
683
  import: pluginImport
470
684
  },
471
685
  rules: {
686
+ "antfu/import-dedupe": ERROR,
687
+ "antfu/no-import-dist": ERROR,
688
+ "antfu/no-import-node-modules-by-path": ERROR,
472
689
  "import/export": ERROR,
473
690
  "import/first": ERROR,
474
- "import/newline-after-import": [OFF, {
475
- considerComments: true,
476
- count: 1
477
- }],
478
691
  "import/no-duplicates": ERROR,
479
692
  "import/no-mutable-exports": ERROR,
480
693
  "import/no-named-default": ERROR,
481
694
  "import/no-self-import": ERROR,
482
695
  "import/no-webpack-loader-syntax": ERROR,
483
696
  // Turned off to avoid conflicts with Perfectionist. https://eslint-plugin-perfectionist.azat.io/rules/sort-imports
484
- "import/order": OFF
697
+ "import/order": OFF,
698
+ ...stylistic2 ? {
699
+ "import/newline-after-import": [ERROR, {
700
+ count: 1,
701
+ considerComments: true
702
+ }]
703
+ } : {}
704
+ }
705
+ },
706
+ {
707
+ files: ["**/bin/**/*", `**/bin.${GLOB_SRC_EXT}`],
708
+ name: "vinicunca/imports/disables/bin",
709
+ rules: {
710
+ "antfu/no-import-dist": OFF,
711
+ "antfu/no-import-node-modules-by-path": OFF
485
712
  }
486
713
  }
487
714
  ];
@@ -523,7 +750,7 @@ async function javascript(options = {}) {
523
750
  {
524
751
  name: "vinicunca/javascript/rules",
525
752
  plugins: {
526
- "antfu": default2,
753
+ "antfu": default3,
527
754
  "unused-imports": default8
528
755
  },
529
756
  rules: {
@@ -789,8 +1016,8 @@ async function jsdoc(options = {}) {
789
1016
  "jsdoc/require-yields-check": WARN,
790
1017
  "jsdoc/valid-types": WARN,
791
1018
  ...stylistic2 ? {
792
- "jsdoc/check-alignment": "warn",
793
- "jsdoc/multiline-blocks": "warn"
1019
+ "jsdoc/check-alignment": WARN,
1020
+ "jsdoc/multiline-blocks": WARN
794
1021
  } : {}
795
1022
  }
796
1023
  }
@@ -1015,21 +1242,40 @@ async function perfectionist() {
1015
1242
  }
1016
1243
 
1017
1244
  // src/configs/react.ts
1245
+ import { isPackageExists as isPackageExists3 } from "local-pkg";
1246
+ var ReactRefreshAllowConstantExportPackages = [
1247
+ "vite"
1248
+ ];
1249
+ var RemixPackages = [
1250
+ "@remix-run/node",
1251
+ "@remix-run/react",
1252
+ "@remix-run/serve",
1253
+ "@remix-run/dev"
1254
+ ];
1255
+ var NextJsPackages = [
1256
+ "next"
1257
+ ];
1018
1258
  async function react(options = {}) {
1019
1259
  const {
1020
1260
  files = [GLOB_SRC],
1021
1261
  overrides = {}
1022
1262
  } = options;
1263
+ const tsconfigPath = options?.tsconfigPath ? toArray(options.tsconfigPath) : void 0;
1264
+ const isTypeAware = !!tsconfigPath;
1023
1265
  const [
1024
1266
  pluginReact,
1025
1267
  pluginReactHooks,
1268
+ pluginReactRefresh,
1026
1269
  parserTs
1027
1270
  ] = await Promise.all([
1028
1271
  interopDefault(import("@eslint-react/eslint-plugin")),
1029
- // @ts-expect-error missing types
1030
1272
  interopDefault(import("eslint-plugin-react-hooks")),
1273
+ interopDefault(import("eslint-plugin-react-refresh")),
1031
1274
  interopDefault(import("@typescript-eslint/parser"))
1032
1275
  ]);
1276
+ const isAllowConstantExport = ReactRefreshAllowConstantExportPackages.some((i) => isPackageExists3(i));
1277
+ const isUsingRemix = RemixPackages.some((i) => isPackageExists3(i));
1278
+ const isUsingNext = NextJsPackages.some((i) => isPackageExists3(i));
1033
1279
  const plugins = pluginReact.configs.all.plugins;
1034
1280
  return [
1035
1281
  {
@@ -1037,12 +1283,10 @@ async function react(options = {}) {
1037
1283
  plugins: {
1038
1284
  "react": plugins["@eslint-react"],
1039
1285
  "react-dom": plugins["@eslint-react/dom"],
1040
- "react-hooks": pluginReactHooks
1041
- },
1042
- settings: {
1043
- react: {
1044
- version: "detect"
1045
- }
1286
+ "react-hooks": pluginReactHooks,
1287
+ "react-hooks-extra": plugins["@eslint-react/hooks-extra"],
1288
+ "react-naming-convention": plugins["@eslint-react/naming-convention"],
1289
+ "react-refresh": pluginReactRefresh
1046
1290
  }
1047
1291
  },
1048
1292
  {
@@ -1052,38 +1296,93 @@ async function react(options = {}) {
1052
1296
  parserOptions: {
1053
1297
  ecmaFeatures: {
1054
1298
  jsx: true
1055
- }
1299
+ },
1300
+ ...isTypeAware ? { project: tsconfigPath } : {}
1056
1301
  },
1057
1302
  sourceType: "module"
1058
1303
  },
1059
1304
  name: "vinicunca/react/rules",
1060
1305
  rules: {
1061
- ...pluginReact.configs.recommended.rules,
1062
- ...pluginReactHooks.configs.recommended.rules,
1063
- "react/boolean-prop-naming": [OFF, {
1064
- message: "",
1065
- propTypeNames: ["bool", "mutuallyExclusiveTrueProps"],
1066
- rule: "^(is|has)[A-Z]([A-Za-z0-9]?)+"
1067
- }],
1068
- "react/destructuring-assignment": [ERROR, "always"],
1069
- "react/jsx-boolean-value": [ERROR, NEVER, { always: [] }],
1070
- "react/jsx-key": OFF,
1071
- "react/jsx-max-depth": OFF,
1072
- "react/jsx-no-duplicate-props": [ERROR, { ignoreCase: true }],
1073
- "react/jsx-no-literals": [OFF, { noStrings: true }],
1074
- "react/jsx-pascal-case": [ERROR, {
1075
- allowAllCaps: true,
1076
- ignore: []
1077
- }],
1078
- "react/jsx-sort-default-props": [OFF, {
1079
- ignoreCase: true
1080
- }],
1081
- "react/no-danger": WARN,
1082
- "react/no-unescaped-entities": OFF,
1083
- "react/prop-types": OFF,
1084
- "react/react-in-jsx-scope": OFF,
1085
- "react/self-closing-comp": ERROR,
1086
- "react/style-prop-object": ERROR,
1306
+ // recommended rules from @eslint-react/dom
1307
+ "react-dom/no-children-in-void-dom-elements": WARN,
1308
+ "react-dom/no-dangerously-set-innerhtml": WARN,
1309
+ "react-dom/no-dangerously-set-innerhtml-with-children": ERROR,
1310
+ "react-dom/no-find-dom-node": ERROR,
1311
+ "react-dom/no-missing-button-type": WARN,
1312
+ "react-dom/no-missing-iframe-sandbox": WARN,
1313
+ "react-dom/no-namespace": ERROR,
1314
+ "react-dom/no-render-return-value": ERROR,
1315
+ "react-dom/no-script-url": WARN,
1316
+ "react-dom/no-unsafe-iframe-sandbox": WARN,
1317
+ "react-dom/no-unsafe-target-blank": WARN,
1318
+ // recommended rules react-hooks
1319
+ "react-hooks/exhaustive-deps": WARN,
1320
+ "react-hooks/rules-of-hooks": ERROR,
1321
+ // react refresh
1322
+ "react-refresh/only-export-components": [
1323
+ WARN,
1324
+ {
1325
+ allowConstantExport: isAllowConstantExport,
1326
+ allowExportNames: [
1327
+ ...isUsingNext ? [
1328
+ "config",
1329
+ "generateStaticParams",
1330
+ "metadata",
1331
+ "generateMetadata",
1332
+ "viewport",
1333
+ "generateViewport"
1334
+ ] : [],
1335
+ ...isUsingRemix ? [
1336
+ "meta",
1337
+ "links",
1338
+ "headers",
1339
+ "loader",
1340
+ "action"
1341
+ ] : []
1342
+ ]
1343
+ }
1344
+ ],
1345
+ // recommended rules from @eslint-react
1346
+ "react/ensure-forward-ref-using-ref": WARN,
1347
+ "react/no-access-state-in-setstate": ERROR,
1348
+ "react/no-array-index-key": WARN,
1349
+ "react/no-children-count": WARN,
1350
+ "react/no-children-for-each": WARN,
1351
+ "react/no-children-map": WARN,
1352
+ "react/no-children-only": WARN,
1353
+ "react/no-children-prop": WARN,
1354
+ "react/no-children-to-array": WARN,
1355
+ "react/no-clone-element": WARN,
1356
+ "react/no-comment-textnodes": WARN,
1357
+ "react/no-component-will-mount": ERROR,
1358
+ "react/no-component-will-receive-props": ERROR,
1359
+ "react/no-component-will-update": ERROR,
1360
+ "react/no-create-ref": ERROR,
1361
+ "react/no-direct-mutation-state": ERROR,
1362
+ "react/no-duplicate-key": ERROR,
1363
+ "react/no-implicit-key": ERROR,
1364
+ "react/no-missing-key": ERROR,
1365
+ "react/no-nested-components": WARN,
1366
+ "react/no-redundant-should-component-update": ERROR,
1367
+ "react/no-set-state-in-component-did-mount": WARN,
1368
+ "react/no-set-state-in-component-did-update": WARN,
1369
+ "react/no-set-state-in-component-will-update": WARN,
1370
+ "react/no-string-refs": ERROR,
1371
+ "react/no-unsafe-component-will-mount": WARN,
1372
+ "react/no-unsafe-component-will-receive-props": WARN,
1373
+ "react/no-unsafe-component-will-update": WARN,
1374
+ "react/no-unstable-context-value": ERROR,
1375
+ "react/no-unstable-default-props": ERROR,
1376
+ "react/no-unused-class-component-members": WARN,
1377
+ "react/no-unused-state": WARN,
1378
+ "react/no-useless-fragment": WARN,
1379
+ "react/prefer-destructuring-assignment": WARN,
1380
+ "react/prefer-shorthand-boolean": WARN,
1381
+ "react/prefer-shorthand-fragment": WARN,
1382
+ ...isTypeAware ? {
1383
+ "react/no-leaked-conditional-rendering": WARN
1384
+ } : {},
1385
+ // overrides
1087
1386
  ...overrides
1088
1387
  }
1089
1388
  }
@@ -1116,6 +1415,79 @@ async function regexp(options = {}) {
1116
1415
  ];
1117
1416
  }
1118
1417
 
1418
+ // src/configs/solid.ts
1419
+ async function solid(options = {}) {
1420
+ const {
1421
+ files = [GLOB_JSX, GLOB_TSX],
1422
+ overrides = {},
1423
+ typescript: typescript2 = true
1424
+ } = options;
1425
+ const tsconfigPath = options?.tsconfigPath ? toArray(options.tsconfigPath) : void 0;
1426
+ const isTypeAware = !!tsconfigPath;
1427
+ const [
1428
+ pluginSolid,
1429
+ parserTs
1430
+ ] = await Promise.all([
1431
+ interopDefault(import("eslint-plugin-solid")),
1432
+ interopDefault(import("@typescript-eslint/parser"))
1433
+ ]);
1434
+ return [
1435
+ {
1436
+ name: "vinicunca/solid/setup",
1437
+ plugins: {
1438
+ solid: pluginSolid
1439
+ }
1440
+ },
1441
+ {
1442
+ files,
1443
+ languageOptions: {
1444
+ parser: parserTs,
1445
+ parserOptions: {
1446
+ ecmaFeatures: {
1447
+ jsx: true
1448
+ },
1449
+ ...isTypeAware ? { project: tsconfigPath } : {}
1450
+ },
1451
+ sourceType: "module"
1452
+ },
1453
+ name: "vinicunca/solid/rules",
1454
+ rules: {
1455
+ // reactivity
1456
+ "solid/components-return-once": WARN,
1457
+ "solid/event-handlers": [ERROR, {
1458
+ // if true, don't warn on ambiguously named event handlers like `onclick` or `onchange`
1459
+ ignoreCase: false,
1460
+ // if true, warn when spreading event handlers onto JSX. Enable for Solid < v1.6.
1461
+ warnOnSpread: false
1462
+ }],
1463
+ // these rules are mostly style suggestions
1464
+ "solid/imports": ERROR,
1465
+ // identifier usage is important
1466
+ "solid/jsx-no-duplicate-props": ERROR,
1467
+ "solid/jsx-no-script-url": ERROR,
1468
+ "solid/jsx-no-undef": ERROR,
1469
+ "solid/jsx-uses-vars": ERROR,
1470
+ "solid/no-destructure": ERROR,
1471
+ // security problems
1472
+ "solid/no-innerhtml": [ERROR, { allowStatic: true }],
1473
+ "solid/no-react-deps": ERROR,
1474
+ "solid/no-react-specific-props": ERROR,
1475
+ "solid/no-unknown-namespaces": ERROR,
1476
+ "solid/prefer-for": ERROR,
1477
+ "solid/reactivity": WARN,
1478
+ "solid/self-closing-comp": ERROR,
1479
+ "solid/style-prop": [ERROR, { styleProps: ["style", "css"] }],
1480
+ ...typescript2 ? {
1481
+ "solid/jsx-no-undef": [ERROR, { typescriptEnabled: true }],
1482
+ "solid/no-unknown-namespaces": OFF
1483
+ } : {},
1484
+ // overrides
1485
+ ...overrides
1486
+ }
1487
+ }
1488
+ ];
1489
+ }
1490
+
1119
1491
  // src/configs/sonar.ts
1120
1492
  async function sonar() {
1121
1493
  return [
@@ -1364,6 +1736,102 @@ function sortTsconfig() {
1364
1736
  ];
1365
1737
  }
1366
1738
 
1739
+ // src/configs/svelte.ts
1740
+ async function svelte(options = {}) {
1741
+ const {
1742
+ files = [GLOB_SVELTE],
1743
+ overrides = {},
1744
+ stylistic: stylistic2 = true
1745
+ } = options;
1746
+ const {
1747
+ indent = 2,
1748
+ quotes = "single"
1749
+ } = e(stylistic2) ? {} : stylistic2;
1750
+ const [
1751
+ pluginSvelte,
1752
+ parserSvelte
1753
+ ] = await Promise.all([
1754
+ interopDefault(import("eslint-plugin-svelte")),
1755
+ interopDefault(import("svelte-eslint-parser"))
1756
+ ]);
1757
+ return [
1758
+ {
1759
+ name: "vinicunca/svelte/setup",
1760
+ plugins: {
1761
+ svelte: pluginSvelte
1762
+ }
1763
+ },
1764
+ {
1765
+ files,
1766
+ languageOptions: {
1767
+ parser: parserSvelte,
1768
+ parserOptions: {
1769
+ extraFileExtensions: [".svelte"],
1770
+ parser: options.typescript ? await interopDefault(import("@typescript-eslint/parser")) : null
1771
+ }
1772
+ },
1773
+ name: "vinicunca/svelte/rules",
1774
+ processor: pluginSvelte.processors[".svelte"],
1775
+ rules: {
1776
+ "import/no-mutable-exports": OFF,
1777
+ "no-undef": OFF,
1778
+ // incompatible with most recent (attribute-form) generic types RFC
1779
+ "no-unused-vars": [ERROR, {
1780
+ args: "none",
1781
+ caughtErrors: "none",
1782
+ ignoreRestSiblings: true,
1783
+ vars: "all",
1784
+ varsIgnorePattern: "^(\\$\\$Props$|\\$\\$Events$|\\$\\$Slots$)"
1785
+ }],
1786
+ "svelte/comment-directive": ERROR,
1787
+ "svelte/no-at-debug-tags": "warn",
1788
+ "svelte/no-at-html-tags": ERROR,
1789
+ "svelte/no-dupe-else-if-blocks": ERROR,
1790
+ "svelte/no-dupe-style-properties": ERROR,
1791
+ "svelte/no-dupe-use-directives": ERROR,
1792
+ "svelte/no-dynamic-slot-name": ERROR,
1793
+ "svelte/no-export-load-in-svelte-module-in-kit-pages": ERROR,
1794
+ "svelte/no-inner-declarations": ERROR,
1795
+ "svelte/no-not-function-handler": ERROR,
1796
+ "svelte/no-object-in-text-mustaches": ERROR,
1797
+ "svelte/no-reactive-functions": ERROR,
1798
+ "svelte/no-reactive-literals": ERROR,
1799
+ "svelte/no-shorthand-style-property-overrides": ERROR,
1800
+ "svelte/no-unknown-style-directive-property": ERROR,
1801
+ "svelte/no-unused-svelte-ignore": ERROR,
1802
+ "svelte/no-useless-mustaches": ERROR,
1803
+ "svelte/require-store-callbacks-use-set-param": ERROR,
1804
+ "svelte/system": ERROR,
1805
+ "svelte/valid-each-key": ERROR,
1806
+ "unused-imports/no-unused-vars": [
1807
+ ERROR,
1808
+ {
1809
+ args: "after-used",
1810
+ argsIgnorePattern: "^_",
1811
+ vars: "all",
1812
+ varsIgnorePattern: "^(_|\\$\\$Props$|\\$\\$Events$|\\$\\$Slots$)"
1813
+ }
1814
+ ],
1815
+ ...stylistic2 ? {
1816
+ "style/indent": OFF,
1817
+ // superseded by svelte/indent
1818
+ "style/no-trailing-spaces": OFF,
1819
+ // superseded by svelte/no-trailing-spaces
1820
+ "svelte/derived-has-same-inputs-outputs": ERROR,
1821
+ "svelte/html-closing-bracket-spacing": ERROR,
1822
+ "svelte/html-quotes": [ERROR, { prefer: quotes }],
1823
+ "svelte/indent": [ERROR, { alignAttributesVertically: true, indent }],
1824
+ "svelte/mustache-spacing": ERROR,
1825
+ "svelte/no-spaces-around-equal-signs-in-attribute": ERROR,
1826
+ "svelte/no-trailing-spaces": ERROR,
1827
+ "svelte/spaced-html-comment": ERROR
1828
+ } : {},
1829
+ ...overrides
1830
+ }
1831
+ }
1832
+ ];
1833
+ }
1834
+
1367
1835
  // src/configs/test.ts
1368
1836
  var _pluginTest;
1369
1837
  async function test(options = {}) {
@@ -1411,21 +1879,84 @@ async function test(options = {}) {
1411
1879
  ];
1412
1880
  }
1413
1881
 
1882
+ // src/configs/toml.ts
1883
+ async function toml(options = {}) {
1884
+ const {
1885
+ files = [GLOB_TOML],
1886
+ overrides = {},
1887
+ stylistic: stylistic2 = true
1888
+ } = options;
1889
+ const {
1890
+ indent = 2
1891
+ } = e(stylistic2) ? {} : stylistic2;
1892
+ const [
1893
+ pluginToml,
1894
+ parserToml
1895
+ ] = await Promise.all([
1896
+ interopDefault(import("eslint-plugin-toml")),
1897
+ interopDefault(import("toml-eslint-parser"))
1898
+ ]);
1899
+ return [
1900
+ {
1901
+ name: "vinicunca/toml/setup",
1902
+ plugins: {
1903
+ toml: pluginToml
1904
+ }
1905
+ },
1906
+ {
1907
+ files,
1908
+ languageOptions: {
1909
+ parser: parserToml
1910
+ },
1911
+ name: "vinicunca/toml/rules",
1912
+ rules: {
1913
+ "style/spaced-comment": OFF,
1914
+ "toml/comma-style": ERROR,
1915
+ "toml/keys-order": ERROR,
1916
+ "toml/no-space-dots": ERROR,
1917
+ "toml/no-unreadable-number-separator": ERROR,
1918
+ "toml/precision-of-fractional-seconds": ERROR,
1919
+ "toml/precision-of-integer": ERROR,
1920
+ "toml/tables-order": ERROR,
1921
+ "toml/vue-custom-block/no-parsing-error": ERROR,
1922
+ ...stylistic2 ? {
1923
+ "toml/array-bracket-newline": ERROR,
1924
+ "toml/array-bracket-spacing": ERROR,
1925
+ "toml/array-element-newline": ERROR,
1926
+ "toml/indent": [ERROR, indent === "tab" ? 2 : indent],
1927
+ "toml/inline-table-curly-spacing": ERROR,
1928
+ "toml/key-spacing": ERROR,
1929
+ "toml/padding-line-between-pairs": ERROR,
1930
+ "toml/padding-line-between-tables": ERROR,
1931
+ "toml/quoted-keys": ERROR,
1932
+ "toml/spaced-comment": ERROR,
1933
+ "toml/table-bracket-spacing": ERROR
1934
+ } : {},
1935
+ ...overrides
1936
+ }
1937
+ }
1938
+ ];
1939
+ }
1940
+
1414
1941
  // src/configs/typescript.ts
1415
1942
  import process2 from "node:process";
1416
1943
  async function typescript(options = {}) {
1417
1944
  const {
1418
1945
  componentExts = [],
1419
1946
  overrides = {},
1420
- parserOptions = {}
1947
+ overridesTypeAware = {},
1948
+ parserOptions = {},
1949
+ type = "app"
1421
1950
  } = options ?? {};
1422
1951
  const files = options.files ?? [
1423
- GLOB_SRC,
1952
+ GLOB_TS,
1953
+ GLOB_TSX,
1424
1954
  ...componentExts.map((ext) => `**/*.${ext}`)
1425
1955
  ];
1426
1956
  const filesTypeAware = options.filesTypeAware ?? [GLOB_TS, GLOB_TSX];
1427
1957
  const ignoresTypeAware = options.ignoresTypeAware ?? [
1428
- `${GLOB_MARKDOWN}/**`
1958
+ `${GLOB_MARKDOWN}/**`,
1959
+ GLOB_ASTRO_TS
1429
1960
  ];
1430
1961
  const tsconfigPath = options?.tsconfigPath ? options.tsconfigPath : void 0;
1431
1962
  const isTypeAware = !!tsconfigPath;
@@ -1445,7 +1976,7 @@ async function typescript(options = {}) {
1445
1976
  "ts/no-unsafe-call": ERROR,
1446
1977
  "ts/no-unsafe-member-access": ERROR,
1447
1978
  "ts/no-unsafe-return": ERROR,
1448
- "ts/promise-function-async": "error",
1979
+ "ts/promise-function-async": ERROR,
1449
1980
  "ts/restrict-plus-operands": ERROR,
1450
1981
  "ts/restrict-template-expressions": ERROR,
1451
1982
  "ts/return-await": [ERROR, "in-try-catch"],
@@ -1487,7 +2018,7 @@ async function typescript(options = {}) {
1487
2018
  // Install the plugins without globs, so they can be configured separately.
1488
2019
  name: "vinicunca/typescript/setup",
1489
2020
  plugins: {
1490
- antfu: default2,
2021
+ antfu: default3,
1491
2022
  ts: pluginTs
1492
2023
  }
1493
2024
  },
@@ -1518,10 +2049,9 @@ async function typescript(options = {}) {
1518
2049
  "no-use-before-define": OFF,
1519
2050
  "no-useless-constructor": OFF,
1520
2051
  "ts/array-type": [ERROR, { default: "generic" }],
1521
- "ts/ban-ts-comment": ["error", { "ts-expect-error": "allow-with-description" }],
2052
+ "ts/ban-ts-comment": [ERROR, { "ts-expect-error": "allow-with-description" }],
1522
2053
  "ts/consistent-type-definitions": [ERROR, "interface"],
1523
2054
  "ts/consistent-type-imports": [ERROR, { disallowTypeAnnotations: false, prefer: "type-imports" }],
1524
- "ts/explicit-function-return-type": OFF,
1525
2055
  "ts/explicit-member-accessibility": OFF,
1526
2056
  "ts/explicit-module-boundary-types": OFF,
1527
2057
  // https://www.totaltypescript.com/method-shorthand-syntax-considered-harmful
@@ -1530,7 +2060,7 @@ async function typescript(options = {}) {
1530
2060
  "ts/no-dupe-class-members": ERROR,
1531
2061
  "ts/no-empty-function": OFF,
1532
2062
  "ts/no-empty-interface": OFF,
1533
- "ts/no-empty-object-type": ["error", { allowInterfaces: "always" }],
2063
+ "ts/no-empty-object-type": [ERROR, { allowInterfaces: "always" }],
1534
2064
  "ts/no-explicit-any": OFF,
1535
2065
  "ts/no-import-type-side-effects": ERROR,
1536
2066
  "ts/no-invalid-this": ERROR,
@@ -1549,14 +2079,13 @@ async function typescript(options = {}) {
1549
2079
  "ts/parameter-properties": OFF,
1550
2080
  "ts/prefer-ts-expect-error": ERROR,
1551
2081
  "ts/triple-slash-reference": OFF,
1552
- ...overrides
1553
- }
1554
- },
1555
- {
1556
- files: filesTypeAware,
1557
- name: "vinicunca/typescript/rules-type-aware",
1558
- rules: {
1559
- ...tsconfigPath ? typeAwareRules : {},
2082
+ ...type === "lib" ? {
2083
+ "ts/explicit-function-return-type": [ERROR, {
2084
+ allowExpressions: true,
2085
+ allowHigherOrderFunctions: true,
2086
+ allowIIFEs: true
2087
+ }]
2088
+ } : {},
1560
2089
  ...overrides
1561
2090
  }
1562
2091
  },
@@ -1564,7 +2093,10 @@ async function typescript(options = {}) {
1564
2093
  files: filesTypeAware,
1565
2094
  ignores: ignoresTypeAware,
1566
2095
  name: "vinicunca/typescript/rules-type-aware",
1567
- rules: typeAwareRules
2096
+ rules: {
2097
+ ...typeAwareRules,
2098
+ ...overridesTypeAware
2099
+ }
1568
2100
  }] : [],
1569
2101
  {
1570
2102
  files: ["**/*.d.?([cm])ts"],
@@ -1572,7 +2104,7 @@ async function typescript(options = {}) {
1572
2104
  rules: {
1573
2105
  "eslint-comments/no-unlimited-disable": OFF,
1574
2106
  "import/no-duplicates": OFF,
1575
- "no-restricted-syntax": "off",
2107
+ "no-restricted-syntax": OFF,
1576
2108
  "unused-imports/no-unused-vars": OFF
1577
2109
  }
1578
2110
  },
@@ -1639,12 +2171,12 @@ async function unocss(options = {}) {
1639
2171
  unocss: pluginUnoCSS
1640
2172
  },
1641
2173
  rules: {
1642
- "unocss/order": "warn",
2174
+ "unocss/order": WARN,
1643
2175
  ...attributify ? {
1644
- "unocss/order-attributify": "warn"
2176
+ "unocss/order-attributify": WARN
1645
2177
  } : {},
1646
2178
  ...strict ? {
1647
- "unocss/blocklist": "error"
2179
+ "unocss/blocklist": ERROR
1648
2180
  } : {}
1649
2181
  }
1650
2182
  }
@@ -1678,6 +2210,26 @@ async function vue(options = {}) {
1678
2210
  name: "vinicunca/vue/setup",
1679
2211
  plugins: {
1680
2212
  vue: pluginVue
2213
+ },
2214
+ // This allows Vue plugin to work with auto imports
2215
+ // https://github.com/vuejs/eslint-plugin-vue/pull/2422
2216
+ languageOptions: {
2217
+ globals: {
2218
+ computed: "readonly",
2219
+ defineEmits: "readonly",
2220
+ defineExpose: "readonly",
2221
+ defineProps: "readonly",
2222
+ onMounted: "readonly",
2223
+ onUnmounted: "readonly",
2224
+ reactive: "readonly",
2225
+ ref: "readonly",
2226
+ shallowReactive: "readonly",
2227
+ shallowRef: "readonly",
2228
+ toRef: "readonly",
2229
+ toRefs: "readonly",
2230
+ watch: "readonly",
2231
+ watchEffect: "readonly"
2232
+ }
1681
2233
  }
1682
2234
  },
1683
2235
  {
@@ -1881,6 +2433,10 @@ var VuePackages = [
1881
2433
  "@slidev/cli"
1882
2434
  ];
1883
2435
  var defaultPluginRenaming = {
2436
+ "@eslint-react": "react",
2437
+ "@eslint-react/dom": "react-dom",
2438
+ "@eslint-react/hooks-extra": "react-hooks-extra",
2439
+ "@eslint-react/naming-convention": "react-naming-convention",
1884
2440
  "@stylistic": "style",
1885
2441
  "@typescript-eslint": "ts",
1886
2442
  "import-x": "import",
@@ -1891,35 +2447,43 @@ var defaultPluginRenaming = {
1891
2447
  };
1892
2448
  function vinicuncaESLint(options = {}, ...userConfigs) {
1893
2449
  const {
2450
+ astro: enableAstro = false,
1894
2451
  autoRenamePlugins = true,
1895
2452
  componentExts = [],
1896
2453
  gitignore: enableGitignore = true,
1897
- isInEditor = isInEditorEnv(),
1898
2454
  jsx: enableJsx = true,
1899
2455
  react: enableReact = false,
1900
2456
  regexp: enableRegexp = true,
1901
- typescript: enableTypeScript = isPackageExists("typescript"),
2457
+ solid: enableSolid = false,
2458
+ svelte: enableSvelte = false,
2459
+ typescript: enableTypeScript = isPackageExists4("typescript"),
1902
2460
  unocss: enableUnoCSS = false,
1903
- vue: enableVue = VuePackages.some((i) => isPackageExists(i))
2461
+ vue: enableVue = VuePackages.some((i) => isPackageExists4(i))
1904
2462
  } = options;
2463
+ let isInEditor = options.isInEditor;
2464
+ if (isInEditor == null) {
2465
+ isInEditor = isInEditorEnv();
2466
+ if (isInEditor) {
2467
+ console.log("[@antfu/eslint-config] Detected running in editor, some rules are disabled.");
2468
+ }
2469
+ }
1905
2470
  let stylisticOptions = {};
1906
2471
  if (options.stylistic === false) {
1907
2472
  stylisticOptions = false;
1908
2473
  } else if (r(options.stylistic)) {
1909
- stylisticOptions = {
1910
- ...options.stylistic,
1911
- jsx: options.jsx ?? true
1912
- };
2474
+ stylisticOptions = options.stylistic;
2475
+ } else {
2476
+ stylisticOptions = {};
1913
2477
  }
1914
2478
  if (stylisticOptions && !("jsx" in stylisticOptions)) {
1915
2479
  stylisticOptions.jsx = enableJsx;
1916
2480
  }
1917
2481
  const configs2 = [];
1918
2482
  if (enableGitignore) {
1919
- if (typeof enableGitignore !== "boolean") {
2483
+ if (!e(enableGitignore)) {
1920
2484
  configs2.push(interopDefault(import("eslint-config-flat-gitignore")).then((r2) => [r2(enableGitignore)]));
1921
2485
  } else {
1922
- configs2.push(interopDefault(import("eslint-config-flat-gitignore")).then((r2) => [r2()]));
2486
+ configs2.push(interopDefault(import("eslint-config-flat-gitignore")).then((r2) => [r2({ strict: false })]));
1923
2487
  }
1924
2488
  }
1925
2489
  const typescriptOptions = resolveSubOptions(options, "typescript");
@@ -1935,8 +2499,11 @@ function vinicuncaESLint(options = {}, ...userConfigs) {
1935
2499
  jsdoc({
1936
2500
  stylistic: stylisticOptions
1937
2501
  }),
1938
- imports(),
2502
+ imports({
2503
+ stylistic: stylisticOptions
2504
+ }),
1939
2505
  unicorn(),
2506
+ command(),
1940
2507
  perfectionist(),
1941
2508
  sonar()
1942
2509
  );
@@ -1950,7 +2517,8 @@ function vinicuncaESLint(options = {}, ...userConfigs) {
1950
2517
  configs2.push(typescript({
1951
2518
  ...typescriptOptions,
1952
2519
  componentExts,
1953
- overrides: getOverrides(options, "typescript")
2520
+ overrides: getOverrides(options, "typescript"),
2521
+ type: options.type
1954
2522
  }));
1955
2523
  }
1956
2524
  if (stylisticOptions) {
@@ -1960,7 +2528,7 @@ function vinicuncaESLint(options = {}, ...userConfigs) {
1960
2528
  }));
1961
2529
  }
1962
2530
  if (enableRegexp) {
1963
- configs2.push(regexp(typeof enableRegexp === "boolean" ? {} : enableRegexp));
2531
+ configs2.push(regexp(e(enableRegexp) ? {} : enableRegexp));
1964
2532
  }
1965
2533
  if (options.test ?? true) {
1966
2534
  configs2.push(test({
@@ -1982,12 +2550,32 @@ function vinicuncaESLint(options = {}, ...userConfigs) {
1982
2550
  tsconfigPath
1983
2551
  }));
1984
2552
  }
2553
+ if (enableSolid) {
2554
+ configs2.push(solid({
2555
+ overrides: getOverrides(options, "solid"),
2556
+ tsconfigPath,
2557
+ typescript: !!enableTypeScript
2558
+ }));
2559
+ }
2560
+ if (enableSvelte) {
2561
+ configs2.push(svelte({
2562
+ overrides: getOverrides(options, "svelte"),
2563
+ stylistic: stylisticOptions,
2564
+ typescript: !!enableTypeScript
2565
+ }));
2566
+ }
1985
2567
  if (enableUnoCSS) {
1986
2568
  configs2.push(unocss({
1987
2569
  ...resolveSubOptions(options, "unocss"),
1988
2570
  overrides: getOverrides(options, "unocss")
1989
2571
  }));
1990
2572
  }
2573
+ if (enableAstro) {
2574
+ configs2.push(astro({
2575
+ overrides: getOverrides(options, "astro"),
2576
+ stylistic: stylisticOptions
2577
+ }));
2578
+ }
1991
2579
  if (options.jsonc ?? true) {
1992
2580
  configs2.push(
1993
2581
  jsonc({
@@ -2004,6 +2592,12 @@ function vinicuncaESLint(options = {}, ...userConfigs) {
2004
2592
  stylistic: stylisticOptions
2005
2593
  }));
2006
2594
  }
2595
+ if (options.toml ?? true) {
2596
+ configs2.push(toml({
2597
+ overrides: getOverrides(options, "toml"),
2598
+ stylistic: stylisticOptions
2599
+ }));
2600
+ }
2007
2601
  if (options.markdown ?? true) {
2008
2602
  configs2.push(
2009
2603
  markdown(
@@ -2017,7 +2611,7 @@ function vinicuncaESLint(options = {}, ...userConfigs) {
2017
2611
  if (options.formatters) {
2018
2612
  configs2.push(formatters(
2019
2613
  options.formatters,
2020
- typeof stylisticOptions === "boolean" ? {} : stylisticOptions
2614
+ e(stylisticOptions) ? {} : stylisticOptions
2021
2615
  ));
2022
2616
  }
2023
2617
  const fusedConfig = flatConfigProps.reduce((acc, key) => {
@@ -2041,19 +2635,22 @@ function vinicuncaESLint(options = {}, ...userConfigs) {
2041
2635
  }
2042
2636
  return composer;
2043
2637
  }
2638
+ function resolveSubOptions(options, key) {
2639
+ return e(options[key]) ? {} : options[key] || {};
2640
+ }
2044
2641
  function getOverrides(options, key) {
2045
2642
  const sub = resolveSubOptions(options, key);
2046
2643
  return {
2047
2644
  ..."overrides" in sub ? sub.overrides : {}
2048
2645
  };
2049
2646
  }
2050
- function resolveSubOptions(options, key) {
2051
- return e(options[key]) ? {} : options[key] || {};
2052
- }
2053
2647
  export {
2054
2648
  GLOB_ALL_SRC,
2649
+ GLOB_ASTRO,
2650
+ GLOB_ASTRO_TS,
2055
2651
  GLOB_CSS,
2056
2652
  GLOB_EXCLUDE,
2653
+ GLOB_GRAPHQL,
2057
2654
  GLOB_HTML,
2058
2655
  GLOB_JS,
2059
2656
  GLOB_JSON,
@@ -2069,20 +2666,29 @@ export {
2069
2666
  GLOB_SRC,
2070
2667
  GLOB_SRC_EXT,
2071
2668
  GLOB_STYLE,
2669
+ GLOB_SVELTE,
2670
+ GLOB_SVG,
2072
2671
  GLOB_TESTS,
2672
+ GLOB_TOML,
2073
2673
  GLOB_TS,
2074
2674
  GLOB_TSX,
2075
2675
  GLOB_VUE,
2676
+ GLOB_XML,
2076
2677
  GLOB_YAML,
2077
2678
  STYLISTIC_CONFIG_DEFAULTS,
2679
+ astro,
2078
2680
  combineConfigs,
2681
+ command,
2079
2682
  comments,
2080
2683
  defaultPluginRenaming,
2684
+ ensurePackages,
2081
2685
  formatters,
2082
2686
  ignores,
2083
2687
  imports,
2084
2688
  interopDefault,
2085
2689
  isInEditorEnv,
2690
+ isInGitHooksOrLintStaged,
2691
+ isPackageInScope,
2086
2692
  javascript,
2087
2693
  jsdoc,
2088
2694
  jsonc,
@@ -2091,8 +2697,8 @@ export {
2091
2697
  node,
2092
2698
  parserPlain,
2093
2699
  perfectionist,
2094
- default2 as pluginAntfu,
2095
- default3 as pluginComments,
2700
+ default3 as pluginAntfu,
2701
+ default2 as pluginComments,
2096
2702
  pluginImport,
2097
2703
  default4 as pluginNode,
2098
2704
  default5 as pluginPerfectionist,
@@ -2103,11 +2709,15 @@ export {
2103
2709
  regexp,
2104
2710
  renamePluginInConfigs,
2105
2711
  renameRules,
2712
+ solid,
2106
2713
  sonar,
2107
2714
  sortPackageJson,
2108
2715
  sortTsconfig,
2109
2716
  stylistic,
2717
+ svelte,
2110
2718
  test,
2719
+ toArray,
2720
+ toml,
2111
2721
  typescript,
2112
2722
  unicorn,
2113
2723
  unocss,