@luxass/eslint-config 4.9.0 → 4.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +83 -52
- package/dist/index.d.cts +364 -245
- package/dist/index.d.ts +364 -245
- package/dist/index.js +81 -52
- package/package.json +31 -39
package/dist/index.cjs
CHANGED
|
@@ -31,6 +31,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
31
31
|
var src_exports = {};
|
|
32
32
|
__export(src_exports, {
|
|
33
33
|
GLOB_ASTRO: () => GLOB_ASTRO,
|
|
34
|
+
GLOB_ASTRO_TS: () => GLOB_ASTRO_TS,
|
|
34
35
|
GLOB_CSS: () => GLOB_CSS,
|
|
35
36
|
GLOB_EXCLUDE: () => GLOB_EXCLUDE,
|
|
36
37
|
GLOB_GRAPHQL: () => GLOB_GRAPHQL,
|
|
@@ -78,6 +79,7 @@ __export(src_exports, {
|
|
|
78
79
|
parserPlain: () => parserPlain,
|
|
79
80
|
react: () => react,
|
|
80
81
|
regexp: () => regexp,
|
|
82
|
+
renamePluginInConfigs: () => renamePluginInConfigs,
|
|
81
83
|
renameRules: () => renameRules,
|
|
82
84
|
resolveSubOptions: () => resolveSubOptions,
|
|
83
85
|
sortPackageJson: () => sortPackageJson,
|
|
@@ -202,6 +204,7 @@ var GLOB_YAML = "**/*.y?(a)ml";
|
|
|
202
204
|
var GLOB_TOML = "**/*.toml";
|
|
203
205
|
var GLOB_HTML = "**/*.htm?(l)";
|
|
204
206
|
var GLOB_ASTRO = "**/*.astro";
|
|
207
|
+
var GLOB_ASTRO_TS = "**/*.astro/*.ts";
|
|
205
208
|
var GLOB_GRAPHQL = "**/*.{g,graph}ql";
|
|
206
209
|
var GLOB_MARKDOWN_CODE = `${GLOB_MARKDOWN}/${GLOB_SRC}`;
|
|
207
210
|
var GLOB_TESTS = [
|
|
@@ -319,6 +322,7 @@ function sortPackageJson() {
|
|
|
319
322
|
"type",
|
|
320
323
|
"private",
|
|
321
324
|
"author",
|
|
325
|
+
"contributors",
|
|
322
326
|
"publisher",
|
|
323
327
|
"packageManager",
|
|
324
328
|
"license",
|
|
@@ -506,6 +510,7 @@ function sortTsconfig() {
|
|
|
506
510
|
"allowSyntheticDefaultImports",
|
|
507
511
|
"esModuleInterop",
|
|
508
512
|
"forceConsistentCasingInFileNames",
|
|
513
|
+
"isolatedDeclarations",
|
|
509
514
|
"isolatedModules",
|
|
510
515
|
"preserveSymlinks",
|
|
511
516
|
"verbatimModuleSyntax",
|
|
@@ -567,10 +572,13 @@ var import_globals = __toESM(require("globals"), 1);
|
|
|
567
572
|
var import_eslint_plugin_unused_imports = __toESM(require("eslint-plugin-unused-imports"), 1);
|
|
568
573
|
var import_eslint_plugin_antfu2 = __toESM(require("eslint-plugin-antfu"), 1);
|
|
569
574
|
async function javascript(options = {}) {
|
|
570
|
-
const {
|
|
575
|
+
const {
|
|
576
|
+
editor = false,
|
|
577
|
+
overrides = {}
|
|
578
|
+
} = options;
|
|
571
579
|
return [
|
|
572
580
|
{
|
|
573
|
-
name: "luxass/javascript",
|
|
581
|
+
name: "luxass/javascript/setup",
|
|
574
582
|
languageOptions: {
|
|
575
583
|
ecmaVersion: 2022,
|
|
576
584
|
globals: {
|
|
@@ -592,7 +600,10 @@ async function javascript(options = {}) {
|
|
|
592
600
|
},
|
|
593
601
|
linterOptions: {
|
|
594
602
|
reportUnusedDisableDirectives: true
|
|
595
|
-
}
|
|
603
|
+
}
|
|
604
|
+
},
|
|
605
|
+
{
|
|
606
|
+
name: "luxass/javascript/rules",
|
|
596
607
|
plugins: {
|
|
597
608
|
"antfu": import_eslint_plugin_antfu2.default,
|
|
598
609
|
"unused-imports": import_eslint_plugin_unused_imports.default
|
|
@@ -847,16 +858,37 @@ async function combine(...configs2) {
|
|
|
847
858
|
const resolved = await Promise.all(configs2);
|
|
848
859
|
return resolved.flat();
|
|
849
860
|
}
|
|
850
|
-
function renameRules(rules,
|
|
861
|
+
function renameRules(rules, map) {
|
|
851
862
|
return Object.fromEntries(
|
|
852
863
|
Object.entries(rules).map(([key, value]) => {
|
|
853
|
-
|
|
854
|
-
|
|
864
|
+
for (const [from, to] of Object.entries(map)) {
|
|
865
|
+
if (key.startsWith(`${from}/`)) {
|
|
866
|
+
return [to + key.slice(from.length), value];
|
|
867
|
+
}
|
|
855
868
|
}
|
|
856
869
|
return [key, value];
|
|
857
870
|
})
|
|
858
871
|
);
|
|
859
872
|
}
|
|
873
|
+
function renamePluginInConfigs(configs2, map) {
|
|
874
|
+
return configs2.map((i) => {
|
|
875
|
+
const clone = { ...i };
|
|
876
|
+
if (clone.rules) {
|
|
877
|
+
clone.rules = renameRules(clone.rules, map);
|
|
878
|
+
}
|
|
879
|
+
if (clone.plugins) {
|
|
880
|
+
clone.plugins = Object.fromEntries(
|
|
881
|
+
Object.entries(clone.plugins).map(([key, value]) => {
|
|
882
|
+
if (key in map) {
|
|
883
|
+
return [map[key], value];
|
|
884
|
+
}
|
|
885
|
+
return [key, value];
|
|
886
|
+
})
|
|
887
|
+
);
|
|
888
|
+
}
|
|
889
|
+
return clone;
|
|
890
|
+
});
|
|
891
|
+
}
|
|
860
892
|
function toArray(value) {
|
|
861
893
|
return Array.isArray(value) ? value : [value];
|
|
862
894
|
}
|
|
@@ -899,7 +931,7 @@ async function jsdoc(options = {}) {
|
|
|
899
931
|
} = options;
|
|
900
932
|
return [
|
|
901
933
|
{
|
|
902
|
-
name: "luxass/jsdoc",
|
|
934
|
+
name: "luxass/jsdoc/rules",
|
|
903
935
|
plugins: {
|
|
904
936
|
jsdoc: await interop(import("eslint-plugin-jsdoc"))
|
|
905
937
|
},
|
|
@@ -1065,36 +1097,24 @@ async function markdown(options = {}) {
|
|
|
1065
1097
|
"import/newline-after-import": "off",
|
|
1066
1098
|
"no-alert": "off",
|
|
1067
1099
|
"no-console": "off",
|
|
1100
|
+
"no-labels": "off",
|
|
1101
|
+
"no-lone-blocks": "off",
|
|
1102
|
+
"no-restricted-syntax": "off",
|
|
1068
1103
|
"no-undef": "off",
|
|
1069
1104
|
"no-unused-expressions": "off",
|
|
1105
|
+
"no-unused-labels": "off",
|
|
1070
1106
|
"no-unused-vars": "off",
|
|
1071
1107
|
"node/prefer-global/process": "off",
|
|
1072
1108
|
"style/comma-dangle": "off",
|
|
1073
1109
|
"style/eol-last": "off",
|
|
1074
|
-
// Type aware rules
|
|
1075
|
-
"ts/await-thenable": "off",
|
|
1076
1110
|
"ts/consistent-type-imports": "off",
|
|
1077
|
-
"ts/dot-notation": "off",
|
|
1078
|
-
"ts/no-floating-promises": "off",
|
|
1079
|
-
"ts/no-for-in-array": "off",
|
|
1080
|
-
"ts/no-implied-eval": "off",
|
|
1081
|
-
"ts/no-misused-promises": "off",
|
|
1082
1111
|
"ts/no-namespace": "off",
|
|
1083
1112
|
"ts/no-redeclare": "off",
|
|
1084
1113
|
"ts/no-require-imports": "off",
|
|
1085
|
-
"ts/no-
|
|
1086
|
-
"ts/no-unnecessary-type-assertion": "off",
|
|
1087
|
-
"ts/no-unsafe-argument": "off",
|
|
1088
|
-
"ts/no-unsafe-assignment": "off",
|
|
1089
|
-
"ts/no-unsafe-call": "off",
|
|
1090
|
-
"ts/no-unsafe-member-access": "off",
|
|
1091
|
-
"ts/no-unsafe-return": "off",
|
|
1114
|
+
"ts/no-unused-expressions": "off",
|
|
1092
1115
|
"ts/no-unused-vars": "off",
|
|
1093
1116
|
"ts/no-use-before-define": "off",
|
|
1094
1117
|
"ts/no-var-requires": "off",
|
|
1095
|
-
"ts/restrict-plus-operands": "off",
|
|
1096
|
-
"ts/restrict-template-expressions": "off",
|
|
1097
|
-
"ts/unbound-method": "off",
|
|
1098
1118
|
"unicode-bom": "off",
|
|
1099
1119
|
"unused-imports/no-unused-imports": "off",
|
|
1100
1120
|
"unused-imports/no-unused-vars": "off",
|
|
@@ -1160,14 +1180,20 @@ async function typescript(options = {}) {
|
|
|
1160
1180
|
const {
|
|
1161
1181
|
exts = [],
|
|
1162
1182
|
overrides = {},
|
|
1163
|
-
parserOptions = {}
|
|
1183
|
+
parserOptions = {},
|
|
1184
|
+
type = "app"
|
|
1164
1185
|
} = options ?? {};
|
|
1165
1186
|
const files = options.files ?? [
|
|
1166
|
-
|
|
1187
|
+
GLOB_TS,
|
|
1188
|
+
GLOB_TSX,
|
|
1167
1189
|
...exts.map((ext) => `**/*.${ext}`)
|
|
1168
1190
|
];
|
|
1169
|
-
const filesTypeAware = options.
|
|
1170
|
-
const
|
|
1191
|
+
const filesTypeAware = options.filesTypeAware ?? [GLOB_TS, GLOB_TSX];
|
|
1192
|
+
const ignoresTypeAware = options.ignoresTypeAware ?? [
|
|
1193
|
+
`${GLOB_MARKDOWN}/**`,
|
|
1194
|
+
GLOB_ASTRO_TS
|
|
1195
|
+
];
|
|
1196
|
+
const tsconfigPath = options?.tsconfigPath ? options.tsconfigPath : void 0;
|
|
1171
1197
|
const isTypeAware = !!tsconfigPath;
|
|
1172
1198
|
const typeAwareRules = {
|
|
1173
1199
|
"dot-notation": "off",
|
|
@@ -1231,7 +1257,7 @@ async function typescript(options = {}) {
|
|
|
1231
1257
|
}
|
|
1232
1258
|
},
|
|
1233
1259
|
...isTypeAware ? [
|
|
1234
|
-
makeParser(true, filesTypeAware),
|
|
1260
|
+
makeParser(true, filesTypeAware, ignoresTypeAware),
|
|
1235
1261
|
makeParser(false, files, filesTypeAware)
|
|
1236
1262
|
] : [makeParser(false, files)],
|
|
1237
1263
|
{
|
|
@@ -1240,13 +1266,15 @@ async function typescript(options = {}) {
|
|
|
1240
1266
|
rules: {
|
|
1241
1267
|
...renameRules(
|
|
1242
1268
|
pluginTs.configs["eslint-recommended"].overrides[0].rules,
|
|
1243
|
-
|
|
1244
|
-
|
|
1269
|
+
{
|
|
1270
|
+
"@typescript-eslint": "ts"
|
|
1271
|
+
}
|
|
1245
1272
|
),
|
|
1246
1273
|
...renameRules(
|
|
1247
1274
|
pluginTs.configs.strict.rules,
|
|
1248
|
-
|
|
1249
|
-
|
|
1275
|
+
{
|
|
1276
|
+
"@typescript-eslint": "ts"
|
|
1277
|
+
}
|
|
1250
1278
|
),
|
|
1251
1279
|
"no-dupe-class-members": "off",
|
|
1252
1280
|
"no-invalid-this": "off",
|
|
@@ -1288,20 +1316,25 @@ async function typescript(options = {}) {
|
|
|
1288
1316
|
"ts/no-wrapper-object-types": "error",
|
|
1289
1317
|
"ts/triple-slash-reference": "off",
|
|
1290
1318
|
"ts/unified-signatures": "off",
|
|
1319
|
+
...type === "lib" ? {
|
|
1320
|
+
"ts/explicit-function-return-type": ["error", {
|
|
1321
|
+
allowExpressions: true,
|
|
1322
|
+
allowHigherOrderFunctions: true,
|
|
1323
|
+
allowIIFEs: true
|
|
1324
|
+
}]
|
|
1325
|
+
} : {},
|
|
1291
1326
|
...overrides
|
|
1292
1327
|
}
|
|
1293
1328
|
},
|
|
1294
|
-
{
|
|
1295
|
-
name: "luxass/typescript/rules-type-aware",
|
|
1329
|
+
...isTypeAware ? [{
|
|
1296
1330
|
files: filesTypeAware,
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
},
|
|
1331
|
+
ignores: ignoresTypeAware,
|
|
1332
|
+
name: "luxass/typescript/rules-type-aware",
|
|
1333
|
+
rules: typeAwareRules
|
|
1334
|
+
}] : [],
|
|
1302
1335
|
{
|
|
1303
1336
|
name: "luxass/typescript/disables/dts",
|
|
1304
|
-
files: ["**/*.d
|
|
1337
|
+
files: ["**/*.d.?([cm])ts"],
|
|
1305
1338
|
rules: {
|
|
1306
1339
|
"eslint-comments/no-unlimited-disable": "off",
|
|
1307
1340
|
"import/no-duplicates": "off",
|
|
@@ -1310,21 +1343,14 @@ async function typescript(options = {}) {
|
|
|
1310
1343
|
}
|
|
1311
1344
|
},
|
|
1312
1345
|
{
|
|
1313
|
-
name: "luxass/typescript/disables/tests",
|
|
1314
1346
|
files: ["**/*.{test,spec}.ts?(x)"],
|
|
1347
|
+
name: "luxass/typescript/disables/test",
|
|
1315
1348
|
rules: {
|
|
1316
1349
|
"no-unused-expressions": "off"
|
|
1317
1350
|
}
|
|
1318
1351
|
},
|
|
1319
1352
|
{
|
|
1320
|
-
name: "luxass/typescript/disables/
|
|
1321
|
-
files: [`**/playground.${GLOB_SRC_EXT}`],
|
|
1322
|
-
rules: {
|
|
1323
|
-
"no-console": "off"
|
|
1324
|
-
}
|
|
1325
|
-
},
|
|
1326
|
-
{
|
|
1327
|
-
name: "luxass/typescript/disables/javascript",
|
|
1353
|
+
name: "luxass/typescript/disables/cjs",
|
|
1328
1354
|
files: ["**/*.js", "**/*.cjs"],
|
|
1329
1355
|
rules: {
|
|
1330
1356
|
"ts/no-require-imports": "off",
|
|
@@ -1627,6 +1653,7 @@ async function test(options = {}) {
|
|
|
1627
1653
|
"test/no-focused-tests": editor ? "off" : "error",
|
|
1628
1654
|
"test/prefer-hooks-in-order": "error",
|
|
1629
1655
|
"test/prefer-lowercase-title": "error",
|
|
1656
|
+
"ts/explicit-function-return-type": "off",
|
|
1630
1657
|
...overrides
|
|
1631
1658
|
}
|
|
1632
1659
|
}
|
|
@@ -2281,7 +2308,8 @@ function luxass(options = {}, ...userConfigs) {
|
|
|
2281
2308
|
typescript: enableTypeScript = (0, import_local_pkg4.isPackageExists)("typescript"),
|
|
2282
2309
|
unocss: enableUnoCSS = false,
|
|
2283
2310
|
tailwindcss: enableTailwindCSS = false,
|
|
2284
|
-
vue: enableVue = VuePackages.some((i) => (0, import_local_pkg4.isPackageExists)(i))
|
|
2311
|
+
vue: enableVue = VuePackages.some((i) => (0, import_local_pkg4.isPackageExists)(i)),
|
|
2312
|
+
type: projectType = "app"
|
|
2285
2313
|
} = options;
|
|
2286
2314
|
const stylisticOptions = options.stylistic === false ? false : typeof options.stylistic === "object" ? options.stylistic : {};
|
|
2287
2315
|
if (stylisticOptions && !("jsx" in stylisticOptions)) {
|
|
@@ -2325,7 +2353,8 @@ function luxass(options = {}, ...userConfigs) {
|
|
|
2325
2353
|
configs2.push(typescript({
|
|
2326
2354
|
...typescriptOptions,
|
|
2327
2355
|
exts,
|
|
2328
|
-
overrides: getOverrides(options, "typescript")
|
|
2356
|
+
overrides: getOverrides(options, "typescript"),
|
|
2357
|
+
type: projectType
|
|
2329
2358
|
}));
|
|
2330
2359
|
}
|
|
2331
2360
|
if (stylisticOptions) {
|
|
@@ -2444,6 +2473,7 @@ var src_default = luxass;
|
|
|
2444
2473
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2445
2474
|
0 && (module.exports = {
|
|
2446
2475
|
GLOB_ASTRO,
|
|
2476
|
+
GLOB_ASTRO_TS,
|
|
2447
2477
|
GLOB_CSS,
|
|
2448
2478
|
GLOB_EXCLUDE,
|
|
2449
2479
|
GLOB_GRAPHQL,
|
|
@@ -2490,6 +2520,7 @@ var src_default = luxass;
|
|
|
2490
2520
|
parserPlain,
|
|
2491
2521
|
react,
|
|
2492
2522
|
regexp,
|
|
2523
|
+
renamePluginInConfigs,
|
|
2493
2524
|
renameRules,
|
|
2494
2525
|
resolveSubOptions,
|
|
2495
2526
|
sortPackageJson,
|