@coderwyd/eslint-config 2.7.3 → 3.1.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.3.0_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,339 +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
- "antfu/no-top-level-await": "off",
165
- "no-console": "off",
166
- "ts/explicit-function-return-type": "off"
167
- }
168
- },
169
- {
170
- files: [`**/cli/${GLOB_SRC}`, `**/cli.${GLOB_SRC_EXT}`],
171
- name: "coderwyd/disables/cli",
172
- rules: {
173
- "antfu/no-top-level-await": "off",
174
- "no-console": "off"
175
- }
176
- },
177
- {
178
- files: ["**/bin/**/*", `**/bin.${GLOB_SRC_EXT}`],
179
- name: "coderwyd/disables/bin",
180
- rules: {
181
- "antfu/no-import-dist": "off",
182
- "antfu/no-import-node-modules-by-path": "off"
183
- }
184
- },
185
- {
186
- files: [GLOB_DTS],
187
- name: "coderwyd/disables/dts",
188
- rules: {
189
- "eslint-comments/no-unlimited-disable": "off",
190
- "import/no-duplicates": "off",
191
- "no-restricted-syntax": "off",
192
- "unused-imports/no-unused-vars": "off"
193
- }
194
- },
195
- {
196
- files: ["**/*.{test,spec}.([tj])s?(x)"],
197
- name: "coderwyd/disables/test",
198
- rules: {
199
- "antfu/no-top-level-await": "off",
200
- "no-unused-expressions": "off"
201
- }
202
- },
203
- {
204
- files: ["**/*.js", "**/*.cjs"],
205
- name: "coderwyd/disables/cjs",
206
- rules: {
207
- "ts/no-require-imports": "off"
208
- }
209
- }
210
- ];
211
- }
212
-
213
- // src/shared/index.ts
214
- var import_node_process = __toESM(require("process"), 1);
215
- var import_node_url = require("url");
216
- var import_local_pkg = require("local-pkg");
217
- var scopeUrl = (0, import_node_url.fileURLToPath)(new URL(".", importMetaUrl));
218
- var isCwdInScope = (0, import_local_pkg.isPackageExists)("@coderwyd/eslint-config");
219
- var parserPlain = {
220
- meta: {
221
- name: "parser-plain"
222
- },
223
- parseForESLint: (code) => ({
224
- ast: {
225
- body: [],
226
- comments: [],
227
- loc: { end: code.length, start: 0 },
228
- range: [0, code.length],
229
- tokens: [],
230
- type: "Program"
231
- },
232
- scopeManager: null,
233
- services: { isPlain: true },
234
- visitorKeys: {
235
- Program: []
236
- }
237
- })
238
- };
239
- async function combine(...configs2) {
240
- const resolved = await Promise.all(configs2);
241
- return resolved.flat();
242
- }
243
- function renameRules(rules, map) {
244
- return Object.fromEntries(
245
- Object.entries(rules).map(([key, value]) => {
246
- for (const [from, to] of Object.entries(map)) {
247
- if (key.startsWith(`${from}/`))
248
- return [to + key.slice(from.length), value];
249
- }
250
- return [key, value];
251
- })
252
- );
253
- }
254
- function renamePluginInConfigs(configs2, map) {
255
- return configs2.map((i) => {
256
- const clone = { ...i };
257
- if (clone.rules)
258
- clone.rules = renameRules(clone.rules, map);
259
- if (clone.plugins) {
260
- clone.plugins = Object.fromEntries(
261
- Object.entries(clone.plugins).map(([key, value]) => {
262
- if (key in map)
263
- return [map[key], value];
264
- return [key, value];
265
- })
266
- );
267
- }
268
- return clone;
269
- });
270
- }
271
- function getVueVersion() {
272
- const pkg = (0, import_local_pkg.getPackageInfoSync)("vue", { paths: [import_node_process.default.cwd()] });
273
- if (pkg && typeof pkg.version === "string" && !Number.isNaN(+pkg.version[0]))
274
- return +pkg.version[0];
275
- return 3;
276
- }
277
- function toArray(value) {
278
- return Array.isArray(value) ? value : [value];
279
- }
280
- async function interopDefault(m) {
281
- const resolved = await m;
282
- return resolved.default || resolved;
283
- }
284
- function isPackageInScope(name) {
285
- return (0, import_local_pkg.isPackageExists)(name, { paths: [scopeUrl] });
286
- }
287
- async function ensurePackages(packages) {
288
- if (import_node_process.default.env.CI || import_node_process.default.stdout.isTTY === false || isCwdInScope === false)
289
- return;
290
- const nonExistingPackages = packages.filter((i) => !isPackageInScope(i));
291
- if (nonExistingPackages.length === 0)
292
- return;
293
- const { default: prompts } = await import("prompts");
294
- const { result } = await prompts([
295
- {
296
- message: `${nonExistingPackages.length === 1 ? "Package is" : "Packages are"} required for this config: ${nonExistingPackages.join(", ")}. Do you want to install them?`,
297
- name: "result",
298
- type: "confirm"
299
- }
300
- ]);
301
- if (result) {
302
- await import("@antfu/install-pkg").then(
303
- (i) => i.installPackage(nonExistingPackages, { dev: true })
304
- );
305
- }
306
- }
307
- function resolveSubOptions(options, key) {
308
- return typeof options[key] === "boolean" ? {} : options[key] || {};
309
- }
310
- function getOverrides(options, key) {
311
- const sub = resolveSubOptions(options, key);
312
- return {
313
- ..."overrides" in sub ? sub.overrides || {} : {}
314
- };
315
- }
316
- function isInEditorEnv() {
317
- if (import_node_process.default.env.CI)
318
- return false;
319
- if (isInGitHooksOrLintStaged())
320
- return false;
321
- 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);
322
- }
323
- function isInGitHooksOrLintStaged() {
324
- 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);
325
- }
326
-
327
- // src/configs/stylistic.ts
328
- var StylisticConfigDefaults = {
329
- indent: 2,
330
- jsx: true,
331
- quotes: "single",
332
- semi: false
333
- };
334
- async function stylistic(options = {}) {
335
- const {
336
- indent,
337
- jsx: jsx2,
338
- overrides = {},
339
- quotes,
340
- semi
341
- } = {
342
- ...StylisticConfigDefaults,
343
- ...options
344
- };
345
- const pluginStylistic = await interopDefault(
346
- import("@stylistic/eslint-plugin")
347
- );
348
- const config = pluginStylistic.configs.customize({
349
- flat: true,
350
- indent,
351
- jsx: jsx2,
352
- pluginName: "style",
353
- quotes,
354
- semi
355
- });
356
- return [
357
- {
358
- name: "coderwyd/stylistic/rules",
359
- plugins: {
360
- antfu: import_eslint_plugin_antfu.default,
361
- style: pluginStylistic
362
- },
363
- rules: {
364
- ...config.rules,
365
- "antfu/consistent-chaining": "error",
366
- "antfu/consistent-list-newline": "error",
367
- "antfu/curly": "error",
368
- "antfu/if-newline": "warn",
369
- "antfu/top-level-function": "warn",
370
- ...overrides
371
- }
372
- }
373
- ];
374
- }
375
-
376
- // src/configs/formatter.ts
377
- async function formatter(options = {}, stylistic2 = {}) {
378
- const { css, graphql, html, markdown, toml, yaml } = options === true ? {
379
- css: true,
380
- graphql: true,
381
- html: true,
382
- markdown: true,
383
- toml: true,
384
- yaml: true
385
- } : options;
386
- const { indent, quotes, semi } = {
387
- ...StylisticConfigDefaults,
388
- ...stylistic2
389
- };
390
- const prettierOptions = Object.assign(
391
- {
392
- endOfLine: "auto",
393
- printWidth: 80,
394
- semi,
395
- singleQuote: quotes === "single",
396
- tabWidth: typeof indent === "number" ? indent : 2,
397
- trailingComma: "all",
398
- useTabs: indent === "tab"
399
- },
400
- typeof options === "boolean" ? {} : options.prettierOptions || {}
401
- );
402
- await ensurePackages(["eslint-plugin-format"]);
403
- const pluginFormat = await interopDefault(import("eslint-plugin-format"));
404
- function createPrettierFormatter(files, parser, plugins) {
405
- const rules = {
406
- ...prettierOptions,
407
- parser
408
- };
409
- const markdownRules = {
410
- printWidth: 120,
411
- ...rules,
412
- embeddedLanguageFormatting: "off"
413
- };
414
- if (plugins?.length)
415
- rules.plugins = [...rules.plugins || [], ...plugins];
416
- const config = {
417
- files,
418
- languageOptions: {
419
- parser: parserPlain
420
- },
421
- name: `coderwyd/formatter/${parser}`,
422
- plugins: {
423
- format: pluginFormat
424
- },
425
- rules: {
426
- "format/prettier": [
427
- "warn",
428
- parser === "markdown" ? markdownRules : rules
429
- ]
430
- }
431
- };
432
- return config;
433
- }
434
- const configs2 = [
435
- {
436
- name: "coderwyd/formatter/setup",
437
- plugins: {
438
- format: pluginFormat
439
- }
440
- }
441
- ];
442
- if (html) {
443
- const htmlConfig = createPrettierFormatter([GLOB_HTML], "html");
444
- configs2.push(htmlConfig);
445
- }
446
- if (css) {
447
- const cssConfig = createPrettierFormatter([GLOB_CSS, GLOB_POSTCSS], "css");
448
- const scssConfig = createPrettierFormatter([GLOB_SCSS], "scss");
449
- const lessConfig = createPrettierFormatter([GLOB_LESS], "less");
450
- configs2.push(cssConfig, scssConfig, lessConfig);
451
- }
452
- if (markdown) {
453
- const markdownConfig = createPrettierFormatter([GLOB_MARKDOWN], "markdown");
454
- configs2.push(markdownConfig);
455
- }
456
- if (graphql) {
457
- const graphqlConfig = createPrettierFormatter([GLOB_GRAPHQL], "graphql");
458
- configs2.push(graphqlConfig);
459
- }
460
- if (yaml) {
461
- const yamlConfig = createPrettierFormatter([GLOB_YAML], "yaml");
462
- configs2.push(yamlConfig);
463
- }
464
- if (toml) {
465
- await ensurePackages(["@toml-tools/parser", "prettier-plugin-toml"]);
466
- const tomlConfig = createPrettierFormatter([GLOB_TOML], "toml", [
467
- "prettier-plugin-toml"
468
- ]);
469
- configs2.push(tomlConfig);
470
- }
471
- return configs2;
472
- }
473
-
474
148
  // src/configs/ignores.ts
