@coderwyd/eslint-config 1.1.0-beta.0 → 1.1.0-beta.1
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 +1441 -0
- package/dist/index.d.cts +178 -0
- package/dist/index.d.ts +30 -6
- package/dist/index.js +204 -160
- package/package.json +19 -20
package/dist/index.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
// src/factory.ts
|
|
2
2
|
import process3 from "process";
|
|
3
|
+
import fs from "fs";
|
|
3
4
|
import { isPackageExists } from "local-pkg";
|
|
4
|
-
|
|
5
|
-
// src/flags.ts
|
|
6
|
-
var OFF = 0;
|
|
5
|
+
import gitignore from "eslint-config-flat-gitignore";
|
|
7
6
|
|
|
8
7
|
// src/plugins.ts
|
|
9
8
|
import { default as default2 } from "eslint-plugin-antfu";
|
|
@@ -13,20 +12,21 @@ import { default as default5 } from "eslint-plugin-jsdoc";
|
|
|
13
12
|
import { default as default6 } from "eslint-plugin-jsonc";
|
|
14
13
|
import { default as default7 } from "eslint-plugin-markdown";
|
|
15
14
|
import { default as default8 } from "eslint-plugin-n";
|
|
16
|
-
import { default as default9 } from "@stylistic/eslint-plugin
|
|
17
|
-
import { default as default10 } from "@
|
|
18
|
-
import { default as default11 } from "
|
|
19
|
-
import { default as default12 } from "eslint-plugin-
|
|
20
|
-
import { default as default13 } from "eslint-plugin-
|
|
21
|
-
import { default as default14 } from "eslint-plugin-
|
|
22
|
-
import { default as default15 } from "eslint-plugin-
|
|
23
|
-
import { default as default16 } from "eslint-plugin-
|
|
24
|
-
import { default as default17 } from "eslint-plugin-react";
|
|
25
|
-
import { default as default18 } from "eslint-plugin-
|
|
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";
|
|
19
|
+
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";
|
|
26
25
|
import { default as default19 } from "@typescript-eslint/parser";
|
|
27
26
|
import { default as default20 } from "vue-eslint-parser";
|
|
28
27
|
import { default as default21 } from "yaml-eslint-parser";
|
|
29
28
|
import { default as default22 } from "jsonc-eslint-parser";
|
|
29
|
+
import { default as default23 } from "astro-eslint-parser";
|
|
30
30
|
|
|
31
31
|
// src/configs/comments.ts
|
|
32
32
|
var comments = [
|
|
@@ -35,8 +35,10 @@ var comments = [
|
|
|
35
35
|
"eslint-comments": default3
|
|
36
36
|
},
|
|
37
37
|
rules: {
|
|
38
|
-
|
|
39
|
-
"eslint-comments/
|
|
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"
|
|
40
42
|
}
|
|
41
43
|
}
|
|
42
44
|
];
|
|
@@ -53,6 +55,7 @@ var GLOB_JSONC = "**/*.jsonc";
|
|
|
53
55
|
var GLOB_MARKDOWN = "**/*.md";
|
|
54
56
|
var GLOB_VUE = "**/*.vue";
|
|
55
57
|
var GLOB_YAML = "**/*.y?(a)ml";
|
|
58
|
+
var GLOB_ASTRO = "**/*.astro";
|
|
56
59
|
var GLOB_MARKDOWN_CODE = `${GLOB_MARKDOWN}/${GLOB_SRC}`;
|
|
57
60
|
var GLOB_TESTS = [
|
|
58
61
|
`**/__tests__/**/*.${GLOB_SRC_EXT}`,
|
|
@@ -110,6 +113,11 @@ var imports = [
|
|
|
110
113
|
|
|
111
114
|
// src/configs/javascript.ts
|
|
112
115
|
import globals from "globals";
|
|
116
|
+
|
|
117
|
+
// src/flags.ts
|
|
118
|
+
var OFF = 0;
|
|
119
|
+
|
|
120
|
+
// src/configs/javascript.ts
|
|
113
121
|
function javascript(options = {}) {
|
|
114
122
|
return [
|
|
115
123
|
{
|
|
@@ -134,7 +142,7 @@ function javascript(options = {}) {
|
|
|
134
142
|
},
|
|
135
143
|
plugins: {
|
|
136
144
|
"antfu": default2,
|
|
137
|
-
"unused-imports":
|
|
145
|
+
"unused-imports": default12
|
|
138
146
|
},
|
|
139
147
|
rules: {
|
|
140
148
|
"accessor-pairs": ["error", { enforceForClassMembers: true, setWithoutGet: true }],
|
|
@@ -144,9 +152,6 @@ function javascript(options = {}) {
|
|
|
144
152
|
"array-callback-return": "error",
|
|
145
153
|
"arrow-parens": ["error", "as-needed", { requireForBlockBody: true }],
|
|
146
154
|
"block-scoped-var": "error",
|
|
147
|
-
"camelcase": OFF,
|
|
148
|
-
"complexity": OFF,
|
|
149
|
-
"consistent-return": OFF,
|
|
150
155
|
"constructor-super": "error",
|
|
151
156
|
"default-case-last": "error",
|
|
152
157
|
"dot-notation": ["error", { allowKeywords: true }],
|
|
@@ -155,7 +160,7 @@ function javascript(options = {}) {
|
|
|
155
160
|
"max-statements-per-line": ["error", { max: 1 }],
|
|
156
161
|
"new-cap": ["error", { capIsNew: false, newIsCap: true, properties: true }],
|
|
157
162
|
"new-parens": "error",
|
|
158
|
-
"no-alert": "
|
|
163
|
+
"no-alert": "error",
|
|
159
164
|
"no-array-constructor": "error",
|
|
160
165
|
"no-async-promise-executor": "error",
|
|
161
166
|
"no-caller": "error",
|
|
@@ -213,7 +218,6 @@ function javascript(options = {}) {
|
|
|
213
218
|
"no-obj-calls": "error",
|
|
214
219
|
"no-octal": "error",
|
|
215
220
|
"no-octal-escape": "error",
|
|
216
|
-
"no-param-reassign": OFF,
|
|
217
221
|
"no-proto": "error",
|
|
218
222
|
"no-prototype-builtins": "error",
|
|
219
223
|
"no-redeclare": ["error", { builtinGlobals: false }],
|
|
@@ -237,8 +241,6 @@ function javascript(options = {}) {
|
|
|
237
241
|
"LabeledStatement",
|
|
238
242
|
"WithStatement"
|
|
239
243
|
],
|
|
240
|
-
"no-return-assign": OFF,
|
|
241
|
-
"no-return-await": OFF,
|
|
242
244
|
"no-self-assign": ["error", { props: true }],
|
|
243
245
|
"no-self-compare": "error",
|
|
244
246
|
"no-sequences": "error",
|
|
@@ -273,7 +275,6 @@ function javascript(options = {}) {
|
|
|
273
275
|
"no-useless-catch": "error",
|
|
274
276
|
"no-useless-computed-key": "error",
|
|
275
277
|
"no-useless-constructor": "error",
|
|
276
|
-
"no-useless-escape": OFF,
|
|
277
278
|
"no-useless-rename": "error",
|
|
278
279
|
"no-useless-return": "error",
|
|
279
280
|
"no-var": "error",
|
|
@@ -309,7 +310,6 @@ function javascript(options = {}) {
|
|
|
309
310
|
"prefer-spread": "error",
|
|
310
311
|
"prefer-template": "error",
|
|
311
312
|
"quote-props": ["error", "consistent-as-needed"],
|
|
312
|
-
"require-await": OFF,
|
|
313
313
|
"sort-imports": [
|
|
314
314
|
"error",
|
|
315
315
|
{
|
|
@@ -324,7 +324,7 @@ function javascript(options = {}) {
|
|
|
324
324
|
"unicode-bom": ["error", "never"],
|
|
325
325
|
"unused-imports/no-unused-imports": options.isInEditor ? OFF : "error",
|
|
326
326
|
"unused-imports/no-unused-vars": [
|
|
327
|
-
"
|
|
327
|
+
"error",
|
|
328
328
|
{ args: "after-used", argsIgnorePattern: "^_", vars: "all", varsIgnorePattern: "^_" }
|
|
329
329
|
],
|
|
330
330
|
"use-isnan": ["error", { enforceForIndexOf: true, enforceForSwitchCase: true }],
|
|
@@ -335,7 +335,7 @@ function javascript(options = {}) {
|
|
|
335
335
|
}
|
|
336
336
|
},
|
|
337
337
|
{
|
|
338
|
-
files: [
|
|
338
|
+
files: [`scripts/${GLOB_SRC}`, `cli.${GLOB_SRC_EXT}`],
|
|
339
339
|
rules: {
|
|
340
340
|
"no-console": OFF
|
|
341
341
|
}
|
|
@@ -350,19 +350,25 @@ var jsdoc = [
|
|
|
350
350
|
jsdoc: default5
|
|
351
351
|
},
|
|
352
352
|
rules: {
|
|
353
|
-
|
|
354
|
-
"jsdoc/check-
|
|
355
|
-
"jsdoc/check-
|
|
356
|
-
"jsdoc/
|
|
357
|
-
"jsdoc/
|
|
358
|
-
"jsdoc/
|
|
359
|
-
"jsdoc/
|
|
360
|
-
"jsdoc/
|
|
361
|
-
"jsdoc/
|
|
362
|
-
"jsdoc/
|
|
363
|
-
"jsdoc/
|
|
364
|
-
"jsdoc/require-
|
|
365
|
-
"jsdoc/
|
|
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"
|
|
366
372
|
}
|
|
367
373
|
}
|
|
368
374
|
];
|
|
@@ -378,16 +384,42 @@ var jsonc = [
|
|
|
378
384
|
jsonc: default6
|
|
379
385
|
},
|
|
380
386
|
rules: {
|
|
381
|
-
...default6.configs["recommended-with-jsonc"].rules,
|
|
382
387
|
"jsonc/array-bracket-spacing": ["error", "never"],
|
|
383
388
|
"jsonc/comma-dangle": ["error", "never"],
|
|
384
389
|
"jsonc/comma-style": ["error", "last"],
|
|
385
390
|
"jsonc/indent": ["error", 2],
|
|
386
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",
|
|
387
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",
|
|
388
415
|
"jsonc/object-curly-newline": ["error", { consistent: true, multiline: true }],
|
|
389
416
|
"jsonc/object-curly-spacing": ["error", "always"],
|
|
390
|
-
"jsonc/object-property-newline": ["error", { allowMultiplePropertiesPerLine: true }]
|
|
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"
|
|
391
423
|
}
|
|
392
424
|
}
|
|
393
425
|
];
|
|
@@ -418,21 +450,19 @@ function markdown(options = {}) {
|
|
|
418
450
|
}
|
|
419
451
|
},
|
|
420
452
|
plugins: {
|
|
421
|
-
ts:
|
|
453
|
+
ts: default10
|
|
422
454
|
},
|
|
423
455
|
rules: {
|
|
424
|
-
...default7.configs.recommended.overrides[1].rules,
|
|
425
456
|
"antfu/no-cjs-exports": OFF,
|
|
426
457
|
"antfu/no-ts-export-equal": OFF,
|
|
427
|
-
"
|
|
458
|
+
"eol-last": OFF,
|
|
428
459
|
"no-alert": OFF,
|
|
429
460
|
"no-console": OFF,
|
|
430
|
-
"no-restricted-imports": OFF,
|
|
431
461
|
"no-undef": OFF,
|
|
432
462
|
"no-unused-expressions": OFF,
|
|
433
463
|
"no-unused-vars": OFF,
|
|
434
464
|
"node/prefer-global/process": OFF,
|
|
435
|
-
"
|
|
465
|
+
"style/comma-dangle": OFF,
|
|
436
466
|
"ts/consistent-type-imports": OFF,
|
|
437
467
|
"ts/no-namespace": OFF,
|
|
438
468
|
"ts/no-redeclare": OFF,
|
|
@@ -440,6 +470,7 @@ function markdown(options = {}) {
|
|
|
440
470
|
"ts/no-unused-vars": OFF,
|
|
441
471
|
"ts/no-use-before-define": OFF,
|
|
442
472
|
"ts/no-var-requires": OFF,
|
|
473
|
+
"unicode-bom": "off",
|
|
443
474
|
"unused-imports/no-unused-imports": OFF,
|
|
444
475
|
"unused-imports/no-unused-vars": OFF
|
|
445
476
|
}
|
|
@@ -677,29 +708,24 @@ var sortTsconfig = [
|
|
|
677
708
|
];
|
|
678
709
|
|
|
679
710
|
// src/configs/stylistic.ts
|
|
680
|
-
|
|
681
|
-
var tsPackage = packages.find((i) => i.shortId === "ts");
|
|
682
|
-
var javascriptStylistic = [
|
|
711
|
+
var stylistic = [
|
|
683
712
|
{
|
|
684
713
|
plugins: {
|
|
685
714
|
style: default9
|
|
686
715
|
},
|
|
687
716
|
rules: {
|
|
717
|
+
"antfu/consistent-list-newline": "error",
|
|
688
718
|
"antfu/if-newline": "error",
|
|
689
|
-
"comma-dangle": ["error", "always-multiline"],
|
|
690
719
|
"curly": ["error", "multi-or-nest", "consistent"],
|
|
691
|
-
"quotes": ["error", "single"],
|
|
692
|
-
"semi": ["error", "never"],
|
|
693
720
|
"style/array-bracket-spacing": ["error", "never"],
|
|
694
721
|
"style/arrow-spacing": ["error", { after: true, before: true }],
|
|
695
722
|
"style/block-spacing": ["error", "always"],
|
|
696
723
|
"style/brace-style": ["error", "stroustrup", { allowSingleLine: true }],
|
|
724
|
+
"style/comma-dangle": ["error", "always-multiline"],
|
|
697
725
|
"style/comma-spacing": ["error", { after: true, before: false }],
|
|
698
726
|
"style/comma-style": ["error", "last"],
|
|
699
727
|
"style/computed-property-spacing": ["error", "never", { enforceForClassMembers: true }],
|
|
700
728
|
"style/dot-location": ["error", "property"],
|
|
701
|
-
"style/func-call-spacing": OFF,
|
|
702
|
-
"style/generator-star-spacing": OFF,
|
|
703
729
|
"style/indent": ["error", 2, {
|
|
704
730
|
ArrayExpression: 1,
|
|
705
731
|
CallExpression: { arguments: 1 },
|
|
@@ -741,6 +767,7 @@ var javascriptStylistic = [
|
|
|
741
767
|
"style/key-spacing": ["error", { afterColon: true, beforeColon: false }],
|
|
742
768
|
"style/keyword-spacing": ["error", { after: true, before: true }],
|
|
743
769
|
"style/lines-between-class-members": ["error", "always", { exceptAfterSingleLine: true }],
|
|
770
|
+
"style/member-delimiter-style": ["error", { multiline: { delimiter: "none" } }],
|
|
744
771
|
"style/multiline-ternary": ["error", "always-multiline"],
|
|
745
772
|
"style/no-mixed-spaces-and-tabs": "error",
|
|
746
773
|
"style/no-multi-spaces": "error",
|
|
@@ -748,12 +775,13 @@ var javascriptStylistic = [
|
|
|
748
775
|
"style/no-tabs": "error",
|
|
749
776
|
"style/no-trailing-spaces": "error",
|
|
750
777
|
"style/no-whitespace-before-property": "error",
|
|
751
|
-
"style/object-curly-newline": OFF,
|
|
752
778
|
"style/object-curly-spacing": ["error", "always"],
|
|
753
779
|
"style/object-property-newline": ["error", { allowMultiplePropertiesPerLine: true }],
|
|
754
780
|
"style/operator-linebreak": ["error", "before"],
|
|
755
781
|
"style/padded-blocks": ["error", { blocks: "never", classes: "never", switches: "never" }],
|
|
782
|
+
"style/quotes": ["error", "single"],
|
|
756
783
|
"style/rest-spread-spacing": ["error", "never"],
|
|
784
|
+
"style/semi": ["error", "never"],
|
|
757
785
|
"style/semi-spacing": ["error", { after: true, before: false }],
|
|
758
786
|
"style/space-before-blocks": ["error", "always"],
|
|
759
787
|
"style/space-before-function-paren": ["error", { anonymous: "always", asyncArrow: "always", named: "never" }],
|
|
@@ -773,53 +801,11 @@ var javascriptStylistic = [
|
|
|
773
801
|
}],
|
|
774
802
|
"style/template-curly-spacing": "error",
|
|
775
803
|
"style/template-tag-spacing": ["error", "never"],
|
|
804
|
+
"style/type-annotation-spacing": ["error", {}],
|
|
776
805
|
"style/yield-star-spacing": ["error", "both"]
|
|
777
806
|
}
|
|
778
807
|
}
|
|
779
808
|
];
|
|
780
|
-
var typescriptStylistic = [
|
|
781
|
-
{
|
|
782
|
-
plugins: {
|
|
783
|
-
"style-ts": default10,
|
|
784
|
-
"ts": default11
|
|
785
|
-
},
|
|
786
|
-
rules: {
|
|
787
|
-
...stylisticJsToTS(javascriptStylistic[0].rules),
|
|
788
|
-
"comma-dangle": OFF,
|
|
789
|
-
"quotes": OFF,
|
|
790
|
-
"semi": OFF,
|
|
791
|
-
"style-ts/member-delimiter-style": ["error", { multiline: { delimiter: "none" } }],
|
|
792
|
-
"style-ts/type-annotation-spacing": ["error", {}],
|
|
793
|
-
"ts/comma-dangle": ["error", "always-multiline"],
|
|
794
|
-
"ts/quotes": ["error", "single"],
|
|
795
|
-
"ts/semi": ["error", "never"]
|
|
796
|
-
}
|
|
797
|
-
}
|
|
798
|
-
];
|
|
799
|
-
function stylisticJsToTS(input) {
|
|
800
|
-
return {
|
|
801
|
-
// turn off all stylistic rules from style
|
|
802
|
-
...Object.fromEntries(
|
|
803
|
-
Object.entries(input).map(([key]) => {
|
|
804
|
-
if (!key.startsWith("style/"))
|
|
805
|
-
return null;
|
|
806
|
-
const basename = key.replace("style/", "");
|
|
807
|
-
if (tsPackage.rules.find((i) => i.name === basename))
|
|
808
|
-
return [key, OFF];
|
|
809
|
-
return null;
|
|
810
|
-
}).filter(Boolean)
|
|
811
|
-
),
|
|
812
|
-
// rename all stylistic rules from style to style/ts
|
|
813
|
-
...Object.fromEntries(
|
|
814
|
-
Object.entries(input).map(([key, value]) => {
|
|
815
|
-
if (!key.startsWith("style/"))
|
|
816
|
-
return null;
|
|
817
|
-
const basename = key.replace("style/", "");
|
|
818
|
-
return tsPackage.rules.find((i) => i.name === basename) ? [`style-ts/${basename}`, value] : null;
|
|
819
|
-
}).filter(Boolean)
|
|
820
|
-
)
|
|
821
|
-
};
|
|
822
|
-
}
|
|
823
809
|
|
|
824
810
|
// src/configs/typescript.ts
|
|
825
811
|
import process from "process";
|
|
@@ -859,16 +845,16 @@ function typescript(options) {
|
|
|
859
845
|
plugins: {
|
|
860
846
|
antfu: default2,
|
|
861
847
|
import: default4,
|
|
862
|
-
ts:
|
|
848
|
+
ts: default10
|
|
863
849
|
},
|
|
864
850
|
rules: {
|
|
865
851
|
...renameRules(
|
|
866
|
-
|
|
852
|
+
default10.configs["eslint-recommended"].overrides[0].rules,
|
|
867
853
|
"@typescript-eslint/",
|
|
868
854
|
"ts/"
|
|
869
855
|
),
|
|
870
856
|
...renameRules(
|
|
871
|
-
|
|
857
|
+
default10.configs.strict.rules,
|
|
872
858
|
"@typescript-eslint/",
|
|
873
859
|
"ts/"
|
|
874
860
|
),
|
|
@@ -886,28 +872,20 @@ function typescript(options) {
|
|
|
886
872
|
"no-useless-constructor": OFF,
|
|
887
873
|
// TS
|
|
888
874
|
"ts/ban-ts-comment": ["error", { "ts-ignore": "allow-with-description" }],
|
|
889
|
-
"ts/ban-ts-ignore": OFF,
|
|
890
|
-
"ts/consistent-indexed-object-style": OFF,
|
|
891
875
|
"ts/consistent-type-definitions": ["error", "interface"],
|
|
892
876
|
"ts/consistent-type-imports": ["error", { disallowTypeAnnotations: false, prefer: "type-imports" }],
|
|
893
|
-
"ts/explicit-function-return-type": OFF,
|
|
894
|
-
"ts/explicit-member-accessibility": OFF,
|
|
895
|
-
"ts/explicit-module-boundary-types": OFF,
|
|
896
|
-
"ts/naming-convention": OFF,
|
|
897
877
|
"ts/no-dupe-class-members": "error",
|
|
898
|
-
"ts/no-
|
|
899
|
-
"ts/no-empty-interface": OFF,
|
|
878
|
+
"ts/no-dynamic-delete": OFF,
|
|
900
879
|
"ts/no-explicit-any": OFF,
|
|
901
880
|
"ts/no-extra-parens": ["error", "functions"],
|
|
902
881
|
"ts/no-invalid-this": "error",
|
|
903
|
-
"ts/no-loss-of-precision": "error",
|
|
904
882
|
"ts/no-invalid-void-type": OFF,
|
|
883
|
+
"ts/no-loss-of-precision": "error",
|
|
905
884
|
"ts/no-non-null-assertion": OFF,
|
|
906
885
|
"ts/no-redeclare": "error",
|
|
907
886
|
"ts/no-require-imports": "error",
|
|
908
887
|
"ts/no-unused-vars": OFF,
|
|
909
888
|
"ts/no-use-before-define": ["error", { classes: false, functions: false, variables: true }],
|
|
910
|
-
"ts/parameter-properties": OFF,
|
|
911
889
|
"ts/prefer-ts-expect-error": "error",
|
|
912
890
|
"ts/triple-slash-reference": OFF
|
|
913
891
|
}
|
|
@@ -957,13 +935,12 @@ function typescriptWithLanguageServer(options) {
|
|
|
957
935
|
}
|
|
958
936
|
},
|
|
959
937
|
plugins: {
|
|
960
|
-
ts:
|
|
938
|
+
ts: default10
|
|
961
939
|
},
|
|
962
940
|
rules: {
|
|
963
941
|
"dot-notation": OFF,
|
|
964
942
|
"no-implied-eval": OFF,
|
|
965
943
|
"no-throw-literal": OFF,
|
|
966
|
-
"require-await": OFF,
|
|
967
944
|
"ts/await-thenable": "error",
|
|
968
945
|
"ts/dot-notation": ["error", { allowKeywords: true }],
|
|
969
946
|
"ts/no-floating-promises": "error",
|
|
@@ -977,7 +954,6 @@ function typescriptWithLanguageServer(options) {
|
|
|
977
954
|
"ts/no-unsafe-call": "error",
|
|
978
955
|
"ts/no-unsafe-member-access": "error",
|
|
979
956
|
"ts/no-unsafe-return": "error",
|
|
980
|
-
"ts/require-await": "error",
|
|
981
957
|
"ts/restrict-plus-operands": "error",
|
|
982
958
|
"ts/restrict-template-expressions": "error",
|
|
983
959
|
"ts/unbound-method": "error"
|
|
@@ -990,7 +966,7 @@ function typescriptWithLanguageServer(options) {
|
|
|
990
966
|
var unicorn = [
|
|
991
967
|
{
|
|
992
968
|
plugins: {
|
|
993
|
-
unicorn:
|
|
969
|
+
unicorn: default11
|
|
994
970
|
},
|
|
995
971
|
rules: {
|
|
996
972
|
// Pass error message when throwing errors
|
|
@@ -1036,16 +1012,16 @@ function getVueVersion() {
|
|
|
1036
1012
|
}
|
|
1037
1013
|
var isVue3 = getVueVersion() === 3;
|
|
1038
1014
|
var vue3Rules = {
|
|
1039
|
-
...
|
|
1040
|
-
...
|
|
1041
|
-
...
|
|
1042
|
-
...
|
|
1015
|
+
...default13.configs.base.rules,
|
|
1016
|
+
...default13.configs["vue3-essential"].rules,
|
|
1017
|
+
...default13.configs["vue3-strongly-recommended"].rules,
|
|
1018
|
+
...default13.configs["vue3-recommended"].rules
|
|
1043
1019
|
};
|
|
1044
1020
|
var vue2Rules = {
|
|
1045
|
-
...
|
|
1046
|
-
...
|
|
1047
|
-
...
|
|
1048
|
-
...
|
|
1021
|
+
...default13.configs.base.rules,
|
|
1022
|
+
...default13.configs.essential.rules,
|
|
1023
|
+
...default13.configs["strongly-recommended"].rules,
|
|
1024
|
+
...default13.configs.recommended.rules
|
|
1049
1025
|
};
|
|
1050
1026
|
function vue(options = {}) {
|
|
1051
1027
|
return [
|
|
@@ -1063,11 +1039,12 @@ function vue(options = {}) {
|
|
|
1063
1039
|
}
|
|
1064
1040
|
},
|
|
1065
1041
|
plugins: {
|
|
1066
|
-
vue:
|
|
1042
|
+
vue: default13
|
|
1067
1043
|
},
|
|
1068
|
-
processor:
|
|
1044
|
+
processor: default13.processors[".vue"],
|
|
1069
1045
|
rules: {
|
|
1070
1046
|
...isVue3 ? vue3Rules : vue2Rules,
|
|
1047
|
+
"node/prefer-global/process": OFF,
|
|
1071
1048
|
"vue/array-bracket-spacing": ["error", "never"],
|
|
1072
1049
|
"vue/arrow-spacing": ["error", { after: true, before: true }],
|
|
1073
1050
|
"vue/block-order": ["error", {
|
|
@@ -1098,7 +1075,6 @@ function vue(options = {}) {
|
|
|
1098
1075
|
"vue/keyword-spacing": ["error", { after: true, before: true }],
|
|
1099
1076
|
"vue/max-attributes-per-line": OFF,
|
|
1100
1077
|
"vue/multi-word-component-names": OFF,
|
|
1101
|
-
"vue/no-constant-condition": "warn",
|
|
1102
1078
|
"vue/no-dupe-keys": OFF,
|
|
1103
1079
|
"vue/no-empty-pattern": "error",
|
|
1104
1080
|
"vue/no-extra-parens": ["error", "functions"],
|
|
@@ -1111,7 +1087,6 @@ function vue(options = {}) {
|
|
|
1111
1087
|
"WithStatement"
|
|
1112
1088
|
],
|
|
1113
1089
|
"vue/no-restricted-v-bind": ["error", "/^v-/"],
|
|
1114
|
-
// reactivity transform
|
|
1115
1090
|
"vue/no-setup-props-reactivity-loss": OFF,
|
|
1116
1091
|
"vue/no-sparse-arrays": "error",
|
|
1117
1092
|
"vue/no-unused-refs": "error",
|
|
@@ -1153,14 +1128,28 @@ var yml = [
|
|
|
1153
1128
|
parser: default21
|
|
1154
1129
|
},
|
|
1155
1130
|
plugins: {
|
|
1156
|
-
yml:
|
|
1131
|
+
yml: default14
|
|
1157
1132
|
},
|
|
1158
1133
|
rules: {
|
|
1159
|
-
...default15.configs.standard.rules,
|
|
1160
1134
|
"style/spaced-comment": OFF,
|
|
1161
|
-
"yml/
|
|
1162
|
-
"yml/
|
|
1163
|
-
"yml/
|
|
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"
|
|
1164
1153
|
}
|
|
1165
1154
|
}
|
|
1166
1155
|
];
|
|
@@ -1171,7 +1160,7 @@ function test(options = {}) {
|
|
|
1171
1160
|
{
|
|
1172
1161
|
files: GLOB_TESTS,
|
|
1173
1162
|
plugins: {
|
|
1174
|
-
"no-only-tests":
|
|
1163
|
+
"no-only-tests": default15
|
|
1175
1164
|
},
|
|
1176
1165
|
rules: {
|
|
1177
1166
|
"no-only-tests/no-only-tests": options.isInEditor ? OFF : "error"
|
|
@@ -1186,24 +1175,49 @@ function react(options = {}) {
|
|
|
1186
1175
|
{
|
|
1187
1176
|
files: [GLOB_JSX, GLOB_TSX],
|
|
1188
1177
|
languageOptions: {
|
|
1189
|
-
parser: options.typescript ? default19 : null,
|
|
1190
1178
|
parserOptions: {
|
|
1179
|
+
ecmaFeatures: {
|
|
1180
|
+
jsx: true
|
|
1181
|
+
},
|
|
1182
|
+
parser: options.typescript ? default19 : null,
|
|
1191
1183
|
sourceType: "module"
|
|
1192
1184
|
}
|
|
1193
1185
|
},
|
|
1194
1186
|
plugins: {
|
|
1195
|
-
"react":
|
|
1196
|
-
"react-hooks":
|
|
1187
|
+
"react": default16,
|
|
1188
|
+
"react-hooks": default17
|
|
1189
|
+
},
|
|
1190
|
+
rules: {
|
|
1191
|
+
"jsx-quotes": ["error", "prefer-double"],
|
|
1192
|
+
...default16.configs.recommended.rules,
|
|
1193
|
+
"react/react-in-jsx-scope": OFF,
|
|
1194
|
+
...default17.configs.recommended.rules
|
|
1197
1195
|
},
|
|
1198
1196
|
settings: {
|
|
1199
1197
|
react: {
|
|
1200
1198
|
version: "detect"
|
|
1201
1199
|
}
|
|
1200
|
+
}
|
|
1201
|
+
}
|
|
1202
|
+
];
|
|
1203
|
+
}
|
|
1204
|
+
|
|
1205
|
+
// src/configs/astro.ts
|
|
1206
|
+
function astro(options = {}) {
|
|
1207
|
+
return [
|
|
1208
|
+
{
|
|
1209
|
+
files: [GLOB_ASTRO],
|
|
1210
|
+
languageOptions: {
|
|
1211
|
+
parser: default23,
|
|
1212
|
+
parserOptions: {
|
|
1213
|
+
extraFileExtensions: [".astro"],
|
|
1214
|
+
parser: options.typescript ? default19 : null
|
|
1215
|
+
}
|
|
1216
|
+
},
|
|
1217
|
+
plugins: {
|
|
1218
|
+
astro: default18
|
|
1202
1219
|
},
|
|
1203
1220
|
rules: {
|
|
1204
|
-
"jsx-quotes": ["error", "prefer-double"],
|
|
1205
|
-
...default17.configs.recommended.rules,
|
|
1206
|
-
"react/react-in-jsx-scope": "off",
|
|
1207
1221
|
...default18.configs.recommended.rules
|
|
1208
1222
|
}
|
|
1209
1223
|
}
|
|
@@ -1211,13 +1225,34 @@ function react(options = {}) {
|
|
|
1211
1225
|
}
|
|
1212
1226
|
|
|
1213
1227
|
// src/factory.ts
|
|
1228
|
+
var flatConfigProps = [
|
|
1229
|
+
"files",
|
|
1230
|
+
"ignores",
|
|
1231
|
+
"languageOptions",
|
|
1232
|
+
"linterOptions",
|
|
1233
|
+
"processor",
|
|
1234
|
+
"plugins",
|
|
1235
|
+
"rules",
|
|
1236
|
+
"settings"
|
|
1237
|
+
];
|
|
1214
1238
|
function coderwyd(options = {}, ...userConfigs) {
|
|
1215
1239
|
const isInEditor = options.isInEditor ?? !!((process3.env.VSCODE_PID || process3.env.JETBRAINS_IDE) && !process3.env.CI);
|
|
1216
1240
|
const enableVue = options.vue ?? (isPackageExists("vue") || isPackageExists("nuxt") || isPackageExists("vitepress") || isPackageExists("@slidev/cli"));
|
|
1217
|
-
const enableReact = options.
|
|
1241
|
+
const enableReact = options.react ?? (isPackageExists("react") || isPackageExists("next") || isPackageExists("react-dom"));
|
|
1242
|
+
const enableAstro = options.astro ?? isPackageExists("astro");
|
|
1218
1243
|
const enableTypeScript = options.typescript ?? isPackageExists("typescript");
|
|
1219
1244
|
const enableStylistic = options.stylistic ?? true;
|
|
1220
|
-
const
|
|
1245
|
+
const enableGitignore = options.gitignore ?? true;
|
|
1246
|
+
const configs = [];
|
|
1247
|
+
if (enableGitignore) {
|
|
1248
|
+
if (typeof enableGitignore !== "boolean") {
|
|
1249
|
+
configs.push([gitignore(enableGitignore)]);
|
|
1250
|
+
} else {
|
|
1251
|
+
if (fs.existsSync(".gitignore"))
|
|
1252
|
+
configs.push([gitignore()]);
|
|
1253
|
+
}
|
|
1254
|
+
}
|
|
1255
|
+
configs.push(
|
|
1221
1256
|
ignores,
|
|
1222
1257
|
javascript({ isInEditor }),
|
|
1223
1258
|
comments,
|
|
@@ -1225,12 +1260,10 @@ function coderwyd(options = {}, ...userConfigs) {
|
|
|
1225
1260
|
jsdoc,
|
|
1226
1261
|
imports,
|
|
1227
1262
|
unicorn
|
|
1228
|
-
|
|
1263
|
+
);
|
|
1229
1264
|
const componentExts = [];
|
|
1230
1265
|
if (enableVue)
|
|
1231
1266
|
componentExts.push("vue");
|
|
1232
|
-
if (enableStylistic)
|
|
1233
|
-
configs.push(javascriptStylistic);
|
|
1234
1267
|
if (enableTypeScript) {
|
|
1235
1268
|
configs.push(typescript({ componentExts }));
|
|
1236
1269
|
if (typeof enableTypeScript !== "boolean") {
|
|
@@ -1239,15 +1272,17 @@ function coderwyd(options = {}, ...userConfigs) {
|
|
|
1239
1272
|
componentExts
|
|
1240
1273
|
}));
|
|
1241
1274
|
}
|
|
1242
|
-
if (enableStylistic)
|
|
1243
|
-
configs.push(typescriptStylistic);
|
|
1244
1275
|
}
|
|
1276
|
+
if (enableStylistic)
|
|
1277
|
+
configs.push(stylistic);
|
|
1245
1278
|
if (options.test ?? true)
|
|
1246
1279
|
configs.push(test({ isInEditor }));
|
|
1247
1280
|
if (enableVue)
|
|
1248
1281
|
configs.push(vue({ typescript: !!enableTypeScript }));
|
|
1249
1282
|
if (enableReact)
|
|
1250
1283
|
configs.push(react({ typescript: !!enableTypeScript }));
|
|
1284
|
+
if (enableAstro)
|
|
1285
|
+
configs.push(astro({ typescript: !!enableTypeScript }));
|
|
1251
1286
|
if (options.jsonc ?? true) {
|
|
1252
1287
|
configs.push(
|
|
1253
1288
|
jsonc,
|
|
@@ -1259,15 +1294,24 @@ function coderwyd(options = {}, ...userConfigs) {
|
|
|
1259
1294
|
configs.push(yml);
|
|
1260
1295
|
if (options.markdown ?? true)
|
|
1261
1296
|
configs.push(markdown({ componentExts }));
|
|
1262
|
-
|
|
1297
|
+
const fusedConfig = flatConfigProps.reduce((acc, key) => {
|
|
1298
|
+
if (key in options)
|
|
1299
|
+
acc[key] = options[key];
|
|
1300
|
+
return acc;
|
|
1301
|
+
}, {});
|
|
1302
|
+
if (Object.keys(fusedConfig).length)
|
|
1303
|
+
configs.push([fusedConfig]);
|
|
1304
|
+
const merged = combine(
|
|
1263
1305
|
...configs,
|
|
1264
1306
|
...userConfigs
|
|
1265
1307
|
);
|
|
1308
|
+
return merged;
|
|
1266
1309
|
}
|
|
1267
1310
|
|
|
1268
1311
|
// src/index.ts
|
|
1269
1312
|
var src_default = coderwyd;
|
|
1270
1313
|
export {
|
|
1314
|
+
astro,
|
|
1271
1315
|
coderwyd,
|
|
1272
1316
|
combine,
|
|
1273
1317
|
comments,
|
|
@@ -1276,39 +1320,39 @@ export {
|
|
|
1276
1320
|
ignores,
|
|
1277
1321
|
imports,
|
|
1278
1322
|
javascript,
|
|
1279
|
-
javascriptStylistic,
|
|
1280
1323
|
jsdoc,
|
|
1281
1324
|
jsonc,
|
|
1282
1325
|
markdown,
|
|
1283
1326
|
node,
|
|
1327
|
+
default23 as parserAstro,
|
|
1284
1328
|
default22 as parserJsonc,
|
|
1285
1329
|
default19 as parserTs,
|
|
1286
1330
|
default20 as parserVue,
|
|
1287
1331
|
default21 as parserYml,
|
|
1288
1332
|
default2 as pluginAntfu,
|
|
1333
|
+
default18 as pluginAstro,
|
|
1289
1334
|
default3 as pluginComments,
|
|
1290
1335
|
default4 as pluginImport,
|
|
1291
1336
|
default5 as pluginJsdoc,
|
|
1292
1337
|
default6 as pluginJsonc,
|
|
1293
1338
|
default7 as pluginMarkdown,
|
|
1294
|
-
|
|
1339
|
+
default15 as pluginNoOnlyTests,
|
|
1295
1340
|
default8 as pluginNode,
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
default9 as
|
|
1299
|
-
default10 as
|
|
1300
|
-
default11 as
|
|
1301
|
-
default12 as
|
|
1302
|
-
default13 as
|
|
1303
|
-
default14 as
|
|
1304
|
-
default15 as pluginYml,
|
|
1341
|
+
default16 as pluginReact,
|
|
1342
|
+
default17 as pluginReactHooks,
|
|
1343
|
+
default9 as pluginStylistic,
|
|
1344
|
+
default10 as pluginTs,
|
|
1345
|
+
default11 as pluginUnicorn,
|
|
1346
|
+
default12 as pluginUnusedImports,
|
|
1347
|
+
default13 as pluginVue,
|
|
1348
|
+
default14 as pluginYml,
|
|
1305
1349
|
react,
|
|
1306
1350
|
renameRules,
|
|
1307
1351
|
sortPackageJson,
|
|
1308
1352
|
sortTsconfig,
|
|
1353
|
+
stylistic,
|
|
1309
1354
|
test,
|
|
1310
1355
|
typescript,
|
|
1311
|
-
typescriptStylistic,
|
|
1312
1356
|
typescriptWithLanguageServer,
|
|
1313
1357
|
unicorn,
|
|
1314
1358
|
vue,
|