@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.cjs CHANGED
@@ -48,7 +48,7 @@ __export(src_exports, {
48
48
  });
49
49
  module.exports = __toCommonJS(src_exports);
50
50
 
51
- // node_modules/.pnpm/tsup@8.2.4_jiti@1.21.6_postcss@8.4.39_tsx@4.19.1_typescript@5.6.2_yaml@2.5.0/node_modules/tsup/assets/cjs_shims.js
51
+ // node_modules/.pnpm/tsup@8.3.0_jiti@2.0.0_postcss@8.4.39_tsx@4.19.1_typescript@5.6.2_yaml@2.5.0/node_modules/tsup/assets/cjs_shims.js
52
52
  var getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.src || new URL("main.js", document.baseURI).href;
53
53
  var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
54
54
 
@@ -93,25 +93,16 @@ function comments() {
93
93
  // src/constants/glob.ts
94
94
  var GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
95
95
  var GLOB_SRC = "**/*.?([cm])[jt]s?(x)";
96
- var GLOB_JSX = "**/*.?([cm])jsx";
97
96
  var GLOB_TS = "**/*.?([cm])ts";
98
97
  var GLOB_DTS = "**/*.d.?([cm])ts";
99
98
  var GLOB_TSX = "**/*.?([cm])tsx";
100
99
  var GLOB_VUE = "**/*.vue";
101
100
  var GLOB_ASTRO_TS = "**/*.astro/*.ts";
102
101
  var GLOB_SVELTE = "**/*.svelte";
103
- var GLOB_HTML = "**/*.htm?(l)";
104
- var GLOB_CSS = "**/*.css";
105
- var GLOB_POSTCSS = "**/*.{p,post}css";
106
- var GLOB_LESS = "**/*.less";
107
- var GLOB_SCSS = "**/*.scss";
108
102
  var GLOB_JSON = "**/*.json";
109
103
  var GLOB_JSON5 = "**/*.json5";
110
104
  var GLOB_JSONC = "**/*.jsonc";
111
105
  var GLOB_MARKDOWN = "**/*.md";
112
- var GLOB_YAML = "**/*.y?(a)ml";
113
- var GLOB_TOML = "**/*.toml";
114
- var GLOB_GRAPHQL = "**/*.{g,graph}ql";
115
106
  var GLOB_MARKDOWN_CODE = `${GLOB_MARKDOWN}/${GLOB_SRC}`;
116
107
  var GLOB_TESTS = [
117
108
  `**/__tests__/**/*.${GLOB_SRC_EXT}`,
@@ -154,336 +145,18 @@ var GLOB_EXCLUDE = [
154
145
  "**/components.d.ts"
155
146
  ];
156
147
 
157
- // src/configs/disables.ts
158
- function disables() {
159
- return [
160
- {
161
- files: [`scripts/${GLOB_SRC}`],
162
- name: "coderwyd/disables/scripts",
163
- rules: {
164
- "no-console": "off",
165
- "ts/explicit-function-return-type": "off"
166
- }
167
- },
168
- {
169
- files: [`cli/${GLOB_SRC}`, `cli.${GLOB_SRC_EXT}`],
170
- name: "coderwyd/disables/cli",
171
- rules: {
172
- "no-console": "off"
173
- }
174
- },
175
- {
176
- files: ["**/bin/**/*", `**/bin.${GLOB_SRC_EXT}`],
177
- name: "coderwyd/disables/bin",
178
- rules: {
179
- "antfu/no-import-dist": "off",
180
- "antfu/no-import-node-modules-by-path": "off"
181
- }
182
- },
183
- {
184
- files: [GLOB_DTS],
185
- name: "coderwyd/disables/dts",
186
- rules: {
187
- "eslint-comments/no-unlimited-disable": "off",
188
- "import/no-duplicates": "off",
189
- "no-restricted-syntax": "off",
190
- "unused-imports/no-unused-vars": "off"
191
- }
192
- },
193
- {
194
- files: ["**/*.{test,spec}.([tj])s?(x)"],
195
- name: "coderwyd/disables/test",
196
- rules: {
197
- "no-unused-expressions": "off"
198
- }
199
- },
200
- {
201
- files: ["**/*.js", "**/*.cjs"],
202
- name: "coderwyd/disables/cjs",
203
- rules: {
204
- "ts/no-require-imports": "off"
205
- }
206
- }
207
- ];
208
- }
209
-
210
- // src/shared/index.ts
211
- var import_node_process = __toESM(require("process"), 1);
212
- var import_node_url = require("url");
213
- var import_local_pkg = require("local-pkg");
214
- var scopeUrl = (0, import_node_url.fileURLToPath)(new URL(".", importMetaUrl));
215
- var isCwdInScope = (0, import_local_pkg.isPackageExists)("@coderwyd/eslint-config");
216
- var parserPlain = {
217
- meta: {
218
- name: "parser-plain"
219
- },
220
- parseForESLint: (code) => ({
221
- ast: {
222
- body: [],
223
- comments: [],
224
- loc: { end: code.length, start: 0 },
225
- range: [0, code.length],
226
- tokens: [],
227
- type: "Program"
228
- },
229
- scopeManager: null,
230
- services: { isPlain: true },
231
- visitorKeys: {
232
- Program: []
233
- }
234
- })
235
- };
236
- async function combine(...configs2) {
237
- const resolved = await Promise.all(configs2);
238
- return resolved.flat();
239
- }
240
- function renameRules(rules, map) {
241
- return Object.fromEntries(
242
- Object.entries(rules).map(([key, value]) => {
243
- for (const [from, to] of Object.entries(map)) {
244
- if (key.startsWith(`${from}/`))
245
- return [to + key.slice(from.length), value];
246
- }
247
- return [key, value];
248
- })
249
- );
250
- }
251
- function renamePluginInConfigs(configs2, map) {
252
- return configs2.map((i) => {
253
- const clone = { ...i };
254
- if (clone.rules)
255
- clone.rules = renameRules(clone.rules, map);
256
- if (clone.plugins) {
257
- clone.plugins = Object.fromEntries(
258
- Object.entries(clone.plugins).map(([key, value]) => {
259
- if (key in map)
260
- return [map[key], value];
261
- return [key, value];
262
- })
263
- );
264
- }
265
- return clone;
266
- });
267
- }
268
- function getVueVersion() {
269
- const pkg = (0, import_local_pkg.getPackageInfoSync)("vue", { paths: [import_node_process.default.cwd()] });
270
- if (pkg && typeof pkg.version === "string" && !Number.isNaN(+pkg.version[0]))
271
- return +pkg.version[0];
272
- return 3;
273
- }
274
- function toArray(value) {
275
- return Array.isArray(value) ? value : [value];
276
- }
277
- async function interopDefault(m) {
278
- const resolved = await m;
279
- return resolved.default || resolved;
280
- }
281
- function isPackageInScope(name) {
282
- return (0, import_local_pkg.isPackageExists)(name, { paths: [scopeUrl] });
283
- }
284
- async function ensurePackages(packages) {
285
- if (import_node_process.default.env.CI || import_node_process.default.stdout.isTTY === false || isCwdInScope === false)
286
- return;
287
- const nonExistingPackages = packages.filter((i) => !isPackageInScope(i));
288
- if (nonExistingPackages.length === 0)
289
- return;
290
- const { default: prompts } = await import("prompts");
291
- const { result } = await prompts([
292
- {
293
- message: `${nonExistingPackages.length === 1 ? "Package is" : "Packages are"} required for this config: ${nonExistingPackages.join(", ")}. Do you want to install them?`,
294
- name: "result",
295
- type: "confirm"
296
- }
297
- ]);
298
- if (result) {
299
- await import("@antfu/install-pkg").then(
300
- (i) => i.installPackage(nonExistingPackages, { dev: true })
301
- );
302
- }
303
- }
304
- function resolveSubOptions(options, key) {
305
- return typeof options[key] === "boolean" ? {} : options[key] || {};
306
- }
307
- function getOverrides(options, key) {
308
- const sub = resolveSubOptions(options, key);
309
- return {
310
- ..."overrides" in sub ? sub.overrides || {} : {}
311
- };
312
- }
313
- function isInEditorEnv() {
314
- if (import_node_process.default.env.CI)
315
- return false;
316
- if (isInGitHooksOrLintStaged())
317
- return false;
318
- 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 || false);
319
- }
320
- function isInGitHooksOrLintStaged() {
321
- 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") || import_node_process.default.env.npm_lifecycle_script?.startsWith("nano-staged") || false);
322
- }
323
-
324
- // src/configs/stylistic.ts
325
- var StylisticConfigDefaults = {
326
- indent: 2,
327
- jsx: true,
328
- quotes: "single",
329
- semi: false
330
- };
331
- async function stylistic(options = {}) {
332
- const {
333
- indent,
334
- jsx: jsx2,
335
- overrides = {},
336
- quotes,
337
- semi
338
- } = {
339
- ...StylisticConfigDefaults,
340
- ...options
341
- };
342
- const pluginStylistic = await interopDefault(
343
- import("@stylistic/eslint-plugin")
344
- );
345
- const config = pluginStylistic.configs.customize({
346
- flat: true,
347
- indent,
348
- jsx: jsx2,
349
- pluginName: "style",
350
- quotes,
351
- semi
352
- });
353
- return [
354
- {
355
- name: "coderwyd/stylistic/rules",
356
- plugins: {
357
- antfu: import_eslint_plugin_antfu.default,
358
- style: pluginStylistic
359
- },
360
- rules: {
361
- ...config.rules,
362
- "antfu/consistent-chaining": "error",
363
- "antfu/consistent-list-newline": "error",
364
- "antfu/curly": "error",
365
- "antfu/if-newline": "warn",
366
- "antfu/top-level-function": "warn",
367
- ...overrides
368
- }
369
- }
370
- ];
371
- }
372
-
373
- // src/configs/formatter.ts
374
- async function formatter(options = {}, stylistic2 = {}) {
375
- const { css, graphql, html, markdown, toml, yaml } = options === true ? {
376
- css: true,
377
- graphql: true,
378
- html: true,
379
- markdown: true,
380
- toml: true,
381
- yaml: true
382
- } : options;
383
- const { indent, quotes, semi } = {
384
- ...StylisticConfigDefaults,
385
- ...stylistic2
386
- };
387
- const prettierOptions = Object.assign(
388
- {
389
- endOfLine: "auto",
390
- printWidth: 80,
391
- semi,
392
- singleQuote: quotes === "single",
393
- tabWidth: typeof indent === "number" ? indent : 2,
394
- trailingComma: "all",
395
- useTabs: indent === "tab"
396
- },
397
- typeof options === "boolean" ? {} : options.prettierOptions || {}
398
- );
399
- await ensurePackages(["eslint-plugin-format"]);
400
- const pluginFormat = await interopDefault(import("eslint-plugin-format"));
401
- function createPrettierFormatter(files, parser, plugins) {
402
- const rules = {
403
- ...prettierOptions,
404
- parser
405
- };
406
- const markdownRules = {
407
- printWidth: 120,
408
- ...rules,
409
- embeddedLanguageFormatting: "off"
410
- };
411
- if (plugins?.length)
412
- rules.plugins = [...rules.plugins || [], ...plugins];
413
- const config = {
414
- files,
415
- languageOptions: {
416
- parser: parserPlain
417
- },
418
- name: `coderwyd/formatter/${parser}`,
419
- plugins: {
420
- format: pluginFormat
421
- },
422
- rules: {
423
- "format/prettier": [
424
- "warn",
425
- parser === "markdown" ? markdownRules : rules
426
- ]
427
- }
428
- };
429
- return config;
430
- }
431
- const configs2 = [
432
- {
433
- name: "coderwyd/formatter/setup",
434
- plugins: {
435
- format: pluginFormat
436
- }
437
- }
438
- ];
439
- if (html) {
440
- const htmlConfig = createPrettierFormatter([GLOB_HTML], "html");
441
- configs2.push(htmlConfig);
442
- }
443
- if (css) {
444
- const cssConfig = createPrettierFormatter([GLOB_CSS, GLOB_POSTCSS], "css");
445
- const scssConfig = createPrettierFormatter([GLOB_SCSS], "scss");
446
- const lessConfig = createPrettierFormatter([GLOB_LESS], "less");
447
- configs2.push(cssConfig, scssConfig, lessConfig);
448
- }
449
- if (markdown) {
450
- const markdownConfig = createPrettierFormatter([GLOB_MARKDOWN], "markdown");
451
- configs2.push(markdownConfig);
452
- }
453
- if (graphql) {
454
- const graphqlConfig = createPrettierFormatter([GLOB_GRAPHQL], "graphql");
455
- configs2.push(graphqlConfig);
456
- }
457
- if (yaml) {
458
- const yamlConfig = createPrettierFormatter([GLOB_YAML], "yaml");
459
- configs2.push(yamlConfig);
460
- }
461
- if (toml) {
462
- await ensurePackages(["@toml-tools/parser", "prettier-plugin-toml"]);
463
- const tomlConfig = createPrettierFormatter([GLOB_TOML], "toml", [
464
- "prettier-plugin-toml"
465
- ]);
466
- configs2.push(tomlConfig);
467
- }
468
- return configs2;
469
- }
470
-
471
148
  // src/configs/ignores.ts
472
149
  function ignores(userIgnores = []) {
473
150
  return [
474
151
  {
475
- ignores: [
476
- ...GLOB_EXCLUDE,
477
- ...userIgnores
478
- ],
152
+ ignores: [...GLOB_EXCLUDE, ...userIgnores],
479
153
  name: "coderwyd/ignores"
480
154
  }
481
155
  ];
482
156
  }
483
157
 
484
158
  // src/configs/imports.ts
485
- function imports(options = {}) {
486
- const { stylistic: stylistic2 = true } = options;
159
+ function imports() {
487
160
  return [
488
161
  {
489
162
  name: "coderwyd/imports/rules",
@@ -500,10 +173,7 @@ function imports(options = {}) {
500
173
  "import/no-mutable-exports": "error",
501
174
  "import/no-named-default": "error",
502
175
  "import/no-self-import": "error",
503
- "import/no-webpack-loader-syntax": "error",
504
- ...stylistic2 ? {
505
- "import/newline-after-import": ["error", { count: 1 }]
506
- } : {}
176
+ "import/no-webpack-loader-syntax": "error"
507
177
  }
508
178
  }
509
179
  ];
@@ -549,12 +219,13 @@ function javascript(options = {}) {
549
219
  "error",
550
220
  { enforceForClassMembers: true, setWithoutGet: true }
551
221
  ],
222
+ "antfu/no-top-level-await": "error",
552
223
  "array-callback-return": "error",
553
224
  "block-scoped-var": "error",
554
225
  "constructor-super": "error",
555
226
  "default-case-last": "error",
556
227
  "dot-notation": ["error", { allowKeywords: true }],
557
- "eqeqeq": ["error", "smart"],
228
+ eqeqeq: ["error", "smart"],
558
229
  "for-direction": "error",
559
230
  "getter-return": "error",
560
231
  "new-cap": [
@@ -735,16 +406,126 @@ function javascript(options = {}) {
735
406
  ],
736
407
  "valid-typeof": ["error", { requireStringLiterals: true }],
737
408
  "vars-on-top": "error",
738
- "yoda": ["error", "never"],
409
+ yoda: ["error", "never"],
739
410
  ...overrides
740
411
  }
741
412
  }
742
413
  ];
743
414
  }
