@coderwyd/eslint-config 1.1.0-beta.1 → 1.1.0-beta.3

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
@@ -7,60 +7,82 @@ import gitignore from "eslint-config-flat-gitignore";
7
7
  // src/plugins.ts
8
8
  import { default as default2 } from "eslint-plugin-antfu";
9
9
  import { default as default3 } from "eslint-plugin-eslint-comments";
10
- import { default as default4 } from "eslint-plugin-i";
11
- import { default as default5 } from "eslint-plugin-jsdoc";
12
- import { default as default6 } from "eslint-plugin-jsonc";
13
- import { default as default7 } from "eslint-plugin-markdown";
14
- import { default as default8 } from "eslint-plugin-n";
15
- import { default as default9 } from "@stylistic/eslint-plugin";
16
- import { default as default10 } from "@typescript-eslint/eslint-plugin";
17
- import { default as default11 } from "eslint-plugin-unicorn";
18
- import { default as default12 } from "eslint-plugin-unused-imports";
10
+ import * as pluginImport from "eslint-plugin-i";
11
+ import { default as default4 } from "eslint-plugin-jsdoc";
12
+ import * as pluginJsonc from "eslint-plugin-jsonc";
13
+ import { default as default5 } from "eslint-plugin-markdown";
14
+ import { default as default6 } from "eslint-plugin-n";
15
+ import { default as default7 } from "@stylistic/eslint-plugin";
16
+ import { default as default8 } from "@typescript-eslint/eslint-plugin";
17
+ import { default as default9 } from "eslint-plugin-unicorn";
18
+ import { default as default10 } from "eslint-plugin-unused-imports";
19
+ import * as pluginYaml from "eslint-plugin-yml";
20
+ import { default as default11 } from "eslint-plugin-no-only-tests";
21
+ import { default as default12 } from "eslint-plugin-vitest";
19
22
  import { default as default13 } from "eslint-plugin-vue";
20
- import { default as default14 } from "eslint-plugin-yml";
21
- import { default as default15 } from "eslint-plugin-no-only-tests";
22
- import { default as default16 } from "eslint-plugin-react";
23
- import { default as default17 } from "eslint-plugin-react-hooks";
24
- import { default as default18 } from "eslint-plugin-astro";
25
- import { default as default19 } from "@typescript-eslint/parser";
26
- import { default as default20 } from "vue-eslint-parser";
27
- import { default as default21 } from "yaml-eslint-parser";
28
- import { default as default22 } from "jsonc-eslint-parser";
29
- import { default as default23 } from "astro-eslint-parser";
23
+ import { default as default14 } from "eslint-plugin-react";
24
+ import { default as default15 } from "eslint-plugin-react-hooks";
25
+ import { default as default16 } from "eslint-plugin-astro";
26
+ import * as parserTs from "@typescript-eslint/parser";
27
+ import { default as default17 } from "vue-eslint-parser";
28
+ import { default as default18 } from "yaml-eslint-parser";
29
+ import { default as default19 } from "jsonc-eslint-parser";
30
+ import { default as default20 } from "astro-eslint-parser";
30
31
 
31
32
  // src/configs/comments.ts