475
149
  function ignores(userIgnores = []) {
476
150
  return [
477
151
  {
478
- ignores: [
479
- ...GLOB_EXCLUDE,
480
- ...userIgnores
481
- ],
152
+ ignores: [...GLOB_EXCLUDE, ...userIgnores],
482
153
  name: "coderwyd/ignores"
483
154
  }
484
155
  ];
485
156
  }
486
157
 
487
158
  // src/configs/imports.ts
488
- function imports(options = {}) {
489
- const { stylistic: stylistic2 = true } = options;
159
+ function imports() {
490
160
  return [
491
161
  {
492
162
  name: "coderwyd/imports/rules",
@@ -503,10 +173,7 @@ function imports(options = {}) {
503
173
  "import/no-mutable-exports": "error",
504
174
  "import/no-named-default": "error",
505
175
  "import/no-self-import": "error",
506
- "import/no-webpack-loader-syntax": "error",
507
- ...stylistic2 ? {
508
- "import/newline-after-import": ["error", { count: 1 }]
509
- } : {}
176
+ "import/no-webpack-loader-syntax": "error"
510
177
  }
511
178
  }
512
179
  ];
@@ -553,12 +220,13 @@ function javascript(options = {}) {
553
220
  { enforceForClassMembers: true, setWithoutGet: true }
554
221
  ],
555
222
  "antfu/no-top-level-await": "error",
223
+ "antfu/top-level-function": "error",
556
224
  "array-callback-return": "error",
557
225
  "block-scoped-var": "error",
558
226
  "constructor-super": "error",
559
227
  "default-case-last": "error",
560
228
  "dot-notation": ["error", { allowKeywords: true }],
561
- "eqeqeq": ["error", "smart"],
229
+ eqeqeq: ["error", "smart"],
562
230
  "for-direction": "error",
563
231
  "getter-return": "error",
564
232
  "new-cap": [
@@ -739,16 +407,126 @@ function javascript(options = {}) {
739
407
  ],
740
408
  "valid-typeof": ["error", { requireStringLiterals: true }],
741
409
  "vars-on-top": "error",
742
- "yoda": ["error", "never"],
410
+ yoda: ["error", "never"],
743
411
  ...overrides
744
412
  }
745
413
  }
746
414
  ];
