@coderwyd/eslint-config 2.4.2 → 2.5.0-beta.2
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/README.md +47 -24
- package/dist/cli.cjs +19 -3
- package/dist/cli.js +19 -3
- package/dist/index.cjs +159 -109
- package/dist/index.d.cts +6412 -3327
- package/dist/index.d.ts +6412 -3327
- package/dist/index.js +159 -108
- package/package.json +7 -6
package/dist/index.js
CHANGED
|
@@ -1,16 +1,6 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
|
-
import process4 from "node:process";
|
|
3
2
|
import fs from "node:fs";
|
|
4
3
|
|
|
5
|
-
// src/constants/prettier.ts
|
|
6
|
-
var DEFAULT_PRETTIER_RULES = {
|
|
7
|
-
arrowParens: "avoid",
|
|
8
|
-
htmlWhitespaceSensitivity: "ignore",
|
|
9
|
-
printWidth: 80,
|
|
10
|
-
semi: false,
|
|
11
|
-
singleQuote: true
|
|
12
|
-
};
|
|
13
|
-
|
|
14
4
|
// src/plugins/index.ts
|
|
15
5
|
import { default as default2 } from "eslint-plugin-antfu";
|
|
16
6
|
import { default as default3 } from "eslint-plugin-eslint-comments";
|
|
@@ -57,7 +47,6 @@ var GLOB_MARKDOWN = "**/*.md";
|
|
|
57
47
|
var GLOB_YAML = "**/*.y?(a)ml";
|
|
58
48
|
var GLOB_TOML = "**/*.toml";
|
|
59
49
|
var GLOB_GRAPHQL = "**/*.{g,graph}ql";
|
|
60
|
-
var GLOB_PRETTIER_LINT = [GLOB_SRC, GLOB_VUE];
|
|
61
50
|
var GLOB_MARKDOWN_CODE = `${GLOB_MARKDOWN}/${GLOB_SRC}`;
|
|
62
51
|
var GLOB_TESTS = [
|
|
63
52
|
`**/__tests__/**/*.${GLOB_SRC_EXT}`,
|
|
@@ -108,7 +97,8 @@ async function ignores() {
|
|
|
108
97
|
}
|
|
109
98
|
|
|
110
99
|
// src/configs/imports.ts
|
|
111
|
-
async function imports() {
|
|
100
|
+
async function imports(options = {}) {
|
|
101
|
+
const { stylistic: stylistic2 = true } = options;
|
|
112
102
|
return [
|
|
113
103
|
{
|
|
114
104
|
name: "coderwyd/imports/rules",
|
|
@@ -143,10 +133,9 @@ async function imports() {
|
|
|
143
133
|
pathGroupsExcludedImportTypes: ["type"]
|
|
144
134
|
}
|
|
145
135
|
],
|
|
146
|
-
...{
|
|
147
|
-
// format
|
|
136
|
+
...stylistic2 ? {
|
|
148
137
|
"import/newline-after-import": ["error", { count: 1 }]
|
|
149
|
-
}
|
|
138
|
+
} : {}
|
|
150
139
|
}
|
|
151
140
|
},
|
|
152
141
|
{
|
|
@@ -202,7 +191,7 @@ async function javascript(options = {}) {
|
|
|
202
191
|
"constructor-super": "error",
|
|
203
192
|
"default-case-last": "error",
|
|
204
193
|
"dot-notation": ["error", { allowKeywords: true }],
|
|
205
|
-
eqeqeq: ["error", "smart"],
|
|
194
|
+
"eqeqeq": ["error", "smart"],
|
|
206
195
|
"for-direction": "error",
|
|
207
196
|
"getter-return": "error",
|
|
208
197
|
"new-cap": [
|
|
@@ -402,7 +391,7 @@ async function javascript(options = {}) {
|
|
|
402
391
|
],
|
|
403
392
|
"valid-typeof": ["error", { requireStringLiterals: true }],
|
|
404
393
|
"vars-on-top": "error",
|
|
405
|
-
yoda: ["error", "never"],
|
|
394
|
+
"yoda": ["error", "never"],
|
|
406
395
|
...overrides
|
|
407
396
|
}
|
|
408
397
|
},
|
|
@@ -425,8 +414,6 @@ async function javascript(options = {}) {
|
|
|
425
414
|
|
|
426
415
|
// src/shared/index.ts
|
|
427
416
|
import process from "node:process";
|
|
428
|
-
import { readFile } from "node:fs/promises";
|
|
429
|
-
import path from "node:path";
|
|
430
417
|
import { getPackageInfoSync, isPackageExists } from "local-pkg";
|
|
431
418
|
var parserPlain = {
|
|
432
419
|
meta: {
|
|
@@ -507,19 +494,11 @@ async function ensurePackages(packages) {
|
|
|
507
494
|
type: "confirm"
|
|
508
495
|
}
|
|
509
496
|
]);
|
|
510
|
-
if (result)
|
|
497
|
+
if (result) {
|
|
511
498
|
await import("@antfu/install-pkg").then(
|
|
512
499
|
(i) => i.installPackage(nonExistingPackages, { dev: true })
|
|
513
500
|
);
|
|
514
|
-
}
|
|
515
|
-
async function loadPrettierConfig(cwd) {
|
|
516
|
-
let prettierConfig = {};
|
|
517
|
-
try {
|
|
518
|
-
const prettierrc = await readFile(path.join(cwd, ".prettierrc"), "utf-8");
|
|
519
|
-
prettierConfig = JSON.parse(prettierrc);
|
|
520
|
-
} catch {
|
|
521
501
|
}
|
|
522
|
-
return prettierConfig;
|
|
523
502
|
}
|
|
524
503
|
function resolveSubOptions(options, key) {
|
|
525
504
|
return typeof options[key] === "boolean" ? {} : options[key] || {};
|
|
@@ -532,7 +511,8 @@ function getOverrides(options, key) {
|
|
|
532
511
|
}
|
|
533
512
|
|
|
534
513
|
// src/configs/jsdoc.ts
|
|
535
|
-
async function jsdoc() {
|
|
514
|
+
async function jsdoc(options = {}) {
|
|
515
|
+
const { stylistic: stylistic2 = true } = options;
|
|
536
516
|
return [
|
|
537
517
|
{
|
|
538
518
|
name: "coderwyd/jsdoc/rules",
|
|
@@ -555,11 +535,10 @@ async function jsdoc() {
|
|
|
555
535
|
"jsdoc/require-returns-check": "warn",
|
|
556
536
|
"jsdoc/require-returns-description": "warn",
|
|
557
537
|
"jsdoc/require-yields-check": "warn",
|
|
558
|
-
...{
|
|
559
|
-
// format
|
|
538
|
+
...stylistic2 ? {
|
|
560
539
|
"jsdoc/check-alignment": "warn",
|
|
561
540
|
"jsdoc/multiline-blocks": "warn"
|
|
562
|
-
}
|
|
541
|
+
} : {}
|
|
563
542
|
}
|
|
564
543
|
}
|
|
565
544
|
];
|
|
@@ -567,7 +546,14 @@ async function jsdoc() {
|
|
|
567
546
|
|
|
568
547
|
// src/configs/jsonc.ts
|
|
569
548
|
async function jsonc(options = {}) {
|
|
570
|
-
const {
|
|
549
|
+
const {
|
|
550
|
+
files = [GLOB_JSON, GLOB_JSON5, GLOB_JSONC],
|
|
551
|
+
overrides = {},
|
|
552
|
+
stylistic: stylistic2 = true
|
|
553
|
+
} = options || {};
|
|
554
|
+
const {
|
|
555
|
+
indent = 2
|
|
556
|
+
} = typeof stylistic2 === "boolean" ? {} : stylistic2;
|
|
571
557
|
const [pluginJsonc, parserJsonc] = await Promise.all([
|
|
572
558
|
interopDefault(import("eslint-plugin-jsonc")),
|
|
573
559
|
interopDefault(import("jsonc-eslint-parser"))
|
|
@@ -612,12 +598,11 @@ async function jsonc(options = {}) {
|
|
|
612
598
|
"jsonc/space-unary-ops": "error",
|
|
613
599
|
"jsonc/valid-json-number": "error",
|
|
614
600
|
"jsonc/vue-custom-block/no-parsing-error": "error",
|
|
615
|
-
...{
|
|
616
|
-
// format
|
|
601
|
+
...stylistic2 ? {
|
|
617
602
|
"jsonc/array-bracket-spacing": ["error", "never"],
|
|
618
603
|
"jsonc/comma-dangle": ["error", "never"],
|
|
619
604
|
"jsonc/comma-style": ["error", "last"],
|
|
620
|
-
"jsonc/indent": ["error",
|
|
605
|
+
"jsonc/indent": ["error", indent],
|
|
621
606
|
"jsonc/key-spacing": [
|
|
622
607
|
"error",
|
|
623
608
|
{ afterColon: true, beforeColon: false }
|
|
@@ -633,7 +618,7 @@ async function jsonc(options = {}) {
|
|
|
633
618
|
],
|
|
634
619
|
"jsonc/quote-props": "error",
|
|
635
620
|
"jsonc/quotes": "error"
|
|
636
|
-
},
|
|
621
|
+
} : {},
|
|
637
622
|
...overrides
|
|
638
623
|
}
|
|
639
624
|
}
|
|
@@ -885,34 +870,52 @@ function sortTsconfig() {
|
|
|
885
870
|
];
|
|
886
871
|
}
|
|
887
872
|
|
|
888
|
-
// src/configs/
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
873
|
+
// src/configs/stylistic.ts
|
|
874
|
+
var StylisticConfigDefaults = {
|
|
875
|
+
indent: 2,
|
|
876
|
+
jsx: true,
|
|
877
|
+
quotes: "single",
|
|
878
|
+
semi: false
|
|
879
|
+
};
|
|
880
|
+
async function stylistic(options = {}) {
|
|
881
|
+
const {
|
|
882
|
+
indent,
|
|
883
|
+
jsx,
|
|
884
|
+
overrides = {},
|
|
885
|
+
quotes,
|
|
886
|
+
semi
|
|
887
|
+
} = {
|
|
888
|
+
...StylisticConfigDefaults,
|
|
889
|
+
...options
|
|
895
890
|
};
|
|
896
|
-
const
|
|
891
|
+
const pluginStylistic = await interopDefault(
|
|
892
|
+
import("@stylistic/eslint-plugin")
|
|
893
|
+
);
|
|
894
|
+
const config = pluginStylistic.configs.customize({
|
|
895
|
+
flat: true,
|
|
896
|
+
indent,
|
|
897
|
+
jsx,
|
|
898
|
+
pluginName: "style",
|
|
899
|
+
quotes,
|
|
900
|
+
semi
|
|
901
|
+
});
|
|
902
|
+
return [
|
|
897
903
|
{
|
|
898
|
-
name: "coderwyd/
|
|
904
|
+
name: "coderwyd/stylistic/rules",
|
|
899
905
|
plugins: {
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
{
|
|
904
|
-
files: GLOB_PRETTIER_LINT,
|
|
905
|
-
name: "coderwyd/prettier/rules",
|
|
906
|
+
antfu: default2,
|
|
907
|
+
style: pluginStylistic
|
|
908
|
+
},
|
|
906
909
|
rules: {
|
|
907
|
-
...
|
|
908
|
-
"
|
|
909
|
-
|
|
910
|
-
"
|
|
911
|
-
"
|
|
910
|
+
...config.rules,
|
|
911
|
+
"antfu/consistent-list-newline": "error",
|
|
912
|
+
"antfu/if-newline": "warn",
|
|
913
|
+
"antfu/top-level-function": "warn",
|
|
914
|
+
"curly": ["error", "multi-or-nest", "consistent"],
|
|
915
|
+
...overrides
|
|
912
916
|
}
|
|
913
917
|
}
|
|
914
918
|
];
|
|
915
|
-
return configs2;
|
|
916
919
|
}
|
|
917
920
|
|
|
918
921
|
// src/configs/typescript.ts
|
|
@@ -1083,9 +1086,9 @@ async function unicorn() {
|
|
|
1083
1086
|
rules: {
|
|
1084
1087
|
// 'unicorn/better-regex': 'error',
|
|
1085
1088
|
"unicorn/catch-error-name": "error",
|
|
1089
|
+
"unicorn/consistent-empty-array-spread": "error",
|
|
1086
1090
|
"unicorn/custom-error-definition": "error",
|
|
1087
1091
|
"unicorn/error-message": "error",
|
|
1088
|
-
"unicorn/escape-case": "error",
|
|
1089
1092
|
// 'unicorn/explicit-length-check': 'error',
|
|
1090
1093
|
// 'unicorn/filename-case': [
|
|
1091
1094
|
// 'error',
|
|
@@ -1093,6 +1096,7 @@ async function unicorn() {
|
|
|
1093
1096
|
// cases: { kebabCase: true, pascalCase: true },
|
|
1094
1097
|
// ignore: [/^[A-Z]+\..*$/],
|
|
1095
1098
|
// },
|
|
1099
|
+
"unicorn/escape-case": "error",
|
|
1096
1100
|
// ],
|
|
1097
1101
|
"unicorn/new-for-builtins": "error",
|
|
1098
1102
|
// 'unicorn/no-array-callback-reference': 'error',
|
|
@@ -1150,11 +1154,15 @@ async function unicorn() {
|
|
|
1150
1154
|
}
|
|
1151
1155
|
|
|
1152
1156
|
// src/configs/vue.ts
|
|
1157
|
+
import { mergeProcessors } from "eslint-merge-processors";
|
|
1153
1158
|
async function vue(options = {}) {
|
|
1154
|
-
const { files = [GLOB_VUE], overrides = {} } = options;
|
|
1155
|
-
const
|
|
1159
|
+
const { files = [GLOB_VUE], overrides = {}, stylistic: stylistic2 = true } = options;
|
|
1160
|
+
const sfcBlocks = options.sfcBlocks === true ? {} : options.sfcBlocks ?? {};
|
|
1161
|
+
const { indent = 2 } = typeof stylistic2 === "boolean" ? {} : stylistic2;
|
|
1162
|
+
const [pluginVue, parserVue, processorVueBlocks] = await Promise.all([
|
|
1156
1163
|
interopDefault(import("eslint-plugin-vue")),
|
|
1157
|
-
interopDefault(import("vue-eslint-parser"))
|
|
1164
|
+
interopDefault(import("vue-eslint-parser")),
|
|
1165
|
+
interopDefault(import("eslint-processor-vue-blocks"))
|
|
1158
1166
|
]);
|
|
1159
1167
|
const isVue3 = getVueVersion() === 3;
|
|
1160
1168
|
const configKeys = isVue3 ? ["vue3-essential", "vue3-strongly-recommended", "vue3-recommended"] : ["essential", "strongly-recommended", "recommended"];
|
|
@@ -1208,7 +1216,16 @@ async function vue(options = {}) {
|
|
|
1208
1216
|
}
|
|
1209
1217
|
},
|
|
1210
1218
|
name: "coderwyd/vue/rules",
|
|
1211
|
-
processor: pluginVue.processors[".vue"]
|
|
1219
|
+
processor: sfcBlocks === false ? pluginVue.processors[".vue"] : mergeProcessors([
|
|
1220
|
+
pluginVue.processors[".vue"],
|
|
1221
|
+
processorVueBlocks({
|
|
1222
|
+
...sfcBlocks,
|
|
1223
|
+
blocks: {
|
|
1224
|
+
styles: true,
|
|
1225
|
+
...sfcBlocks.blocks
|
|
1226
|
+
}
|
|
1227
|
+
})
|
|
1228
|
+
]),
|
|
1212
1229
|
rules: {
|
|
1213
1230
|
...pluginVue.configs.base.rules,
|
|
1214
1231
|
...vueRules,
|
|
@@ -1236,7 +1253,7 @@ async function vue(options = {}) {
|
|
|
1236
1253
|
"vue/dot-location": ["error", "property"],
|
|
1237
1254
|
"vue/dot-notation": ["error", { allowKeywords: true }],
|
|
1238
1255
|
"vue/eqeqeq": ["error", "smart"],
|
|
1239
|
-
"vue/html-indent": ["error",
|
|
1256
|
+
"vue/html-indent": ["error", indent],
|
|
1240
1257
|
"vue/html-quotes": ["error", "double"],
|
|
1241
1258
|
"vue/html-self-closing": [
|
|
1242
1259
|
"error",
|
|
@@ -1286,8 +1303,7 @@ async function vue(options = {}) {
|
|
|
1286
1303
|
"vue/space-infix-ops": "error",
|
|
1287
1304
|
"vue/space-unary-ops": ["error", { nonwords: false, words: true }],
|
|
1288
1305
|
"vue/valid-define-options": "warn",
|
|
1289
|
-
...{
|
|
1290
|
-
// format
|
|
1306
|
+
...stylistic2 ? {
|
|
1291
1307
|
"vue/array-bracket-spacing": ["error", "never"],
|
|
1292
1308
|
"vue/arrow-spacing": ["error", { after: true, before: true }],
|
|
1293
1309
|
"vue/block-spacing": ["error", "always"],
|
|
@@ -1298,7 +1314,11 @@ async function vue(options = {}) {
|
|
|
1298
1314
|
singleline: "always"
|
|
1299
1315
|
}
|
|
1300
1316
|
],
|
|
1301
|
-
"vue/brace-style": [
|
|
1317
|
+
"vue/brace-style": [
|
|
1318
|
+
"error",
|
|
1319
|
+
"stroustrup",
|
|
1320
|
+
{ allowSingleLine: true }
|
|
1321
|
+
],
|
|
1302
1322
|
"vue/comma-dangle": ["error", "always-multiline"],
|
|
1303
1323
|
"vue/comma-spacing": ["error", { after: true, before: false }],
|
|
1304
1324
|
"vue/comma-style": ["error", "last"],
|
|
@@ -1325,7 +1345,7 @@ async function vue(options = {}) {
|
|
|
1325
1345
|
"vue/quote-props": ["error", "consistent-as-needed"],
|
|
1326
1346
|
"vue/space-in-parens": ["error", "never"],
|
|
1327
1347
|
"vue/template-curly-spacing": "error"
|
|
1328
|
-
},
|
|
1348
|
+
} : {},
|
|
1329
1349
|
...overrides
|
|
1330
1350
|
}
|
|
1331
1351
|
}
|
|
@@ -1423,7 +1443,7 @@ async function react(options = {}) {
|
|
|
1423
1443
|
{
|
|
1424
1444
|
name: "coderwyd/react/setup",
|
|
1425
1445
|
plugins: {
|
|
1426
|
-
react: plugins["@eslint-react"],
|
|
1446
|
+
"react": plugins["@eslint-react"],
|
|
1427
1447
|
"react-dom": plugins["@eslint-react/dom"],
|
|
1428
1448
|
"react-hooks": pluginReactHooks,
|
|
1429
1449
|
"react-hooks-extra": plugins["@eslint-react/hooks-extra"],
|
|
@@ -1552,7 +1572,7 @@ async function unocss(options = {}) {
|
|
|
1552
1572
|
}
|
|
1553
1573
|
|
|
1554
1574
|
// src/configs/formatter.ts
|
|
1555
|
-
async function formatter(options = {},
|
|
1575
|
+
async function formatter(options = {}, stylistic2 = {}) {
|
|
1556
1576
|
const { css, graphql, html, markdown, toml, yaml } = options === true ? {
|
|
1557
1577
|
css: true,
|
|
1558
1578
|
graphql: true,
|
|
@@ -1561,10 +1581,27 @@ async function formatter(options = {}, prettierRules2 = {}) {
|
|
|
1561
1581
|
toml: true,
|
|
1562
1582
|
yaml: true
|
|
1563
1583
|
} : options;
|
|
1564
|
-
const
|
|
1584
|
+
const { indent, quotes, semi } = {
|
|
1585
|
+
...StylisticConfigDefaults,
|
|
1586
|
+
...stylistic2
|
|
1587
|
+
};
|
|
1588
|
+
const prettierOptions = Object.assign(
|
|
1589
|
+
{
|
|
1590
|
+
endOfLine: "auto",
|
|
1591
|
+
printWidth: 80,
|
|
1592
|
+
semi,
|
|
1593
|
+
singleQuote: quotes === "single",
|
|
1594
|
+
tabWidth: typeof indent === "number" ? indent : 2,
|
|
1595
|
+
trailingComma: "all",
|
|
1596
|
+
useTabs: indent === "tab"
|
|
1597
|
+
},
|
|
1598
|
+
typeof options === "boolean" ? {} : options.prettierOptions || {}
|
|
1599
|
+
);
|
|
1600
|
+
await ensurePackages(["eslint-plugin-format"]);
|
|
1601
|
+
const pluginFormat = await interopDefault(import("eslint-plugin-format"));
|
|
1565
1602
|
function createPrettierFormatter(files, parser, plugins) {
|
|
1566
1603
|
const rules = {
|
|
1567
|
-
...
|
|
1604
|
+
...prettierOptions,
|
|
1568
1605
|
parser
|
|
1569
1606
|
};
|
|
1570
1607
|
const markdownRules = {
|
|
@@ -1572,9 +1609,8 @@ async function formatter(options = {}, prettierRules2 = {}) {
|
|
|
1572
1609
|
...rules,
|
|
1573
1610
|
embeddedLanguageFormatting: "off"
|
|
1574
1611
|
};
|
|
1575
|
-
if (plugins?.length)
|
|
1612
|
+
if (plugins?.length)
|
|
1576
1613
|
rules.plugins = [...rules.plugins || [], ...plugins];
|
|
1577
|
-
}
|
|
1578
1614
|
const config = {
|
|
1579
1615
|
files,
|
|
1580
1616
|
languageOptions: {
|
|
@@ -1582,10 +1618,10 @@ async function formatter(options = {}, prettierRules2 = {}) {
|
|
|
1582
1618
|
},
|
|
1583
1619
|
name: `coderwyd/formatter/${parser}`,
|
|
1584
1620
|
plugins: {
|
|
1585
|
-
|
|
1621
|
+
format: pluginFormat
|
|
1586
1622
|
},
|
|
1587
1623
|
rules: {
|
|
1588
|
-
"
|
|
1624
|
+
"format/prettier": [
|
|
1589
1625
|
"warn",
|
|
1590
1626
|
parser === "markdown" ? markdownRules : rules
|
|
1591
1627
|
]
|
|
@@ -1597,7 +1633,7 @@ async function formatter(options = {}, prettierRules2 = {}) {
|
|
|
1597
1633
|
{
|
|
1598
1634
|
name: "coderwyd/formatter/setup",
|
|
1599
1635
|
plugins: {
|
|
1600
|
-
|
|
1636
|
+
format: pluginFormat
|
|
1601
1637
|
}
|
|
1602
1638
|
}
|
|
1603
1639
|
];
|
|
@@ -1635,7 +1671,11 @@ async function formatter(options = {}, prettierRules2 = {}) {
|
|
|
1635
1671
|
|
|
1636
1672
|
// src/configs/svelte.ts
|
|
1637
1673
|
async function svelte(options = {}) {
|
|
1638
|
-
const { files = [GLOB_SVELTE], overrides = {} } = options;
|
|
1674
|
+
const { files = [GLOB_SVELTE], overrides = {}, stylistic: stylistic2 = true } = options;
|
|
1675
|
+
const {
|
|
1676
|
+
indent = 2,
|
|
1677
|
+
quotes = "single"
|
|
1678
|
+
} = typeof stylistic2 === "boolean" ? {} : stylistic2;
|
|
1639
1679
|
await ensurePackages(["eslint-plugin-svelte"]);
|
|
1640
1680
|
const [pluginSvelte, parserSvelte] = await Promise.all([
|
|
1641
1681
|
interopDefault(import("eslint-plugin-svelte")),
|
|
@@ -1705,22 +1745,23 @@ async function svelte(options = {}) {
|
|
|
1705
1745
|
varsIgnorePattern: "^(_|\\$\\$Props$|\\$\\$Events$|\\$\\$Slots$)"
|
|
1706
1746
|
}
|
|
1707
1747
|
],
|
|
1708
|
-
...{
|
|
1709
|
-
|
|
1748
|
+
...stylistic2 ? {
|
|
1749
|
+
"style/indent": "off",
|
|
1750
|
+
// superseded by svelte/indent
|
|
1710
1751
|
"style/no-trailing-spaces": "off",
|
|
1711
1752
|
// superseded by svelte/no-trailing-spaces
|
|
1712
1753
|
"svelte/derived-has-same-inputs-outputs": "error",
|
|
1713
1754
|
"svelte/html-closing-bracket-spacing": "error",
|
|
1714
|
-
"svelte/html-quotes": ["error", { prefer:
|
|
1755
|
+
"svelte/html-quotes": ["error", { prefer: quotes }],
|
|
1715
1756
|
"svelte/indent": [
|
|
1716
1757
|
"error",
|
|
1717
|
-
{ alignAttributesVertically: true, indent
|
|
1758
|
+
{ alignAttributesVertically: true, indent }
|
|
1718
1759
|
],
|
|
1719
1760
|
"svelte/mustache-spacing": "error",
|
|
1720
1761
|
"svelte/no-spaces-around-equal-signs-in-attribute": "error",
|
|
1721
1762
|
"svelte/no-trailing-spaces": "error",
|
|
1722
1763
|
"svelte/spaced-html-comment": "error"
|
|
1723
|
-
},
|
|
1764
|
+
} : {},
|
|
1724
1765
|
...overrides
|
|
1725
1766
|
}
|
|
1726
1767
|
}
|
|
@@ -1812,11 +1853,16 @@ var flatConfigProps = [
|
|
|
1812
1853
|
"settings"
|
|
1813
1854
|
];
|
|
1814
1855
|
var defaultPluginRenaming = {
|
|
1856
|
+
"@eslint-react": "react",
|
|
1857
|
+
"@eslint-react/dom": "react-dom",
|
|
1858
|
+
"@eslint-react/hooks-extra": "react-hooks-extra",
|
|
1859
|
+
"@eslint-react/naming-convention": "react-naming-convention",
|
|
1860
|
+
"@stylistic": "style",
|
|
1815
1861
|
"@typescript-eslint": "ts",
|
|
1816
1862
|
"import-x": "import",
|
|
1817
|
-
n: "node",
|
|
1818
|
-
vitest: "test",
|
|
1819
|
-
yml: "yaml"
|
|
1863
|
+
"n": "node",
|
|
1864
|
+
"vitest": "test",
|
|
1865
|
+
"yml": "yaml"
|
|
1820
1866
|
};
|
|
1821
1867
|
async function defineConfig(options = {}, ...userConfigs) {
|
|
1822
1868
|
const {
|
|
@@ -1834,9 +1880,11 @@ async function defineConfig(options = {}, ...userConfigs) {
|
|
|
1834
1880
|
tailwindcss: enableTailwindCSS = hasTailwindCSS,
|
|
1835
1881
|
typescript: enableTypeScript = hasTypeScript,
|
|
1836
1882
|
unocss: enableUnoCSS = false,
|
|
1837
|
-
usePrettierrc = true,
|
|
1838
1883
|
vue: enableVue = hasVue
|
|
1839
1884
|
} = options;
|
|
1885
|
+
const stylisticOptions = options.stylistic === false ? false : typeof options.stylistic === "object" ? options.stylistic : {};
|
|
1886
|
+
if (stylisticOptions && !("jsx" in stylisticOptions))
|
|
1887
|
+
stylisticOptions.jsx = options.jsx ?? true;
|
|
1840
1888
|
const configs2 = [];
|
|
1841
1889
|
if (enableGitignore) {
|
|
1842
1890
|
if (typeof enableGitignore !== "boolean") {
|
|
@@ -1846,12 +1894,13 @@ async function defineConfig(options = {}, ...userConfigs) {
|
|
|
1846
1894
|
])
|
|
1847
1895
|
);
|
|
1848
1896
|
} else {
|
|
1849
|
-
if (fs.existsSync(".gitignore"))
|
|
1897
|
+
if (fs.existsSync(".gitignore")) {
|
|
1850
1898
|
configs2.push(
|
|
1851
1899
|
interopDefault(import("eslint-config-flat-gitignore")).then((r) => [
|
|
1852
1900
|
r()
|
|
1853
1901
|
])
|
|
1854
1902
|
);
|
|
1903
|
+
}
|
|
1855
1904
|
}
|
|
1856
1905
|
}
|
|
1857
1906
|
configs2.push(
|
|
@@ -1862,8 +1911,12 @@ async function defineConfig(options = {}, ...userConfigs) {
|
|
|
1862
1911
|
}),
|
|
1863
1912
|
comments(),
|
|
1864
1913
|
node(),
|
|
1865
|
-
jsdoc(
|
|
1866
|
-
|
|
1914
|
+
jsdoc({
|
|
1915
|
+
stylistic: stylisticOptions
|
|
1916
|
+
}),
|
|
1917
|
+
imports({
|
|
1918
|
+
stylistic: stylisticOptions
|
|
1919
|
+
}),
|
|
1867
1920
|
unicorn(),
|
|
1868
1921
|
command(),
|
|
1869
1922
|
// Optional plugins (installed but not enabled by default)
|
|
@@ -1880,6 +1933,14 @@ async function defineConfig(options = {}, ...userConfigs) {
|
|
|
1880
1933
|
})
|
|
1881
1934
|
);
|
|
1882
1935
|
}
|
|
1936
|
+
if (stylisticOptions) {
|
|
1937
|
+
configs2.push(
|
|
1938
|
+
stylistic({
|
|
1939
|
+
...stylisticOptions,
|
|
1940
|
+
overrides: getOverrides(options, "stylistic")
|
|
1941
|
+
})
|
|
1942
|
+
);
|
|
1943
|
+
}
|
|
1883
1944
|
if (enableRegexp)
|
|
1884
1945
|
configs2.push(regexp(typeof enableRegexp === "boolean" ? {} : enableRegexp));
|
|
1885
1946
|
if (options.test ?? true) {
|
|
@@ -1895,6 +1956,7 @@ async function defineConfig(options = {}, ...userConfigs) {
|
|
|
1895
1956
|
vue({
|
|
1896
1957
|
...resolveSubOptions(options, "vue"),
|
|
1897
1958
|
overrides: getOverrides(options, "typescript"),
|
|
1959
|
+
stylistic: stylisticOptions,
|
|
1898
1960
|
typescript: !!enableTypeScript
|
|
1899
1961
|
})
|
|
1900
1962
|
);
|
|
@@ -1911,6 +1973,7 @@ async function defineConfig(options = {}, ...userConfigs) {
|
|
|
1911
1973
|
configs2.push(
|
|
1912
1974
|
svelte({
|
|
1913
1975
|
overrides: getOverrides(options, "svelte"),
|
|
1976
|
+
stylistic: stylisticOptions,
|
|
1914
1977
|
typescript: !!enableTypeScript
|
|
1915
1978
|
})
|
|
1916
1979
|
);
|
|
@@ -1934,31 +1997,20 @@ async function defineConfig(options = {}, ...userConfigs) {
|
|
|
1934
1997
|
if (options.jsonc ?? true) {
|
|
1935
1998
|
configs2.push(
|
|
1936
1999
|
jsonc({
|
|
1937
|
-
overrides: getOverrides(options, "jsonc")
|
|
2000
|
+
overrides: getOverrides(options, "jsonc"),
|
|
2001
|
+
stylistic: stylisticOptions
|
|
1938
2002
|
}),
|
|
1939
2003
|
sortPackageJson(),
|
|
1940
2004
|
sortTsconfig()
|
|
1941
2005
|
);
|
|
1942
2006
|
}
|
|
1943
2007
|
if (formatterOptions) {
|
|
1944
|
-
let prettierRules2 = {
|
|
1945
|
-
...DEFAULT_PRETTIER_RULES
|
|
1946
|
-
};
|
|
1947
|
-
if (options.prettierRules) {
|
|
1948
|
-
prettierRules2 = { ...prettierRules2, ...options.prettierRules };
|
|
1949
|
-
}
|
|
1950
|
-
if (usePrettierrc) {
|
|
1951
|
-
const prettierConfig = await loadPrettierConfig(
|
|
1952
|
-
options.cwd ?? process4.cwd()
|
|
1953
|
-
);
|
|
1954
|
-
Object.assign(prettierRules2, prettierConfig);
|
|
1955
|
-
}
|
|
1956
2008
|
configs2.push(
|
|
1957
|
-
|
|
1958
|
-
|
|
2009
|
+
formatter(
|
|
2010
|
+
formatterOptions,
|
|
2011
|
+
typeof stylisticOptions === "boolean" ? {} : stylisticOptions
|
|
2012
|
+
)
|
|
1959
2013
|
);
|
|
1960
|
-
} else {
|
|
1961
|
-
configs2.push(prettier());
|
|
1962
2014
|
}
|
|
1963
2015
|
const fusedConfig = flatConfigProps.reduce((acc, key) => {
|
|
1964
2016
|
if (key in options)
|
|
@@ -1980,7 +2032,6 @@ export {
|
|
|
1980
2032
|
getOverrides,
|
|
1981
2033
|
getVueVersion,
|
|
1982
2034
|
interopDefault,
|
|
1983
|
-
loadPrettierConfig,
|
|
1984
2035
|
parserPlain,
|
|
1985
2036
|
renamePluginInConfigs,
|
|
1986
2037
|
renameRules,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coderwyd/eslint-config",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.5.0-beta.2",
|
|
5
5
|
"description": "Donny's ESLint config",
|
|
6
6
|
"author": "Donny Wang <donny526@outlook.com> (https://github.com/coderwyd/)",
|
|
7
7
|
"license": "MIT",
|
|
@@ -11,8 +11,7 @@
|
|
|
11
11
|
"eslint-config",
|
|
12
12
|
"eslint-config-vue",
|
|
13
13
|
"eslint-config-react",
|
|
14
|
-
"eslint-config-svelte"
|
|
15
|
-
"prettier"
|
|
14
|
+
"eslint-config-svelte"
|
|
16
15
|
],
|
|
17
16
|
"publishConfig": {
|
|
18
17
|
"access": "public"
|
|
@@ -66,34 +65,35 @@
|
|
|
66
65
|
},
|
|
67
66
|
"dependencies": {
|
|
68
67
|
"@antfu/install-pkg": "^0.3.3",
|
|
68
|
+
"@stylistic/eslint-plugin": "^2.1.0",
|
|
69
69
|
"@toml-tools/parser": "^1.0.0",
|
|
70
70
|
"@typescript-eslint/eslint-plugin": "^7.9.0",
|
|
71
71
|
"@typescript-eslint/parser": "^7.9.0",
|
|
72
72
|
"eslint-config-flat-gitignore": "^0.1.5",
|
|
73
|
-
"eslint-
|
|
73
|
+
"eslint-merge-processors": "^0.1.0",
|
|
74
74
|
"eslint-plugin-antfu": "^2.2.0",
|
|
75
75
|
"eslint-plugin-command": "^0.2.3",
|
|
76
76
|
"eslint-plugin-eslint-comments": "^3.2.0",
|
|
77
|
+
"eslint-plugin-format": "^0.1.1",
|
|
77
78
|
"eslint-plugin-import-x": "^0.5.0",
|
|
78
79
|
"eslint-plugin-jsdoc": "^48.2.5",
|
|
79
80
|
"eslint-plugin-jsonc": "^2.15.1",
|
|
80
81
|
"eslint-plugin-n": "^17.7.0",
|
|
81
82
|
"eslint-plugin-no-only-tests": "^3.1.0",
|
|
82
83
|
"eslint-plugin-perfectionist": "^2.10.0",
|
|
83
|
-
"eslint-plugin-prettier": "^5.1.3",
|
|
84
84
|
"eslint-plugin-regexp": "^2.5.0",
|
|
85
85
|
"eslint-plugin-tailwindcss": "^3.15.2",
|
|
86
86
|
"eslint-plugin-unicorn": "^53.0.0",
|
|
87
87
|
"eslint-plugin-unused-imports": "^3.2.0",
|
|
88
88
|
"eslint-plugin-vitest": "^0.5.4",
|
|
89
89
|
"eslint-plugin-vue": "^9.26.0",
|
|
90
|
+
"eslint-processor-vue-blocks": "^0.1.2",
|
|
90
91
|
"eslint-typegen": "^0.2.4",
|
|
91
92
|
"globals": "^15.3.0",
|
|
92
93
|
"jsonc-eslint-parser": "^2.4.0",
|
|
93
94
|
"local-pkg": "^0.5.0",
|
|
94
95
|
"parse-gitignore": "^2.0.0",
|
|
95
96
|
"picocolors": "^1.0.1",
|
|
96
|
-
"prettier": "^3.2.5",
|
|
97
97
|
"prettier-plugin-toml": "^2.0.1",
|
|
98
98
|
"prompts": "^2.4.2",
|
|
99
99
|
"vue-eslint-parser": "^9.4.2",
|
|
@@ -103,6 +103,7 @@
|
|
|
103
103
|
"@antfu/ni": "^0.21.12",
|
|
104
104
|
"@eslint-react/eslint-plugin": "^1.5.12",
|
|
105
105
|
"@eslint/config-inspector": "^0.4.8",
|
|
106
|
+
"@stylistic/eslint-plugin-migrate": "^2.1.0",
|
|
106
107
|
"@types/eslint": "^8.56.10",
|
|
107
108
|
"@types/fs-extra": "^11.0.4",
|
|
108
109
|
"@types/node": "^20.12.12",
|