32
- var comments = [
33
- {
34
- plugins: {
35
- "eslint-comments": default3
36
- },
37
- rules: {
38
- "eslint-comments/no-aggregating-enable": "error",
39
- "eslint-comments/no-duplicate-disable": "error",
40
- "eslint-comments/no-unlimited-disable": "error",
41
- "eslint-comments/no-unused-enable": "error"
33
+ function comments() {
34
+ return [
35
+ {
36
+ name: "coderwyd:eslint-comments",
37
+ plugins: {
38
+ "eslint-comments": default3
39
+ },
40
+ rules: {
41
+ "eslint-comments/no-aggregating-enable": "error",
42
+ "eslint-comments/no-duplicate-disable": "error",
43
+ "eslint-comments/no-unlimited-disable": "error",
44
+ "eslint-comments/no-unused-enable": "error"
45
+ }
42
46
  }
43
- }
44
- ];
47
+ ];
48
+ }
45
49
 
46
50
  // src/globs.ts
47
51
  var GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
48
52
  var GLOB_SRC = "**/*.?([cm])[jt]s?(x)";
53
+ var GLOB_JS = "**/*.?([cm])js";
49
54
  var GLOB_JSX = "**/*.?([cm])jsx";
50
55
  var GLOB_TS = "**/*.?([cm])ts";
51
56
  var GLOB_TSX = "**/*.?([cm])tsx";
57
+ var GLOB_STYLE = "**/*.{c,le,sc}ss";
58
+ var GLOB_CSS = "**/*.css";
59
+ var GLOB_LESS = "**/*.less";
60
+ var GLOB_SCSS = "**/*.scss";
52
61
  var GLOB_JSON = "**/*.json";
53
62
  var GLOB_JSON5 = "**/*.json5";
54
63
  var GLOB_JSONC = "**/*.jsonc";
55
64
  var GLOB_MARKDOWN = "**/*.md";
56
65
  var GLOB_VUE = "**/*.vue";
57
66
  var GLOB_YAML = "**/*.y?(a)ml";
67
+ var GLOB_HTML = "**/*.htm?(l)";
58
68
  var GLOB_ASTRO = "**/*.astro";
59
69
  var GLOB_MARKDOWN_CODE = `${GLOB_MARKDOWN}/${GLOB_SRC}`;
60
70
  var GLOB_TESTS = [
61
71
  `**/__tests__/**/*.${GLOB_SRC_EXT}`,
62
72
  `**/*.spec.${GLOB_SRC_EXT}`,
63
- `**/*.test.${GLOB_SRC_EXT}`
73
+ `**/*.test.${GLOB_SRC_EXT}`,
74
+ `**/*.bench.${GLOB_SRC_EXT}`,
75
+ `**/*.benchmark.${GLOB_SRC_EXT}`
76
+ ];
77
+ var GLOB_ALL_SRC = [
78
+ GLOB_SRC,
79
+ GLOB_STYLE,
80
+ GLOB_JSON,
81
+ GLOB_JSON5,
82
+ GLOB_MARKDOWN,
83
+ GLOB_VUE,
84
+ GLOB_YAML,
85
+ GLOB_HTML
64
86
  ];
65
87
  var GLOB_EXCLUDE = [
66
88
  "**/node_modules",
@@ -68,6 +90,7 @@ var GLOB_EXCLUDE = [
68
90
  "**/package-lock.json",
69
91
  "**/yarn.lock",
70
92
  "**/pnpm-lock.yaml",
93
+ "**/bun.lockb",
71
94
  "**/output",
72
95
  "**/coverage",
73
96
  "**/temp",
@@ -76,6 +99,7 @@ var GLOB_EXCLUDE = [
76
99
  "**/.vercel",
77
100
  "**/.changeset",
78
101
  "**/.idea",
102
+ "**/.cache",
79
103
  "**/.output",
80
104
  "**/.vite-inspect",
81
105
  "**/CHANGELOG*.md",
@@ -87,29 +111,43 @@ var GLOB_EXCLUDE = [
87
111
  ];
88
112
 
89
113
  // src/configs/ignores.ts
90
- var ignores = [
91
- { ignores: GLOB_EXCLUDE }
92
- ];
114
+ function ignores() {
115
+ return [
116
+ {
117
+ ignores: GLOB_EXCLUDE
118
+ }
119
+ ];
120
+ }
93
121
 
94
122
  // src/configs/imports.ts
95
- var imports = [
96
- {
97
- plugins: {
98
- import: default4
99
- },
100
- rules: {
101
- "import/export": "error",
102
- "import/first": "error",
103
- "import/newline-after-import": ["error", { considerComments: true, count: 1 }],
104
- "import/no-duplicates": "error",
105
- "import/no-mutable-exports": "error",
106
- "import/no-named-default": "error",
107
- "import/no-self-import": "error",
108
- "import/no-webpack-loader-syntax": "error",
109
- "import/order": "error"
123
+ function imports(options = {}) {
124
+ const {
125
+ stylistic: stylistic2 = true
126
+ } = options;
127
+ return [
128
+ {
129
+ name: "coderwyd:imports",
130
+ plugins: {
131
+ antfu: default2,
132
+ import: pluginImport
133
+ },
134
+ rules: {
135
+ "antfu/import-dedupe": "error",
136
+ "antfu/no-import-node-modules-by-path": "error",
137
+ "import/first": "error",
138
+ "import/no-duplicates": "error",
139
+ "import/no-mutable-exports": "error",
140
+ "import/no-named-default": "error",
141
+ "import/no-self-import": "error",
142
+ "import/no-webpack-loader-syntax": "error",
143
+ "import/order": "error",
144
+ ...stylistic2 ? {
145
+ "import/newline-after-import": ["error", { considerComments: true, count: 1 }]
146
+ } : {}
147
+ }
110
148
  }
111
- }
112
- ];
149
+ ];
150
+ }
113
151
 
114
152
  // src/configs/javascript.ts
115
153
  import globals from "globals";
@@ -119,6 +157,10 @@ var OFF = 0;
119
157
 
120
158
  // src/configs/javascript.ts
121
159
  function javascript(options = {}) {
160
+ const {
161
+ isInEditor = false,
162
+ overrides = {}
163
+ } = options;
122
164
  return [
123
165
  {
124
166
  languageOptions: {
@@ -140,26 +182,21 @@ function javascript(options = {}) {
140
182
  },
141
183
  sourceType: "module"
142
184
  },
185
+ name: "coderwyd:javascript",
143
186
  plugins: {
144
187
  "antfu": default2,
145
- "unused-imports": default12
188
+ "unused-imports": default10
146
189
  },
147
190
  rules: {
148
191
  "accessor-pairs": ["error", { enforceForClassMembers: true, setWithoutGet: true }],
149
- "antfu/import-dedupe": "error",
150
- "antfu/no-import-node-modules-by-path": "error",
151
- "antfu/top-level-function": "error",
152
192
  "array-callback-return": "error",
153
193
  "arrow-parens": ["error", "as-needed", { requireForBlockBody: true }],
154
194
  "block-scoped-var": "error",
155
195
  "constructor-super": "error",
156
196
  "default-case-last": "error",
157
197
  "dot-notation": ["error", { allowKeywords: true }],
158
- "eol-last": "error",
159
198
  "eqeqeq": ["error", "smart"],
160
- "max-statements-per-line": ["error", { max: 1 }],
161
199
  "new-cap": ["error", { capIsNew: false, newIsCap: true, properties: true }],
162
- "new-parens": "error",
163
200
  "no-alert": "error",
164
201
  "no-array-constructor": "error",
165
202
  "no-async-promise-executor": "error",
@@ -170,7 +207,6 @@ function javascript(options = {}) {
170
207
  "no-cond-assign": ["error", "always"],
171
208
  "no-console": ["error", { allow: ["warn", "error"] }],
172
209
  "no-const-assign": "error",
173
- "no-constant-condition": "warn",
174
210
  "no-control-regex": "error",
175
211
  "no-debugger": "error",
176
212
  "no-delete-var": "error",
@@ -186,9 +222,7 @@ function javascript(options = {}) {
186
222
  "no-extend-native": "error",
187
223
  "no-extra-bind": "error",
188
224
  "no-extra-boolean-cast": "error",
189
- "no-extra-parens": ["error", "functions"],
190
225
  "no-fallthrough": "error",
191
- "no-floating-decimal": "error",
192
226
  "no-func-assign": "error",
193
227
  "no-global-assign": "error",
194
228
  "no-implied-eval": "error",
@@ -201,14 +235,6 @@ function javascript(options = {}) {
201
235
  "no-lone-blocks": "error",
202
236
  "no-loss-of-precision": "error",
203
237
  "no-misleading-character-class": "error",
204
- "no-mixed-operators": ["error", {
205
- allowSamePrecedence: true,
206
- groups: [
207
- ["==", "!=", "===", "!==", ">", ">=", "<", "<="],
208
- ["&&", "||"],
209
- ["in", "instanceof"]
210
- ]
211
- }],
212
238
  "no-multi-str": "error",
213
239
  "no-new": "error",
214
240
  "no-new-func": "error",
@@ -239,7 +265,9 @@ function javascript(options = {}) {
239
265
  "error",
240
266
  "DebuggerStatement",
241
267
  "LabeledStatement",
242
- "WithStatement"
268
+ "WithStatement",
269
+ "TSEnumDeclaration[const=true]",
270
+ "TSExportAssignment"
243
271
  ],
244
272
  "no-self-assign": ["error", { props: true }],
245
273
  "no-self-compare": "error",
@@ -309,7 +337,6 @@ function javascript(options = {}) {
309
337
  "prefer-rest-params": "error",
310
338
  "prefer-spread": "error",
311
339
  "prefer-template": "error",
312
- "quote-props": ["error", "consistent-as-needed"],
313
340
  "sort-imports": [
314
341
  "error",
315
342
  {
@@ -322,7 +349,7 @@ function javascript(options = {}) {
322
349
  ],
323
350
  "symbol-description": "error",
324
351
  "unicode-bom": ["error", "never"],
325
- "unused-imports/no-unused-imports": options.isInEditor ? OFF : "error",
352
+ "unused-imports/no-unused-imports": isInEditor ? OFF : "error",
326
353
  "unused-imports/no-unused-vars": [
327
354
  "error",
328
355
  { args: "after-used", argsIgnorePattern: "^_", vars: "all", varsIgnorePattern: "^_" }
@@ -330,12 +357,13 @@ function javascript(options = {}) {
330
357
  "use-isnan": ["error", { enforceForIndexOf: true, enforceForSwitchCase: true }],
331
358
  "valid-typeof": ["error", { requireStringLiterals: true }],
332
359
  "vars-on-top": "error",
333
- "wrap-iife": ["error", "any", { functionPrototypeMethods: true }],
334
- "yoda": ["error", "never"]
360
+ "yoda": ["error", "never"],
361
+ ...overrides
335
362
  }
336
363
  },
337
364
  {
338
365
  files: [`scripts/${GLOB_SRC}`, `cli.${GLOB_SRC_EXT}`],
366
+ name: "coderwyd:scripts-overrides",
339
367
  rules: {
340
368
  "no-console": OFF
341
369
  }
@@ -344,97 +372,124 @@ function javascript(options = {}) {
344
372
  }
345
373
 
346
374
  // src/configs/jsdoc.ts
347
- var jsdoc = [
348
- {
349
- plugins: {
350
- jsdoc: default5
351
- },
352
- rules: {
353
- "jsdoc/check-access": "warn",
354
- "jsdoc/check-alignment": "warn",
355
- "jsdoc/check-param-names": "warn",
356
- "jsdoc/check-property-names": "warn",
357
- "jsdoc/check-types": "warn",
358
- "jsdoc/empty-tags": "warn",
359
- "jsdoc/implements-on-classes": "warn",
360
- "jsdoc/multiline-blocks": "warn",
361
- "jsdoc/no-defaults": "warn",
362
- "jsdoc/no-multi-asterisks": "warn",
363
- "jsdoc/no-types": "warn",
364
- "jsdoc/require-param-name": "warn",
365
- "jsdoc/require-property": "warn",
366
- "jsdoc/require-property-description": "warn",
367
- "jsdoc/require-property-name": "warn",
368
- "jsdoc/require-returns-check": "warn",
369
- "jsdoc/require-returns-description": "warn",
370
- "jsdoc/require-yields-check": "warn",
371
- "jsdoc/valid-types": "warn"
375
+ function jsdoc(options = {}) {
376
+ const {
377
+ stylistic: stylistic2 = true
378
+ } = options;
379
+ return [
380
+ {
381
+ name: "coderwyd:jsdoc",
382
+ plugins: {
383
+ jsdoc: default4
384
+ },
385
+ rules: {
386
+ "jsdoc/check-access": "warn",
387
+ "jsdoc/check-param-names": "warn",
388
+ "jsdoc/check-property-names": "warn",
389
+ "jsdoc/check-types": "warn",
390
+ "jsdoc/empty-tags": "warn",
391
+ "jsdoc/implements-on-classes": "warn",
392
+ "jsdoc/no-defaults": "warn",
393
+ "jsdoc/no-multi-asterisks": "warn",
394
+ "jsdoc/require-param-name": "warn",
395
+ "jsdoc/require-property": "warn",
396
+ "jsdoc/require-property-description": "warn",
397
+ "jsdoc/require-property-name": "warn",
398
+ "jsdoc/require-returns-check": "warn",
399
+ "jsdoc/require-returns-description": "warn",
400
+ "jsdoc/require-yields-check": "warn",
401
+ ...stylistic2 ? {
402
+ "jsdoc/check-alignment": "warn",
403
+ "jsdoc/multiline-blocks": "warn"
404
+ } : {}
405
+ }
372
406
  }
373
- }
374
- ];
407
+ ];
408
+ }
375
409
 
376
410
  // src/configs/jsonc.ts
377
- var jsonc = [
378
- {
379
- files: [GLOB_JSON, GLOB_JSON5, GLOB_JSONC],
380
- languageOptions: {
381
- parser: default22
382
- },
383
- plugins: {
384
- jsonc: default6
411
+ function jsonc(options = {}) {
412
+ const {
413
+ stylistic: stylistic2 = true,
414
+ overrides = {}
415
+ } = options;
416
+ const {
417
+ indent = 2
418
+ } = typeof stylistic2 === "boolean" ? {} : stylistic2;
419
+ return [
420
+ {
421
+ name: "coderwyd:jsonc:setup",
422
+ plugins: {
423
+ jsonc: pluginJsonc
424
+ }
385
425
  },
386
- rules: {
387
- "jsonc/array-bracket-spacing": ["error", "never"],
388
- "jsonc/comma-dangle": ["error", "never"],
389
- "jsonc/comma-style": ["error", "last"],
390
- "jsonc/indent": ["error", 2],
391
- "jsonc/key-spacing": ["error", { afterColon: true, beforeColon: false }],
392
- "jsonc/no-bigint-literals": "error",
393
- "jsonc/no-binary-expression": "error",
394
- "jsonc/no-binary-numeric-literals": "error",
395
- "jsonc/no-dupe-keys": "error",
396
- "jsonc/no-escape-sequence-in-identifier": "error",
397
- "jsonc/no-floating-decimal": "error",
398
- "jsonc/no-hexadecimal-numeric-literals": "error",
399
- "jsonc/no-infinity": "error",
400
- "jsonc/no-multi-str": "error",
401
- "jsonc/no-nan": "error",
402
- "jsonc/no-number-props": "error",
403
- "jsonc/no-numeric-separators": "error",
404
- "jsonc/no-octal": "error",
405
- "jsonc/no-octal-escape": "error",
406
- "jsonc/no-octal-numeric-literals": "error",
407
- "jsonc/no-parenthesized": "error",
408
- "jsonc/no-plus-sign": "error",
409
- "jsonc/no-regexp-literals": "error",
410
- "jsonc/no-sparse-arrays": "error",
411
- "jsonc/no-template-literals": "error",
412
- "jsonc/no-undefined-value": "error",
413
- "jsonc/no-unicode-codepoint-escapes": "error",
414
- "jsonc/no-useless-escape": "error",
415
- "jsonc/object-curly-newline": ["error", { consistent: true, multiline: true }],
416
- "jsonc/object-curly-spacing": ["error", "always"],
417
- "jsonc/object-property-newline": ["error", { allowMultiplePropertiesPerLine: true }],
418
- "jsonc/quote-props": "error",
419
- "jsonc/quotes": "error",
420
- "jsonc/space-unary-ops": "error",
421
- "jsonc/valid-json-number": "error",
422
- "jsonc/vue-custom-block/no-parsing-error": "error"
426
+ {
427
+ files: [GLOB_JSON, GLOB_JSON5, GLOB_JSONC],
428
+ languageOptions: {
429
+ parser: default19
430
+ },
431
+ name: "coderwyd:jsonc:rules",
432
+ rules: {
433
+ "jsonc/no-bigint-literals": "error",
434
+ "jsonc/no-binary-expression": "error",
435
+ "jsonc/no-binary-numeric-literals": "error",
436
+ "jsonc/no-dupe-keys": "error",
437
+ "jsonc/no-escape-sequence-in-identifier": "error",
438
+ "jsonc/no-floating-decimal": "error",
439
+ "jsonc/no-hexadecimal-numeric-literals": "error",
440
+ "jsonc/no-infinity": "error",
441
+ "jsonc/no-multi-str": "error",
442
+ "jsonc/no-nan": "error",
443
+ "jsonc/no-number-props": "error",
444
+ "jsonc/no-numeric-separators": "error",
445
+ "jsonc/no-octal": "error",
446
+ "jsonc/no-octal-escape": "error",
447
+ "jsonc/no-octal-numeric-literals": "error",
448
+ "jsonc/no-parenthesized": "error",
449
+ "jsonc/no-plus-sign": "error",
450
+ "jsonc/no-regexp-literals": "error",
451
+ "jsonc/no-sparse-arrays": "error",
452
+ "jsonc/no-template-literals": "error",
453
+ "jsonc/no-undefined-value": "error",
454
+ "jsonc/no-unicode-codepoint-escapes": "error",
455
+ "jsonc/no-useless-escape": "error",
456
+ "jsonc/space-unary-ops": "error",
457
+ "jsonc/valid-json-number": "error",
458
+ "jsonc/vue-custom-block/no-parsing-error": "error",
459
+ ...stylistic2 ? {
460
+ "jsonc/array-bracket-spacing": ["error", "never"],
461
+ "jsonc/comma-dangle": ["error", "never"],
462
+ "jsonc/comma-style": ["error", "last"],
463
+ "jsonc/indent": ["error", indent],
464
+ "jsonc/key-spacing": ["error", { afterColon: true, beforeColon: false }],
465
+ "jsonc/object-curly-newline": ["error", { consistent: true, multiline: true }],
466
+ "jsonc/object-curly-spacing": ["error", "always"],
467
+ "jsonc/object-property-newline": ["error", { allowMultiplePropertiesPerLine: true }],
468
+ "jsonc/quote-props": "error",
469
+ "jsonc/quotes": "error"
470
+ } : {},
471
+ ...overrides
472
+ }
423
473
  }
424
- }
425
- ];
474
+ ];
475
+ }
426
476
 
427
477
  // src/configs/markdown.ts
428
478
  function markdown(options = {}) {
429
479
  const {
430
- componentExts = []
480
+ componentExts = [],
481
+ overrides = {}
431
482
  } = options;
432
483
  return [
433
484
  {
434
- files: [GLOB_MARKDOWN],
485
+ name: "coderwyd:markdown:setup",
435
486
  plugins: {
436
- markdown: default7
437
- },
487
+ markdown: default5
488
+ }
489
+ },
490
+ {
491
+ files: [GLOB_MARKDOWN],
492
+ name: "coderwyd:markdown:processor",
438
493
  processor: "markdown/markdown"
439
494
  },
440
495
  {
@@ -449,13 +504,10 @@ function markdown(options = {}) {
449
504
  }
450
505
  }
451
506
  },
452
- plugins: {
453
- ts: default10
454
- },
507
+ name: "coderwyd:markdown:rules",
455
508
  rules: {
456
509
  "antfu/no-cjs-exports": OFF,
457
510
  "antfu/no-ts-export-equal": OFF,
458
- "eol-last": OFF,
459
511
  "no-alert": OFF,
460
512
  "no-console": OFF,
461
513
  "no-undef": OFF,
@@ -463,6 +515,7 @@ function markdown(options = {}) {
463
515
  "no-unused-vars": OFF,
464
516
  "node/prefer-global/process": OFF,
465
517
  "style/comma-dangle": OFF,
518
+ "style/eol-last": OFF,
466
519
  "ts/consistent-type-imports": OFF,
467
520
  "ts/no-namespace": OFF,
468
521
  "ts/no-redeclare": OFF,
@@ -472,340 +525,395 @@ function markdown(options = {}) {
472
525
  "ts/no-var-requires": OFF,
473
526
  "unicode-bom": "off",
474
527
  "unused-imports/no-unused-imports": OFF,
475
- "unused-imports/no-unused-vars": OFF
528
+ "unused-imports/no-unused-vars": OFF,
529
+ // Type aware rules
530
+ ...{
531
+ "ts/await-thenable": OFF,
532
+ "ts/dot-notation": OFF,
533
+ "ts/no-floating-promises": OFF,
534
+ "ts/no-for-in-array": OFF,
535
+ "ts/no-implied-eval": OFF,
536
+ "ts/no-misused-promises": OFF,
537
+ "ts/no-throw-literal": OFF,
538
+ "ts/no-unnecessary-type-assertion": OFF,
539
+ "ts/no-unsafe-argument": OFF,
540
+ "ts/no-unsafe-assignment": OFF,
541
+ "ts/no-unsafe-call": OFF,
542
+ "ts/no-unsafe-member-access": OFF,
543
+ "ts/no-unsafe-return": OFF,
544
+ "ts/restrict-plus-operands": OFF,
545
+ "ts/restrict-template-expressions": OFF,
546
+ "ts/unbound-method": OFF
547
+ },
548
+ ...overrides
476
549
  }
477
550
  }
478
551
  ];
479
552
  }
480
553
 
481
554
  // src/configs/node.ts
482
- var node = [
483
- {
484
- plugins: {
485
- node: default8
486
- },
487
- rules: {
488
- "node/handle-callback-err": ["error", "^(err|error)$"],
489
- "node/no-deprecated-api": "error",
490
- "node/no-exports-assign": "error",
491
- "node/no-new-require": "error",
492
- "node/no-path-concat": "error",
493
- "node/prefer-global/buffer": ["error", "never"],
494
- "node/prefer-global/process": ["error", "never"],
495
- "node/process-exit-as-throw": "error"
555
+ function node() {
556
+ return [
557
+ {
558
+ name: "coderwyd:node",
559
+ plugins: {
560
+ node: default6
561
+ },
562
+ rules: {
563
+ "node/handle-callback-err": ["error", "^(err|error)$"],
564
+ "node/no-deprecated-api": "error",
565
+ "node/no-exports-assign": "error",
566
+ "node/no-new-require": "error",
567
+ "node/no-path-concat": "error",
568
+ "node/prefer-global/buffer": ["error", "never"],
569
+ "node/prefer-global/process": ["error", "never"],
570
+ "node/process-exit-as-throw": "error"
571
+ }
496
572
  }
497
- }
498
- ];
573
+ ];
574
+ }
499
575
 
500
576
  // src/configs/sort.ts
501
- var sortPackageJson = [
502
- {
503
- files: ["**/package.json"],
504
- rules: {
505
- "jsonc/sort-array-values": [
506
- "error",
507
- {
508
- order: { type: "asc" },
509
- pathPattern: "^files$"
510
- }
511
- ],
512
- "jsonc/sort-keys": [
513
- "error",
514
- {
515
- order: [
516
- "publisher",
517
- "name",
518
- "displayName",
519
- "type",
520
- "version",
521
- "private",
522
- "packageManager",
523
- "description",
524
- "author",
525
- "license",
526
- "funding",
527
- "homepage",
528
- "repository",
529
- "bugs",
530
- "keywords",
531
- "categories",
532
- "sideEffects",
533
- "exports",
534
- "main",
535
- "module",
536
- "unpkg",
537
- "jsdelivr",
538
- "types",
539
- "typesVersions",
540
- "bin",
541
- "icon",
542
- "files",
543
- "engines",
544
- "activationEvents",
545
- "contributes",
546
- "scripts",
547
- "peerDependencies",
548
- "peerDependenciesMeta",
549
- "dependencies",
550
- "optionalDependencies",
551
- "devDependencies",
552
- "pnpm",
553
- "overrides",
554
- "resolutions",
555
- "husky",
556
- "simple-git-hooks",
557
- "lint-staged",
558
- "eslintConfig"
559
- ],
560
- pathPattern: "^$"
561
- },
562
- {
563
- order: { type: "asc" },
564
- pathPattern: "^(?:dev|peer|optional|bundled)?[Dd]ependencies$"
565
- },
566
- {
567
- order: { type: "asc" },
568
- pathPattern: "^resolutions$"
569
- },
570
- {
571
- order: { type: "asc" },
572
- pathPattern: "^pnpm.overrides$"
573
- },
574
- {
575
- order: [
576
- "types",
577
- "import",
578
- "require",
579
- "default"
580
- ],
581
- pathPattern: "^exports.*$"
582
- }
583
- ]
577
+ function sortPackageJson() {
578
+ return [
579
+ {
580
+ files: ["**/package.json"],
581
+ name: "coderwyd:sort-package-json",
582
+ rules: {
583
+ "jsonc/sort-array-values": [
584
+ "error",
585
+ {
586
+ order: { type: "asc" },
587
+ pathPattern: "^files$"
588
+ }
589
+ ],
590
+ "jsonc/sort-keys": [
591
+ "error",
592
+ {
593
+ order: [
594
+ "publisher",
595
+ "name",
596
+ "displayName",
597
+ "type",
598
+ "version",
599
+ "private",
600
+ "packageManager",
601
+ "description",
602
+ "author",
603
+ "license",
604
+ "funding",
605
+ "homepage",
606
+ "repository",
607
+ "bugs",
608
+ "keywords",
609
+ "categories",
610
+ "sideEffects",
611
+ "exports",
612
+ "main",
613
+ "module",
614
+ "unpkg",
615
+ "jsdelivr",
616
+ "types",
617
+ "typesVersions",
618
+ "bin",
619
+ "icon",
620
+ "files",
621
+ "engines",
622
+ "activationEvents",
623
+ "contributes",
624
+ "scripts",
625
+ "peerDependencies",
626
+ "peerDependenciesMeta",
627
+ "dependencies",
628
+ "optionalDependencies",
629
+ "devDependencies",
630
+ "pnpm",
631
+ "overrides",
632
+ "resolutions",
633
+ "husky",
634
+ "simple-git-hooks",
635
+ "lint-staged",
636
+ "nano-staged",
637
+ "eslintConfig"
638
+ ],
639
+ pathPattern: "^$"
640
+ },
641
+ {
642
+ order: { type: "asc" },
643
+ pathPattern: "^(?:dev|peer|optional|bundled)?[Dd]ependencies$"
644
+ },
645
+ {
646
+ order: { type: "asc" },
647
+ pathPattern: "^resolutions$"
648
+ },
649
+ {
650
+ order: { type: "asc" },
651
+ pathPattern: "^pnpm.overrides$"
652
+ },
653
+ {
654
+ order: [
655
+ "types",
656
+ "import",
657
+ "require",
658
+ "default"
659
+ ],
660
+ pathPattern: "^exports.*$"
661
+ }
662
+ ]
663
+ }
584
664
  }
585
- }
586
- ];
587
- var sortTsconfig = [
588
- {
589
- files: ["**/tsconfig.json", "**/tsconfig.*.json"],
590
- rules: {
591
- "jsonc/sort-keys": [
592
- "error",
593
- {
594
- order: [
595
- "extends",
596
- "compilerOptions",
597
- "references",
598
- "files",
599
- "include",
600
- "exclude"
601
- ],
602
- pathPattern: "^$"
603
- },
604
- {
605
- order: [
606
- /* Projects */
607
- "incremental",
608
- "composite",
609
- "tsBuildInfoFile",
610
- "disableSourceOfProjectReferenceRedirect",
611
- "disableSolutionSearching",
612
- "disableReferencedProjectLoad",
613
- /* Language and Environment */
614
- "target",
615
- "lib",
616
- "jsx",
617
- "experimentalDecorators",
618
- "emitDecoratorMetadata",
619
- "jsxFactory",
620
- "jsxFragmentFactory",
621
- "jsxImportSource",
622
- "reactNamespace",
623
- "noLib",
624
- "useDefineForClassFields",
625
- "moduleDetection",
626
- /* Modules */
627
- "module",
628
- "rootDir",
629
- "moduleResolution",
630
- "baseUrl",
631
- "paths",
632
- "rootDirs",
633
- "typeRoots",
634
- "types",
635
- "allowUmdGlobalAccess",
636
- "moduleSuffixes",
637
- "allowImportingTsExtensions",
638
- "resolvePackageJsonExports",
639
- "resolvePackageJsonImports",
640
- "customConditions",
641
- "resolveJsonModule",
642
- "allowArbitraryExtensions",
643
- "noResolve",
644
- /* JavaScript Support */
645
- "allowJs",
646
- "checkJs",
647
- "maxNodeModuleJsDepth",
648
- /* Emit */
649
- "declaration",
650
- "declarationMap",
651
- "emitDeclarationOnly",
652
- "sourceMap",
653
- "inlineSourceMap",
654
- "outFile",
655
- "outDir",
656
- "removeComments",
657
- "noEmit",
658
- "importHelpers",
659
- "importsNotUsedAsValues",
660
- "downlevelIteration",
661
- "sourceRoot",
662
- "mapRoot",
663
- "inlineSources",
664
- "emitBOM",
665
- "newLine",
666
- "stripInternal",
667
- "noEmitHelpers",
668
- "noEmitOnError",
669
- "preserveConstEnums",
670
- "declarationDir",
671
- "preserveValueImports",
672
- /* Interop Constraints */
673
- "isolatedModules",
674
- "verbatimModuleSyntax",
675
- "allowSyntheticDefaultImports",
676
- "esModuleInterop",
677
- "preserveSymlinks",
678
- "forceConsistentCasingInFileNames",
679
- /* Type Checking */
680
- "strict",
681
- "strictBindCallApply",
682
- "strictFunctionTypes",
683
- "strictNullChecks",
684
- "strictPropertyInitialization",
685
- "allowUnreachableCode",
686
- "allowUnusedLabels",
687
- "alwaysStrict",
688
- "exactOptionalPropertyTypes",
689
- "noFallthroughCasesInSwitch",
690
- "noImplicitAny",
691
- "noImplicitOverride",
692
- "noImplicitReturns",
693
- "noImplicitThis",
694
- "noPropertyAccessFromIndexSignature",
695
- "noUncheckedIndexedAccess",
696
- "noUnusedLocals",
697
- "noUnusedParameters",
698
- "useUnknownInCatchVariables",
699
- /* Completeness */
700
- "skipDefaultLibCheck",
701
- "skipLibCheck"
702
- ],
703
- pathPattern: "^compilerOptions$"
704
- }
705
- ]
665
+ ];
666
+ }
667
+ function sortTsconfig() {
668
+ return [
669
+ {
670
+ files: ["**/tsconfig.json", "**/tsconfig.*.json"],
671
+ name: "coderwyd:sort-tsconfig",
672
+ rules: {
673
+ "jsonc/sort-keys": [
674
+ "error",
675
+ {
676
+ order: [
677
+ "extends",
678
+ "compilerOptions",
679
+ "references",
680
+ "files",
681
+ "include",
682
+ "exclude"
683
+ ],
684
+ pathPattern: "^$"
685
+ },
686
+ {
687
+ order: [
688
+ /* Projects */
689
+ "incremental",
690
+ "composite",
691
+ "tsBuildInfoFile",
692
+ "disableSourceOfProjectReferenceRedirect",
693
+ "disableSolutionSearching",
694
+ "disableReferencedProjectLoad",
695
+ /* Language and Environment */
696
+ "target",
697
+ "jsx",
698
+ "jsxFactory",
699
+ "jsxFragmentFactory",
700
+ "jsxImportSource",
701
+ "lib",
702
+ "moduleDetection",
703
+ "noLib",
704
+ "reactNamespace",
705
+ "useDefineForClassFields",
706
+ "emitDecoratorMetadata",
707
+ "experimentalDecorators",
708
+ /* Modules */
709
+ "baseUrl",
710
+ "rootDir",
711
+ "rootDirs",
712
+ "customConditions",
713
+ "module",
714
+ "moduleResolution",
715
+ "moduleSuffixes",
716
+ "noResolve",
717
+ "paths",
718
+ "resolveJsonModule",
719
+ "resolvePackageJsonExports",
720
+ "resolvePackageJsonImports",
721
+ "typeRoots",
722
+ "types",
723
+ "allowArbitraryExtensions",
724
+ "allowImportingTsExtensions",
725
+ "allowUmdGlobalAccess",
726
+ /* JavaScript Support */
727
+ "allowJs",
728
+ "checkJs",
729
+ "maxNodeModuleJsDepth",
730
+ /* Type Checking */
731
+ "strict",
732
+ "strictBindCallApply",
733
+ "strictFunctionTypes",
734
+ "strictNullChecks",
735
+ "strictPropertyInitialization",
736
+ "allowUnreachableCode",
737
+ "allowUnusedLabels",
738
+ "alwaysStrict",
739
+ "exactOptionalPropertyTypes",
740
+ "noFallthroughCasesInSwitch",
741
+ "noImplicitAny",
742
+ "noImplicitOverride",
743
+ "noImplicitReturns",
744
+ "noImplicitThis",
745
+ "noPropertyAccessFromIndexSignature",
746
+ "noUncheckedIndexedAccess",
747
+ "noUnusedLocals",
748
+ "noUnusedParameters",
749
+ "useUnknownInCatchVariables",
750
+ /* Emit */
751
+ "declaration",
752
+ "declarationDir",
753
+ "declarationMap",
754
+ "downlevelIteration",
755
+ "emitBOM",
756
+ "emitDeclarationOnly",
757
+ "importHelpers",
758
+ "importsNotUsedAsValues",
759
+ "inlineSourceMap",
760
+ "inlineSources",
761
+ "mapRoot",
762
+ "newLine",
763
+ "noEmit",
764
+ "noEmitHelpers",
765
+ "noEmitOnError",
766
+ "outDir",
767
+ "outFile",
768
+ "preserveConstEnums",
769
+ "preserveValueImports",
770
+ "removeComments",
771
+ "sourceMap",
772
+ "sourceRoot",
773
+ "stripInternal",
774
+ /* Interop Constraints */
775
+ "allowSyntheticDefaultImports",
776
+ "esModuleInterop",
777
+ "forceConsistentCasingInFileNames",
778
+ "isolatedModules",
779
+ "preserveSymlinks",
780
+ "verbatimModuleSyntax",
781
+ /* Completeness */
782
+ "skipDefaultLibCheck",
783
+ "skipLibCheck"
784
+ ],
785
+ pathPattern: "^compilerOptions$"
786
+ }
787
+ ]
788
+ }
706
789
  }
707
- }
708
- ];
790
+ ];
791
+ }
709
792
 
710
793
  // src/configs/stylistic.ts
711
- var stylistic = [
712
- {
713
- plugins: {
714
- style: default9
715
- },
716
- rules: {
717
- "antfu/consistent-list-newline": "error",
718
- "antfu/if-newline": "error",
719
- "curly": ["error", "multi-or-nest", "consistent"],
720
- "style/array-bracket-spacing": ["error", "never"],
721
- "style/arrow-spacing": ["error", { after: true, before: true }],
722
- "style/block-spacing": ["error", "always"],
723
- "style/brace-style": ["error", "stroustrup", { allowSingleLine: true }],
724
- "style/comma-dangle": ["error", "always-multiline"],
725
- "style/comma-spacing": ["error", { after: true, before: false }],
726
- "style/comma-style": ["error", "last"],
727
- "style/computed-property-spacing": ["error", "never", { enforceForClassMembers: true }],
728
- "style/dot-location": ["error", "property"],
729
- "style/indent": ["error", 2, {
730
- ArrayExpression: 1,
731
- CallExpression: { arguments: 1 },
732
- FunctionDeclaration: { body: 1, parameters: 1 },
733
- FunctionExpression: { body: 1, parameters: 1 },
734
- ImportDeclaration: 1,
735
- MemberExpression: 1,
736
- ObjectExpression: 1,
737
- SwitchCase: 1,
738
- VariableDeclarator: 1,
739
- flatTernaryExpressions: false,
740
- ignoreComments: false,
741
- ignoredNodes: [
742
- "TemplateLiteral *",
743
- "JSXElement",
744
- "JSXElement > *",
745
- "JSXAttribute",
746
- "JSXIdentifier",
747
- "JSXNamespacedName",
748
- "JSXMemberExpression",
749
- "JSXSpreadAttribute",
750
- "JSXExpressionContainer",
751
- "JSXOpeningElement",
752
- "JSXClosingElement",
753
- "JSXFragment",
754
- "JSXOpeningFragment",
755
- "JSXClosingFragment",
756
- "JSXText",
757
- "JSXEmptyExpression",
758
- "JSXSpreadChild",
759
- "TSTypeParameterInstantiation",
760
- "FunctionExpression > .params[decorators.length > 0]",
761
- "FunctionExpression > .params > :matches(Decorator, :not(:first-child))",
762
- "ClassBody.body > PropertyDefinition[decorators.length > 0] > .key"
763
- ],
764
- offsetTernaryExpressions: true,
765
- outerIIFEBody: 1
766
- }],
767
- "style/key-spacing": ["error", { afterColon: true, beforeColon: false }],
768
- "style/keyword-spacing": ["error", { after: true, before: true }],
769
- "style/lines-between-class-members": ["error", "always", { exceptAfterSingleLine: true }],
770
- "style/member-delimiter-style": ["error", { multiline: { delimiter: "none" } }],
771
- "style/multiline-ternary": ["error", "always-multiline"],
772
- "style/no-mixed-spaces-and-tabs": "error",
773
- "style/no-multi-spaces": "error",
774
- "style/no-multiple-empty-lines": ["error", { max: 1, maxBOF: 0, maxEOF: 0 }],
775
- "style/no-tabs": "error",
776
- "style/no-trailing-spaces": "error",
777
- "style/no-whitespace-before-property": "error",
778
- "style/object-curly-spacing": ["error", "always"],
779
- "style/object-property-newline": ["error", { allowMultiplePropertiesPerLine: true }],
780
- "style/operator-linebreak": ["error", "before"],
781
- "style/padded-blocks": ["error", { blocks: "never", classes: "never", switches: "never" }],
782
- "style/quotes": ["error", "single"],
783
- "style/rest-spread-spacing": ["error", "never"],
784
- "style/semi": ["error", "never"],
785
- "style/semi-spacing": ["error", { after: true, before: false }],
786
- "style/space-before-blocks": ["error", "always"],
787
- "style/space-before-function-paren": ["error", { anonymous: "always", asyncArrow: "always", named: "never" }],
788
- "style/space-in-parens": ["error", "never"],
789
- "style/space-infix-ops": "error",
790
- "style/space-unary-ops": ["error", { nonwords: false, words: true }],
791
- "style/spaced-comment": ["error", "always", {
792
- block: {
793
- balanced: true,
794
- exceptions: ["*"],
795
- markers: ["!"]
796
- },
797
- line: {
798
- exceptions: ["/", "#"],
799
- markers: ["/"]
800
- }
801
- }],
802
- "style/template-curly-spacing": "error",
803
- "style/template-tag-spacing": ["error", "never"],
804
- "style/type-annotation-spacing": ["error", {}],
805
- "style/yield-star-spacing": ["error", "both"]
794
+ function stylistic(options = {}) {
795
+ const {
796
+ indent = 2,
797
+ quotes = "single"
798
+ } = options;
799
+ return [
800
+ {
801
+ name: "coderwyd:stylistic",
802
+ plugins: {
803
+ antfu: default2,
804
+ style: default7
805
+ },
806
+ rules: {
807
+ "antfu/consistent-list-newline": "error",
808
+ "antfu/if-newline": "error",
809
+ "antfu/top-level-function": "error",
810
+ "curly": ["error", "multi-or-nest", "consistent"],
811
+ "style/array-bracket-spacing": ["error", "never"],
812
+ "style/arrow-spacing": ["error", { after: true, before: true }],
813
+ "style/block-spacing": ["error", "always"],
814
+ "style/brace-style": ["error", "stroustrup", { allowSingleLine: true }],
815
+ "style/comma-dangle": ["error", "always-multiline"],
816
+ "style/comma-spacing": ["error", { after: true, before: false }],
817
+ "style/comma-style": ["error", "last"],
818
+ "style/computed-property-spacing": ["error", "never", { enforceForClassMembers: true }],
819
+ "style/dot-location": ["error", "property"],
820
+ "style/eol-last": "error",
821
+ "style/indent": ["error", indent, {
822
+ ArrayExpression: 1,
823
+ CallExpression: { arguments: 1 },
824
+ FunctionDeclaration: { body: 1, parameters: 1 },
825
+ FunctionExpression: { body: 1, parameters: 1 },
826
+ ImportDeclaration: 1,
827
+ MemberExpression: 1,
828
+ ObjectExpression: 1,
829
+ SwitchCase: 1,
830
+ VariableDeclarator: 1,
831
+ flatTernaryExpressions: false,
832
+ ignoreComments: false,
833
+ ignoredNodes: [
834
+ "TemplateLiteral *",
835
+ "JSXElement",
836
+ "JSXElement > *",
837
+ "JSXAttribute",
838
+ "JSXIdentifier",
839
+ "JSXNamespacedName",
840
+ "JSXMemberExpression",
841
+ "JSXSpreadAttribute",
842
+ "JSXExpressionContainer",
843
+ "JSXOpeningElement",
844
+ "JSXClosingElement",
845
+ "JSXFragment",
846
+ "JSXOpeningFragment",
847
+ "JSXClosingFragment",
848
+ "JSXText",
849
+ "JSXEmptyExpression",
850
+ "JSXSpreadChild",
851
+ "TSTypeParameterInstantiation",
852
+ "FunctionExpression > .params[decorators.length > 0]",
853
+ "FunctionExpression > .params > :matches(Decorator, :not(:first-child))",
854
+ "ClassBody.body > PropertyDefinition[decorators.length > 0] > .key"
855
+ ],
856
+ offsetTernaryExpressions: true,
857
+ outerIIFEBody: 1
858
+ }],
859
+ "style/jsx-quotes": "error",
860
+ "style/key-spacing": ["error", { afterColon: true, beforeColon: false }],
861
+ "style/keyword-spacing": ["error", { after: true, before: true }],
862
+ "style/lines-between-class-members": ["error", "always", { exceptAfterSingleLine: true }],
863
+ "style/max-statements-per-line": ["error", { max: 1 }],
864
+ "style/member-delimiter-style": ["error", { multiline: { delimiter: "none" } }],
865
+ "style/multiline-ternary": ["error", "always-multiline"],
866
+ "style/new-parens": "error",
867
+ "style/no-extra-parens": ["error", "functions"],
868
+ "style/no-floating-decimal": "error",
869
+ "style/no-mixed-operators": ["error", {
870
+ allowSamePrecedence: true,
871
+ groups: [
872
+ ["==", "!=", "===", "!==", ">", ">=", "<", "<="],
873
+ ["&&", "||"],
874
+ ["in", "instanceof"]
875
+ ]
876
+ }],
877
+ "style/no-mixed-spaces-and-tabs": "error",
878
+ "style/no-multi-spaces": "error",
879
+ "style/no-multiple-empty-lines": ["error", { max: 1, maxBOF: 0, maxEOF: 0 }],
880
+ "style/no-tabs": indent === "tab" ? "off" : "error",
881
+ "style/no-trailing-spaces": "error",
882
+ "style/no-whitespace-before-property": "error",
883
+ "style/object-curly-spacing": ["error", "always"],
884
+ "style/object-property-newline": ["error", { allowMultiplePropertiesPerLine: true }],
885
+ "style/operator-linebreak": ["error", "before"],
886
+ "style/padded-blocks": ["error", { blocks: "never", classes: "never", switches: "never" }],
887
+ "style/quote-props": ["error", "consistent-as-needed"],
888
+ "style/quotes": ["error", quotes, { allowTemplateLiterals: true, avoidEscape: false }],
889
+ "style/rest-spread-spacing": ["error", "never"],
890
+ "style/semi": ["error", "never"],
891
+ "style/semi-spacing": ["error", { after: true, before: false }],
892
+ "style/space-before-blocks": ["error", "always"],
893
+ "style/space-before-function-paren": ["error", { anonymous: "always", asyncArrow: "always", named: "never" }],
894
+ "style/space-in-parens": ["error", "never"],
895
+ "style/space-infix-ops": "error",
896
+ "style/space-unary-ops": ["error", { nonwords: false, words: true }],
897
+ "style/spaced-comment": ["error", "always", {
898
+ block: {
899
+ balanced: true,
900
+ exceptions: ["*"],
901
+ markers: ["!"]
902
+ },
903
+ line: {
904
+ exceptions: ["/", "#"],
905
+ markers: ["/"]
906
+ }
907
+ }],
908
+ "style/template-curly-spacing": "error",
909
+ "style/template-tag-spacing": ["error", "never"],
910
+ "style/type-annotation-spacing": ["error", {}],
911
+ "style/wrap-iife": ["error", "any", { functionPrototypeMethods: true }],
912
+ "style/yield-star-spacing": ["error", "both"]
913
+ }
806
914
  }
807
- }
808
- ];
915
+ ];
916
+ }
809
917
 
810
918
  // src/configs/typescript.ts
811
919
  import process from "process";
@@ -827,44 +935,74 @@ function renameRules(rules, from, to) {
827
935
  // src/configs/typescript.ts
828
936
  function typescript(options) {
829
937
  const {
830
- componentExts = []
938
+ componentExts = [],
939
+ overrides = {},
940
+ parserOptions = {},
941
+ tsconfigPath
831
942
  } = options ?? {};
943
+ const typeAwareRules = {
944
+ "dot-notation": OFF,
945
+ "no-implied-eval": OFF,
946
+ "no-throw-literal": OFF,
947
+ "ts/await-thenable": "error",
948
+ "ts/ban-types": ["error", { types: { Function: false } }],
949
+ "ts/dot-notation": ["error", { allowKeywords: true }],
950
+ "ts/no-floating-promises": "error",
951
+ "ts/no-for-in-array": "error",
952
+ "ts/no-implied-eval": "error",
953
+ "ts/no-misused-promises": "error",
954
+ "ts/no-throw-literal": "error",
955
+ "ts/no-unnecessary-type-assertion": "error",
956
+ "ts/no-unsafe-argument": "error",
957
+ "ts/no-unsafe-assignment": "error",
958
+ "ts/no-unsafe-call": "error",
959
+ "ts/no-unsafe-member-access": "error",
960
+ "ts/no-unsafe-return": "error",
961
+ "ts/restrict-plus-operands": "error",
962
+ "ts/restrict-template-expressions": "error",
963
+ "ts/unbound-method": "error"
964
+ };
832
965
  return [
966
+ {
967
+ name: "coderwyd:typescript:setup",
968
+ plugins: {
969
+ antfu: default2,
970
+ import: pluginImport,
971
+ ts: default8
972
+ }
973
+ },
833
974
  {
834
975
  files: [
835
- GLOB_TS,
836
- GLOB_TSX,
976
+ GLOB_SRC,
837
977
  ...componentExts.map((ext) => `**/*.${ext}`)
838
978
  ],
839
979
  languageOptions: {
840
- parser: default19,
980
+ parser: parserTs,
841
981
  parserOptions: {
842
- sourceType: "module"
982
+ sourceType: "module",
983
+ ...tsconfigPath ? {
984
+ project: [tsconfigPath],
985
+ tsconfigRootDir: process.cwd()
986
+ } : {},
987
+ ...parserOptions
843
988
  }
844
989
  },
845
- plugins: {
846
- antfu: default2,
847
- import: default4,
848
- ts: default10
849
- },
990
+ name: "coderwyd:typescript:rules",
850
991
  rules: {
851
992
  ...renameRules(
852
- default10.configs["eslint-recommended"].overrides[0].rules,
993
+ default8.configs["eslint-recommended"].overrides[0].rules,
853
994
  "@typescript-eslint/",
854
995
  "ts/"
855
996
  ),
856
997
  ...renameRules(
857
- default10.configs.strict.rules,
998
+ default8.configs.strict.rules,
858
999
  "@typescript-eslint/",
859
1000
  "ts/"
860
1001
  ),
861
1002
  "antfu/generic-spacing": "error",
862
1003
  "antfu/named-tuple-spacing": "error",
863
1004
  "antfu/no-cjs-exports": "error",
864
- "antfu/no-const-enum": "error",
865
- "antfu/no-ts-export-equal": "error",
866
1005
  "no-dupe-class-members": OFF,
867
- "no-extra-parens": OFF,
868
1006
  "no-invalid-this": OFF,
869
1007
  "no-loss-of-precision": OFF,
870
1008
  "no-redeclare": OFF,
@@ -877,7 +1015,7 @@ function typescript(options) {
877
1015
  "ts/no-dupe-class-members": "error",
878
1016
  "ts/no-dynamic-delete": OFF,
879
1017
  "ts/no-explicit-any": OFF,
880
- "ts/no-extra-parens": ["error", "functions"],
1018
+ "ts/no-extraneous-class": OFF,
881
1019
  "ts/no-invalid-this": "error",
882
1020
  "ts/no-invalid-void-type": OFF,
883
1021
  "ts/no-loss-of-precision": "error",
@@ -886,26 +1024,34 @@ function typescript(options) {
886
1024
  "ts/no-require-imports": "error",
887
1025
  "ts/no-unused-vars": OFF,
888
1026
  "ts/no-use-before-define": ["error", { classes: false, functions: false, variables: true }],
1027
+ "ts/no-useless-constructor": OFF,
889
1028
  "ts/prefer-ts-expect-error": "error",
890
- "ts/triple-slash-reference": OFF
1029
+ "ts/triple-slash-reference": OFF,
1030
+ "ts/unified-signatures": OFF,
1031
+ ...tsconfigPath ? typeAwareRules : {},
1032
+ ...overrides
891
1033
  }
892
1034
  },
893
1035
  {
894
1036
  files: ["**/*.d.ts"],
1037
+ name: "coderwyd:typescript:dts-overrides",
895
1038
  rules: {
896
1039
  "eslint-comments/no-unlimited-disable": OFF,
897
1040
  "import/no-duplicates": OFF,
1041
+ "no-restricted-syntax": OFF,
898
1042
  "unused-imports/no-unused-vars": OFF
899
1043
  }
900
1044
  },
901
1045
  {
902
1046
  files: GLOB_TESTS,
1047
+ name: "coderwyd:typescript:tests-overrides",
903
1048
  rules: {
904
1049
  "no-unused-expressions": OFF
905
1050
  }
906
1051
  },
907
1052
  {
908
- files: [GLOB_JSX],
1053
+ files: [GLOB_JS],
1054
+ name: "coderwyd:typescript:javascript-overrides",
909
1055
  rules: {
910
1056
  "ts/no-require-imports": OFF,
911
1057
  "ts/no-var-requires": OFF
@@ -913,94 +1059,47 @@ function typescript(options) {
913
1059
  }
914
1060
  ];
915
1061
  }
916
- function typescriptWithLanguageServer(options) {
917
- const {
918
- componentExts = [],
919
- tsconfigPath,
920
- tsconfigRootDir = process.cwd()
921
- } = options;
1062
+
1063
+ // src/configs/unicorn.ts
1064
+ function unicorn() {
922
1065
  return [
923
1066
  {
924
- files: [
925
- GLOB_TS,
926
- GLOB_TSX,
927
- ...componentExts.map((ext) => `**/*.${ext}`)
928
- ],
929
- ignores: ["**/*.md/*.*"],
930
- languageOptions: {
931
- parser: default19,
932
- parserOptions: {
933
- project: [tsconfigPath],
934
- tsconfigRootDir
935
- }
936
- },
1067
+ name: "coderwyd:unicorn",
937
1068
  plugins: {
938
- ts: default10
1069
+ unicorn: default9
939
1070
  },
940
1071
  rules: {
941
- "dot-notation": OFF,
942
- "no-implied-eval": OFF,
943
- "no-throw-literal": OFF,
944
- "ts/await-thenable": "error",
945
- "ts/dot-notation": ["error", { allowKeywords: true }],
946
- "ts/no-floating-promises": "error",
947
- "ts/no-for-in-array": "error",
948
- "ts/no-implied-eval": "error",
949
- "ts/no-misused-promises": "error",
950
- "ts/no-throw-literal": "error",
951
- "ts/no-unnecessary-type-assertion": "error",
952
- "ts/no-unsafe-argument": "error",
953
- "ts/no-unsafe-assignment": "error",
954
- "ts/no-unsafe-call": "error",
955
- "ts/no-unsafe-member-access": "error",
956
- "ts/no-unsafe-return": "error",
957
- "ts/restrict-plus-operands": "error",
958
- "ts/restrict-template-expressions": "error",
959
- "ts/unbound-method": "error"
1072
+ // Pass error message when throwing errors
1073
+ "unicorn/error-message": "error",
1074
+ // Uppercase regex escapes
1075
+ "unicorn/escape-case": "error",
1076
+ // Array.isArray instead of instanceof
1077
+ "unicorn/no-instanceof-array": "error",
1078
+ // Ban `new Array` as `Array` constructor's params are ambiguous
1079
+ "unicorn/no-new-array": "error",
1080
+ // Prevent deprecated `new Buffer()`
1081
+ "unicorn/no-new-buffer": "error",
1082
+ // Lowercase number formatting for octal, hex, binary (0x1'error' instead of 0X1'error')
1083
+ "unicorn/number-literal-case": "error",
1084
+ // textContent instead of innerText
1085
+ "unicorn/prefer-dom-node-text-content": "error",
1086
+ // includes over indexOf when checking for existence
1087
+ "unicorn/prefer-includes": "error",
1088
+ // Prefer using the node: protocol
1089
+ "unicorn/prefer-node-protocol": "error",
1090
+ // Prefer using number properties like `Number.isNaN` rather than `isNaN`
1091
+ "unicorn/prefer-number-properties": "error",
1092
+ // String methods startsWith/endsWith instead of more complicated stuff
1093
+ "unicorn/prefer-string-starts-ends-with": "error",
1094
+ // Enforce throwing type error when throwing error while checking typeof
1095
+ "unicorn/prefer-type-error": "error",
1096
+ // Use new when throwing error
1097
+ "unicorn/throw-new-error": "error"
960
1098
  }
961
1099
  }
962
1100
  ];
963
1101
  }
964
1102
 
965
- // src/configs/unicorn.ts
966
- var unicorn = [
967
- {
968
- plugins: {
969
- unicorn: default11
970
- },
971
- rules: {
972
- // Pass error message when throwing errors
973
- "unicorn/error-message": "error",
974
- // Uppercase regex escapes
975
- "unicorn/escape-case": "error",
976
- // Array.isArray instead of instanceof
977
- "unicorn/no-instanceof-array": "error",
978
- // Ban `new Array` as `Array` constructor's params are ambiguous
979
- "unicorn/no-new-array": "error",
980
- // Prevent deprecated `new Buffer()`
981
- "unicorn/no-new-buffer": "error",
982
- // Keep regex literals safe!
983
- "unicorn/no-unsafe-regex": "error",
984
- // Lowercase number formatting for octal, hex, binary (0x1'error' instead of 0X1'error')
985
- "unicorn/number-literal-case": "error",
986
- // includes over indexOf when checking for existence
987
- "unicorn/prefer-includes": "error",
988
- // Prefer using the node: protocol
989
- "unicorn/prefer-node-protocol": "error",
990
- // Prefer using number properties like `Number.isNaN` rather than `isNaN`
991
- "unicorn/prefer-number-properties": "error",
992
- // String methods startsWith/endsWith instead of more complicated stuff
993
- "unicorn/prefer-string-starts-ends-with": "error",
994
- // textContent instead of innerText
995
- "unicorn/prefer-text-content": "error",
996
- // Enforce throwing type error when throwing error while checking typeof
997
- "unicorn/prefer-type-error": "error",
998
- // Use new when throwing error
999
- "unicorn/throw-new-error": "error"
1000
- }
1001
- }
1002
- ];
1003
-
1004
1103
  // src/configs/vue.ts
1005
1104
  import process2 from "process";
1006
1105
  import { getPackageInfoSync } from "local-pkg";
@@ -1024,41 +1123,41 @@ var vue2Rules = {
1024
1123
  ...default13.configs.recommended.rules
1025
1124
  };
1026
1125
  function vue(options = {}) {
1126
+ const {
1127
+ overrides = {},
1128
+ stylistic: stylistic2 = true
1129
+ } = options;
1130
+ const {
1131
+ indent = 2
1132
+ } = typeof stylistic2 === "boolean" ? {} : stylistic2;
1027
1133
  return [
1134
+ {
1135
+ name: "coderwyd:vue:setup",
1136
+ plugins: {
1137
+ vue: default13
1138
+ }
1139
+ },
1028
1140
  {
1029
1141
  files: [GLOB_VUE],
1030
1142
  languageOptions: {
1031
- parser: default20,
1143
+ parser: default17,
1032
1144
  parserOptions: {
1033
1145
  ecmaFeatures: {
1034
1146
  jsx: true
1035
1147
  },
1036
1148
  extraFileExtensions: [".vue"],
1037
- parser: options.typescript ? default19 : null,
1149
+ parser: options.typescript ? parserTs : null,
1038
1150
  sourceType: "module"
1039
1151
  }
1040
1152
  },
1041
- plugins: {
1042
- vue: default13
1043
- },
1153
+ name: "coderwyd:vue:rules",
1044
1154
  processor: default13.processors[".vue"],
1045
1155
  rules: {
1046
1156
  ...isVue3 ? vue3Rules : vue2Rules,
1047
1157
  "node/prefer-global/process": OFF,
1048
- "vue/array-bracket-spacing": ["error", "never"],
1049
- "vue/arrow-spacing": ["error", { after: true, before: true }],
1050
1158
  "vue/block-order": ["error", {
1051
1159
  order: ["script", "template", "style"]
1052
1160
  }],
1053
- "vue/block-spacing": ["error", "always"],
1054
- "vue/block-tag-newline": ["error", {
1055
- multiline: "always",
1056
- singleline: "always"
1057
- }],
1058
- "vue/brace-style": ["error", "stroustrup", { allowSingleLine: true }],
1059
- "vue/comma-dangle": ["error", "always-multiline"],
1060
- "vue/comma-spacing": ["error", { after: true, before: false }],
1061
- "vue/comma-style": ["error", "last"],
1062
1161
  "vue/component-name-in-template-casing": ["error", "PascalCase"],
1063
1162
  "vue/component-options-name-casing": ["error", "PascalCase"],
1064
1163
  "vue/custom-event-name-casing": ["error", "camelCase"],
@@ -1068,11 +1167,8 @@ function vue(options = {}) {
1068
1167
  "vue/dot-location": ["error", "property"],
1069
1168
  "vue/dot-notation": ["error", { allowKeywords: true }],
1070
1169
  "vue/eqeqeq": ["error", "smart"],
1071
- "vue/html-comment-content-spacing": ["error", "always", {
1072
- exceptions: ["-"]
1073
- }],
1074
- "vue/key-spacing": ["error", { afterColon: true, beforeColon: false }],
1075
- "vue/keyword-spacing": ["error", { after: true, before: true }],
1170
+ "vue/html-indent": ["error", indent],
1171
+ "vue/html-quotes": ["error", "double"],
1076
1172
  "vue/max-attributes-per-line": OFF,
1077
1173
  "vue/multi-word-component-names": OFF,
1078
1174
  "vue/no-dupe-keys": OFF,
@@ -1092,10 +1188,6 @@ function vue(options = {}) {
1092
1188
  "vue/no-unused-refs": "error",
1093
1189
  "vue/no-useless-v-bind": "error",
1094
1190
  "vue/no-v-html": OFF,
1095
- "vue/no-v-text-v-html-on-component": OFF,
1096
- "vue/object-curly-newline": OFF,
1097
- "vue/object-curly-spacing": ["error", "always"],
1098
- "vue/object-property-newline": ["error", { allowMultiplePropertiesPerLine: true }],
1099
1191
  "vue/object-shorthand": [
1100
1192
  "error",
1101
1193
  "always",
@@ -1104,99 +1196,309 @@ function vue(options = {}) {
1104
1196
  ignoreConstructors: false
1105
1197
  }
1106
1198
  ],
1107
- "vue/operator-linebreak": ["error", "before"],
1108
- "vue/padding-line-between-blocks": ["error", "always"],
1109
1199
  "vue/prefer-separate-static-class": "error",
1110
1200
  "vue/prefer-template": "error",
1111
- "vue/quote-props": ["error", "consistent-as-needed"],
1112
1201
  "vue/require-default-prop": OFF,
1113
1202
  "vue/require-prop-types": OFF,
1114
- "vue/space-in-parens": ["error", "never"],
1115
1203
  "vue/space-infix-ops": "error",
1116
1204
  "vue/space-unary-ops": ["error", { nonwords: false, words: true }],
1117
- "vue/template-curly-spacing": "error"
1205
+ ...stylistic2 ? {
1206
+ "vue/array-bracket-spacing": ["error", "never"],
1207
+ "vue/arrow-spacing": ["error", { after: true, before: true }],
1208
+ "vue/block-spacing": ["error", "always"],
1209
+ "vue/block-tag-newline": ["error", {
1210
+ multiline: "always",
1211
+ singleline: "always"
1212
+ }],
1213
+ "vue/brace-style": ["error", "stroustrup", { allowSingleLine: true }],
1214
+ "vue/comma-dangle": ["error", "always-multiline"],
1215
+ "vue/comma-spacing": ["error", { after: true, before: false }],
1216
+ "vue/comma-style": ["error", "last"],
1217
+ "vue/html-comment-content-spacing": ["error", "always", {
1218
+ exceptions: ["-"]
1219
+ }],
1220
+ "vue/key-spacing": ["error", { afterColon: true, beforeColon: false }],
1221
+ "vue/keyword-spacing": ["error", { after: true, before: true }],
1222
+ "vue/object-curly-newline": OFF,
1223
+ "vue/object-curly-spacing": ["error", "always"],
1224
+ "vue/object-property-newline": ["error", { allowMultiplePropertiesPerLine: true }],
1225
+ "vue/operator-linebreak": ["error", "before"],
1226
+ "vue/padding-line-between-blocks": ["error", "always"],
1227
+ "vue/quote-props": ["error", "consistent-as-needed"],
1228
+ "vue/space-in-parens": ["error", "never"],
1229
+ "vue/template-curly-spacing": "error"
1230
+ } : {},
1231
+ ...overrides
1118
1232
  }
1119
1233
  }
1120
1234
  ];
1121
1235
  }
1122
1236
 
1123
- // src/configs/yml.ts
1124
- var yml = [
1125
- {
1126
- files: [GLOB_YAML],
1127
- languageOptions: {
1128
- parser: default21
1129
- },
1130
- plugins: {
1131
- yml: default14
1237
+ // src/configs/yaml.ts
1238
+ function yaml(options = {}) {
1239
+ const {
1240
+ overrides = {},
1241
+ stylistic: stylistic2 = true
1242
+ } = options;
1243
+ const {
1244
+ indent = 2,
1245
+ quotes = "single"
1246
+ } = typeof stylistic2 === "boolean" ? {} : stylistic2;
1247
+ return [
1248
+ {
1249
+ name: "coderwyd:yaml:setup",
1250
+ plugins: {
1251
+ yaml: pluginYaml
1252
+ }
1132
1253
  },
1133
- rules: {
1134
- "style/spaced-comment": OFF,
1135
- "yml/block-mapping": "error",
1136
- "yml/block-mapping-question-indicator-newline": "error",
1137
- "yml/block-sequence": "error",
1138
- "yml/block-sequence-hyphen-indicator-newline": "error",
1139
- "yml/flow-mapping-curly-newline": "error",
1140
- "yml/flow-mapping-curly-spacing": "error",
1141
- "yml/flow-sequence-bracket-newline": "error",
1142
- "yml/flow-sequence-bracket-spacing": "error",
1143
- "yml/indent": ["error", 2],
1144
- "yml/key-spacing": "error",
1145
- "yml/no-empty-key": "error",
1146
- "yml/no-empty-sequence-entry": "error",
1147
- "yml/no-irregular-whitespace": "error",
1148
- "yml/no-tab-indent": "error",
1149
- "yml/plain-scalar": "error",
1150
- "yml/quotes": ["error", { avoidEscape: false, prefer: "single" }],
1151
- "yml/spaced-comment": "error",
1152
- "yml/vue-custom-block/no-parsing-error": "error"
1254
+ {
1255
+ files: [GLOB_YAML],
1256
+ languageOptions: {
1257
+ parser: default18
1258
+ },
1259
+ name: "coderwyd:yaml:rules",
1260
+ rules: {
1261
+ "style/spaced-comment": OFF,
1262
+ "yaml/block-mapping": "error",
1263
+ "yaml/block-sequence": "error",
1264
+ "yaml/no-empty-key": "error",
1265
+ "yaml/no-empty-sequence-entry": "error",
1266
+ "yaml/no-irregular-whitespace": "error",
1267
+ "yaml/plain-scalar": "error",
1268
+ "yaml/vue-custom-block/no-parsing-error": "error",
1269
+ ...stylistic2 ? {
1270
+ "yaml/block-mapping-question-indicator-newline": "error",
1271
+ "yaml/block-sequence-hyphen-indicator-newline": "error",
1272
+ "yaml/flow-mapping-curly-newline": "error",
1273
+ "yaml/flow-mapping-curly-spacing": "error",
1274
+ "yaml/flow-sequence-bracket-newline": "error",
1275
+ "yaml/flow-sequence-bracket-spacing": "error",
1276
+ "yaml/indent": ["error", indent === "tab" ? 2 : indent],
1277
+ "yaml/key-spacing": "error",
1278
+ "yaml/no-tab-indent": "error",
1279
+ "yaml/quotes": ["error", { avoidEscape: false, prefer: quotes }],
1280
+ "yaml/spaced-comment": "error"
1281
+ } : {},
1282
+ ...overrides
1283
+ }
1153
1284
  }
1154
- }
1155
- ];
1285
+ ];
1286
+ }
1156
1287
 
1157
1288
  // src/configs/test.ts
1158
1289
  function test(options = {}) {
1290
+ const {
1291
+ isInEditor = false,
1292
+ overrides = {}
1293
+ } = options;
1159
1294
  return [
1160
1295
  {
1161
- files: GLOB_TESTS,
1296
+ name: "coderwyd:test:setup",
1162
1297
  plugins: {
1163
- "no-only-tests": default15
1164
- },
1298
+ test: {
1299
+ ...default12,
1300
+ rules: {
1301
+ ...default12.rules,
1302
+ // extend `test/no-only-tests` rule
1303
+ ...default11.rules
1304
+ }
1305
+ }
1306
+ }
1307
+ },
1308
+ {
1309
+ files: GLOB_TESTS,
1310
+ name: "coderwyd:test:rules",
1165
1311
  rules: {
1166
- "no-only-tests/no-only-tests": options.isInEditor ? OFF : "error"
1312
+ "test/consistent-test-it": ["error", { fn: "it", withinDescribe: "it" }],
1313
+ "test/no-identical-title": "error",
1314
+ "test/no-only-tests": isInEditor ? OFF : "error",
1315
+ "test/prefer-hooks-in-order": "error",
1316
+ "test/prefer-lowercase-title": "error",
1317
+ ...overrides
1167
1318
  }
1168
1319
  }
1169
1320
  ];
1170
1321
  }
1171
1322
 
1172
1323
  // src/configs/react.ts
1324
+ import globals2 from "globals";
1173
1325
  function react(options = {}) {
1326
+ const {
1327
+ overrides = {},
1328
+ stylistic: stylistic2 = true
1329
+ } = options;
1330
+ const {
1331
+ indent = 2
1332
+ } = typeof stylistic2 === "boolean" ? {} : stylistic2;
1333
+ const extensions = [GLOB_JSX, ...[options.typescript ? GLOB_TSX : ""]];
1174
1334
  return [
1175
1335
  {
1176
- files: [GLOB_JSX, GLOB_TSX],
1336
+ name: "coderwyd:react:setup",
1337
+ plugins: {
1338
+ "react": default14,
1339
+ "react-hooks": default15
1340
+ },
1341
+ settings: {
1342
+ "import/extensions": extensions,
1343
+ "import/resolver": {
1344
+ node: { extensions }
1345
+ },
1346
+ "react": {
1347
+ version: "detect"
1348
+ }
1349
+ }
1350
+ },
1351
+ {
1352
+ files: [GLOB_JSX, ...[options.typescript ? GLOB_TSX : ""]],
1177
1353
  languageOptions: {
1354
+ globals: globals2.browser,
1178
1355
  parserOptions: {
1179
1356
  ecmaFeatures: {
1180
1357
  jsx: true
1181
1358
  },
1182
- parser: options.typescript ? default19 : null,
1183
- sourceType: "module"
1359
+ // for @typescript/eslint-parser
1360
+ jsxPragma: void 0,
1361
+ // FIXME: @typescript-eslint v6 throws deprecation warnings
1362
+ // See https://github.com/jsx-eslint/eslint-plugin-react/issues/3602
1363
+ // Remove this when they support typescript 5.2
1364
+ suppressDeprecatedPropertyWarnings: true
1184
1365
  }
1185
1366
  },
1186
- plugins: {
1187
- "react": default16,
1188
- "react-hooks": default17
1189
- },
1367
+ name: "coderwyd:react:rules",
1190
1368
  rules: {
1191
- "jsx-quotes": ["error", "prefer-double"],
1192
- ...default16.configs.recommended.rules,
1193
- "react/react-in-jsx-scope": OFF,
1194
- ...default17.configs.recommended.rules
1195
- },
1196
- settings: {
1197
- react: {
1198
- version: "detect"
1199
- }
1369
+ ...default14.configs.recommended.rules,
1370
+ ...default15.configs.recommended.rules,
1371
+ "node/prefer-global/process": OFF,
1372
+ "react/display-name": ["off", { ignoreTranspilerName: false }],
1373
+ "react/iframe-missing-sandbox": "warn",
1374
+ "react/jsx-curly-brace-presence": ["error", { children: "never", props: "never" }],
1375
+ "react/no-unknown-property": ["error", {
1376
+ ignore: [
1377
+ // SVG
1378
+ "clip-path",
1379
+ "clip-rule",
1380
+ "fill-opacity",
1381
+ "fill-rule",
1382
+ "stroke-dasharray",
1383
+ "stroke-dashoffset",
1384
+ "stroke-linecap",
1385
+ "stroke-linejoin",
1386
+ "stroke-miterlimit",
1387
+ "stroke-opacity",
1388
+ "stroke-width"
1389
+ ]
1390
+ }],
1391
+ "react/no-unused-class-component-methods": "error",
1392
+ "react/no-unused-state": "error",
1393
+ "react/prop-types": "off",
1394
+ "react/react-in-jsx-scope": "off",
1395
+ ...stylistic2 ? {
1396
+ "react/jsx-boolean-value": ["error", "never", { always: [] }],
1397
+ "react/jsx-closing-bracket-location": ["error", "tag-aligned"],
1398
+ "react/jsx-curly-newline": ["error", {
1399
+ multiline: "consistent",
1400
+ singleline: "consistent"
1401
+ }],
1402
+ "react/jsx-curly-spacing": ["error", "never", { allowMultiline: true }],
1403
+ "react/jsx-first-prop-new-line": ["error", "multiline-multiprop"],
1404
+ "react/jsx-fragments": ["error", "syntax"],
1405
+ "react/jsx-indent": ["error", indent, { checkAttributes: false, indentLogicalExpressions: true }],
1406
+ "react/jsx-indent-props": ["error", indent],
1407
+ "react/jsx-max-props-per-line": ["error", { maximum: 1, when: "multiline" }],
1408
+ "react/jsx-no-useless-fragment": "error",
1409
+ "react/jsx-props-no-multi-spaces": "error",
1410
+ "react/jsx-tag-spacing": ["error", {
1411
+ afterOpening: "never",
1412
+ beforeClosing: "never",
1413
+ beforeSelfClosing: "always",
1414
+ closingSlash: "never"
1415
+ }],
1416
+ "react/jsx-wrap-multilines": ["error", {
1417
+ arrow: "parens-new-line",
1418
+ assignment: "parens-new-line",
1419
+ condition: "parens-new-line",
1420
+ declaration: "parens-new-line",
1421
+ logical: "parens-new-line",
1422
+ prop: "parens-new-line",
1423
+ return: "parens-new-line"
1424
+ }],
1425
+ "react/sort-comp": ["error", {
1426
+ groups: {
1427
+ lifecycle: [
1428
+ "displayName",
1429
+ "propTypes",
1430
+ "contextTypes",
1431
+ "childContextTypes",
1432
+ "mixins",
1433
+ "statics",
1434
+ "defaultProps",
1435
+ "constructor",
1436
+ "getDefaultProps",
1437
+ "getInitialState",
1438
+ "state",
1439
+ "getChildContext",
1440
+ "getDerivedStateFromProps",
1441
+ "componentWillMount",
1442
+ "UNSAFE_componentWillMount",
1443
+ "componentDidMount",
1444
+ "componentWillReceiveProps",
1445
+ "UNSAFE_componentWillReceiveProps",
1446
+ "shouldComponentUpdate",
1447
+ "componentWillUpdate",
1448
+ "UNSAFE_componentWillUpdate",
1449
+ "getSnapshotBeforeUpdate",
1450
+ "componentDidUpdate",
1451
+ "componentDidCatch",
1452
+ "componentWillUnmount"
1453
+ ],
1454
+ rendering: [
1455
+ "/^render.+$/",
1456
+ "render"
1457
+ ]
1458
+ },
1459
+ order: [
1460
+ "static-variables",
1461
+ "static-methods",
1462
+ "instance-variables",
1463
+ "lifecycle",
1464
+ "/^handle.+$/",
1465
+ "/^on.+$/",
1466
+ "getters",
1467
+ "setters",
1468
+ "/^(get|set)(?!(InitialState$|DefaultProps$|ChildContext$)).+$/",
1469
+ "instance-methods",
1470
+ "everything-else",
1471
+ "rendering"
1472
+ ]
1473
+ }],
1474
+ "react/style-prop-object": "error",
1475
+ "style/indent": ["error", indent, {
1476
+ SwitchCase: 1,
1477
+ VariableDeclarator: 1,
1478
+ // from: https://github.com/airbnb/javascript/blob/master/packages/eslint-config-airbnb-base/rules/style.js
1479
+ ignoredNodes: [
1480
+ "JSXElement",
1481
+ "JSXElement :not(JSXExpressionContainer, JSXExpressionContainer *)",
1482
+ "JSXAttribute",
1483
+ "JSXIdentifier",
1484
+ "JSXNamespacedName",
1485
+ "JSXMemberExpression",
1486
+ "JSXSpreadAttribute",
1487
+ "JSXOpeningElement",
1488
+ "JSXClosingElement",
1489
+ "JSXFragment",
1490
+ "JSXOpeningFragment",
1491
+ "JSXClosingFragment",
1492
+ "JSXText",
1493
+ "JSXEmptyExpression",
1494
+ "JSXSpreadChild"
1495
+ ],
1496
+ offsetTernaryExpressions: true,
1497
+ outerIIFEBody: 1
1498
+ }],
1499
+ "style/jsx-quotes": ["error", "prefer-double"]
1500
+ } : {},
1501
+ ...overrides
1200
1502
  }
1201
1503
  }
1202
1504
  ];
@@ -1204,21 +1506,24 @@ function react(options = {}) {
1204
1506
 
1205
1507
  // src/configs/astro.ts
1206
1508
  function astro(options = {}) {
1509
+ const { overrides = {} } = options;
1207
1510
  return [
1208
1511
  {
1209
1512
  files: [GLOB_ASTRO],
1210
1513
  languageOptions: {
1211
- parser: default23,
1514
+ parser: default20,
1212
1515
  parserOptions: {
1213
1516
  extraFileExtensions: [".astro"],
1214
- parser: options.typescript ? default19 : null
1517
+ parser: options.typescript ? parserTs : null
1215
1518
  }
1216
1519
  },
1520
+ name: "coderwyd:astro",
1217
1521
  plugins: {
1218
- astro: default18
1522
+ astro: default16
1219
1523
  },
1220
1524
  rules: {
1221
- ...default18.configs.recommended.rules
1525
+ ...default16.configs.recommended.rules,
1526
+ ...overrides
1222
1527
  }
1223
1528
  }
1224
1529
  ];
@@ -1235,14 +1540,31 @@ var flatConfigProps = [
1235
1540
  "rules",
1236
1541
  "settings"
1237
1542
  ];
1543
+ var VuePackages = [
1544
+ "vue",
1545
+ "nuxt",
1546
+ "vitepress",
1547
+ "@slidev/cli"
1548
+ ];
1549
+ var ReactPackages = [
1550
+ "react",
1551
+ "next"
1552
+ ];
1553
+ var AstroPackages = [
1554
+ "astro"
1555
+ ];
1238
1556
  function coderwyd(options = {}, ...userConfigs) {
1239
- const isInEditor = options.isInEditor ?? !!((process3.env.VSCODE_PID || process3.env.JETBRAINS_IDE) && !process3.env.CI);
1240
- const enableVue = options.vue ?? (isPackageExists("vue") || isPackageExists("nuxt") || isPackageExists("vitepress") || isPackageExists("@slidev/cli"));
1241
- const enableReact = options.react ?? (isPackageExists("react") || isPackageExists("next") || isPackageExists("react-dom"));
1242
- const enableAstro = options.astro ?? isPackageExists("astro");
1243
- const enableTypeScript = options.typescript ?? isPackageExists("typescript");
1244
- const enableStylistic = options.stylistic ?? true;
1245
- const enableGitignore = options.gitignore ?? true;
1557
+ const {
1558
+ isInEditor = !!((process3.env.VSCODE_PID || process3.env.JETBRAINS_IDE) && !process3.env.CI),
1559
+ vue: enableVue = VuePackages.some((i) => isPackageExists(i)),
1560
+ react: enableReact = ReactPackages.some((i) => isPackageExists(i)),
1561
+ astro: enableAstro = AstroPackages.some((i) => isPackageExists(i)),
1562
+ typescript: enableTypeScript = isPackageExists("typescript"),
1563
+ stylistic: enableStylistic = true,
1564
+ gitignore: enableGitignore = true,
1565
+ overrides = {},
1566
+ componentExts = []
1567
+ } = options;
1246
1568
  const configs = [];
1247
1569
  if (enableGitignore) {
1248
1570
  if (typeof enableGitignore !== "boolean") {
@@ -1253,47 +1575,68 @@ function coderwyd(options = {}, ...userConfigs) {
1253
1575
  }
1254
1576
  }
1255
1577
  configs.push(
1256
- ignores,
1578
+ ignores(),
1257
1579
  javascript({ isInEditor }),
1258
- comments,
1259
- node,
1260
- jsdoc,
1261
- imports,
1262
- unicorn
1580
+ comments(),
1581
+ node(),
1582
+ jsdoc({
1583
+ stylistic: enableStylistic
1584
+ }),
1585
+ imports({
1586
+ stylistic: enableStylistic
1587
+ }),
1588
+ unicorn()
1263
1589
  );
1264
- const componentExts = [];
1265
1590
  if (enableVue)
1266
1591
  componentExts.push("vue");
1267
1592
  if (enableTypeScript) {
1268
- configs.push(typescript({ componentExts }));
1269
- if (typeof enableTypeScript !== "boolean") {
1270
- configs.push(typescriptWithLanguageServer({
1271
- ...enableTypeScript,
1272
- componentExts
1273
- }));
1274
- }
1593
+ configs.push(typescript({
1594
+ ...typeof enableTypeScript !== "boolean" ? enableTypeScript : {},
1595
+ componentExts,
1596
+ overrides: overrides.typescript
1597
+ }));
1598
+ }
1599
+ if (enableStylistic) {
1600
+ configs.push(stylistic(
1601
+ typeof enableStylistic === "boolean" ? {} : enableStylistic
1602
+ ));
1275
1603
  }
1276
- if (enableStylistic)
1277
- configs.push(stylistic);
1278
1604
  if (options.test ?? true)
1279
- configs.push(test({ isInEditor }));
1280
- if (enableVue)
1281
- configs.push(vue({ typescript: !!enableTypeScript }));
1282
- if (enableReact)
1283
- configs.push(react({ typescript: !!enableTypeScript }));
1284
- if (enableAstro)
1285
- configs.push(astro({ typescript: !!enableTypeScript }));
1605
+ configs.push(test({ isInEditor, overrides: overrides.test }));
1606
+ if (enableVue) {
1607
+ configs.push(vue({
1608
+ overrides: overrides.vue,
1609
+ stylistic: enableStylistic,
1610
+ typescript: !!enableTypeScript
1611
+ }));
1612
+ }
1613
+ if (enableReact) {
1614
+ configs.push(react({
1615
+ overrides: overrides.react,
1616
+ typescript: !!enableTypeScript
1617
+ }));
1618
+ }
1619
+ if (enableAstro) {
1620
+ configs.push(astro({
1621
+ overrides: overrides.astro,
1622
+ typescript: !!enableTypeScript
1623
+ }));
1624
+ }
1286
1625
  if (options.jsonc ?? true) {
1287
1626
  configs.push(
1288
- jsonc,
1289
- sortPackageJson,
1290
- sortTsconfig
1627
+ jsonc(),
1628
+ sortPackageJson(),
1629
+ sortTsconfig()
1291
1630
  );
1292
1631
  }
1293
- if (options.yaml ?? true)
1294
- configs.push(yml);
1632
+ if (options.yaml ?? true) {
1633
+ configs.push(yaml({
1634
+ overrides: overrides.yaml,
1635
+ stylistic: enableStylistic
1636
+ }));
1637
+ }
1295
1638
  if (options.markdown ?? true)
1296
- configs.push(markdown({ componentExts }));
1639
+ configs.push(markdown({ componentExts, overrides: overrides.markdown }));
1297
1640
  const fusedConfig = flatConfigProps.reduce((acc, key) => {
1298
1641
  if (key in options)
1299
1642
  acc[key] = options[key];
@@ -1311,6 +1654,28 @@ function coderwyd(options = {}, ...userConfigs) {
1311
1654
  // src/index.ts
1312
1655
  var src_default = coderwyd;
1313
1656
  export {
1657
+ GLOB_ALL_SRC,
1658
+ GLOB_ASTRO,
1659
+ GLOB_CSS,
1660
+ GLOB_EXCLUDE,
1661
+ GLOB_HTML,
1662
+ GLOB_JS,
1663
+ GLOB_JSON,
1664
+ GLOB_JSON5,
1665
+ GLOB_JSONC,
1666
+ GLOB_JSX,
1667
+ GLOB_LESS,
1668
+ GLOB_MARKDOWN,
1669
+ GLOB_MARKDOWN_CODE,
1670
+ GLOB_SCSS,
1671
+ GLOB_SRC,
1672
+ GLOB_SRC_EXT,
1673
+ GLOB_STYLE,
1674
+ GLOB_TESTS,
1675
+ GLOB_TS,
1676
+ GLOB_TSX,
1677
+ GLOB_VUE,
1678
+ GLOB_YAML,
1314
1679
  astro,
1315
1680
  coderwyd,
1316
1681
  combine,
@@ -1324,28 +1689,29 @@ export {
1324
1689
  jsonc,
1325
1690
  markdown,
1326
1691
  node,
1327
- default23 as parserAstro,
1328
- default22 as parserJsonc,
1329
- default19 as parserTs,
1330
- default20 as parserVue,
1331
- default21 as parserYml,
1692
+ default20 as parserAstro,
1693
+ default19 as parserJsonc,
1694
+ parserTs,
1695
+ default17 as parserVue,
1696
+ default18 as parserYaml,
1332
1697
  default2 as pluginAntfu,
1333
- default18 as pluginAstro,
1698
+ default16 as pluginAstro,
1334
1699
  default3 as pluginComments,
1335
- default4 as pluginImport,
1336
- default5 as pluginJsdoc,
1337
- default6 as pluginJsonc,
1338
- default7 as pluginMarkdown,
1339
- default15 as pluginNoOnlyTests,
1340
- default8 as pluginNode,
1341
- default16 as pluginReact,
1342
- default17 as pluginReactHooks,
1343
- default9 as pluginStylistic,
1344
- default10 as pluginTs,
1345
- default11 as pluginUnicorn,
1346
- default12 as pluginUnusedImports,
1700
+ pluginImport,
1701
+ default4 as pluginJsdoc,
1702
+ pluginJsonc,
1703
+ default5 as pluginMarkdown,
1704
+ default11 as pluginNoOnlyTests,
1705
+ default6 as pluginNode,
1706
+ default14 as pluginReact,
1707
+ default15 as pluginReactHooks,
1708
+ default7 as pluginStylistic,
1709
+ default8 as pluginTs,
1710
+ default9 as pluginUnicorn,
1711
+ default10 as pluginUnusedImports,
1712
+ default12 as pluginVitest,
1347
1713
  default13 as pluginVue,
1348
- default14 as pluginYml,
1714
+ pluginYaml,
1349
1715
  react,
1350
1716
  renameRules,
1351
1717
  sortPackageJson,
@@ -1353,8 +1719,7 @@ export {
1353
1719
  stylistic,
1354
1720
  test,
1355
1721
  typescript,
1356
- typescriptWithLanguageServer,
1357
1722
  unicorn,
1358
1723
  vue,
1359
- yml
1724
+ yaml
1360
1725
  };