744
415
 
416
+ // src/shared/index.ts
417
+ var import_node_process = __toESM(require("process"), 1);
418
+ var import_node_url = require("url");
419
+ var import_local_pkg = require("local-pkg");
420
+ var scopeUrl = (0, import_node_url.fileURLToPath)(new URL(".", importMetaUrl));
421
+ var isCwdInScope = (0, import_local_pkg.isPackageExists)("@coderwyd/eslint-config");
422
+ var parserPlain = {
423
+ meta: {
424
+ name: "parser-plain"
425
+ },
426
+ parseForESLint: (code) => ({
427
+ ast: {
428
+ body: [],
429
+ comments: [],
430
+ loc: { end: code.length, start: 0 },
431
+ range: [0, code.length],
432
+ tokens: [],
433
+ type: "Program"
434
+ },
435
+ scopeManager: null,
436
+ services: { isPlain: true },
437
+ visitorKeys: {
438
+ Program: []
439
+ }
440
+ })
441
+ };
442
+ async function combine(...configs2) {
443
+ const resolved = await Promise.all(configs2);
444
+ return resolved.flat();
445
+ }
446
+ function renameRules(rules, map) {
447
+ return Object.fromEntries(
448
+ Object.entries(rules).map(([key, value]) => {
449
+ for (const [from, to] of Object.entries(map)) {
450
+ if (key.startsWith(`${from}/`))
451
+ return [to + key.slice(from.length), value];
452
+ }
453
+ return [key, value];
454
+ })
455
+ );
456
+ }
457
+ function renamePluginInConfigs(configs2, map) {
458
+ return configs2.map((i) => {
459
+ const clone = { ...i };
460
+ if (clone.rules) clone.rules = renameRules(clone.rules, map);
461
+ if (clone.plugins) {
462
+ clone.plugins = Object.fromEntries(
463
+ Object.entries(clone.plugins).map(([key, value]) => {
464
+ if (key in map) return [map[key], value];
465
+ return [key, value];
466
+ })
467
+ );
468
+ }
469
+ return clone;
470
+ });
471
+ }
472
+ function getVueVersion() {
473
+ const pkg = (0, import_local_pkg.getPackageInfoSync)("vue", { paths: [import_node_process.default.cwd()] });
474
+ if (pkg && typeof pkg.version === "string" && !Number.isNaN(+pkg.version[0]))
475
+ return +pkg.version[0];
476
+ return 3;
477
+ }
478
+ function toArray(value) {
479
+ return Array.isArray(value) ? value : [value];
480
+ }
481
+ async function interopDefault(m) {
482
+ const resolved = await m;
483
+ return resolved.default || resolved;
484
+ }
485
+ function isPackageInScope(name) {
486
+ return (0, import_local_pkg.isPackageExists)(name, { paths: [scopeUrl] });
487
+ }
488
+ async function ensurePackages(packages) {
489
+ if (import_node_process.default.env.CI || import_node_process.default.stdout.isTTY === false || isCwdInScope === false)
490
+ return;
491
+ const nonExistingPackages = packages.filter((i) => !isPackageInScope(i));
492
+ if (nonExistingPackages.length === 0) return;
493
+ const { default: prompts } = await import("prompts");
494
+ const { result } = await prompts([
495
+ {
496
+ message: `${nonExistingPackages.length === 1 ? "Package is" : "Packages are"} required for this config: ${nonExistingPackages.join(", ")}. Do you want to install them?`,
497
+ name: "result",
498
+ type: "confirm"
499
+ }
500
+ ]);
501
+ if (result) {
502
+ await import("@antfu/install-pkg").then(
503
+ (i) => i.installPackage(nonExistingPackages, { dev: true })
504
+ );
505
+ }
506
+ }
507
+ function resolveSubOptions(options, key) {
508
+ return typeof options[key] === "boolean" ? {} : options[key] || {};
509
+ }
510
+ function getOverrides(options, key) {
511
+ const sub = resolveSubOptions(options, key);
512
+ return {
513
+ ..."overrides" in sub ? sub.overrides || {} : {}
514
+ };
515
+ }
516
+ function isInEditorEnv() {
517
+ if (import_node_process.default.env.CI) return false;
518
+ if (isInGitHooksOrLintStaged()) {
519
+ return false;
520
+ }
521
+ 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 || false);
522
+ }
523
+ function isInGitHooksOrLintStaged() {
524
+ 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") || import_node_process.default.env.npm_lifecycle_script?.startsWith("nano-staged") || false);
525
+ }
526
+
745
527
  // src/configs/jsdoc.ts
