@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.cjs
CHANGED
|
@@ -37,7 +37,6 @@ __export(src_exports, {
|
|
|
37
37
|
getOverrides: () => getOverrides,
|
|
38
38
|
getVueVersion: () => getVueVersion,
|
|
39
39
|
interopDefault: () => interopDefault,
|
|
40
|
-
loadPrettierConfig: () => loadPrettierConfig,
|
|
41
40
|
parserPlain: () => parserPlain,
|
|
42
41
|
renamePluginInConfigs: () => renamePluginInConfigs,
|
|
43
42
|
renameRules: () => renameRules,
|
|
@@ -45,18 +44,8 @@ __export(src_exports, {
|
|
|
45
44
|
toArray: () => toArray
|
|
46
45
|
});
|
|
47
46
|
module.exports = __toCommonJS(src_exports);
|
|
48
|
-
var import_node_process4 = __toESM(require("process"), 1);
|
|
49
47
|
var import_node_fs = __toESM(require("fs"), 1);
|
|
50
48
|
|
|
51
|
-
// src/constants/prettier.ts
|
|
52
|
-
var DEFAULT_PRETTIER_RULES = {
|
|
53
|
-
arrowParens: "avoid",
|
|
54
|
-
htmlWhitespaceSensitivity: "ignore",
|
|
55
|
-
printWidth: 80,
|
|
56
|
-
semi: false,
|
|
57
|
-
singleQuote: true
|
|
58
|
-
};
|
|
59
|
-
|
|
60
49
|
// src/plugins/index.ts
|
|
61
50
|
var import_eslint_plugin_antfu = __toESM(require("eslint-plugin-antfu"), 1);
|
|
62
51
|
var import_eslint_plugin_eslint_comments = __toESM(require("eslint-plugin-eslint-comments"), 1);
|
|
@@ -103,7 +92,6 @@ var GLOB_MARKDOWN = "**/*.md";
|
|
|
103
92
|
var GLOB_YAML = "**/*.y?(a)ml";
|
|
104
93
|
var GLOB_TOML = "**/*.toml";
|
|
105
94
|
var GLOB_GRAPHQL = "**/*.{g,graph}ql";
|
|
106
|
-
var GLOB_PRETTIER_LINT = [GLOB_SRC, GLOB_VUE];
|
|
107
95
|
var GLOB_MARKDOWN_CODE = `${GLOB_MARKDOWN}/${GLOB_SRC}`;
|
|
108
96
|
var GLOB_TESTS = [
|
|
109
97
|
`**/__tests__/**/*.${GLOB_SRC_EXT}`,
|
|
@@ -154,7 +142,8 @@ async function ignores() {
|
|
|
154
142
|
}
|
|
155
143
|
|
|
156
144
|
// src/configs/imports.ts
|
|
157
|
-
async function imports() {
|
|
145
|
+
async function imports(options = {}) {
|
|
146
|
+
const { stylistic: stylistic2 = true } = options;
|
|
158
147
|
return [
|
|
159
148
|
{
|
|
160
149
|
name: "coderwyd/imports/rules",
|
|
@@ -189,10 +178,9 @@ async function imports() {
|
|
|
189
178
|
pathGroupsExcludedImportTypes: ["type"]
|
|
190
179
|
}
|
|
191
180
|
],
|
|
192
|
-
...{
|
|
193
|
-
// format
|
|
181
|
+
...stylistic2 ? {
|
|
194
182
|
"import/newline-after-import": ["error", { count: 1 }]
|
|
195
|
-
}
|
|
183
|
+
} : {}
|
|
196
184
|
}
|
|
197
185
|
},
|
|
198
186
|
{
|
|
@@ -248,7 +236,7 @@ async function javascript(options = {}) {
|
|
|
248
236
|
"constructor-super": "error",
|
|
249
237
|
"default-case-last": "error",
|
|
250
238
|
"dot-notation": ["error", { allowKeywords: true }],
|
|
251
|
-
eqeqeq: ["error", "smart"],
|
|
239
|
+
"eqeqeq": ["error", "smart"],
|
|
252
240
|
"for-direction": "error",
|
|
253
241
|
"getter-return": "error",
|
|
254
242
|
"new-cap": [
|
|
@@ -448,7 +436,7 @@ async function javascript(options = {}) {
|
|
|
448
436
|
],
|
|
449
437
|
"valid-typeof": ["error", { requireStringLiterals: true }],
|
|
450
438
|
"vars-on-top": "error",
|
|
451
|
-
yoda: ["error", "never"],
|
|
439
|
+
"yoda": ["error", "never"],
|
|
452
440
|
...overrides
|
|
453
441
|
}
|
|
454
442
|
},
|
|
@@ -471,8 +459,6 @@ async function javascript(options = {}) {
|
|
|
471
459
|
|
|
472
460
|
// src/shared/index.ts
|
|
473
461
|
var import_node_process = __toESM(require("process"), 1);
|
|
474
|
-
var import_promises = require("fs/promises");
|
|
475
|
-
var import_node_path = __toESM(require("path"), 1);
|
|
476
462
|
var import_local_pkg = require("local-pkg");
|
|
477
463
|
var parserPlain = {
|
|
478
464
|
meta: {
|
|
@@ -553,19 +539,11 @@ async function ensurePackages(packages) {
|
|
|
553
539
|
type: "confirm"
|
|
554
540
|
}
|
|
555
541
|
]);
|
|
556
|
-
if (result)
|
|
542
|
+
if (result) {
|
|
557
543
|
await import("@antfu/install-pkg").then(
|
|
558
544
|
(i) => i.installPackage(nonExistingPackages, { dev: true })
|
|
559
545
|
);
|
|
560
|
-
}
|
|
561
|
-
async function loadPrettierConfig(cwd) {
|
|
562
|
-
let prettierConfig = {};
|
|
563
|
-
try {
|
|
564
|
-
const prettierrc = await (0, import_promises.readFile)(import_node_path.default.join(cwd, ".prettierrc"), "utf-8");
|
|
565
|
-
prettierConfig = JSON.parse(prettierrc);
|
|
566
|
-
} catch {
|
|
567
546
|
}
|
|
568
|
-
return prettierConfig;
|
|
569
547
|
}
|
|
570
548
|
function resolveSubOptions(options, key) {
|
|
571
549
|
return typeof options[key] === "boolean" ? {} : options[key] || {};
|
|
@@ -578,7 +556,8 @@ function getOverrides(options, key) {
|
|
|
578
556
|
}
|
|
579
557
|
|
|
580
558
|
// src/configs/jsdoc.ts
|
|
581
|
-
async function jsdoc() {
|
|
559
|
+
async function jsdoc(options = {}) {
|
|
560
|
+
const { stylistic: stylistic2 = true } = options;
|
|
582
561
|
return [
|
|
583
562
|
{
|
|
584
563
|
name: "coderwyd/jsdoc/rules",
|
|
@@ -601,11 +580,10 @@ async function jsdoc() {
|
|
|
601
580
|
"jsdoc/require-returns-check": "warn",
|
|
602
581
|
"jsdoc/require-returns-description": "warn",
|
|
603
582
|
"jsdoc/require-yields-check": "warn",
|
|
604
|
-
...{
|
|
605
|
-
// format
|
|
583
|
+
...stylistic2 ? {
|
|
606
584
|
"jsdoc/check-alignment": "warn",
|
|
607
585
|
"jsdoc/multiline-blocks": "warn"
|
|
608
|
-
}
|
|
586
|
+
} : {}
|
|
609
587
|
}
|
|
610
588
|
}
|
|
611
589
|
];
|
|
@@ -613,7 +591,14 @@ async function jsdoc() {
|
|
|
613
591
|
|
|
614
592
|
// src/configs/jsonc.ts
|
|
615
593
|
async function jsonc(options = {}) {
|
|
616
|
-
const {
|
|
594
|
+
const {
|
|
595
|
+
files = [GLOB_JSON, GLOB_JSON5, GLOB_JSONC],
|
|
596
|
+
overrides = {},
|
|
597
|
+
stylistic: stylistic2 = true
|
|
598
|
+
} = options || {};
|
|
599
|
+
const {
|
|
600
|
+
indent = 2
|
|
601
|
+
} = typeof stylistic2 === "boolean" ? {} : stylistic2;
|
|
617
602
|
const [pluginJsonc, parserJsonc] = await Promise.all([
|
|
618
603
|
interopDefault(import("eslint-plugin-jsonc")),
|
|
619
604
|
interopDefault(import("jsonc-eslint-parser"))
|
|
@@ -658,12 +643,11 @@ async function jsonc(options = {}) {
|
|
|
658
643
|
"jsonc/space-unary-ops": "error",
|
|
659
644
|
"jsonc/valid-json-number": "error",
|
|
660
645
|
"jsonc/vue-custom-block/no-parsing-error": "error",
|
|
661
|
-
...{
|
|
662
|
-
// format
|
|
646
|
+
...stylistic2 ? {
|
|
663
647
|
"jsonc/array-bracket-spacing": ["error", "never"],
|
|
664
648
|
"jsonc/comma-dangle": ["error", "never"],
|
|
665
649
|
"jsonc/comma-style": ["error", "last"],
|
|
666
|
-
"jsonc/indent": ["error",
|
|
650
|
+
"jsonc/indent": ["error", indent],
|
|
667
651
|
"jsonc/key-spacing": [
|
|
668
652
|
"error",
|
|
669
653
|
{ afterColon: true, beforeColon: false }
|
|
@@ -679,7 +663,7 @@ async function jsonc(options = {}) {
|
|
|
679
663
|
],
|
|
680
664
|
"jsonc/quote-props": "error",
|
|
681
665
|
"jsonc/quotes": "error"
|
|
682
|
-
},
|
|
666
|
+
} : {},
|
|
683
667
|
...overrides
|
|
684
668
|
}
|
|
685
669
|
}
|
|
@@ -931,34 +915,52 @@ function sortTsconfig() {
|
|
|
931
915
|
];
|
|
932
916
|
}
|
|
933
917
|
|
|
934
|
-
// src/configs/
|
|
935
|
-
var
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
918
|
+
// src/configs/stylistic.ts
|
|
919
|
+
var StylisticConfigDefaults = {
|
|
920
|
+
indent: 2,
|
|
921
|
+
jsx: true,
|
|
922
|
+
quotes: "single",
|
|
923
|
+
semi: false
|
|
924
|
+
};
|
|
925
|
+
async function stylistic(options = {}) {
|
|
926
|
+
const {
|
|
927
|
+
indent,
|
|
928
|
+
jsx,
|
|
929
|
+
overrides = {},
|
|
930
|
+
quotes,
|
|
931
|
+
semi
|
|
932
|
+
} = {
|
|
933
|
+
...StylisticConfigDefaults,
|
|
934
|
+
...options
|
|
941
935
|
};
|
|
942
|
-
const
|
|
936
|
+
const pluginStylistic = await interopDefault(
|
|
937
|
+
import("@stylistic/eslint-plugin")
|
|
938
|
+
);
|
|
939
|
+
const config = pluginStylistic.configs.customize({
|
|
940
|
+
flat: true,
|
|
941
|
+
indent,
|
|
942
|
+
jsx,
|
|
943
|
+
pluginName: "style",
|
|
944
|
+
quotes,
|
|
945
|
+
semi
|
|
946
|
+
});
|
|
947
|
+
return [
|
|
943
948
|
{
|
|
944
|
-
name: "coderwyd/
|
|
949
|
+
name: "coderwyd/stylistic/rules",
|
|
945
950
|
plugins: {
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
{
|
|
950
|
-
files: GLOB_PRETTIER_LINT,
|
|
951
|
-
name: "coderwyd/prettier/rules",
|
|
951
|
+
antfu: import_eslint_plugin_antfu.default,
|
|
952
|
+
style: pluginStylistic
|
|
953
|
+
},
|
|
952
954
|
rules: {
|
|
953
|
-
...
|
|
954
|
-
"
|
|
955
|
-
|
|
956
|
-
"
|
|
957
|
-
"
|
|
955
|
+
...config.rules,
|
|
956
|
+
"antfu/consistent-list-newline": "error",
|
|
957
|
+
"antfu/if-newline": "warn",
|
|
958
|
+
"antfu/top-level-function": "warn",
|
|
959
|
+
"curly": ["error", "multi-or-nest", "consistent"],
|
|
960
|
+
...overrides
|
|
958
961
|
}
|
|
959
962
|
}
|
|
960
963
|
];
|
|
961
|
-
return configs2;
|
|
962
964
|
}
|
|
963
965
|
|
|
964
966
|
// src/configs/typescript.ts
|
|
@@ -1129,9 +1131,9 @@ async function unicorn() {
|
|
|
1129
1131
|
rules: {
|
|
1130
1132
|
// 'unicorn/better-regex': 'error',
|
|
1131
1133
|
"unicorn/catch-error-name": "error",
|
|
1134
|
+
"unicorn/consistent-empty-array-spread": "error",
|
|
1132
1135
|
"unicorn/custom-error-definition": "error",
|
|
1133
1136
|
"unicorn/error-message": "error",
|
|
1134
|
-
"unicorn/escape-case": "error",
|
|
1135
1137
|
// 'unicorn/explicit-length-check': 'error',
|
|
1136
1138
|
// 'unicorn/filename-case': [
|
|
1137
1139
|
// 'error',
|
|
@@ -1139,6 +1141,7 @@ async function unicorn() {
|
|
|
1139
1141
|
// cases: { kebabCase: true, pascalCase: true },
|
|
1140
1142
|
// ignore: [/^[A-Z]+\..*$/],
|
|
1141
1143
|
// },
|
|
1144
|
+
"unicorn/escape-case": "error",
|
|
1142
1145
|
// ],
|
|
1143
1146
|
"unicorn/new-for-builtins": "error",
|
|
1144
1147
|
// 'unicorn/no-array-callback-reference': 'error',
|
|
@@ -1196,11 +1199,15 @@ async function unicorn() {
|
|
|
1196
1199
|
}
|
|
1197
1200
|
|
|
1198
1201
|
// src/configs/vue.ts
|
|
1202
|
+
var import_eslint_merge_processors = require("eslint-merge-processors");
|
|
1199
1203
|
async function vue(options = {}) {
|
|
1200
|
-
const { files = [GLOB_VUE], overrides = {} } = options;
|
|
1201
|
-
const
|
|
1204
|
+
const { files = [GLOB_VUE], overrides = {}, stylistic: stylistic2 = true } = options;
|
|
1205
|
+
const sfcBlocks = options.sfcBlocks === true ? {} : options.sfcBlocks ?? {};
|
|
1206
|
+
const { indent = 2 } = typeof stylistic2 === "boolean" ? {} : stylistic2;
|
|
1207
|
+
const [pluginVue, parserVue, processorVueBlocks] = await Promise.all([
|
|
1202
1208
|
interopDefault(import("eslint-plugin-vue")),
|
|
1203
|
-
interopDefault(import("vue-eslint-parser"))
|
|
1209
|
+
interopDefault(import("vue-eslint-parser")),
|
|
1210
|
+
interopDefault(import("eslint-processor-vue-blocks"))
|
|
1204
1211
|
]);
|
|
1205
1212
|
const isVue3 = getVueVersion() === 3;
|
|
1206
1213
|
const configKeys = isVue3 ? ["vue3-essential", "vue3-strongly-recommended", "vue3-recommended"] : ["essential", "strongly-recommended", "recommended"];
|
|
@@ -1254,7 +1261,16 @@ async function vue(options = {}) {
|
|
|
1254
1261
|
}
|
|
1255
1262
|
},
|
|
1256
1263
|
name: "coderwyd/vue/rules",
|
|
1257
|
-
processor: pluginVue.processors[".vue"],
|
|
1264
|
+
processor: sfcBlocks === false ? pluginVue.processors[".vue"] : (0, import_eslint_merge_processors.mergeProcessors)([
|
|
1265
|
+
pluginVue.processors[".vue"],
|
|
1266
|
+
processorVueBlocks({
|
|
1267
|
+
...sfcBlocks,
|
|
1268
|
+
blocks: {
|
|
1269
|
+
styles: true,
|
|
1270
|
+
...sfcBlocks.blocks
|
|
1271
|
+
}
|
|
1272
|
+
})
|
|
1273
|
+
]),
|
|
1258
1274
|
rules: {
|
|
1259
1275
|
...pluginVue.configs.base.rules,
|
|
1260
1276
|
...vueRules,
|
|
@@ -1282,7 +1298,7 @@ async function vue(options = {}) {
|
|
|
1282
1298
|
"vue/dot-location": ["error", "property"],
|
|
1283
1299
|
"vue/dot-notation": ["error", { allowKeywords: true }],
|
|
1284
1300
|
"vue/eqeqeq": ["error", "smart"],
|
|
1285
|
-
"vue/html-indent": ["error",
|
|
1301
|
+
"vue/html-indent": ["error", indent],
|
|
1286
1302
|
"vue/html-quotes": ["error", "double"],
|
|
1287
1303
|
"vue/html-self-closing": [
|
|
1288
1304
|
"error",
|
|
@@ -1332,8 +1348,7 @@ async function vue(options = {}) {
|
|
|
1332
1348
|
"vue/space-infix-ops": "error",
|
|
1333
1349
|
"vue/space-unary-ops": ["error", { nonwords: false, words: true }],
|
|
1334
1350
|
"vue/valid-define-options": "warn",
|
|
1335
|
-
...{
|
|
1336
|
-
// format
|
|
1351
|
+
...stylistic2 ? {
|
|
1337
1352
|
"vue/array-bracket-spacing": ["error", "never"],
|
|
1338
1353
|
"vue/arrow-spacing": ["error", { after: true, before: true }],
|
|
1339
1354
|
"vue/block-spacing": ["error", "always"],
|
|
@@ -1344,7 +1359,11 @@ async function vue(options = {}) {
|
|
|
1344
1359
|
singleline: "always"
|
|
1345
1360
|
}
|
|
1346
1361
|
],
|
|
1347
|
-
"vue/brace-style": [
|
|
1362
|
+
"vue/brace-style": [
|
|
1363
|
+
"error",
|
|
1364
|
+
"stroustrup",
|
|
1365
|
+
{ allowSingleLine: true }
|
|
1366
|
+
],
|
|
1348
1367
|
"vue/comma-dangle": ["error", "always-multiline"],
|
|
1349
1368
|
"vue/comma-spacing": ["error", { after: true, before: false }],
|
|
1350
1369
|
"vue/comma-style": ["error", "last"],
|
|
@@ -1371,7 +1390,7 @@ async function vue(options = {}) {
|
|
|
1371
1390
|
"vue/quote-props": ["error", "consistent-as-needed"],
|
|
1372
1391
|
"vue/space-in-parens": ["error", "never"],
|
|
1373
1392
|
"vue/template-curly-spacing": "error"
|
|
1374
|
-
},
|
|
1393
|
+
} : {},
|
|
1375
1394
|
...overrides
|
|
1376
1395
|
}
|
|
1377
1396
|
}
|
|
@@ -1469,7 +1488,7 @@ async function react(options = {}) {
|
|
|
1469
1488
|
{
|
|
1470
1489
|
name: "coderwyd/react/setup",
|
|
1471
1490
|
plugins: {
|
|
1472
|
-
react: plugins["@eslint-react"],
|
|
1491
|
+
"react": plugins["@eslint-react"],
|
|
1473
1492
|
"react-dom": plugins["@eslint-react/dom"],
|
|
1474
1493
|
"react-hooks": pluginReactHooks,
|
|
1475
1494
|
"react-hooks-extra": plugins["@eslint-react/hooks-extra"],
|
|
@@ -1598,7 +1617,7 @@ async function unocss(options = {}) {
|
|
|
1598
1617
|
}
|
|
1599
1618
|
|
|
1600
1619
|
// src/configs/formatter.ts
|
|
1601
|
-
async function formatter(options = {},
|
|
1620
|
+
async function formatter(options = {}, stylistic2 = {}) {
|
|
1602
1621
|
const { css, graphql, html, markdown, toml, yaml } = options === true ? {
|
|
1603
1622
|
css: true,
|
|
1604
1623
|
graphql: true,
|
|
@@ -1607,10 +1626,27 @@ async function formatter(options = {}, prettierRules2 = {}) {
|
|
|
1607
1626
|
toml: true,
|
|
1608
1627
|
yaml: true
|
|
1609
1628
|
} : options;
|
|
1610
|
-
const
|
|
1629
|
+
const { indent, quotes, semi } = {
|
|
1630
|
+
...StylisticConfigDefaults,
|
|
1631
|
+
...stylistic2
|
|
1632
|
+
};
|
|
1633
|
+
const prettierOptions = Object.assign(
|
|
1634
|
+
{
|
|
1635
|
+
endOfLine: "auto",
|
|
1636
|
+
printWidth: 80,
|
|
1637
|
+
semi,
|
|
1638
|
+
singleQuote: quotes === "single",
|
|
1639
|
+
tabWidth: typeof indent === "number" ? indent : 2,
|
|
1640
|
+
trailingComma: "all",
|
|
1641
|
+
useTabs: indent === "tab"
|
|
1642
|
+
},
|
|
1643
|
+
typeof options === "boolean" ? {} : options.prettierOptions || {}
|
|
1644
|
+
);
|
|
1645
|
+
await ensurePackages(["eslint-plugin-format"]);
|
|
1646
|
+
const pluginFormat = await interopDefault(import("eslint-plugin-format"));
|
|
1611
1647
|
function createPrettierFormatter(files, parser, plugins) {
|
|
1612
1648
|
const rules = {
|
|
1613
|
-
...
|
|
1649
|
+
...prettierOptions,
|
|
1614
1650
|
parser
|
|
1615
1651
|
};
|
|
1616
1652
|
const markdownRules = {
|
|
@@ -1618,9 +1654,8 @@ async function formatter(options = {}, prettierRules2 = {}) {
|
|
|
1618
1654
|
...rules,
|
|
1619
1655
|
embeddedLanguageFormatting: "off"
|
|
1620
1656
|
};
|
|
1621
|
-
if (plugins?.length)
|
|
1657
|
+
if (plugins?.length)
|
|
1622
1658
|
rules.plugins = [...rules.plugins || [], ...plugins];
|
|
1623
|
-
}
|
|
1624
1659
|
const config = {
|
|
1625
1660
|
files,
|
|
1626
1661
|
languageOptions: {
|
|
@@ -1628,10 +1663,10 @@ async function formatter(options = {}, prettierRules2 = {}) {
|
|
|
1628
1663
|
},
|
|
1629
1664
|
name: `coderwyd/formatter/${parser}`,
|
|
1630
1665
|
plugins: {
|
|
1631
|
-
|
|
1666
|
+
format: pluginFormat
|
|
1632
1667
|
},
|
|
1633
1668
|
rules: {
|
|
1634
|
-
"
|
|
1669
|
+
"format/prettier": [
|
|
1635
1670
|
"warn",
|
|
1636
1671
|
parser === "markdown" ? markdownRules : rules
|
|
1637
1672
|
]
|
|
@@ -1643,7 +1678,7 @@ async function formatter(options = {}, prettierRules2 = {}) {
|
|
|
1643
1678
|
{
|
|
1644
1679
|
name: "coderwyd/formatter/setup",
|
|
1645
1680
|
plugins: {
|
|
1646
|
-
|
|
1681
|
+
format: pluginFormat
|
|
1647
1682
|
}
|
|
1648
1683
|
}
|
|
1649
1684
|
];
|
|
@@ -1681,7 +1716,11 @@ async function formatter(options = {}, prettierRules2 = {}) {
|
|
|
1681
1716
|
|
|
1682
1717
|
// src/configs/svelte.ts
|
|
1683
1718
|
async function svelte(options = {}) {
|
|
1684
|
-
const { files = [GLOB_SVELTE], overrides = {} } = options;
|
|
1719
|
+
const { files = [GLOB_SVELTE], overrides = {}, stylistic: stylistic2 = true } = options;
|
|
1720
|
+
const {
|
|
1721
|
+
indent = 2,
|
|
1722
|
+
quotes = "single"
|
|
1723
|
+
} = typeof stylistic2 === "boolean" ? {} : stylistic2;
|
|
1685
1724
|
await ensurePackages(["eslint-plugin-svelte"]);
|
|
1686
1725
|
const [pluginSvelte, parserSvelte] = await Promise.all([
|
|
1687
1726
|
interopDefault(import("eslint-plugin-svelte")),
|
|
@@ -1751,22 +1790,23 @@ async function svelte(options = {}) {
|
|
|
1751
1790
|
varsIgnorePattern: "^(_|\\$\\$Props$|\\$\\$Events$|\\$\\$Slots$)"
|
|
1752
1791
|
}
|
|
1753
1792
|
],
|
|
1754
|
-
...{
|
|
1755
|
-
|
|
1793
|
+
...stylistic2 ? {
|
|
1794
|
+
"style/indent": "off",
|
|
1795
|
+
// superseded by svelte/indent
|
|
1756
1796
|
"style/no-trailing-spaces": "off",
|
|
1757
1797
|
// superseded by svelte/no-trailing-spaces
|
|
1758
1798
|
"svelte/derived-has-same-inputs-outputs": "error",
|
|
1759
1799
|
"svelte/html-closing-bracket-spacing": "error",
|
|
1760
|
-
"svelte/html-quotes": ["error", { prefer:
|
|
1800
|
+
"svelte/html-quotes": ["error", { prefer: quotes }],
|
|
1761
1801
|
"svelte/indent": [
|
|
1762
1802
|
"error",
|
|
1763
|
-
{ alignAttributesVertically: true, indent
|
|
1803
|
+
{ alignAttributesVertically: true, indent }
|
|
1764
1804
|
],
|
|
1765
1805
|
"svelte/mustache-spacing": "error",
|
|
1766
1806
|
"svelte/no-spaces-around-equal-signs-in-attribute": "error",
|
|
1767
1807
|
"svelte/no-trailing-spaces": "error",
|
|
1768
1808
|
"svelte/spaced-html-comment": "error"
|
|
1769
|
-
},
|
|
1809
|
+
} : {},
|
|
1770
1810
|
...overrides
|
|
1771
1811
|
}
|
|
1772
1812
|
}
|
|
@@ -1858,11 +1898,16 @@ var flatConfigProps = [
|
|
|
1858
1898
|
"settings"
|
|
1859
1899
|
];
|
|
1860
1900
|
var defaultPluginRenaming = {
|
|
1901
|
+
"@eslint-react": "react",
|
|
1902
|
+
"@eslint-react/dom": "react-dom",
|
|
1903
|
+
"@eslint-react/hooks-extra": "react-hooks-extra",
|
|
1904
|
+
"@eslint-react/naming-convention": "react-naming-convention",
|
|
1905
|
+
"@stylistic": "style",
|
|
1861
1906
|
"@typescript-eslint": "ts",
|
|
1862
1907
|
"import-x": "import",
|
|
1863
|
-
n: "node",
|
|
1864
|
-
vitest: "test",
|
|
1865
|
-
yml: "yaml"
|
|
1908
|
+
"n": "node",
|
|
1909
|
+
"vitest": "test",
|
|
1910
|
+
"yml": "yaml"
|
|
1866
1911
|
};
|
|
1867
1912
|
async function defineConfig(options = {}, ...userConfigs) {
|
|
1868
1913
|
const {
|
|
@@ -1880,9 +1925,11 @@ async function defineConfig(options = {}, ...userConfigs) {
|
|
|
1880
1925
|
tailwindcss: enableTailwindCSS = hasTailwindCSS,
|
|
1881
1926
|
typescript: enableTypeScript = hasTypeScript,
|
|
1882
1927
|
unocss: enableUnoCSS = false,
|
|
1883
|
-
usePrettierrc = true,
|
|
1884
1928
|
vue: enableVue = hasVue
|
|
1885
1929
|
} = options;
|
|
1930
|
+
const stylisticOptions = options.stylistic === false ? false : typeof options.stylistic === "object" ? options.stylistic : {};
|
|
1931
|
+
if (stylisticOptions && !("jsx" in stylisticOptions))
|
|
1932
|
+
stylisticOptions.jsx = options.jsx ?? true;
|
|
1886
1933
|
const configs2 = [];
|
|
1887
1934
|
if (enableGitignore) {
|
|
1888
1935
|
if (typeof enableGitignore !== "boolean") {
|
|
@@ -1892,12 +1939,13 @@ async function defineConfig(options = {}, ...userConfigs) {
|
|
|
1892
1939
|
])
|
|
1893
1940
|
);
|
|
1894
1941
|
} else {
|
|
1895
|
-
if (import_node_fs.default.existsSync(".gitignore"))
|
|
1942
|
+
if (import_node_fs.default.existsSync(".gitignore")) {
|
|
1896
1943
|
configs2.push(
|
|
1897
1944
|
interopDefault(import("eslint-config-flat-gitignore")).then((r) => [
|
|
1898
1945
|
r()
|
|
1899
1946
|
])
|
|
1900
1947
|
);
|
|
1948
|
+
}
|
|
1901
1949
|
}
|
|
1902
1950
|
}
|
|
1903
1951
|
configs2.push(
|
|
@@ -1908,8 +1956,12 @@ async function defineConfig(options = {}, ...userConfigs) {
|
|
|
1908
1956
|
}),
|
|
1909
1957
|
comments(),
|
|
1910
1958
|
node(),
|
|
1911
|
-
jsdoc(
|
|
1912
|
-
|
|
1959
|
+
jsdoc({
|
|
1960
|
+
stylistic: stylisticOptions
|
|
1961
|
+
}),
|
|
1962
|
+
imports({
|
|
1963
|
+
stylistic: stylisticOptions
|
|
1964
|
+
}),
|
|
1913
1965
|
unicorn(),
|
|
1914
1966
|
command(),
|
|
1915
1967
|
// Optional plugins (installed but not enabled by default)
|
|
@@ -1926,6 +1978,14 @@ async function defineConfig(options = {}, ...userConfigs) {
|
|
|
1926
1978
|
})
|
|
1927
1979
|
);
|
|
1928
1980
|
}
|
|
1981
|
+
if (stylisticOptions) {
|
|
1982
|
+
configs2.push(
|
|
1983
|
+
stylistic({
|
|
1984
|
+
...stylisticOptions,
|
|
1985
|
+
overrides: getOverrides(options, "stylistic")
|
|
1986
|
+
})
|
|
1987
|
+
);
|
|
1988
|
+
}
|
|
1929
1989
|
if (enableRegexp)
|
|
1930
1990
|
configs2.push(regexp(typeof enableRegexp === "boolean" ? {} : enableRegexp));
|
|
1931
1991
|
if (options.test ?? true) {
|
|
@@ -1941,6 +2001,7 @@ async function defineConfig(options = {}, ...userConfigs) {
|
|
|
1941
2001
|
vue({
|
|
1942
2002
|
...resolveSubOptions(options, "vue"),
|
|
1943
2003
|
overrides: getOverrides(options, "typescript"),
|
|
2004
|
+
stylistic: stylisticOptions,
|
|
1944
2005
|
typescript: !!enableTypeScript
|
|
1945
2006
|
})
|
|
1946
2007
|
);
|
|
@@ -1957,6 +2018,7 @@ async function defineConfig(options = {}, ...userConfigs) {
|
|
|
1957
2018
|
configs2.push(
|
|
1958
2019
|
svelte({
|
|
1959
2020
|
overrides: getOverrides(options, "svelte"),
|
|
2021
|
+
stylistic: stylisticOptions,
|
|
1960
2022
|
typescript: !!enableTypeScript
|
|
1961
2023
|
})
|
|
1962
2024
|
);
|
|
@@ -1980,31 +2042,20 @@ async function defineConfig(options = {}, ...userConfigs) {
|
|
|
1980
2042
|
if (options.jsonc ?? true) {
|
|
1981
2043
|
configs2.push(
|
|
1982
2044
|
jsonc({
|
|
1983
|
-
overrides: getOverrides(options, "jsonc")
|
|
2045
|
+
overrides: getOverrides(options, "jsonc"),
|
|
2046
|
+
stylistic: stylisticOptions
|
|
1984
2047
|
}),
|
|
1985
2048
|
sortPackageJson(),
|
|
1986
2049
|
sortTsconfig()
|
|
1987
2050
|
);
|
|
1988
2051
|
}
|
|
1989
2052
|
if (formatterOptions) {
|
|
1990
|
-
let prettierRules2 = {
|
|
1991
|
-
...DEFAULT_PRETTIER_RULES
|
|
1992
|
-
};
|
|
1993
|
-
if (options.prettierRules) {
|
|
1994
|
-
prettierRules2 = { ...prettierRules2, ...options.prettierRules };
|
|
1995
|
-
}
|
|
1996
|
-
if (usePrettierrc) {
|
|
1997
|
-
const prettierConfig = await loadPrettierConfig(
|
|
1998
|
-
options.cwd ?? import_node_process4.default.cwd()
|
|
1999
|
-
);
|
|
2000
|
-
Object.assign(prettierRules2, prettierConfig);
|
|
2001
|
-
}
|
|
2002
2053
|
configs2.push(
|
|
2003
|
-
|
|
2004
|
-
|
|
2054
|
+
formatter(
|
|
2055
|
+
formatterOptions,
|
|
2056
|
+
typeof stylisticOptions === "boolean" ? {} : stylisticOptions
|
|
2057
|
+
)
|
|
2005
2058
|
);
|
|
2006
|
-
} else {
|
|
2007
|
-
configs2.push(prettier());
|
|
2008
2059
|
}
|
|
2009
2060
|
const fusedConfig = flatConfigProps.reduce((acc, key) => {
|
|
2010
2061
|
if (key in options)
|
|
@@ -2027,7 +2078,6 @@ async function defineConfig(options = {}, ...userConfigs) {
|
|
|
2027
2078
|
getOverrides,
|
|
2028
2079
|
getVueVersion,
|
|
2029
2080
|
interopDefault,
|
|
2030
|
-
loadPrettierConfig,
|
|
2031
2081
|
parserPlain,
|
|
2032
2082
|
renamePluginInConfigs,
|
|
2033
2083
|
renameRules,
|