@coderwyd/eslint-config 2.7.2 → 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.js CHANGED
@@ -39,25 +39,16 @@ function comments() {
39
39
  // src/constants/glob.ts
40
40
  var GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
41
41
  var GLOB_SRC = "**/*.?([cm])[jt]s?(x)";
42
- var GLOB_JSX = "**/*.?([cm])jsx";
43
42
  var GLOB_TS = "**/*.?([cm])ts";
44
43
  var GLOB_DTS = "**/*.d.?([cm])ts";
45
44
  var GLOB_TSX = "**/*.?([cm])tsx";
46
45
  var GLOB_VUE = "**/*.vue";
47
46
  var GLOB_ASTRO_TS = "**/*.astro/*.ts";
48
47
  var GLOB_SVELTE = "**/*.svelte";
49
- var GLOB_HTML = "**/*.htm?(l)";
50
- var GLOB_CSS = "**/*.css";
51
- var GLOB_POSTCSS = "**/*.{p,post}css";
52
- var GLOB_LESS = "**/*.less";
53
- var GLOB_SCSS = "**/*.scss";
54
48
  var GLOB_JSON = "**/*.json";
55
49
  var GLOB_JSON5 = "**/*.json5";
56
50
  var GLOB_JSONC = "**/*.jsonc";
57
51
  var GLOB_MARKDOWN = "**/*.md";
58
- var GLOB_YAML = "**/*.y?(a)ml";
59
- var GLOB_TOML = "**/*.toml";
60
- var GLOB_GRAPHQL = "**/*.{g,graph}ql";
61
52
  var GLOB_MARKDOWN_CODE = `${GLOB_MARKDOWN}/${GLOB_SRC}`;
62
53
  var GLOB_TESTS = [
63
54
  `**/__tests__/**/*.${GLOB_SRC_EXT}`,
@@ -100,336 +91,18 @@ var GLOB_EXCLUDE = [
100
91
  "**/components.d.ts"
101
92
  ];
102
93
 
103
- // src/configs/disables.ts
104
- function disables() {
105
- return [
106
- {
107
- files: [`scripts/${GLOB_SRC}`],
108
- name: "coderwyd/disables/scripts",
109
- rules: {
110
- "no-console": "off",
111
- "ts/explicit-function-return-type": "off"
112
- }
113
- },
114
- {
115
- files: [`cli/${GLOB_SRC}`, `cli.${GLOB_SRC_EXT}`],
116
- name: "coderwyd/disables/cli",
117
- rules: {
118
- "no-console": "off"
119
- }
120
- },
121
- {
122
- files: ["**/bin/**/*", `**/bin.${GLOB_SRC_EXT}`],
123
- name: "coderwyd/disables/bin",
124
- rules: {
125
- "antfu/no-import-dist": "off",
126
- "antfu/no-import-node-modules-by-path": "off"
127
- }
128
- },
129
- {
130
- files: [GLOB_DTS],
131
- name: "coderwyd/disables/dts",
132
- rules: {
133
- "eslint-comments/no-unlimited-disable": "off",
134
- "import/no-duplicates": "off",
135
- "no-restricted-syntax": "off",
136
- "unused-imports/no-unused-vars": "off"
137
- }
138
- },
139
- {
140
- files: ["**/*.{test,spec}.([tj])s?(x)"],
141
- name: "coderwyd/disables/test",
142
- rules: {
143
- "no-unused-expressions": "off"
144
- }
145
- },
146
- {
147
- files: ["**/*.js", "**/*.cjs"],
148
- name: "coderwyd/disables/cjs",
149
- rules: {
150
- "ts/no-require-imports": "off"
151
- }
152
- }
153
- ];
154
- }
155
-
156
- // src/shared/index.ts
157
- import process from "node:process";
158
- import { fileURLToPath } from "node:url";
159
- import { getPackageInfoSync, isPackageExists } from "local-pkg";
160
- var scopeUrl = fileURLToPath(new URL(".", import.meta.url));
161
- var isCwdInScope = isPackageExists("@coderwyd/eslint-config");
162
- var parserPlain = {
163
- meta: {
164
- name: "parser-plain"
165
- },
166
- parseForESLint: (code) => ({
167
- ast: {
168
- body: [],
169
- comments: [],
170
- loc: { end: code.length, start: 0 },
171
- range: [0, code.length],
172
- tokens: [],
173
- type: "Program"
174
- },
175
- scopeManager: null,
176
- services: { isPlain: true },
177
- visitorKeys: {
178
- Program: []
179
- }
180
- })
181
- };
182
- async function combine(...configs2) {
183
- const resolved = await Promise.all(configs2);
184
- return resolved.flat();
185
- }
186
- function renameRules(rules, map) {
187
- return Object.fromEntries(
188
- Object.entries(rules).map(([key, value]) => {
189
- for (const [from, to] of Object.entries(map)) {
190
- if (key.startsWith(`${from}/`))
191
- return [to + key.slice(from.length), value];
192
- }
193
- return [key, value];
194
- })
195
- );
196
- }
197
- function renamePluginInConfigs(configs2, map) {
198
- return configs2.map((i) => {
199
- const clone = { ...i };
200
- if (clone.rules)
201
- clone.rules = renameRules(clone.rules, map);
202
- if (clone.plugins) {
203
- clone.plugins = Object.fromEntries(
204
- Object.entries(clone.plugins).map(([key, value]) => {
205
- if (key in map)
206
- return [map[key], value];
207
- return [key, value];
208
- })
209
- );
210
- }
211
- return clone;
212
- });
213
- }
214
- function getVueVersion() {
215
- const pkg = getPackageInfoSync("vue", { paths: [process.cwd()] });
216
- if (pkg && typeof pkg.version === "string" && !Number.isNaN(+pkg.version[0]))
217
- return +pkg.version[0];
218
- return 3;
219
- }
220
- function toArray(value) {
221
- return Array.isArray(value) ? value : [value];
222
- }
223
- async function interopDefault(m) {
224
- const resolved = await m;
225
- return resolved.default || resolved;
226
- }
227
- function isPackageInScope(name) {
228
- return isPackageExists(name, { paths: [scopeUrl] });
229
- }
230
- async function ensurePackages(packages) {
231
- if (process.env.CI || process.stdout.isTTY === false || isCwdInScope === false)
232
- return;
233
- const nonExistingPackages = packages.filter((i) => !isPackageInScope(i));
234
- if (nonExistingPackages.length === 0)
235
- return;
236
- const { default: prompts } = await import("prompts");
237
- const { result } = await prompts([
238
- {
239
- message: `${nonExistingPackages.length === 1 ? "Package is" : "Packages are"} required for this config: ${nonExistingPackages.join(", ")}. Do you want to install them?`,
240
- name: "result",
241
- type: "confirm"
242
- }
243
- ]);
244
- if (result) {
245
- await import("@antfu/install-pkg").then(
246
- (i) => i.installPackage(nonExistingPackages, { dev: true })
247
- );
248
- }
249
- }
250
- function resolveSubOptions(options, key) {
251
- return typeof options[key] === "boolean" ? {} : options[key] || {};
252
- }
253
- function getOverrides(options, key) {
254
- const sub = resolveSubOptions(options, key);
255
- return {
256
- ..."overrides" in sub ? sub.overrides || {} : {}
257
- };
258
- }
259
- function isInEditorEnv() {
260
- if (process.env.CI)
261
- return false;
262
- if (isInGitHooksOrLintStaged())
263
- return false;
264
- return !!(process.env.VSCODE_PID || process.env.VSCODE_CWD || process.env.JETBRAINS_IDE || process.env.VIM || process.env.NVIM || false);
265
- }
266
- function isInGitHooksOrLintStaged() {
267
- return !!(process.env.GIT_PARAMS || process.env.VSCODE_GIT_COMMAND || process.env.npm_lifecycle_script?.startsWith("lint-staged") || process.env.npm_lifecycle_script?.startsWith("nano-staged") || false);
268
- }
269
-
270
- // src/configs/stylistic.ts
271
- var StylisticConfigDefaults = {
272
- indent: 2,
273
- jsx: true,
274
- quotes: "single",
275
- semi: false
276
- };
277
- async function stylistic(options = {}) {
278
- const {
279
- indent,
280
- jsx: jsx2,
281
- overrides = {},
282
- quotes,
283
- semi
284
- } = {
285
- ...StylisticConfigDefaults,
286
- ...options
287
- };
288
- const pluginStylistic = await interopDefault(
289
- import("@stylistic/eslint-plugin")
290
- );
291
- const config = pluginStylistic.configs.customize({
292
- flat: true,
293
- indent,
294
- jsx: jsx2,
295
- pluginName: "style",
296
- quotes,
297
- semi
298
- });
299
- return [
300
- {
301
- name: "coderwyd/stylistic/rules",
302
- plugins: {
303
- antfu: default3,
304
- style: pluginStylistic
305
- },
306
- rules: {
307
- ...config.rules,
308
- "antfu/consistent-chaining": "error",
309
- "antfu/consistent-list-newline": "error",
310
- "antfu/curly": "error",
311
- "antfu/if-newline": "warn",
312
- "antfu/top-level-function": "warn",
313
- ...overrides
314
- }
315
- }
316
- ];
317
- }
318
-
319
- // src/configs/formatter.ts
320
- async function formatter(options = {}, stylistic2 = {}) {
321
- const { css, graphql, html, markdown, toml, yaml } = options === true ? {
322
- css: true,
323
- graphql: true,
324
- html: true,
325
- markdown: true,
326
- toml: true,
327
- yaml: true
328
- } : options;
329
- const { indent, quotes, semi } = {
330
- ...StylisticConfigDefaults,
331
- ...stylistic2
332
- };
333
- const prettierOptions = Object.assign(
334
- {
335
- endOfLine: "auto",
336
- printWidth: 80,
337
- semi,
338
- singleQuote: quotes === "single",
339
- tabWidth: typeof indent === "number" ? indent : 2,
340
- trailingComma: "all",
341
- useTabs: indent === "tab"
342
- },
343
- typeof options === "boolean" ? {} : options.prettierOptions || {}
344
- );
345
- await ensurePackages(["eslint-plugin-format"]);
346
- const pluginFormat = await interopDefault(import("eslint-plugin-format"));
347
- function createPrettierFormatter(files, parser, plugins) {
348
- const rules = {
349
- ...prettierOptions,
350
- parser
351
- };
352
- const markdownRules = {
353
- printWidth: 120,
354
- ...rules,
355
- embeddedLanguageFormatting: "off"
356
- };
357
- if (plugins?.length)
358
- rules.plugins = [...rules.plugins || [], ...plugins];
359
- const config = {
360
- files,
361
- languageOptions: {
362
- parser: parserPlain
363
- },
364
- name: `coderwyd/formatter/${parser}`,
365
- plugins: {
366
- format: pluginFormat
367
- },
368
- rules: {
369
- "format/prettier": [
370
- "warn",
371
- parser === "markdown" ? markdownRules : rules
372
- ]
373
- }
374
- };
375
- return config;
376
- }
377
- const configs2 = [
378
- {
379
- name: "coderwyd/formatter/setup",
380
- plugins: {
381
- format: pluginFormat
382
- }
383
- }
384
- ];
385
- if (html) {
386
- const htmlConfig = createPrettierFormatter([GLOB_HTML], "html");
387
- configs2.push(htmlConfig);
388
- }
389
- if (css) {
390
- const cssConfig = createPrettierFormatter([GLOB_CSS, GLOB_POSTCSS], "css");
391
- const scssConfig = createPrettierFormatter([GLOB_SCSS], "scss");
392
- const lessConfig = createPrettierFormatter([GLOB_LESS], "less");
393
- configs2.push(cssConfig, scssConfig, lessConfig);
394
- }
395
- if (markdown) {
396
- const markdownConfig = createPrettierFormatter([GLOB_MARKDOWN], "markdown");
397
- configs2.push(markdownConfig);
398
- }
399
- if (graphql) {
400
- const graphqlConfig = createPrettierFormatter([GLOB_GRAPHQL], "graphql");
401
- configs2.push(graphqlConfig);
402
- }
403
- if (yaml) {
404
- const yamlConfig = createPrettierFormatter([GLOB_YAML], "yaml");
405
- configs2.push(yamlConfig);
406
- }
407
- if (toml) {
408
- await ensurePackages(["@toml-tools/parser", "prettier-plugin-toml"]);
409
- const tomlConfig = createPrettierFormatter([GLOB_TOML], "toml", [
410
- "prettier-plugin-toml"
411
- ]);
412
- configs2.push(tomlConfig);
413
- }
414
- return configs2;
415
- }
416
-
417
94
  // src/configs/ignores.ts
418
95
  function ignores(userIgnores = []) {
419
96
  return [
420
97
  {
421
- ignores: [
422
- ...GLOB_EXCLUDE,
423
- ...userIgnores
424
- ],
98
+ ignores: [...GLOB_EXCLUDE, ...userIgnores],
425
99
  name: "coderwyd/ignores"
426
100
  }
427
101
  ];
428
102
  }
429
103
 
430
104
  // src/configs/imports.ts
431
- function imports(options = {}) {
432
- const { stylistic: stylistic2 = true } = options;
105
+ function imports() {
433
106
  return [
434
107
  {
435
108
  name: "coderwyd/imports/rules",
@@ -446,10 +119,7 @@ function imports(options = {}) {
446
119
  "import/no-mutable-exports": "error",
447
120
  "import/no-named-default": "error",
448
121
  "import/no-self-import": "error",
449
- "import/no-webpack-loader-syntax": "error",
450
- ...stylistic2 ? {
451
- "import/newline-after-import": ["error", { count: 1 }]
452
- } : {}
122
+ "import/no-webpack-loader-syntax": "error"
453
123
  }
454
124
  }
455
125
  ];
@@ -495,12 +165,13 @@ function javascript(options = {}) {
495
165
  "error",
496
166
  { enforceForClassMembers: true, setWithoutGet: true }
497
167
  ],
168
+ "antfu/no-top-level-await": "error",
498
169
  "array-callback-return": "error",
499
170
  "block-scoped-var": "error",
500
171
  "constructor-super": "error",
501
172
  "default-case-last": "error",
502
173
  "dot-notation": ["error", { allowKeywords: true }],
503
- "eqeqeq": ["error", "smart"],
174
+ eqeqeq: ["error", "smart"],
504
175
  "for-direction": "error",
505
176
  "getter-return": "error",
506
177
  "new-cap": [
@@ -681,16 +352,126 @@ function javascript(options = {}) {
681
352
  ],
682
353
  "valid-typeof": ["error", { requireStringLiterals: true }],
683
354
  "vars-on-top": "error",
684
- "yoda": ["error", "never"],
355
+ yoda: ["error", "never"],
685
356
  ...overrides
686
357
  }
687
358
  }
688
359
  ];
689
360
  }
690
361
 
362
+ // src/shared/index.ts
363
+ import process from "node:process";
364
+ import { fileURLToPath } from "node:url";
365
+ import { getPackageInfoSync, isPackageExists } from "local-pkg";
366
+ var scopeUrl = fileURLToPath(new URL(".", import.meta.url));
367
+ var isCwdInScope = isPackageExists("@coderwyd/eslint-config");
368
+ var parserPlain = {
369
+ meta: {
370
+ name: "parser-plain"
371
+ },
372
+ parseForESLint: (code) => ({
373
+ ast: {
374
+ body: [],
375
+ comments: [],
376
+ loc: { end: code.length, start: 0 },
377
+ range: [0, code.length],
378
+ tokens: [],
379
+ type: "Program"
380
+ },
381
+ scopeManager: null,
382
+ services: { isPlain: true },
383
+ visitorKeys: {
384
+ Program: []
385
+ }
386
+ })
387
+ };
388
+ async function combine(...configs2) {
389
+ const resolved = await Promise.all(configs2);
390
+ return resolved.flat();
391
+ }
392
+ function renameRules(rules, map) {
393
+ return Object.fromEntries(
394
+ Object.entries(rules).map(([key, value]) => {
395
+ for (const [from, to] of Object.entries(map)) {
396
+ if (key.startsWith(`${from}/`))
397
+ return [to + key.slice(from.length), value];
398
+ }
399
+ return [key, value];
400
+ })
401
+ );
402
+ }
403
+ function renamePluginInConfigs(configs2, map) {
404
+ return configs2.map((i) => {
405
+ const clone = { ...i };
406
+ if (clone.rules) clone.rules = renameRules(clone.rules, map);
407
+ if (clone.plugins) {
408
+ clone.plugins = Object.fromEntries(
409
+ Object.entries(clone.plugins).map(([key, value]) => {
410
+ if (key in map) return [map[key], value];
411
+ return [key, value];
412
+ })
413
+ );
414
+ }
415
+ return clone;
416
+ });
417
+ }
418
+ function getVueVersion() {
419
+ const pkg = getPackageInfoSync("vue", { paths: [process.cwd()] });
420
+ if (pkg && typeof pkg.version === "string" && !Number.isNaN(+pkg.version[0]))
421
+ return +pkg.version[0];
422
+ return 3;
423
+ }
424
+ function toArray(value) {
425
+ return Array.isArray(value) ? value : [value];
426
+ }
427
+ async function interopDefault(m) {
428
+ const resolved = await m;
429
+ return resolved.default || resolved;
430
+ }
431
+ function isPackageInScope(name) {
432
+ return isPackageExists(name, { paths: [scopeUrl] });
433
+ }
434
+ async function ensurePackages(packages) {
435
+ if (process.env.CI || process.stdout.isTTY === false || isCwdInScope === false)
436
+ return;
437
+ const nonExistingPackages = packages.filter((i) => !isPackageInScope(i));
438
+ if (nonExistingPackages.length === 0) return;
439
+ const { default: prompts } = await import("prompts");
440
+ const { result } = await prompts([
441
+ {
442
+ message: `${nonExistingPackages.length === 1 ? "Package is" : "Packages are"} required for this config: ${nonExistingPackages.join(", ")}. Do you want to install them?`,
443
+ name: "result",
444
+ type: "confirm"
445
+ }
446
+ ]);
447
+ if (result) {
448
+ await import("@antfu/install-pkg").then(
449
+ (i) => i.installPackage(nonExistingPackages, { dev: true })
450
+ );
451
+ }
452
+ }
453
+ function resolveSubOptions(options, key) {
454
+ return typeof options[key] === "boolean" ? {} : options[key] || {};
455
+ }
456
+ function getOverrides(options, key) {
457
+ const sub = resolveSubOptions(options, key);
458
+ return {
459
+ ..."overrides" in sub ? sub.overrides || {} : {}
460
+ };
461
+ }
462
+ function isInEditorEnv() {
463
+ if (process.env.CI) return false;
464
+ if (isInGitHooksOrLintStaged()) {
465
+ return false;
466
+ }
467
+ return !!(process.env.VSCODE_PID || process.env.VSCODE_CWD || process.env.JETBRAINS_IDE || process.env.VIM || process.env.NVIM || false);
468
+ }
469
+ function isInGitHooksOrLintStaged() {
470
+ return !!(process.env.GIT_PARAMS || process.env.VSCODE_GIT_COMMAND || process.env.npm_lifecycle_script?.startsWith("lint-staged") || process.env.npm_lifecycle_script?.startsWith("nano-staged") || false);
471
+ }
472
+
691
473
  // src/configs/jsdoc.ts
692
- async function jsdoc(options = {}) {
693
- const { stylistic: stylistic2 = true } = options;
474
+ async function jsdoc() {
694
475
  return [
695
476
  {
696
477
  name: "coderwyd/jsdoc/rules",
@@ -712,11 +493,7 @@ async function jsdoc(options = {}) {
712
493
  "jsdoc/require-property-name": "warn",
713
494
  "jsdoc/require-returns-check": "warn",
714
495
  "jsdoc/require-returns-description": "warn",
715
- "jsdoc/require-yields-check": "warn",
716
- ...stylistic2 ? {
717
- "jsdoc/check-alignment": "warn",
718
- "jsdoc/multiline-blocks": "warn"
719
- } : {}
496
+ "jsdoc/require-yields-check": "warn"
720
497
  }
721
498
  }
722
499
  ];
@@ -724,14 +501,7 @@ async function jsdoc(options = {}) {
724
501
 
725
502
  // src/configs/jsonc.ts
726
503
  async function jsonc(options = {}) {
727
- const {
728
- files = [GLOB_JSON, GLOB_JSON5, GLOB_JSONC],
729
- overrides = {},
730
- stylistic: stylistic2 = true
731
- } = options || {};
732
- const {
733
- indent = 2
734
- } = typeof stylistic2 === "boolean" ? {} : stylistic2;
504
+ const { files = [GLOB_JSON, GLOB_JSON5, GLOB_JSONC], overrides = {} } = options || {};
735
505
  const [pluginJsonc, parserJsonc] = await Promise.all([
736
506
  interopDefault(import("eslint-plugin-jsonc")),
737
507
  interopDefault(import("jsonc-eslint-parser"))
@@ -776,50 +546,12 @@ async function jsonc(options = {}) {
776
546
  "jsonc/space-unary-ops": "error",
777
547
  "jsonc/valid-json-number": "error",
778
548
  "jsonc/vue-custom-block/no-parsing-error": "error",
779
- ...stylistic2 ? {
780
- "jsonc/array-bracket-spacing": ["error", "never"],
781
- "jsonc/comma-dangle": ["error", "never"],
782
- "jsonc/comma-style": ["error", "last"],
783
- "jsonc/indent": ["error", indent],
784
- "jsonc/key-spacing": [
785
- "error",
786
- { afterColon: true, beforeColon: false }
787
- ],
788
- "jsonc/object-curly-newline": [
789
- "error",
790
- { consistent: true, multiline: true }
791
- ],
792
- "jsonc/object-curly-spacing": ["error", "always"],
793
- "jsonc/object-property-newline": [
794
- "error",
795
- { allowMultiplePropertiesPerLine: true }
796
- ],
797
- "jsonc/quote-props": "error",
798
- "jsonc/quotes": "error"
799
- } : {},
800
549
  ...overrides
801
550
  }
802
551
  }
803
552
  ];
804
553
  }
805
554
 
806
- // src/configs/jsx.ts
807
- function jsx() {
808
- return [
809
- {
810
- files: [GLOB_JSX, GLOB_TSX],
811
- languageOptions: {
812
- parserOptions: {
813
- ecmaFeatures: {
814
- jsx: true
815
- }
816
- }
817
- },
818
- name: "coderwyd/jsx/setup"
819
- }
820
- ];
821
- }
822
-
823
555
  // src/configs/node.ts
824
556
  function node() {
825
557
  return [
@@ -852,7 +584,10 @@ function perfectionist() {
852
584
  perfectionist: default5
853
585
  },
854
586
  rules: {
855
- "perfectionist/sort-exports": ["error", { order: "asc", type: "natural" }],
587
+ "perfectionist/sort-exports": [
588
+ "error",
589
+ { order: "asc", type: "natural" }
590
+ ],
856
591
  "perfectionist/sort-imports": [
857
592
  "warn",
858
593
  {
@@ -888,6 +623,27 @@ function perfectionist() {
888
623
  ];
889
624
  }
890
625
 
626
+ // src/configs/prettier.ts
627
+ import prettierRules from "eslint-config-prettier";
628
+ var { rules: eslintRules } = prettierRules;
629
+ async function prettier() {
630
+ const pluginPrettier = await interopDefault(import("eslint-plugin-prettier"));
631
+ return [
632
+ {
633
+ name: "coderwyd/prettier/rules",
634
+ plugins: {
635
+ prettier: pluginPrettier
636
+ },
637
+ rules: {
638
+ ...eslintRules,
639
+ "arrow-body-style": "off",
640
+ "prefer-arrow-callback": "off",
641
+ "prettier/prettier": "warn"
642
+ }
643
+ }
644
+ ];
645
+ }
646
+
891
647
  // src/configs/react.ts
892
648
  import { isPackageExists as isPackageExists3 } from "local-pkg";
893
649
 
@@ -896,12 +652,7 @@ import process2 from "node:process";
896
652
  import { isPackageExists as isPackageExists2 } from "local-pkg";
897
653
  var isInEditor = !!((process2.env.VSCODE_PID || process2.env.VSCODE_CWD || process2.env.JETBRAINS_IDE || process2.env.VIM || process2.env.NVIM) && !process2.env.CI);
898
654
  var hasTypeScript = isPackageExists2("typescript");
899
- var VueJsPackages = [
900
- "vue",
901
- "nuxt",
902
- "vitepress",
903
- "@slidev/cli"
904
- ];
655
+ var VueJsPackages = ["vue", "nuxt", "vitepress", "@slidev/cli"];
905
656
  var hasVue = hasPackages(VueJsPackages);
906
657
  var RemixPackages = [
907
658
  "@remix-run/node",
@@ -941,7 +692,7 @@ async function react(options = {}) {
941
692
  {
942
693
  name: "coderwyd/react/setup",
943
694
  plugins: {
944
- "react": plugins["@eslint-react"],
695
+ react: plugins["@eslint-react"],
945
696
  "react-dom": plugins["@eslint-react/dom"],
946
697
  "react-hooks": pluginReactHooks,
947
698
  "react-hooks-extra": plugins["@eslint-react/hooks-extra"],
@@ -985,6 +736,13 @@ async function react(options = {}) {
985
736
  allowConstantExport: isAllowConstantExport,
986
737
  allowExportNames: [
987
738
  ...isUsingNext ? [
739
+ "dynamic",
740
+ "dynamicParams",
741
+ "revalidate",
742
+ "fetchCache",
743
+ "runtime",
744
+ "preferredRegion",
745
+ "maxDuration",
988
746
  "config",
989
747
  "generateStaticParams",
990
748
  "metadata",
@@ -1052,8 +810,7 @@ function regexp(options = {}) {
1052
810
  };
1053
811
  if (options.level === "warn") {
1054
812
  Object.keys(rules).forEach((key) => {
1055
- if (rules[key] === "error")
1056
- rules[key] = "warn";
813
+ if (rules[key] === "error") rules[key] = "warn";
1057
814
  });
1058
815
  }
1059
816
  return [
@@ -1292,13 +1049,65 @@ function sortTsconfig() {
1292
1049
  ];
1293
1050
  }
1294
1051
 
1052
+ // src/configs/specials.ts
1053
+ function specials() {
1054
+ return [
1055
+ {
1056
+ files: [`**/scripts/${GLOB_SRC}`],
1057
+ name: "coderwyd/specials/scripts",
1058
+ rules: {
1059
+ "antfu/no-top-level-await": "off",
1060
+ "no-console": "off",
1061
+ "ts/explicit-function-return-type": "off"
1062
+ }
1063
+ },
1064
+ {
1065
+ files: [`**/cli/${GLOB_SRC}`, `**/cli.${GLOB_SRC_EXT}`],
1066
+ name: "coderwyd/specials/cli",
1067
+ rules: {
1068
+ "antfu/no-top-level-await": "off",
1069
+ "no-console": "off"
1070
+ }
1071
+ },
1072
+ {
1073
+ files: ["**/bin/**/*", `**/bin.${GLOB_SRC_EXT}`],
1074
+ name: "coderwyd/specials/bin",
1075
+ rules: {
1076
+ "antfu/no-import-dist": "off",
1077
+ "antfu/no-import-node-modules-by-path": "off"
1078
+ }
1079
+ },
1080
+ {
1081
+ files: [GLOB_DTS],
1082
+ name: "coderwyd/specials/dts",
1083
+ rules: {
1084
+ "eslint-comments/no-unlimited-disable": "off",
1085
+ "import/no-duplicates": "off",
1086
+ "no-restricted-syntax": "off",
1087
+ "unused-imports/no-unused-vars": "off"
1088
+ }
1089
+ },
1090
+ {
1091
+ files: ["**/*.{test,spec}.([tj])s?(x)"],
1092
+ name: "coderwyd/specials/test",
1093
+ rules: {
1094
+ "antfu/no-top-level-await": "off",
1095
+ "no-unused-expressions": "off"
1096
+ }
1097
+ },
1098
+ {
1099
+ files: ["**/*.js", "**/*.cjs"],
1100
+ name: "coderwyd/specials/cjs",
1101
+ rules: {
1102
+ "ts/no-require-imports": "off"
1103
+ }
1104
+ }
1105
+ ];
1106
+ }
1107
+
1295
1108
  // src/configs/svelte.ts
1296
1109
  async function svelte(options = {}) {
1297
- const { files = [GLOB_SVELTE], overrides = {}, stylistic: stylistic2 = true } = options;
1298
- const {
1299
- indent = 2,
1300
- quotes = "single"
1301
- } = typeof stylistic2 === "boolean" ? {} : stylistic2;
1110
+ const { files = [GLOB_SVELTE], overrides = {} } = options;
1302
1111
  await ensurePackages(["eslint-plugin-svelte"]);
1303
1112
  const [pluginSvelte, parserSvelte] = await Promise.all([
1304
1113
  interopDefault(import("eslint-plugin-svelte")),
@@ -1367,23 +1176,6 @@ async function svelte(options = {}) {
1367
1176
  varsIgnorePattern: "^(_|\\$\\$Props$|\\$\\$Events$|\\$\\$Slots$)"
1368
1177
  }
1369
1178
  ],
1370
- ...stylistic2 ? {
1371
- "style/indent": "off",
1372
- // superseded by svelte/indent
1373
- "style/no-trailing-spaces": "off",
1374
- // superseded by svelte/no-trailing-spaces
1375
- "svelte/derived-has-same-inputs-outputs": "error",
1376
- "svelte/html-closing-bracket-spacing": "error",
1377
- "svelte/html-quotes": ["error", { prefer: quotes }],
1378
- "svelte/indent": [
1379
- "error",
1380
- { alignAttributesVertically: true, indent }
1381
- ],
1382
- "svelte/mustache-spacing": "error",
1383
- "svelte/no-spaces-around-equal-signs-in-attribute": "error",
1384
- "svelte/no-trailing-spaces": "error",
1385
- "svelte/spaced-html-comment": "error"
1386
- } : {},
1387
1179
  ...overrides
1388
1180
  }
1389
1181
  }
@@ -1466,7 +1258,12 @@ async function test(options = {}) {
1466
1258
  // src/configs/typescript.ts
1467
1259
  import process3 from "node:process";
1468
1260
  async function typescript(options = {}) {
1469
- const { componentExts = [], overrides = {}, overridesTypeAware = {}, parserOptions = {} } = options;
1261
+ const {
1262
+ componentExts = [],
1263
+ overrides = {},
1264
+ overridesTypeAware = {},
1265
+ parserOptions = {}
1266
+ } = options;
1470
1267
  const files = options.files ?? [
1471
1268
  GLOB_TS,
1472
1269
  GLOB_TSX,
@@ -1584,8 +1381,16 @@ async function typescript(options = {}) {
1584
1381
  "ts/no-import-type-side-effects": "error",
1585
1382
  "ts/no-invalid-void-type": "off",
1586
1383
  "ts/no-non-null-assertion": "off",
1587
- "ts/no-redeclare": "error",
1384
+ "ts/no-redeclare": ["error", { builtinGlobals: false }],
1588
1385
  "ts/no-require-imports": "error",
1386
+ "ts/no-unused-expressions": [
1387
+ "error",
1388
+ {
1389
+ allowShortCircuit: true,
1390
+ allowTaggedTemplates: true,
1391
+ allowTernary: true
1392
+ }
1393
+ ],
1589
1394
  "ts/no-unused-vars": "off",
1590
1395
  "ts/no-use-before-define": [
1591
1396
  "error",
@@ -1718,15 +1523,11 @@ async function unocss(options = {}) {
1718
1523
  }
1719
1524
 
1720
1525
  // src/configs/vue.ts
1721
- import { mergeProcessors } from "eslint-merge-processors";
1722
1526
  async function vue(options = {}) {
1723
- const { files = [GLOB_VUE], overrides = {}, stylistic: stylistic2 = true } = options;
1724
- const sfcBlocks = options.sfcBlocks === true ? {} : options.sfcBlocks ?? {};
1725
- const { indent = 2 } = typeof stylistic2 === "boolean" ? {} : stylistic2;
1726
- const [pluginVue, parserVue, processorVueBlocks] = await Promise.all([
1527
+ const { files = [GLOB_VUE], overrides = {} } = options;
1528
+ const [pluginVue, parserVue] = await Promise.all([
1727
1529
  interopDefault(import("eslint-plugin-vue")),
1728
- interopDefault(import("vue-eslint-parser")),
1729
- interopDefault(import("eslint-processor-vue-blocks"))
1530
+ interopDefault(import("vue-eslint-parser"))
1730
1531
  ]);
1731
1532
  const isVue3 = getVueVersion() === 3;
1732
1533
  const configKeys = isVue3 ? ["vue3-essential", "vue3-strongly-recommended", "vue3-recommended"] : ["essential", "strongly-recommended", "recommended"];
@@ -1738,32 +1539,6 @@ async function vue(options = {}) {
1738
1539
  };
1739
1540
  }, {});
1740
1541
  return [
1741
- {
1742
- // This allows Vue plugin to work with auto imports
1743
- // https://github.com/vuejs/eslint-plugin-vue/pull/2422
1744
- languageOptions: {
1745
- globals: {
1746
- computed: "readonly",
1747
- defineEmits: "readonly",
1748
- defineExpose: "readonly",
1749
- defineProps: "readonly",
1750
- onMounted: "readonly",
1751
- onUnmounted: "readonly",
1752
- reactive: "readonly",
1753
- ref: "readonly",
1754
- shallowReactive: "readonly",
1755
- shallowRef: "readonly",
1756
- toRef: "readonly",
1757
- toRefs: "readonly",
1758
- watch: "readonly",
1759
- watchEffect: "readonly"
1760
- }
1761
- },
1762
- name: "coderwyd/vue/setup",
1763
- plugins: {
1764
- vue: pluginVue
1765
- }
1766
- },
1767
1542
  {
1768
1543
  files,
1769
1544
  languageOptions: {
@@ -1780,20 +1555,16 @@ async function vue(options = {}) {
1780
1555
  }
1781
1556
  },
1782
1557
  name: "coderwyd/vue/rules",
1783
- processor: sfcBlocks === false ? pluginVue.processors[".vue"] : mergeProcessors([
1784
- pluginVue.processors[".vue"],
1785
- processorVueBlocks({
1786
- ...sfcBlocks,
1787
- blocks: {
1788
- styles: true,
1789
- ...sfcBlocks.blocks
1790
- }
1791
- })
1792
- ]),
1558
+ plugins: {
1559
+ vue: pluginVue
1560
+ },
1561
+ processor: pluginVue.processors[".vue"],
1793
1562
  rules: {
1794
1563
  ...pluginVue.configs.base.rules,
1795
1564
  ...vueRules,
1565
+ "antfu/no-top-level-await": "off",
1796
1566
  "node/prefer-global/process": "off",
1567
+ "ts/explicit-function-return-type": "off",
1797
1568
  "vue/block-order": [
1798
1569
  "error",
1799
1570
  {
@@ -1819,11 +1590,7 @@ async function vue(options = {}) {
1819
1590
  }
1820
1591
  ],
1821
1592
  // 'vue/define-props-declaration': ['warn', 'type-based'],
1822
- "vue/dot-location": ["error", "property"],
1823
- "vue/dot-notation": ["error", { allowKeywords: true }],
1824
1593
  "vue/eqeqeq": ["error", "smart"],
1825
- "vue/html-indent": ["error", indent],
1826
- "vue/html-quotes": ["error", "double"],
1827
1594
  "vue/html-self-closing": [
1828
1595
  "error",
1829
1596
  {
@@ -1840,7 +1607,6 @@ async function vue(options = {}) {
1840
1607
  "vue/multi-word-component-names": "off",
1841
1608
  // 'vue/next-tick-style': ['warn', 'promise'],
1842
1609
  "vue/no-constant-condition": "warn",
1843
- "vue/no-dupe-keys": "off",
1844
1610
  "vue/no-duplicate-attr-inheritance": "warn",
1845
1611
  "vue/no-empty-pattern": "error",
1846
1612
  "vue/no-extra-parens": ["error", "functions"],
@@ -1872,6 +1638,7 @@ async function vue(options = {}) {
1872
1638
  ignoreConstructors: false
1873
1639
  }
1874
1640
  ],
1641
+ "vue/padding-line-between-blocks": ["error", "always"],
1875
1642
  "vue/prefer-define-options": "warn",
1876
1643
  "vue/prefer-separate-static-class": "error",
1877
1644
  "vue/prefer-template": "error",
@@ -1892,50 +1659,6 @@ async function vue(options = {}) {
1892
1659
  "vue/space-infix-ops": "error",
1893
1660
  "vue/space-unary-ops": ["error", { nonwords: false, words: true }],
1894
1661
  "vue/valid-define-options": "warn",
1895
- ...stylistic2 ? {
1896
- "vue/array-bracket-spacing": ["error", "never"],
1897
- "vue/arrow-spacing": ["error", { after: true, before: true }],
1898
- "vue/block-spacing": ["error", "always"],
1899
- "vue/block-tag-newline": [
1900
- "error",
1901
- {
1902
- multiline: "always",
1903
- singleline: "always"
1904
- }
1905
- ],
1906
- "vue/brace-style": [
1907
- "error",
1908
- "stroustrup",
1909
- { allowSingleLine: true }
1910
- ],
1911
- "vue/comma-dangle": ["error", "always-multiline"],
1912
- "vue/comma-spacing": ["error", { after: true, before: false }],
1913
- "vue/comma-style": ["error", "last"],
1914
- "vue/html-comment-content-newline": "warn",
1915
- "vue/html-comment-content-spacing": [
1916
- "error",
1917
- "always",
1918
- {
1919
- exceptions: ["-"]
1920
- }
1921
- ],
1922
- "vue/key-spacing": [
1923
- "error",
1924
- { afterColon: true, beforeColon: false }
1925
- ],
1926
- "vue/keyword-spacing": ["error", { after: true, before: true }],
1927
- "vue/object-curly-newline": "off",
1928
- "vue/object-curly-spacing": ["error", "always"],
1929
- "vue/object-property-newline": [
1930
- "error",
1931
- { allowMultiplePropertiesPerLine: true }
1932
- ],
1933
- "vue/operator-linebreak": ["error", "before"],
1934
- "vue/padding-line-between-blocks": ["error", "always"],
1935
- "vue/quote-props": ["error", "consistent-as-needed"],
1936
- "vue/space-in-parens": ["error", "never"],
1937
- "vue/template-curly-spacing": "error"
1938
- } : {},
1939
1662
  ...overrides
1940
1663
  }
1941
1664
  }
@@ -1957,23 +1680,17 @@ var defaultPluginRenaming = {
1957
1680
  "@eslint-react/dom": "react-dom",
1958
1681
  "@eslint-react/hooks-extra": "react-hooks-extra",
1959
1682
  "@eslint-react/naming-convention": "react-naming-convention",
1960
- "@stylistic": "style",
1961
1683
  "@typescript-eslint": "ts",
1962
1684
  "import-x": "import",
1963
- "n": "node",
1964
- "vitest": "test",
1965
- "yml": "yaml"
1685
+ n: "node",
1686
+ vitest: "test",
1687
+ yml: "yaml"
1966
1688
  };
1967
1689
  async function defineConfig(options = {}, ...userConfigs) {
1968
1690
  const {
1969
1691
  autoRenamePlugins = true,
1970
1692
  componentExts = [],
1971
- formatter: formatterOptions = {
1972
- css: true,
1973
- html: true
1974
- },
1975
1693
  gitignore: enableGitignore = true,
1976
- jsx: enableJsx = true,
1977
1694
  react: enableReact = false,
1978
1695
  regexp: enableRegexp = true,
1979
1696
  svelte: enableSvelte = false,
@@ -1986,11 +1703,10 @@ async function defineConfig(options = {}, ...userConfigs) {
1986
1703
  if (isInEditor2 == null) {
1987
1704
  isInEditor2 = isInEditorEnv();
1988
1705
  if (isInEditor2)
1989
- console.log("[@coderwyd/eslint-config] Detected running in editor, some rules are disabled.");
1706
+ console.log(
1707
+ "[@coderwyd/eslint-config] Detected running in editor, some rules are disabled."
1708
+ );
1990
1709
  }
1991
- const stylisticOptions = options.stylistic === false ? false : typeof options.stylistic === "object" ? options.stylistic : {};
1992
- if (stylisticOptions && !("jsx" in stylisticOptions))
1993
- stylisticOptions.jsx = enableJsx;
1994
1710
  const configs2 = [];
1995
1711
  if (enableGitignore) {
1996
1712
  if (typeof enableGitignore !== "boolean") {
@@ -2003,7 +1719,11 @@ async function defineConfig(options = {}, ...userConfigs) {
2003
1719
  ])
2004
1720
  );
2005
1721
  } else {
2006
- configs2.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r({ name: "coderwyd/gitignore", strict: false })]));
1722
+ configs2.push(
1723
+ interopDefault(import("eslint-config-flat-gitignore")).then((r) => [
1724
+ r({ name: "coderwyd/gitignore", strict: false })
1725
+ ])
1726
+ );
2007
1727
  }
2008
1728
  }
2009
1729
  const typescriptOptions = resolveSubOptions(options, "typescript");
@@ -2016,22 +1736,15 @@ async function defineConfig(options = {}, ...userConfigs) {
2016
1736
  }),
2017
1737
  comments(),
2018
1738
  node(),
2019
- jsdoc({
2020
- stylistic: stylisticOptions
2021
- }),
2022
- imports({
2023
- stylistic: stylisticOptions
2024
- }),
1739
+ jsdoc(),
1740
+ imports(),
2025
1741
  unicorn(),
2026
1742
  command(),
1743
+ prettier(),
2027
1744
  // Optional plugins (installed but not enabled by default)
2028
1745
  perfectionist()
2029
1746
  );
2030
- if (enableVue)
2031
- componentExts.push("vue");
2032
- if (enableJsx) {
2033
- configs2.push(jsx());
2034
- }
1747
+ if (enableVue) componentExts.push("vue");
2035
1748
  if (enableTypeScript) {
2036
1749
  configs2.push(
2037
1750
  typescript({
@@ -2041,14 +1754,6 @@ async function defineConfig(options = {}, ...userConfigs) {
2041
1754
  })
2042
1755
  );
2043
1756
  }
2044
- if (stylisticOptions) {
2045
- configs2.push(
2046
- stylistic({
2047
- ...stylisticOptions,
2048
- overrides: getOverrides(options, "stylistic")
2049
- })
2050
- );
2051
- }
2052
1757
  if (enableRegexp)
2053
1758
  configs2.push(regexp(typeof enableRegexp === "boolean" ? {} : enableRegexp));
2054
1759
  if (options.test ?? true) {
@@ -2064,7 +1769,6 @@ async function defineConfig(options = {}, ...userConfigs) {
2064
1769
  vue({
2065
1770
  ...resolveSubOptions(options, "vue"),
2066
1771
  overrides: getOverrides(options, "typescript"),
2067
- stylistic: stylisticOptions,
2068
1772
  typescript: !!enableTypeScript
2069
1773
  })
2070
1774
  );
@@ -2081,7 +1785,6 @@ async function defineConfig(options = {}, ...userConfigs) {
2081
1785
  configs2.push(
2082
1786
  svelte({
2083
1787
  overrides: getOverrides(options, "svelte"),
2084
- stylistic: stylisticOptions,
2085
1788
  typescript: !!enableTypeScript
2086
1789
  })
2087
1790
  );
@@ -2105,32 +1808,23 @@ async function defineConfig(options = {}, ...userConfigs) {
2105
1808
  if (options.jsonc ?? true) {
2106
1809
  configs2.push(
2107
1810
  jsonc({
2108
- overrides: getOverrides(options, "jsonc"),
2109
- stylistic: stylisticOptions
1811
+ overrides: getOverrides(options, "jsonc")
2110
1812
  }),
2111
1813
  sortPackageJson(),
2112
1814
  sortTsconfig()
2113
1815
  );
2114
1816
  }
2115
- if (formatterOptions) {
2116
- configs2.push(
2117
- formatter(
2118
- formatterOptions,
2119
- typeof stylisticOptions === "boolean" ? {} : stylisticOptions
2120
- )
2121
- );
2122
- }
2123
- configs2.push(disables());
1817
+ configs2.push(specials());
2124
1818
  if ("files" in options) {
2125
- throw new Error('[@coderwyd/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.');
1819
+ throw new Error(
1820
+ '[@coderwyd/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.'
1821
+ );
2126
1822
  }
2127
1823
  const fusedConfig = flatConfigProps.reduce((acc, key) => {
2128
- if (key in options)
2129
- acc[key] = options[key];
1824
+ if (key in options) acc[key] = options[key];
2130
1825
  return acc;
2131
1826
  }, {});
2132
- if (Object.keys(fusedConfig).length > 0)
2133
- configs2.push([fusedConfig]);
1827
+ if (Object.keys(fusedConfig).length > 0) configs2.push([fusedConfig]);
2134
1828
  const merged = await combine(...configs2, ...userConfigs);
2135
1829
  if (autoRenamePlugins)
2136
1830
  return renamePluginInConfigs(merged, defaultPluginRenaming);