746
- async function jsdoc(options = {}) {
747
- const { stylistic: stylistic2 = true } = options;
528
+ async function jsdoc() {
748
529
  return [
749
530
  {
750
531
  name: "coderwyd/jsdoc/rules",
@@ -766,11 +547,7 @@ async function jsdoc(options = {}) {
766
547
  "jsdoc/require-property-name": "warn",
767
548
  "jsdoc/require-returns-check": "warn",
768
549
  "jsdoc/require-returns-description": "warn",
769
- "jsdoc/require-yields-check": "warn",
770
- ...stylistic2 ? {
771
- "jsdoc/check-alignment": "warn",
772
- "jsdoc/multiline-blocks": "warn"
773
- } : {}
550
+ "jsdoc/require-yields-check": "warn"
774
551
  }
775
552
  }
776
553
  ];
@@ -778,14 +555,7 @@ async function jsdoc(options = {}) {
778
555
 
779
556
  // src/configs/jsonc.ts
780
557
  async function jsonc(options = {}) {
781
- const {
782
- files = [GLOB_JSON, GLOB_JSON5, GLOB_JSONC],
783
- overrides = {},
784
- stylistic: stylistic2 = true
785
- } = options || {};
786
- const {
787
- indent = 2
788
- } = typeof stylistic2 === "boolean" ? {} : stylistic2;
558
+ const { files = [GLOB_JSON, GLOB_JSON5, GLOB_JSONC], overrides = {} } = options || {};
789
559
  const [pluginJsonc, parserJsonc] = await Promise.all([
790
560
  interopDefault(import("eslint-plugin-jsonc")),
791
561
  interopDefault(import("jsonc-eslint-parser"))
@@ -830,50 +600,12 @@ async function jsonc(options = {}) {
830
600
  "jsonc/space-unary-ops": "error",
831
601
  "jsonc/valid-json-number": "error",
832
602
  "jsonc/vue-custom-block/no-parsing-error": "error",
833
- ...stylistic2 ? {
834
- "jsonc/array-bracket-spacing": ["error", "never"],
835
- "jsonc/comma-dangle": ["error", "never"],
836
- "jsonc/comma-style": ["error", "last"],
837
- "jsonc/indent": ["error", indent],
838
- "jsonc/key-spacing": [
839
- "error",
840
- { afterColon: true, beforeColon: false }
841
- ],
842
- "jsonc/object-curly-newline": [
843
- "error",
844
- { consistent: true, multiline: true }
845
- ],
846
- "jsonc/object-curly-spacing": ["error", "always"],
847
- "jsonc/object-property-newline": [
848
- "error",
849
- { allowMultiplePropertiesPerLine: true }
850
- ],
851
- "jsonc/quote-props": "error",
852
- "jsonc/quotes": "error"
853
- } : {},
854
603
  ...overrides
855
604
  }
856
605
  }
857
606
  ];
858
607
  }
859
608
 
860
- // src/configs/jsx.ts
861
- function jsx() {
862
- return [
863
- {
864
- files: [GLOB_JSX, GLOB_TSX],
865
- languageOptions: {
866
- parserOptions: {
867
- ecmaFeatures: {
868
- jsx: true
869
- }
870
- }
871
- },
872
- name: "coderwyd/jsx/setup"
873
- }
874
- ];
875
- }
876
-
877
609
  // src/configs/node.ts
878
610
  function node() {
879
611
  return [
@@ -906,7 +638,10 @@ function perfectionist() {
906
638
  perfectionist: import_eslint_plugin_perfectionist.default
907
639
  },
908
640
  rules: {
909
- "perfectionist/sort-exports": ["error", { order: "asc", type: "natural" }],
641
+ "perfectionist/sort-exports": [
642
+ "error",
643
+ { order: "asc", type: "natural" }
644
+ ],
910
645
  "perfectionist/sort-imports": [
911
646
  "warn",
912
647
  {
@@ -942,6 +677,27 @@ function perfectionist() {
942
677
  ];
943
678
  }
944
679
 
680
+ // src/configs/prettier.ts
681
+ var import_eslint_config_prettier = __toESM(require("eslint-config-prettier"), 1);
682
+ var { rules: eslintRules } = import_eslint_config_prettier.default;
683
+ async function prettier() {
684
+ const pluginPrettier = await interopDefault(import("eslint-plugin-prettier"));
685
+ return [
686
+ {
687
+ name: "coderwyd/prettier/rules",
688
+ plugins: {
689
+ prettier: pluginPrettier
690
+ },
691
+ rules: {
692
+ ...eslintRules,
693
+ "arrow-body-style": "off",
694
+ "prefer-arrow-callback": "off",
695
+ "prettier/prettier": "warn"
696
+ }
697
+ }
698
+ ];
699
+ }
700
+
945
701
  // src/configs/react.ts
946
702
  var import_local_pkg3 = require("local-pkg");
947
703
 
@@ -950,12 +706,7 @@ var import_node_process2 = __toESM(require("process"), 1);
950
706
  var import_local_pkg2 = require("local-pkg");
951
707
  var isInEditor = !!((import_node_process2.default.env.VSCODE_PID || import_node_process2.default.env.VSCODE_CWD || import_node_process2.default.env.JETBRAINS_IDE || import_node_process2.default.env.VIM || import_node_process2.default.env.NVIM) && !import_node_process2.default.env.CI);
952
708
  var hasTypeScript = (0, import_local_pkg2.isPackageExists)("typescript");
953
- var VueJsPackages = [
954
- "vue",
955
- "nuxt",
956
- "vitepress",
957
- "@slidev/cli"
958
- ];
709
+ var VueJsPackages = ["vue", "nuxt", "vitepress", "@slidev/cli"];
959
710
  var hasVue = hasPackages(VueJsPackages);
960
711
  var RemixPackages = [
961
712
  "@remix-run/node",
@@ -995,7 +746,7 @@ async function react(options = {}) {
995
746
  {
996
747
  name: "coderwyd/react/setup",
997
748
  plugins: {
998
- "react": plugins["@eslint-react"],
749
+ react: plugins["@eslint-react"],
999
750
  "react-dom": plugins["@eslint-react/dom"],
1000
751
  "react-hooks": pluginReactHooks,
1001
752
  "react-hooks-extra": plugins["@eslint-react/hooks-extra"],
@@ -1039,6 +790,13 @@ async function react(options = {}) {
1039
790
  allowConstantExport: isAllowConstantExport,
1040
791
  allowExportNames: [
1041
792
  ...isUsingNext ? [
793
+ "dynamic",
794
+ "dynamicParams",
795
+ "revalidate",
796
+ "fetchCache",
797
+ "runtime",
798
+ "preferredRegion",
799
+ "maxDuration",
1042
800
  "config",
1043
801
  "generateStaticParams",
1044
802
  "metadata",
@@ -1106,8 +864,7 @@ function regexp(options = {}) {
1106
864
  };
1107
865
  if (options.level === "warn") {
1108
866
  Object.keys(rules).forEach((key) => {
1109
- if (rules[key] === "error")
1110
- rules[key] = "warn";
867
+ if (rules[key] === "error") rules[key] = "warn";
1111
868
  });
1112
869
  }
1113
870
  return [
@@ -1346,13 +1103,65 @@ function sortTsconfig() {
1346
1103
  ];
1347
1104
  }
1348
1105
 
1106
+ // src/configs/specials.ts
1107
+ function specials() {
1108
+ return [
1109
+ {
1110
+ files: [`**/scripts/${GLOB_SRC}`],
1111
+ name: "coderwyd/specials/scripts",
1112
+ rules: {
1113
+ "antfu/no-top-level-await": "off",
1114
+ "no-console": "off",
1115
+ "ts/explicit-function-return-type": "off"
1116
+ }
1117
+ },
1118
+ {
1119
+ files: [`**/cli/${GLOB_SRC}`, `**/cli.${GLOB_SRC_EXT}`],
1120
+ name: "coderwyd/specials/cli",
1121
+ rules: {
1122
+ "antfu/no-top-level-await": "off",
1123
+ "no-console": "off"
1124
+ }
1125
+ },
1126
+ {
1127
+ files: ["**/bin/**/*", `**/bin.${GLOB_SRC_EXT}`],
1128
+ name: "coderwyd/specials/bin",
1129
+ rules: {
1130
+ "antfu/no-import-dist": "off",
1131
+ "antfu/no-import-node-modules-by-path": "off"
1132
+ }
1133
+ },
1134
+ {
1135
+ files: [GLOB_DTS],
1136
+ name: "coderwyd/specials/dts",
1137
+ rules: {
1138
+ "eslint-comments/no-unlimited-disable": "off",
1139
+ "import/no-duplicates": "off",
1140
+ "no-restricted-syntax": "off",
1141
+ "unused-imports/no-unused-vars": "off"
1142
+ }
1143
+ },
1144
+ {
1145
+ files: ["**/*.{test,spec}.([tj])s?(x)"],
1146
+ name: "coderwyd/specials/test",
1147
+ rules: {
1148
+ "antfu/no-top-level-await": "off",
1149
+ "no-unused-expressions": "off"
1150
+ }
1151
+ },
1152
+ {
1153
+ files: ["**/*.js", "**/*.cjs"],
1154
+ name: "coderwyd/specials/cjs",
1155
+ rules: {
1156
+ "ts/no-require-imports": "off"
1157
+ }
1158
+ }
1159
+ ];
1160
+ }
1161
+
1349
1162
  // src/configs/svelte.ts
1350
1163
  async function svelte(options = {}) {
1351
- const { files = [GLOB_SVELTE], overrides = {}, stylistic: stylistic2 = true } = options;
1352
- const {
1353
- indent = 2,
1354
- quotes = "single"
1355
- } = typeof stylistic2 === "boolean" ? {} : stylistic2;
1164
+ const { files = [GLOB_SVELTE], overrides = {} } = options;
1356
1165
  await ensurePackages(["eslint-plugin-svelte"]);
1357
1166
  const [pluginSvelte, parserSvelte] = await Promise.all([
1358
1167
  interopDefault(import("eslint-plugin-svelte")),
@@ -1421,23 +1230,6 @@ async function svelte(options = {}) {
1421
1230
  varsIgnorePattern: "^(_|\\$\\$Props$|\\$\\$Events$|\\$\\$Slots$)"
1422
1231
  }
1423
1232
  ],
1424
- ...stylistic2 ? {
1425
- "style/indent": "off",
1426
- // superseded by svelte/indent
1427
- "style/no-trailing-spaces": "off",
1428
- // superseded by svelte/no-trailing-spaces
1429
- "svelte/derived-has-same-inputs-outputs": "error",
1430
- "svelte/html-closing-bracket-spacing": "error",
1431
- "svelte/html-quotes": ["error", { prefer: quotes }],
1432
- "svelte/indent": [
1433
- "error",
1434
- { alignAttributesVertically: true, indent }
1435
- ],
1436
- "svelte/mustache-spacing": "error",
1437
- "svelte/no-spaces-around-equal-signs-in-attribute": "error",
1438
- "svelte/no-trailing-spaces": "error",
1439
- "svelte/spaced-html-comment": "error"
1440
- } : {},
1441
1233
  ...overrides
1442
1234
  }
1443
1235
  }
@@ -1520,7 +1312,12 @@ async function test(options = {}) {
1520
1312
  // src/configs/typescript.ts
1521
1313
  var import_node_process3 = __toESM(require("process"), 1);
1522
1314
  async function typescript(options = {}) {
1523
- const { componentExts = [], overrides = {}, overridesTypeAware = {}, parserOptions = {} } = options;
1315
+ const {
1316
+ componentExts = [],
1317
+ overrides = {},
1318
+ overridesTypeAware = {},
1319
+ parserOptions = {}
1320
+ } = options;
1524
1321
  const files = options.files ?? [
1525
1322
  GLOB_TS,
1526
1323
  GLOB_TSX,
@@ -1638,8 +1435,16 @@ async function typescript(options = {}) {
1638
1435
  "ts/no-import-type-side-effects": "error",
1639
1436
  "ts/no-invalid-void-type": "off",
1640
1437
  "ts/no-non-null-assertion": "off",
1641
- "ts/no-redeclare": "error",
1438
+ "ts/no-redeclare": ["error", { builtinGlobals: false }],
1642
1439
  "ts/no-require-imports": "error",
1440
+ "ts/no-unused-expressions": [
1441
+ "error",
1442
+ {
1443
+ allowShortCircuit: true,
1444
+ allowTaggedTemplates: true,
1445
+ allowTernary: true
1446
+ }
1447
+ ],
1643
1448
  "ts/no-unused-vars": "off",
1644
1449
  "ts/no-use-before-define": [
1645
1450
  "error",
@@ -1772,15 +1577,11 @@ async function unocss(options = {}) {
1772
1577
  }
1773
1578
 
1774
1579
  // src/configs/vue.ts
1775
- var import_eslint_merge_processors = require("eslint-merge-processors");
1776
1580
  async function vue(options = {}) {
1777
- const { files = [GLOB_VUE], overrides = {}, stylistic: stylistic2 = true } = options;
1778
- const sfcBlocks = options.sfcBlocks === true ? {} : options.sfcBlocks ?? {};
1779
- const { indent = 2 } = typeof stylistic2 === "boolean" ? {} : stylistic2;
1780
- const [pluginVue, parserVue, processorVueBlocks] = await Promise.all([
1581
+ const { files = [GLOB_VUE], overrides = {} } = options;
1582
+ const [pluginVue, parserVue] = await Promise.all([
1781
1583
  interopDefault(import("eslint-plugin-vue")),
1782
- interopDefault(import("vue-eslint-parser")),
1783
- interopDefault(import("eslint-processor-vue-blocks"))
1584
+ interopDefault(import("vue-eslint-parser"))
1784
1585
  ]);
1785
1586
  const isVue3 = getVueVersion() === 3;
1786
1587
  const configKeys = isVue3 ? ["vue3-essential", "vue3-strongly-recommended", "vue3-recommended"] : ["essential", "strongly-recommended", "recommended"];
@@ -1792,32 +1593,6 @@ async function vue(options = {}) {
1792
1593
  };
1793
1594
  }, {});
1794
1595
  return [
1795
- {
1796
- // This allows Vue plugin to work with auto imports
1797
- // https://github.com/vuejs/eslint-plugin-vue/pull/2422
1798
- languageOptions: {
1799
- globals: {
1800
- computed: "readonly",
1801
- defineEmits: "readonly",
1802
- defineExpose: "readonly",
1803
- defineProps: "readonly",
1804
- onMounted: "readonly",
1805
- onUnmounted: "readonly",
1806
- reactive: "readonly",
1807
- ref: "readonly",
1808
- shallowReactive: "readonly",
1809
- shallowRef: "readonly",
1810
- toRef: "readonly",
1811
- toRefs: "readonly",
1812
- watch: "readonly",
1813
- watchEffect: "readonly"
1814
- }
1815
- },
1816
- name: "coderwyd/vue/setup",
1817
- plugins: {
1818
- vue: pluginVue
1819
- }
1820
- },
1821
1596
  {
1822
1597
  files,
1823
1598
  languageOptions: {
@@ -1834,20 +1609,16 @@ async function vue(options = {}) {
1834
1609
  }
1835
1610
  },
1836
1611
  name: "coderwyd/vue/rules",
1837
- processor: sfcBlocks === false ? pluginVue.processors[".vue"] : (0, import_eslint_merge_processors.mergeProcessors)([
1838
- pluginVue.processors[".vue"],
1839
- processorVueBlocks({
1840
- ...sfcBlocks,
1841
- blocks: {
1842
- styles: true,
1843
- ...sfcBlocks.blocks
1844
- }
1845
- })
1846
- ]),
1612
+ plugins: {
1613
+ vue: pluginVue
1614
+ },
1615
+ processor: pluginVue.processors[".vue"],
1847
1616
  rules: {
1848
1617
  ...pluginVue.configs.base.rules,
1849
1618
  ...vueRules,
1619
+ "antfu/no-top-level-await": "off",
1850
1620
  "node/prefer-global/process": "off",
1621
+ "ts/explicit-function-return-type": "off",
1851
1622
  "vue/block-order": [
1852
1623
  "error",
1853
1624
  {
@@ -1873,11 +1644,7 @@ async function vue(options = {}) {
1873
1644
  }
1874
1645
  ],
1875
1646
  // 'vue/define-props-declaration': ['warn', 'type-based'],
1876
- "vue/dot-location": ["error", "property"],
1877
- "vue/dot-notation": ["error", { allowKeywords: true }],
1878
1647
  "vue/eqeqeq": ["error", "smart"],
1879
- "vue/html-indent": ["error", indent],
1880
- "vue/html-quotes": ["error", "double"],
1881
1648
  "vue/html-self-closing": [
1882
1649
  "error",
1883
1650
  {
@@ -1894,7 +1661,6 @@ async function vue(options = {}) {
1894
1661
  "vue/multi-word-component-names": "off",
1895
1662
  // 'vue/next-tick-style': ['warn', 'promise'],
1896
1663
  "vue/no-constant-condition": "warn",
1897
- "vue/no-dupe-keys": "off",
1898
1664
  "vue/no-duplicate-attr-inheritance": "warn",
1899
1665
  "vue/no-empty-pattern": "error",
1900
1666
  "vue/no-extra-parens": ["error", "functions"],
@@ -1926,6 +1692,7 @@ async function vue(options = {}) {
1926
1692
  ignoreConstructors: false
1927
1693
  }
1928
1694
  ],
1695
+ "vue/padding-line-between-blocks": ["error", "always"],
1929
1696
  "vue/prefer-define-options": "warn",
1930
1697
  "vue/prefer-separate-static-class": "error",
1931
1698
  "vue/prefer-template": "error",
@@ -1946,50 +1713,6 @@ async function vue(options = {}) {
1946
1713
  "vue/space-infix-ops": "error",
1947
1714
  "vue/space-unary-ops": ["error", { nonwords: false, words: true }],
1948
1715
  "vue/valid-define-options": "warn",
1949
- ...stylistic2 ? {
1950
- "vue/array-bracket-spacing": ["error", "never"],
1951
- "vue/arrow-spacing": ["error", { after: true, before: true }],
1952
- "vue/block-spacing": ["error", "always"],
1953
- "vue/block-tag-newline": [
1954
- "error",
1955
- {
1956
- multiline: "always",
1957
- singleline: "always"
1958
- }
1959
- ],
1960
- "vue/brace-style": [
1961
- "error",
1962
- "stroustrup",
1963
- { allowSingleLine: true }
1964
- ],
1965
- "vue/comma-dangle": ["error", "always-multiline"],
1966
- "vue/comma-spacing": ["error", { after: true, before: false }],
1967
- "vue/comma-style": ["error", "last"],
1968
- "vue/html-comment-content-newline": "warn",
1969
- "vue/html-comment-content-spacing": [
1970
- "error",
1971
- "always",
1972
- {
1973
- exceptions: ["-"]
1974
- }
1975
- ],
1976
- "vue/key-spacing": [
1977
- "error",
1978
- { afterColon: true, beforeColon: false }
1979
- ],
1980
- "vue/keyword-spacing": ["error", { after: true, before: true }],
1981
- "vue/object-curly-newline": "off",
1982
- "vue/object-curly-spacing": ["error", "always"],
1983
- "vue/object-property-newline": [
1984
- "error",
1985
- { allowMultiplePropertiesPerLine: true }
1986
- ],
1987
- "vue/operator-linebreak": ["error", "before"],
1988
- "vue/padding-line-between-blocks": ["error", "always"],
1989
- "vue/quote-props": ["error", "consistent-as-needed"],
1990
- "vue/space-in-parens": ["error", "never"],
1991
- "vue/template-curly-spacing": "error"
1992
- } : {},
1993
1716
  ...overrides
1994
1717
  }
1995
1718
  }
@@ -2011,23 +1734,17 @@ var defaultPluginRenaming = {
2011
1734
  "@eslint-react/dom": "react-dom",
2012
1735
  "@eslint-react/hooks-extra": "react-hooks-extra",
2013
1736
  "@eslint-react/naming-convention": "react-naming-convention",
2014
- "@stylistic": "style",
2015
1737
  "@typescript-eslint": "ts",
2016
1738
  "import-x": "import",
2017
- "n": "node",
2018
- "vitest": "test",
2019
- "yml": "yaml"
1739
+ n: "node",
1740
+ vitest: "test",
1741
+ yml: "yaml"
2020
1742
  };
2021
1743
  async function defineConfig(options = {}, ...userConfigs) {
2022
1744
  const {
2023
1745
  autoRenamePlugins = true,
2024
1746
  componentExts = [],
2025
- formatter: formatterOptions = {
2026
- css: true,
2027
- html: true
2028
- },
2029
1747
  gitignore: enableGitignore = true,
2030
- jsx: enableJsx = true,
2031
1748
  react: enableReact = false,
2032
1749
  regexp: enableRegexp = true,
2033
1750
  svelte: enableSvelte = false,
@@ -2040,11 +1757,10 @@ async function defineConfig(options = {}, ...userConfigs) {
2040
1757
  if (isInEditor2 == null) {
2041
1758
  isInEditor2 = isInEditorEnv();
2042
1759
  if (isInEditor2)
2043
- console.log("[@coderwyd/eslint-config] Detected running in editor, some rules are disabled.");
1760
+ console.log(
1761
+ "[@coderwyd/eslint-config] Detected running in editor, some rules are disabled."
1762
+ );
2044
1763
  }
2045
- const stylisticOptions = options.stylistic === false ? false : typeof options.stylistic === "object" ? options.stylistic : {};
2046
- if (stylisticOptions && !("jsx" in stylisticOptions))
2047
- stylisticOptions.jsx = enableJsx;
2048
1764
  const configs2 = [];
2049
1765
  if (enableGitignore) {
2050
1766
  if (typeof enableGitignore !== "boolean") {
@@ -2057,7 +1773,11 @@ async function defineConfig(options = {}, ...userConfigs) {
2057
1773
  ])
2058
1774
  );
2059
1775
  } else {
2060
- configs2.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r({ name: "coderwyd/gitignore", strict: false })]));
1776
+ configs2.push(
1777
+ interopDefault(import("eslint-config-flat-gitignore")).then((r) => [
1778
+ r({ name: "coderwyd/gitignore", strict: false })
1779
+ ])
1780
+ );
2061
1781
  }
2062
1782
  }
2063
1783
  const typescriptOptions = resolveSubOptions(options, "typescript");
@@ -2070,22 +1790,15 @@ async function defineConfig(options = {}, ...userConfigs) {
2070
1790
  }),
2071
1791
  comments(),
2072
1792
  node(),
2073
- jsdoc({
2074
- stylistic: stylisticOptions
2075
- }),
2076
- imports({
2077
- stylistic: stylisticOptions
2078
- }),
1793
+ jsdoc(),
1794
+ imports(),
2079
1795
  unicorn(),
2080
1796
  command(),
1797
+ prettier(),
2081
1798
  // Optional plugins (installed but not enabled by default)
2082
1799
  perfectionist()
2083
1800
  );
2084
- if (enableVue)
2085
- componentExts.push("vue");
2086
- if (enableJsx) {
2087
- configs2.push(jsx());
2088
- }
1801
+ if (enableVue) componentExts.push("vue");
2089
1802
  if (enableTypeScript) {
2090
1803
  configs2.push(
2091
1804
  typescript({
@@ -2095,14 +1808,6 @@ async function defineConfig(options = {}, ...userConfigs) {
2095
1808
  })
2096
1809
  );
2097
1810
  }
2098
- if (stylisticOptions) {
2099
- configs2.push(
2100
- stylistic({
2101
- ...stylisticOptions,
2102
- overrides: getOverrides(options, "stylistic")
2103
- })
2104
- );
2105
- }
2106
1811
  if (enableRegexp)
2107
1812
  configs2.push(regexp(typeof enableRegexp === "boolean" ? {} : enableRegexp));
2108
1813
  if (options.test ?? true) {
@@ -2118,7 +1823,6 @@ async function defineConfig(options = {}, ...userConfigs) {
2118
1823
  vue({
2119
1824
  ...resolveSubOptions(options, "vue"),
2120
1825
  overrides: getOverrides(options, "typescript"),
2121
- stylistic: stylisticOptions,
2122
1826
  typescript: !!enableTypeScript
2123
1827
  })
2124
1828
  );
@@ -2135,7 +1839,6 @@ async function defineConfig(options = {}, ...userConfigs) {
2135
1839
  configs2.push(
2136
1840
  svelte({
2137
1841
  overrides: getOverrides(options, "svelte"),
2138
- stylistic: stylisticOptions,
2139
1842
  typescript: !!enableTypeScript
2140
1843
  })
2141
1844
  );
@@ -2159,32 +1862,23 @@ async function defineConfig(options = {}, ...userConfigs) {
2159
1862
  if (options.jsonc ?? true) {
2160
1863
  configs2.push(
2161
1864
  jsonc({
2162
- overrides: getOverrides(options, "jsonc"),
2163
- stylistic: stylisticOptions
1865
+ overrides: getOverrides(options, "jsonc")
2164
1866
  }),
2165
1867
  sortPackageJson(),
2166
1868
  sortTsconfig()
2167
1869
  );
2168
1870
  }
2169
- if (formatterOptions) {
2170
- configs2.push(
2171
- formatter(
2172
- formatterOptions,
2173
- typeof stylisticOptions === "boolean" ? {} : stylisticOptions
2174
- )
2175
- );
2176
- }
2177
- configs2.push(disables());
1871
+ configs2.push(specials());
2178
1872
  if ("files" in options) {
2179
- 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.');
1873
+ throw new Error(
1874
+ '[@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.'
1875
+ );
2180
1876
  }
2181
1877
  const fusedConfig = flatConfigProps.reduce((acc, key) => {
2182
- if (key in options)
2183
- acc[key] = options[key];
1878
+ if (key in options) acc[key] = options[key];
2184
1879
  return acc;
2185
1880
  }, {});
2186
- if (Object.keys(fusedConfig).length > 0)
2187
- configs2.push([fusedConfig]);
1881
+ if (Object.keys(fusedConfig).length > 0) configs2.push([fusedConfig]);
2188
1882
  const merged = await combine(...configs2, ...userConfigs);
2189
1883
  if (autoRenamePlugins)
2190
1884
  return renamePluginInConfigs(merged, defaultPluginRenaming);