747
415
  }
748
416
 
417
+ // src/shared/index.ts
418
+ var import_node_process = __toESM(require("process"), 1);
419
+ var import_node_url = require("url");
420
+ var import_local_pkg = require("local-pkg");
421
+ var scopeUrl = (0, import_node_url.fileURLToPath)(new URL(".", importMetaUrl));
422
+ var isCwdInScope = (0, import_local_pkg.isPackageExists)("@coderwyd/eslint-config");
423
+ var parserPlain = {
424
+ meta: {
425
+ name: "parser-plain"
426
+ },
427
+ parseForESLint: (code) => ({
428
+ ast: {
429
+ body: [],
430
+ comments: [],
431
+ loc: { end: code.length, start: 0 },
432
+ range: [0, code.length],
433
+ tokens: [],
434
+ type: "Program"
435
+ },
436
+ scopeManager: null,
437
+ services: { isPlain: true },
438
+ visitorKeys: {
439
+ Program: []
440
+ }
441
+ })
442
+ };
443
+ async function combine(...configs2) {
444
+ const resolved = await Promise.all(configs2);
445
+ return resolved.flat();
446
+ }
447
+ function renameRules(rules, map) {
448
+ return Object.fromEntries(
449
+ Object.entries(rules).map(([key, value]) => {
450
+ for (const [from, to] of Object.entries(map)) {
451
+ if (key.startsWith(`${from}/`))
452
+ return [to + key.slice(from.length), value];
453
+ }
454
+ return [key, value];
455
+ })
456
+ );
457
+ }
458
+ function renamePluginInConfigs(configs2, map) {
459
+ return configs2.map((i) => {
460
+ const clone = { ...i };
461
+ if (clone.rules) clone.rules = renameRules(clone.rules, map);
462
+ if (clone.plugins) {
463
+ clone.plugins = Object.fromEntries(
464
+ Object.entries(clone.plugins).map(([key, value]) => {
465
+ if (key in map) return [map[key], value];
466
+ return [key, value];
467
+ })
468
+ );
469
+ }
470
+ return clone;
471
+ });
472
+ }
473
+ function getVueVersion() {
474
+ const pkg = (0, import_local_pkg.getPackageInfoSync)("vue", { paths: [import_node_process.default.cwd()] });
475
+ if (pkg && typeof pkg.version === "string" && !Number.isNaN(+pkg.version[0]))
476
+ return +pkg.version[0];
477
+ return 3;
478
+ }
479
+ function toArray(value) {
480
+ return Array.isArray(value) ? value : [value];
481
+ }
482
+ async function interopDefault(m) {
483
+ const resolved = await m;
484
+ return resolved.default || resolved;
485
+ }
486
+ function isPackageInScope(name) {
487
+ return (0, import_local_pkg.isPackageExists)(name, { paths: [scopeUrl] });
488
+ }
489
+ async function ensurePackages(packages) {
490
+ if (import_node_process.default.env.CI || import_node_process.default.stdout.isTTY === false || isCwdInScope === false)
491
+ return;
492
+ const nonExistingPackages = packages.filter((i) => !isPackageInScope(i));
493
+ if (nonExistingPackages.length === 0) return;
494
+ const { default: prompts } = await import("prompts");
495
+ const { result } = await prompts([
496
+ {
497
+ message: `${nonExistingPackages.length === 1 ? "Package is" : "Packages are"} required for this config: ${nonExistingPackages.join(", ")}. Do you want to install them?`,
498
+ name: "result",
499
+ type: "confirm"
500
+ }
501
+ ]);
502
+ if (result) {
503
+ await import("@antfu/install-pkg").then(
504
+ (i) => i.installPackage(nonExistingPackages, { dev: true })
505
+ );
506
+ }
507
+ }
508
+ function resolveSubOptions(options, key) {
509
+ return typeof options[key] === "boolean" ? {} : options[key] || {};
510
+ }
511
+ function getOverrides(options, key) {
512
+ const sub = resolveSubOptions(options, key);
513
+ return {
514
+ ..."overrides" in sub ? sub.overrides || {} : {}
515
+ };
516
+ }
517
+ function isInEditorEnv() {
518
+ if (import_node_process.default.env.CI) return false;
519
+ if (isInGitHooksOrLintStaged()) {
520
+ return false;
521
+ }
522
+ 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);
523
+ }
524
+ function isInGitHooksOrLintStaged() {
525
+ 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);
526
+ }
527
+
749
528
  // src/configs/jsdoc.ts
750
- async function jsdoc(options = {}) {
751
- const { stylistic: stylistic2 = true } = options;
529
+ async function jsdoc() {
752
530
  return [
753
531
  {
754
532
  name: "coderwyd/jsdoc/rules",
@@ -770,11 +548,7 @@ async function jsdoc(options = {}) {
770
548
  "jsdoc/require-property-name": "warn",
771
549
  "jsdoc/require-returns-check": "warn",
772
550
  "jsdoc/require-returns-description": "warn",
773
- "jsdoc/require-yields-check": "warn",
774
- ...stylistic2 ? {
775
- "jsdoc/check-alignment": "warn",
776
- "jsdoc/multiline-blocks": "warn"
777
- } : {}
551
+ "jsdoc/require-yields-check": "warn"
778
552
  }
779
553
  }
780
554
  ];
@@ -782,14 +556,7 @@ async function jsdoc(options = {}) {
782
556
 
783
557
  // src/configs/jsonc.ts
784
558
  async function jsonc(options = {}) {
785
- const {
786
- files = [GLOB_JSON, GLOB_JSON5, GLOB_JSONC],
787
- overrides = {},
788
- stylistic: stylistic2 = true
789
- } = options || {};
790
- const {
791
- indent = 2
792
- } = typeof stylistic2 === "boolean" ? {} : stylistic2;
559
+ const { files = [GLOB_JSON, GLOB_JSON5, GLOB_JSONC], overrides = {} } = options || {};
793
560
  const [pluginJsonc, parserJsonc] = await Promise.all([
794
561
  interopDefault(import("eslint-plugin-jsonc")),
795
562
  interopDefault(import("jsonc-eslint-parser"))
@@ -834,50 +601,12 @@ async function jsonc(options = {}) {
834
601
  "jsonc/space-unary-ops": "error",
835
602
  "jsonc/valid-json-number": "error",
836
603
  "jsonc/vue-custom-block/no-parsing-error": "error",
837
- ...stylistic2 ? {
838
- "jsonc/array-bracket-spacing": ["error", "never"],
839
- "jsonc/comma-dangle": ["error", "never"],
840
- "jsonc/comma-style": ["error", "last"],
841
- "jsonc/indent": ["error", indent],
842
- "jsonc/key-spacing": [
843
- "error",
844
- { afterColon: true, beforeColon: false }
845
- ],
846
- "jsonc/object-curly-newline": [
847
- "error",
848
- { consistent: true, multiline: true }
849
- ],
850
- "jsonc/object-curly-spacing": ["error", "always"],
851
- "jsonc/object-property-newline": [
852
- "error",
853
- { allowMultiplePropertiesPerLine: true }
854
- ],
855
- "jsonc/quote-props": "error",
856
- "jsonc/quotes": "error"
857
- } : {},
858
604
  ...overrides
859
605
  }
860
606
  }
861
607
  ];
862
608
  }
863
609
 
864
- // src/configs/jsx.ts
865
- function jsx() {
866
- return [
867
- {
868
- files: [GLOB_JSX, GLOB_TSX],
869
- languageOptions: {
870
- parserOptions: {
871
- ecmaFeatures: {
872
- jsx: true
873
- }
874
- }
875
- },
876
- name: "coderwyd/jsx/setup"
877
- }
878
- ];
879
- }
880
-
881
610
  // src/configs/node.ts
882
611
  function node() {
883
612
  return [
@@ -910,7 +639,10 @@ function perfectionist() {
910
639
  perfectionist: import_eslint_plugin_perfectionist.default
911
640
  },
912
641
  rules: {
913
- "perfectionist/sort-exports": ["error", { order: "asc", type: "natural" }],
642
+ "perfectionist/sort-exports": [
643
+ "error",
644
+ { order: "asc", type: "natural" }
645
+ ],
914
646
  "perfectionist/sort-imports": [
915
647
  "warn",
916
648
  {
@@ -946,6 +678,27 @@ function perfectionist() {
946
678
  ];
947
679
  }
948
680
 
681
+ // src/configs/prettier.ts
682
+ var import_eslint_config_prettier = __toESM(require("eslint-config-prettier"), 1);
683
+ var { rules: eslintRules } = import_eslint_config_prettier.default;
684
+ async function prettier() {
685
+ const pluginPrettier = await interopDefault(import("eslint-plugin-prettier"));
686
+ return [
687
+ {
688
+ name: "coderwyd/prettier/rules",
689
+ plugins: {
690
+ prettier: pluginPrettier
691
+ },
692
+ rules: {
693
+ ...eslintRules,
694
+ "arrow-body-style": "off",
695
+ "prefer-arrow-callback": "off",
696
+ "prettier/prettier": "warn"
697
+ }
698
+ }
699
+ ];
700
+ }
701
+
949
702
  // src/configs/react.ts
950
703
  var import_local_pkg3 = require("local-pkg");
951
704
 
@@ -954,12 +707,7 @@ var import_node_process2 = __toESM(require("process"), 1);
954
707
  var import_local_pkg2 = require("local-pkg");
955
708
  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);
956
709
  var hasTypeScript = (0, import_local_pkg2.isPackageExists)("typescript");
957
- var VueJsPackages = [
958
- "vue",
959
- "nuxt",
960
- "vitepress",
961
- "@slidev/cli"
962
- ];
710
+ var VueJsPackages = ["vue", "nuxt", "vitepress", "@slidev/cli"];
963
711
  var hasVue = hasPackages(VueJsPackages);
964
712
  var RemixPackages = [
965
713
  "@remix-run/node",
@@ -999,7 +747,7 @@ async function react(options = {}) {
999
747
  {
1000
748
  name: "coderwyd/react/setup",
1001
749
  plugins: {
1002
- "react": plugins["@eslint-react"],
750
+ react: plugins["@eslint-react"],
1003
751
  "react-dom": plugins["@eslint-react/dom"],
1004
752
  "react-hooks": pluginReactHooks,
1005
753
  "react-hooks-extra": plugins["@eslint-react/hooks-extra"],
@@ -1117,8 +865,7 @@ function regexp(options = {}) {
1117
865
  };
1118
866
  if (options.level === "warn") {
1119
867
  Object.keys(rules).forEach((key) => {
1120
- if (rules[key] === "error")
1121
- rules[key] = "warn";
868
+ if (rules[key] === "error") rules[key] = "warn";
1122
869
  });
1123
870
  }
1124
871
  return [
@@ -1357,13 +1104,65 @@ function sortTsconfig() {
1357
1104
  ];
1358
1105
  }
1359
1106
 
1107
+ // src/configs/specials.ts
1108
+ function specials() {
1109
+ return [
1110
+ {
1111
+ files: [`**/scripts/${GLOB_SRC}`],
1112
+ name: "coderwyd/specials/scripts",
1113
+ rules: {
1114
+ "antfu/no-top-level-await": "off",
1115
+ "no-console": "off",
1116
+ "ts/explicit-function-return-type": "off"
1117
+ }
1118
+ },
1119
+ {
1120
+ files: [`**/cli/${GLOB_SRC}`, `**/cli.${GLOB_SRC_EXT}`],
1121
+ name: "coderwyd/specials/cli",
1122
+ rules: {
1123
+ "antfu/no-top-level-await": "off",
1124
+ "no-console": "off"
1125
+ }
1126
+ },
1127
+ {
1128
+ files: ["**/bin/**/*", `**/bin.${GLOB_SRC_EXT}`],
1129
+ name: "coderwyd/specials/bin",
1130
+ rules: {
1131
+ "antfu/no-import-dist": "off",
1132
+ "antfu/no-import-node-modules-by-path": "off"
1133
+ }
1134
+ },
1135
+ {
1136
+ files: [GLOB_DTS],
1137
+ name: "coderwyd/specials/dts",
1138
+ rules: {
1139
+ "eslint-comments/no-unlimited-disable": "off",
1140
+ "import/no-duplicates": "off",
1141
+ "no-restricted-syntax": "off",
1142
+ "unused-imports/no-unused-vars": "off"
1143
+ }
1144
+ },
1145
+ {
1146
+ files: ["**/*.{test,spec}.([tj])s?(x)"],
1147
+ name: "coderwyd/specials/test",
1148
+ rules: {
1149
+ "antfu/no-top-level-await": "off",
1150
+ "no-unused-expressions": "off"
1151
+ }
1152
+ },
1153
+ {
1154
+ files: ["**/*.js", "**/*.cjs"],
1155
+ name: "coderwyd/specials/cjs",
1156
+ rules: {
1157
+ "ts/no-require-imports": "off"
1158
+ }
1159
+ }
1160
+ ];
1161
+ }
1162
+
1360
1163
  // src/configs/svelte.ts
1361
1164
  async function svelte(options = {}) {
1362
- const { files = [GLOB_SVELTE], overrides = {}, stylistic: stylistic2 = true } = options;
1363
- const {
1364
- indent = 2,
1365
- quotes = "single"
1366
- } = typeof stylistic2 === "boolean" ? {} : stylistic2;
1165
+ const { files = [GLOB_SVELTE], overrides = {} } = options;
1367
1166
  await ensurePackages(["eslint-plugin-svelte"]);
1368
1167
  const [pluginSvelte, parserSvelte] = await Promise.all([
1369
1168
  interopDefault(import("eslint-plugin-svelte")),
@@ -1432,23 +1231,6 @@ async function svelte(options = {}) {
1432
1231
  varsIgnorePattern: "^(_|\\$\\$Props$|\\$\\$Events$|\\$\\$Slots$)"
1433
1232
  }
1434
1233
  ],
1435
- ...stylistic2 ? {
1436
- "style/indent": "off",
1437
- // superseded by svelte/indent
1438
- "style/no-trailing-spaces": "off",
1439
- // superseded by svelte/no-trailing-spaces
1440
- "svelte/derived-has-same-inputs-outputs": "error",
1441
- "svelte/html-closing-bracket-spacing": "error",
1442
- "svelte/html-quotes": ["error", { prefer: quotes }],
1443
- "svelte/indent": [
1444
- "error",
1445
- { alignAttributesVertically: true, indent }
1446
- ],
1447
- "svelte/mustache-spacing": "error",
1448
- "svelte/no-spaces-around-equal-signs-in-attribute": "error",
1449
- "svelte/no-trailing-spaces": "error",
1450
- "svelte/spaced-html-comment": "error"
1451
- } : {},
1452
1234
  ...overrides
1453
1235
  }
1454
1236
  }
@@ -1531,7 +1313,12 @@ async function test(options = {}) {
1531
1313
  // src/configs/typescript.ts
1532
1314
  var import_node_process3 = __toESM(require("process"), 1);
1533
1315
  async function typescript(options = {}) {
1534
- const { componentExts = [], overrides = {}, overridesTypeAware = {}, parserOptions = {} } = options;
1316
+ const {
1317
+ componentExts = [],
1318
+ overrides = {},
1319
+ overridesTypeAware = {},
1320
+ parserOptions = {}
1321
+ } = options;
1535
1322
  const files = options.files ?? [
1536
1323
  GLOB_TS,
1537
1324
  GLOB_TSX,
@@ -1651,11 +1438,14 @@ async function typescript(options = {}) {
1651
1438
  "ts/no-non-null-assertion": "off",
1652
1439
  "ts/no-redeclare": ["error", { builtinGlobals: false }],
1653
1440
  "ts/no-require-imports": "error",
1654
- "ts/no-unused-expressions": ["error", {
1655
- allowShortCircuit: true,
1656
- allowTaggedTemplates: true,
1657
- allowTernary: true
1658
- }],
1441
+ "ts/no-unused-expressions": [
1442
+ "error",
1443
+ {
1444
+ allowShortCircuit: true,
1445
+ allowTaggedTemplates: true,
1446
+ allowTernary: true
1447
+ }
1448
+ ],
1659
1449
  "ts/no-unused-vars": "off",
1660
1450
  "ts/no-use-before-define": [
1661
1451
  "error",
@@ -1788,15 +1578,11 @@ async function unocss(options = {}) {
1788
1578
  }
1789
1579
 
1790
1580
  // src/configs/vue.ts
1791
- var import_eslint_merge_processors = require("eslint-merge-processors");
1792
1581
  async function vue(options = {}) {
1793
- const { files = [GLOB_VUE], overrides = {}, stylistic: stylistic2 = true } = options;
1794
- const sfcBlocks = options.sfcBlocks === true ? {} : options.sfcBlocks ?? {};
1795
- const { indent = 2 } = typeof stylistic2 === "boolean" ? {} : stylistic2;
1796
- const [pluginVue, parserVue, processorVueBlocks] = await Promise.all([
1582
+ const { files = [GLOB_VUE], overrides = {} } = options;
1583
+ const [pluginVue, parserVue] = await Promise.all([
1797
1584
  interopDefault(import("eslint-plugin-vue")),
1798
- interopDefault(import("vue-eslint-parser")),
1799
- interopDefault(import("eslint-processor-vue-blocks"))
1585
+ interopDefault(import("vue-eslint-parser"))
1800
1586
  ]);
1801
1587
  const isVue3 = getVueVersion() === 3;
1802
1588
  const configKeys = isVue3 ? ["vue3-essential", "vue3-strongly-recommended", "vue3-recommended"] : ["essential", "strongly-recommended", "recommended"];
@@ -1808,32 +1594,6 @@ async function vue(options = {}) {
1808
1594
  };
1809
1595
  }, {});
1810
1596
  return [
1811
- {
1812
- // This allows Vue plugin to work with auto imports
1813
- // https://github.com/vuejs/eslint-plugin-vue/pull/2422
1814
- languageOptions: {
1815
- globals: {
1816
- computed: "readonly",
1817
- defineEmits: "readonly",
1818
- defineExpose: "readonly",
1819
- defineProps: "readonly",
1820
- onMounted: "readonly",
1821
- onUnmounted: "readonly",
1822
- reactive: "readonly",
1823
- ref: "readonly",
1824
- shallowReactive: "readonly",
1825
- shallowRef: "readonly",
1826
- toRef: "readonly",
1827
- toRefs: "readonly",
1828
- watch: "readonly",
1829
- watchEffect: "readonly"
1830
- }
1831
- },
1832
- name: "coderwyd/vue/setup",
1833
- plugins: {
1834
- vue: pluginVue
1835
- }
1836
- },
1837
1597
  {
1838
1598
  files,
1839
1599
  languageOptions: {
@@ -1850,16 +1610,10 @@ async function vue(options = {}) {
1850
1610
  }
1851
1611
  },
1852
1612
  name: "coderwyd/vue/rules",
1853
- processor: sfcBlocks === false ? pluginVue.processors[".vue"] : (0, import_eslint_merge_processors.mergeProcessors)([
1854
- pluginVue.processors[".vue"],
1855
- processorVueBlocks({
1856
- ...sfcBlocks,
1857
- blocks: {
1858
- styles: true,
1859
- ...sfcBlocks.blocks
1860
- }
1861
- })
1862
- ]),
1613
+ plugins: {
1614
+ vue: pluginVue
1615
+ },
1616
+ processor: pluginVue.processors[".vue"],
1863
1617
  rules: {
1864
1618
  ...pluginVue.configs.base.rules,
1865
1619
  ...vueRules,
@@ -1891,11 +1645,7 @@ async function vue(options = {}) {
1891
1645
  }
1892
1646
  ],
1893
1647
  // 'vue/define-props-declaration': ['warn', 'type-based'],
1894
- "vue/dot-location": ["error", "property"],
1895
- "vue/dot-notation": ["error", { allowKeywords: true }],
1896
1648
  "vue/eqeqeq": ["error", "smart"],
1897
- "vue/html-indent": ["error", indent],
1898
- "vue/html-quotes": ["error", "double"],
1899
1649
  "vue/html-self-closing": [
1900
1650
  "error",
1901
1651
  {
@@ -1912,7 +1662,6 @@ async function vue(options = {}) {
1912
1662
  "vue/multi-word-component-names": "off",
1913
1663
  // 'vue/next-tick-style': ['warn', 'promise'],
1914
1664
  "vue/no-constant-condition": "warn",
1915
- "vue/no-dupe-keys": "off",
1916
1665
  "vue/no-duplicate-attr-inheritance": "warn",
1917
1666
  "vue/no-empty-pattern": "error",
1918
1667
  "vue/no-extra-parens": ["error", "functions"],
@@ -1944,6 +1693,7 @@ async function vue(options = {}) {
1944
1693
  ignoreConstructors: false
1945
1694
  }
1946
1695
  ],
1696
+ "vue/padding-line-between-blocks": ["error", "always"],
1947
1697
  "vue/prefer-define-options": "warn",
1948
1698
  "vue/prefer-separate-static-class": "error",
1949
1699
  "vue/prefer-template": "error",
@@ -1964,50 +1714,6 @@ async function vue(options = {}) {
1964
1714
  "vue/space-infix-ops": "error",
1965
1715
  "vue/space-unary-ops": ["error", { nonwords: false, words: true }],
1966
1716
  "vue/valid-define-options": "warn",
1967
- ...stylistic2 ? {
1968
- "vue/array-bracket-spacing": ["error", "never"],
1969
- "vue/arrow-spacing": ["error", { after: true, before: true }],
1970
- "vue/block-spacing": ["error", "always"],
1971
- "vue/block-tag-newline": [
1972
- "error",
1973
- {
1974
- multiline: "always",
1975
- singleline: "always"
1976
- }
1977
- ],
1978
- "vue/brace-style": [
1979
- "error",
1980
- "stroustrup",
1981
- { allowSingleLine: true }
1982
- ],
1983
- "vue/comma-dangle": ["error", "always-multiline"],
1984
- "vue/comma-spacing": ["error", { after: true, before: false }],
1985
- "vue/comma-style": ["error", "last"],
1986
- "vue/html-comment-content-newline": "warn",
1987
- "vue/html-comment-content-spacing": [
1988
- "error",
1989
- "always",
1990
- {
1991
- exceptions: ["-"]
1992
- }
1993
- ],
1994
- "vue/key-spacing": [
1995
- "error",
1996
- { afterColon: true, beforeColon: false }
1997
- ],
1998
- "vue/keyword-spacing": ["error", { after: true, before: true }],
1999
- "vue/object-curly-newline": "off",
2000
- "vue/object-curly-spacing": ["error", "always"],
2001
- "vue/object-property-newline": [
2002
- "error",
2003
- { allowMultiplePropertiesPerLine: true }
2004
- ],
2005
- "vue/operator-linebreak": ["error", "before"],
2006
- "vue/padding-line-between-blocks": ["error", "always"],
2007
- "vue/quote-props": ["error", "consistent-as-needed"],
2008
- "vue/space-in-parens": ["error", "never"],
2009
- "vue/template-curly-spacing": "error"
2010
- } : {},
2011
1717
  ...overrides
2012
1718
  }
2013
1719
  }
@@ -2029,23 +1735,17 @@ var defaultPluginRenaming = {
2029
1735
  "@eslint-react/dom": "react-dom",
2030
1736
  "@eslint-react/hooks-extra": "react-hooks-extra",
2031
1737
  "@eslint-react/naming-convention": "react-naming-convention",
2032
- "@stylistic": "style",
2033
1738
  "@typescript-eslint": "ts",
2034
1739
  "import-x": "import",
2035
- "n": "node",
2036
- "vitest": "test",
2037
- "yml": "yaml"
1740
+ n: "node",
1741
+ vitest: "test",
1742
+ yml: "yaml"
2038
1743
  };
2039
1744
  async function defineConfig(options = {}, ...userConfigs) {
2040
1745
  const {
2041
1746
  autoRenamePlugins = true,
2042
1747
  componentExts = [],
2043
- formatter: formatterOptions = {
2044
- css: true,
2045
- html: true
2046
- },
2047
1748
  gitignore: enableGitignore = true,
2048
- jsx: enableJsx = true,
2049
1749
  react: enableReact = false,
2050
1750
  regexp: enableRegexp = true,
2051
1751
  svelte: enableSvelte = false,
@@ -2058,11 +1758,10 @@ async function defineConfig(options = {}, ...userConfigs) {
2058
1758
  if (isInEditor2 == null) {
2059
1759
  isInEditor2 = isInEditorEnv();
2060
1760
  if (isInEditor2)
2061
- console.log("[@coderwyd/eslint-config] Detected running in editor, some rules are disabled.");
1761
+ console.log(
1762
+ "[@coderwyd/eslint-config] Detected running in editor, some rules are disabled."
1763
+ );
2062
1764
  }
2063
- const stylisticOptions = options.stylistic === false ? false : typeof options.stylistic === "object" ? options.stylistic : {};
2064
- if (stylisticOptions && !("jsx" in stylisticOptions))
2065
- stylisticOptions.jsx = enableJsx;
2066
1765
  const configs2 = [];
2067
1766
  if (enableGitignore) {
2068
1767
  if (typeof enableGitignore !== "boolean") {
@@ -2075,7 +1774,11 @@ async function defineConfig(options = {}, ...userConfigs) {
2075
1774
  ])
2076
1775
  );
2077
1776
  } else {
2078
- configs2.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r({ name: "coderwyd/gitignore", strict: false })]));
1777
+ configs2.push(
1778
+ interopDefault(import("eslint-config-flat-gitignore")).then((r) => [
1779
+ r({ name: "coderwyd/gitignore", strict: false })
1780
+ ])
1781
+ );
2079
1782
  }
2080
1783
  }
2081
1784
  const typescriptOptions = resolveSubOptions(options, "typescript");
@@ -2088,22 +1791,14 @@ async function defineConfig(options = {}, ...userConfigs) {
2088
1791
  }),
2089
1792
  comments(),
2090
1793
  node(),
2091
- jsdoc({
2092
- stylistic: stylisticOptions
2093
- }),
2094
- imports({
2095
- stylistic: stylisticOptions
2096
- }),
1794
+ jsdoc(),
1795
+ imports(),
2097
1796
  unicorn(),
2098
1797
  command(),
2099
1798
  // Optional plugins (installed but not enabled by default)
2100
1799
  perfectionist()
2101
1800
  );
2102
- if (enableVue)
2103
- componentExts.push("vue");
2104
- if (enableJsx) {
2105
- configs2.push(jsx());
2106
- }
1801
+ if (enableVue) componentExts.push("vue");
2107
1802
  if (enableTypeScript) {
2108
1803
  configs2.push(
2109
1804
  typescript({
@@ -2113,14 +1808,6 @@ async function defineConfig(options = {}, ...userConfigs) {
2113
1808
  })
2114
1809
  );
2115
1810
  }
2116
- if (stylisticOptions) {
2117
- configs2.push(
2118
- stylistic({
2119
- ...stylisticOptions,
2120
- overrides: getOverrides(options, "stylistic")
2121
- })
2122
- );
2123
- }
2124
1811
  if (enableRegexp)
2125
1812
  configs2.push(regexp(typeof enableRegexp === "boolean" ? {} : enableRegexp));
2126
1813
  if (options.test ?? true) {
@@ -2136,7 +1823,6 @@ async function defineConfig(options = {}, ...userConfigs) {
2136
1823
  vue({
2137
1824
  ...resolveSubOptions(options, "vue"),
2138
1825
  overrides: getOverrides(options, "typescript"),
2139
- stylistic: stylisticOptions,
2140
1826
  typescript: !!enableTypeScript
2141
1827
  })
2142
1828
  );
@@ -2153,7 +1839,6 @@ async function defineConfig(options = {}, ...userConfigs) {
2153
1839
  configs2.push(
2154
1840
  svelte({
2155
1841
  overrides: getOverrides(options, "svelte"),
2156
- stylistic: stylisticOptions,
2157
1842
  typescript: !!enableTypeScript
2158
1843
  })
2159
1844
  );
@@ -2177,32 +1862,23 @@ async function defineConfig(options = {}, ...userConfigs) {
2177
1862
  if (options.jsonc ?? true) {
2178
1863
  configs2.push(
2179
1864
  jsonc({
2180
- overrides: getOverrides(options, "jsonc"),
2181
- stylistic: stylisticOptions
1865
+ overrides: getOverrides(options, "jsonc")
2182
1866
  }),
2183
1867
  sortPackageJson(),
2184
1868
  sortTsconfig()
2185
1869
  );
2186
1870
  }
2187
- if (formatterOptions) {
2188
- configs2.push(
2189
- formatter(
2190
- formatterOptions,
2191
- typeof stylisticOptions === "boolean" ? {} : stylisticOptions
2192
- )
2193
- );
2194
- }
2195
- configs2.push(disables());
1871
+ configs2.push(specials(), prettier());
2196
1872
  if ("files" in options) {
2197
- 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
+ );
2198
1876
  }
2199
1877
  const fusedConfig = flatConfigProps.reduce((acc, key) => {
2200
- if (key in options)
2201
- acc[key] = options[key];
1878
+ if (key in options) acc[key] = options[key];
2202
1879
  return acc;
2203
1880
  }, {});
2204
- if (Object.keys(fusedConfig).length > 0)
2205
- configs2.push([fusedConfig]);
1881
+ if (Object.keys(fusedConfig).length > 0) configs2.push([fusedConfig]);
2206
1882
  const merged = await combine(...configs2, ...userConfigs);
2207
1883
  if (autoRenamePlugins)
2208
1884
  return renamePluginInConfigs(merged, defaultPluginRenaming);