@luxass/eslint-config 4.9.0 → 4.10.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/README.md +13 -12
- package/dist/index.cjs +83 -52
- package/dist/index.d.cts +452 -245
- package/dist/index.d.ts +452 -245
- package/dist/index.js +82 -53
- package/package.json +32 -40
package/dist/index.js
CHANGED
|
@@ -105,6 +105,7 @@ var GLOB_YAML = "**/*.y?(a)ml";
|
|
|
105
105
|
var GLOB_TOML = "**/*.toml";
|
|
106
106
|
var GLOB_HTML = "**/*.htm?(l)";
|
|
107
107
|
var GLOB_ASTRO = "**/*.astro";
|
|
108
|
+
var GLOB_ASTRO_TS = "**/*.astro/*.ts";
|
|
108
109
|
var GLOB_GRAPHQL = "**/*.{g,graph}ql";
|
|
109
110
|
var GLOB_MARKDOWN_CODE = `${GLOB_MARKDOWN}/${GLOB_SRC}`;
|
|
110
111
|
var GLOB_TESTS = [
|
|
@@ -222,6 +223,7 @@ function sortPackageJson() {
|
|
|
222
223
|
"type",
|
|
223
224
|
"private",
|
|
224
225
|
"author",
|
|
226
|
+
"contributors",
|
|
225
227
|
"publisher",
|
|
226
228
|
"packageManager",
|
|
227
229
|
"license",
|
|
@@ -409,6 +411,7 @@ function sortTsconfig() {
|
|
|
409
411
|
"allowSyntheticDefaultImports",
|
|
410
412
|
"esModuleInterop",
|
|
411
413
|
"forceConsistentCasingInFileNames",
|
|
414
|
+
"isolatedDeclarations",
|
|
412
415
|
"isolatedModules",
|
|
413
416
|
"preserveSymlinks",
|
|
414
417
|
"verbatimModuleSyntax",
|
|
@@ -467,13 +470,16 @@ async function imports(options = {}) {
|
|
|
467
470
|
|
|
468
471
|
// src/configs/javascript.ts
|
|
469
472
|
import globals from "globals";
|
|
470
|
-
import pluginUnusedImports from "eslint-plugin-unused-imports";
|
|
473
|
+
import { default as pluginUnusedImports } from "eslint-plugin-unused-imports";
|
|
471
474
|
import pluginAntfu2 from "eslint-plugin-antfu";
|
|
472
475
|
async function javascript(options = {}) {
|
|
473
|
-
const {
|
|
476
|
+
const {
|
|
477
|
+
editor = false,
|
|
478
|
+
overrides = {}
|
|
479
|
+
} = options;
|
|
474
480
|
return [
|
|
475
481
|
{
|
|
476
|
-
name: "luxass/javascript",
|
|
482
|
+
name: "luxass/javascript/setup",
|
|
477
483
|
languageOptions: {
|
|
478
484
|
ecmaVersion: 2022,
|
|
479
485
|
globals: {
|
|
@@ -495,7 +501,10 @@ async function javascript(options = {}) {
|
|
|
495
501
|
},
|
|
496
502
|
linterOptions: {
|
|
497
503
|
reportUnusedDisableDirectives: true
|
|
498
|
-
}
|
|
504
|
+
}
|
|
505
|
+
},
|
|
506
|
+
{
|
|
507
|
+
name: "luxass/javascript/rules",
|
|
499
508
|
plugins: {
|
|
500
509
|
"antfu": pluginAntfu2,
|
|
501
510
|
"unused-imports": pluginUnusedImports
|
|
@@ -750,16 +759,37 @@ async function combine(...configs2) {
|
|
|
750
759
|
const resolved = await Promise.all(configs2);
|
|
751
760
|
return resolved.flat();
|
|
752
761
|
}
|
|
753
|
-
function renameRules(rules,
|
|
762
|
+
function renameRules(rules, map) {
|
|
754
763
|
return Object.fromEntries(
|
|
755
764
|
Object.entries(rules).map(([key, value]) => {
|
|
756
|
-
|
|
757
|
-
|
|
765
|
+
for (const [from, to] of Object.entries(map)) {
|
|
766
|
+
if (key.startsWith(`${from}/`)) {
|
|
767
|
+
return [to + key.slice(from.length), value];
|
|
768
|
+
}
|
|
758
769
|
}
|
|
759
770
|
return [key, value];
|
|
760
771
|
})
|
|
761
772
|
);
|
|
762
773
|
}
|
|
774
|
+
function renamePluginInConfigs(configs2, map) {
|
|
775
|
+
return configs2.map((i) => {
|
|
776
|
+
const clone = { ...i };
|
|
777
|
+
if (clone.rules) {
|
|
778
|
+
clone.rules = renameRules(clone.rules, map);
|
|
779
|
+
}
|
|
780
|
+
if (clone.plugins) {
|
|
781
|
+
clone.plugins = Object.fromEntries(
|
|
782
|
+
Object.entries(clone.plugins).map(([key, value]) => {
|
|
783
|
+
if (key in map) {
|
|
784
|
+
return [map[key], value];
|
|
785
|
+
}
|
|
786
|
+
return [key, value];
|
|
787
|
+
})
|
|
788
|
+
);
|
|
789
|
+
}
|
|
790
|
+
return clone;
|
|
791
|
+
});
|
|
792
|
+
}
|
|
763
793
|
function toArray(value) {
|
|
764
794
|
return Array.isArray(value) ? value : [value];
|
|
765
795
|
}
|
|
@@ -802,7 +832,7 @@ async function jsdoc(options = {}) {
|
|
|
802
832
|
} = options;
|
|
803
833
|
return [
|
|
804
834
|
{
|
|
805
|
-
name: "luxass/jsdoc",
|
|
835
|
+
name: "luxass/jsdoc/rules",
|
|
806
836
|
plugins: {
|
|
807
837
|
jsdoc: await interop(import("eslint-plugin-jsdoc"))
|
|
808
838
|
},
|
|
@@ -968,36 +998,24 @@ async function markdown(options = {}) {
|
|
|
968
998
|
"import/newline-after-import": "off",
|
|
969
999
|
"no-alert": "off",
|
|
970
1000
|
"no-console": "off",
|
|
1001
|
+
"no-labels": "off",
|
|
1002
|
+
"no-lone-blocks": "off",
|
|
1003
|
+
"no-restricted-syntax": "off",
|
|
971
1004
|
"no-undef": "off",
|
|
972
1005
|
"no-unused-expressions": "off",
|
|
1006
|
+
"no-unused-labels": "off",
|
|
973
1007
|
"no-unused-vars": "off",
|
|
974
1008
|
"node/prefer-global/process": "off",
|
|
975
1009
|
"style/comma-dangle": "off",
|
|
976
1010
|
"style/eol-last": "off",
|
|
977
|
-
// Type aware rules
|
|
978
|
-
"ts/await-thenable": "off",
|
|
979
1011
|
"ts/consistent-type-imports": "off",
|
|
980
|
-
"ts/dot-notation": "off",
|
|
981
|
-
"ts/no-floating-promises": "off",
|
|
982
|
-
"ts/no-for-in-array": "off",
|
|
983
|
-
"ts/no-implied-eval": "off",
|
|
984
|
-
"ts/no-misused-promises": "off",
|
|
985
1012
|
"ts/no-namespace": "off",
|
|
986
1013
|
"ts/no-redeclare": "off",
|
|
987
1014
|
"ts/no-require-imports": "off",
|
|
988
|
-
"ts/no-
|
|
989
|
-
"ts/no-unnecessary-type-assertion": "off",
|
|
990
|
-
"ts/no-unsafe-argument": "off",
|
|
991
|
-
"ts/no-unsafe-assignment": "off",
|
|
992
|
-
"ts/no-unsafe-call": "off",
|
|
993
|
-
"ts/no-unsafe-member-access": "off",
|
|
994
|
-
"ts/no-unsafe-return": "off",
|
|
1015
|
+
"ts/no-unused-expressions": "off",
|
|
995
1016
|
"ts/no-unused-vars": "off",
|
|
996
1017
|
"ts/no-use-before-define": "off",
|
|
997
1018
|
"ts/no-var-requires": "off",
|
|
998
|
-
"ts/restrict-plus-operands": "off",
|
|
999
|
-
"ts/restrict-template-expressions": "off",
|
|
1000
|
-
"ts/unbound-method": "off",
|
|
1001
1019
|
"unicode-bom": "off",
|
|
1002
1020
|
"unused-imports/no-unused-imports": "off",
|
|
1003
1021
|
"unused-imports/no-unused-vars": "off",
|
|
@@ -1063,14 +1081,20 @@ async function typescript(options = {}) {
|
|
|
1063
1081
|
const {
|
|
1064
1082
|
exts = [],
|
|
1065
1083
|
overrides = {},
|
|
1066
|
-
parserOptions = {}
|
|
1084
|
+
parserOptions = {},
|
|
1085
|
+
type = "app"
|
|
1067
1086
|
} = options ?? {};
|
|
1068
1087
|
const files = options.files ?? [
|
|
1069
|
-
|
|
1088
|
+
GLOB_TS,
|
|
1089
|
+
GLOB_TSX,
|
|
1070
1090
|
...exts.map((ext) => `**/*.${ext}`)
|
|
1071
1091
|
];
|
|
1072
|
-
const filesTypeAware = options.
|
|
1073
|
-
const
|
|
1092
|
+
const filesTypeAware = options.filesTypeAware ?? [GLOB_TS, GLOB_TSX];
|
|
1093
|
+
const ignoresTypeAware = options.ignoresTypeAware ?? [
|
|
1094
|
+
`${GLOB_MARKDOWN}/**`,
|
|
1095
|
+
GLOB_ASTRO_TS
|
|
1096
|
+
];
|
|
1097
|
+
const tsconfigPath = options?.tsconfigPath ? options.tsconfigPath : void 0;
|
|
1074
1098
|
const isTypeAware = !!tsconfigPath;
|
|
1075
1099
|
const typeAwareRules = {
|
|
1076
1100
|
"dot-notation": "off",
|
|
@@ -1134,7 +1158,7 @@ async function typescript(options = {}) {
|
|
|
1134
1158
|
}
|
|
1135
1159
|
},
|
|
1136
1160
|
...isTypeAware ? [
|
|
1137
|
-
makeParser(true, filesTypeAware),
|
|
1161
|
+
makeParser(true, filesTypeAware, ignoresTypeAware),
|
|
1138
1162
|
makeParser(false, files, filesTypeAware)
|
|
1139
1163
|
] : [makeParser(false, files)],
|
|
1140
1164
|
{
|
|
@@ -1143,13 +1167,15 @@ async function typescript(options = {}) {
|
|
|
1143
1167
|
rules: {
|
|
1144
1168
|
...renameRules(
|
|
1145
1169
|
pluginTs.configs["eslint-recommended"].overrides[0].rules,
|
|
1146
|
-
|
|
1147
|
-
|
|
1170
|
+
{
|
|
1171
|
+
"@typescript-eslint": "ts"
|
|
1172
|
+
}
|
|
1148
1173
|
),
|
|
1149
1174
|
...renameRules(
|
|
1150
1175
|
pluginTs.configs.strict.rules,
|
|
1151
|
-
|
|
1152
|
-
|
|
1176
|
+
{
|
|
1177
|
+
"@typescript-eslint": "ts"
|
|
1178
|
+
}
|
|
1153
1179
|
),
|
|
1154
1180
|
"no-dupe-class-members": "off",
|
|
1155
1181
|
"no-invalid-this": "off",
|
|
@@ -1191,20 +1217,25 @@ async function typescript(options = {}) {
|
|
|
1191
1217
|
"ts/no-wrapper-object-types": "error",
|
|
1192
1218
|
"ts/triple-slash-reference": "off",
|
|
1193
1219
|
"ts/unified-signatures": "off",
|
|
1220
|
+
...type === "lib" ? {
|
|
1221
|
+
"ts/explicit-function-return-type": ["error", {
|
|
1222
|
+
allowExpressions: true,
|
|
1223
|
+
allowHigherOrderFunctions: true,
|
|
1224
|
+
allowIIFEs: true
|
|
1225
|
+
}]
|
|
1226
|
+
} : {},
|
|
1194
1227
|
...overrides
|
|
1195
1228
|
}
|
|
1196
1229
|
},
|
|
1197
|
-
{
|
|
1198
|
-
name: "luxass/typescript/rules-type-aware",
|
|
1230
|
+
...isTypeAware ? [{
|
|
1199
1231
|
files: filesTypeAware,
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
},
|
|
1232
|
+
ignores: ignoresTypeAware,
|
|
1233
|
+
name: "luxass/typescript/rules-type-aware",
|
|
1234
|
+
rules: typeAwareRules
|
|
1235
|
+
}] : [],
|
|
1205
1236
|
{
|
|
1206
1237
|
name: "luxass/typescript/disables/dts",
|
|
1207
|
-
files: ["**/*.d
|
|
1238
|
+
files: ["**/*.d.?([cm])ts"],
|
|
1208
1239
|
rules: {
|
|
1209
1240
|
"eslint-comments/no-unlimited-disable": "off",
|
|
1210
1241
|
"import/no-duplicates": "off",
|
|
@@ -1213,21 +1244,14 @@ async function typescript(options = {}) {
|
|
|
1213
1244
|
}
|
|
1214
1245
|
},
|
|
1215
1246
|
{
|
|
1216
|
-
name: "luxass/typescript/disables/tests",
|
|
1217
1247
|
files: ["**/*.{test,spec}.ts?(x)"],
|
|
1248
|
+
name: "luxass/typescript/disables/test",
|
|
1218
1249
|
rules: {
|
|
1219
1250
|
"no-unused-expressions": "off"
|
|
1220
1251
|
}
|
|
1221
1252
|
},
|
|
1222
1253
|
{
|
|
1223
|
-
name: "luxass/typescript/disables/
|
|
1224
|
-
files: [`**/playground.${GLOB_SRC_EXT}`],
|
|
1225
|
-
rules: {
|
|
1226
|
-
"no-console": "off"
|
|
1227
|
-
}
|
|
1228
|
-
},
|
|
1229
|
-
{
|
|
1230
|
-
name: "luxass/typescript/disables/javascript",
|
|
1254
|
+
name: "luxass/typescript/disables/cjs",
|
|
1231
1255
|
files: ["**/*.js", "**/*.cjs"],
|
|
1232
1256
|
rules: {
|
|
1233
1257
|
"ts/no-require-imports": "off",
|
|
@@ -1530,6 +1554,7 @@ async function test(options = {}) {
|
|
|
1530
1554
|
"test/no-focused-tests": editor ? "off" : "error",
|
|
1531
1555
|
"test/prefer-hooks-in-order": "error",
|
|
1532
1556
|
"test/prefer-lowercase-title": "error",
|
|
1557
|
+
"ts/explicit-function-return-type": "off",
|
|
1533
1558
|
...overrides
|
|
1534
1559
|
}
|
|
1535
1560
|
}
|
|
@@ -2184,7 +2209,8 @@ function luxass(options = {}, ...userConfigs) {
|
|
|
2184
2209
|
typescript: enableTypeScript = isPackageExists4("typescript"),
|
|
2185
2210
|
unocss: enableUnoCSS = false,
|
|
2186
2211
|
tailwindcss: enableTailwindCSS = false,
|
|
2187
|
-
vue: enableVue = VuePackages.some((i) => isPackageExists4(i))
|
|
2212
|
+
vue: enableVue = VuePackages.some((i) => isPackageExists4(i)),
|
|
2213
|
+
type: projectType = "app"
|
|
2188
2214
|
} = options;
|
|
2189
2215
|
const stylisticOptions = options.stylistic === false ? false : typeof options.stylistic === "object" ? options.stylistic : {};
|
|
2190
2216
|
if (stylisticOptions && !("jsx" in stylisticOptions)) {
|
|
@@ -2228,7 +2254,8 @@ function luxass(options = {}, ...userConfigs) {
|
|
|
2228
2254
|
configs2.push(typescript({
|
|
2229
2255
|
...typescriptOptions,
|
|
2230
2256
|
exts,
|
|
2231
|
-
overrides: getOverrides(options, "typescript")
|
|
2257
|
+
overrides: getOverrides(options, "typescript"),
|
|
2258
|
+
type: projectType
|
|
2232
2259
|
}));
|
|
2233
2260
|
}
|
|
2234
2261
|
if (stylisticOptions) {
|
|
@@ -2346,6 +2373,7 @@ function luxass(options = {}, ...userConfigs) {
|
|
|
2346
2373
|
var src_default = luxass;
|
|
2347
2374
|
export {
|
|
2348
2375
|
GLOB_ASTRO,
|
|
2376
|
+
GLOB_ASTRO_TS,
|
|
2349
2377
|
GLOB_CSS,
|
|
2350
2378
|
GLOB_EXCLUDE,
|
|
2351
2379
|
GLOB_GRAPHQL,
|
|
@@ -2393,6 +2421,7 @@ export {
|
|
|
2393
2421
|
parserPlain,
|
|
2394
2422
|
react,
|
|
2395
2423
|
regexp,
|
|
2424
|
+
renamePluginInConfigs,
|
|
2396
2425
|
renameRules,
|
|
2397
2426
|
resolveSubOptions,
|
|
2398
2427
|
sortPackageJson,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@luxass/eslint-config",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.10.1",
|
|
4
4
|
"description": "ESLint config for @luxass",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": {
|
|
@@ -8,11 +8,11 @@
|
|
|
8
8
|
"email": "lucasnrgaard@gmail.com",
|
|
9
9
|
"url": "https://luxass.dev"
|
|
10
10
|
},
|
|
11
|
-
"packageManager": "pnpm@9.
|
|
11
|
+
"packageManager": "pnpm@9.6.0",
|
|
12
12
|
"license": "MIT",
|
|
13
13
|
"repository": {
|
|
14
14
|
"type": "git",
|
|
15
|
-
"url": "https://github.com/luxass/eslint-config.git"
|
|
15
|
+
"url": "git+https://github.com/luxass/eslint-config.git"
|
|
16
16
|
},
|
|
17
17
|
"keywords": [
|
|
18
18
|
"eslint",
|
|
@@ -92,22 +92,22 @@
|
|
|
92
92
|
"@antfu/install-pkg": "^0.3.3",
|
|
93
93
|
"@clack/prompts": "^0.7.0",
|
|
94
94
|
"@eslint-community/eslint-plugin-eslint-comments": "^4.3.0",
|
|
95
|
-
"@stylistic/eslint-plugin": "^2.6.0-beta.
|
|
96
|
-
"@typescript-eslint/eslint-plugin": "8.0.0-alpha.
|
|
97
|
-
"@typescript-eslint/parser": "8.0.0-alpha.
|
|
98
|
-
"eslint-config-flat-gitignore": "^0.1.
|
|
99
|
-
"eslint-flat-config-utils": "^0.
|
|
95
|
+
"@stylistic/eslint-plugin": "^2.6.0-beta.1",
|
|
96
|
+
"@typescript-eslint/eslint-plugin": "8.0.0-alpha.54",
|
|
97
|
+
"@typescript-eslint/parser": "8.0.0-alpha.54",
|
|
98
|
+
"eslint-config-flat-gitignore": "^0.1.8",
|
|
99
|
+
"eslint-flat-config-utils": "^0.3.0",
|
|
100
100
|
"eslint-merge-processors": "^0.1.0",
|
|
101
101
|
"eslint-plugin-antfu": "^2.3.4",
|
|
102
|
-
"eslint-plugin-import-x": "^
|
|
103
|
-
"eslint-plugin-jsdoc": "^48.
|
|
102
|
+
"eslint-plugin-import-x": "^3.1.0",
|
|
103
|
+
"eslint-plugin-jsdoc": "^48.8.3",
|
|
104
104
|
"eslint-plugin-jsonc": "^2.16.0",
|
|
105
|
-
"eslint-plugin-markdown": "^5.
|
|
106
|
-
"eslint-plugin-n": "^17.
|
|
105
|
+
"eslint-plugin-markdown": "^5.1.0",
|
|
106
|
+
"eslint-plugin-n": "^17.10.1",
|
|
107
107
|
"eslint-plugin-regexp": "^2.6.0",
|
|
108
108
|
"eslint-plugin-toml": "^0.11.1",
|
|
109
|
-
"eslint-plugin-unicorn": "^
|
|
110
|
-
"eslint-plugin-unused-imports": "^4.0.
|
|
109
|
+
"eslint-plugin-unicorn": "^55.0.0",
|
|
110
|
+
"eslint-plugin-unused-imports": "^4.0.1",
|
|
111
111
|
"eslint-plugin-vitest": "^0.5.4",
|
|
112
112
|
"eslint-plugin-vue": "^9.27.0",
|
|
113
113
|
"eslint-plugin-yml": "^1.14.0",
|
|
@@ -121,37 +121,29 @@
|
|
|
121
121
|
"yaml-eslint-parser": "^1.2.3"
|
|
122
122
|
},
|
|
123
123
|
"devDependencies": {
|
|
124
|
-
"@eslint-react/eslint-plugin": "^1.
|
|
125
|
-
"@eslint/config-inspector": "^0.5.
|
|
126
|
-
"@stylistic/eslint-plugin-migrate": "^2.
|
|
127
|
-
"@types/eslint": "^
|
|
124
|
+
"@eslint-react/eslint-plugin": "^1.6.0",
|
|
125
|
+
"@eslint/config-inspector": "^0.5.2",
|
|
126
|
+
"@stylistic/eslint-plugin-migrate": "^2.4.0",
|
|
127
|
+
"@types/eslint": "^9.6.0",
|
|
128
128
|
"@types/estree": "^1.0.5",
|
|
129
|
-
"@types/node": "^20.14.
|
|
130
|
-
"@typescript-eslint/rule-tester": "^7.
|
|
131
|
-
"@unocss/eslint-plugin": "^0.61.
|
|
129
|
+
"@types/node": "^20.14.12",
|
|
130
|
+
"@typescript-eslint/rule-tester": "^7.17.0",
|
|
131
|
+
"@unocss/eslint-plugin": "^0.61.6",
|
|
132
132
|
"astro-eslint-parser": "^1.0.2",
|
|
133
|
-
"eslint": "^9.
|
|
134
|
-
"eslint-plugin-astro": "^1.2.
|
|
133
|
+
"eslint": "^9.8.0",
|
|
134
|
+
"eslint-plugin-astro": "^1.2.3",
|
|
135
135
|
"eslint-plugin-format": "^0.1.2",
|
|
136
136
|
"eslint-plugin-react-hooks": "^4.6.2",
|
|
137
|
-
"eslint-plugin-react-refresh": "^0.4.
|
|
137
|
+
"eslint-plugin-react-refresh": "^0.4.9",
|
|
138
138
|
"eslint-plugin-tailwindcss": "^3.17.4",
|
|
139
|
-
"eslint-typegen": "^0.
|
|
139
|
+
"eslint-typegen": "^0.3.0",
|
|
140
140
|
"jiti": "^1.21.6",
|
|
141
|
-
"
|
|
142
|
-
"
|
|
143
|
-
"
|
|
144
|
-
"
|
|
145
|
-
"
|
|
146
|
-
"
|
|
147
|
-
"
|
|
148
|
-
"vitest": "^1.6.0",
|
|
149
|
-
"vue": "^3.4.31"
|
|
150
|
-
},
|
|
151
|
-
"simple-git-hooks": {
|
|
152
|
-
"pre-commit": "pnpm lint-staged"
|
|
153
|
-
},
|
|
154
|
-
"lint-staged": {
|
|
155
|
-
"*": "eslint --fix"
|
|
141
|
+
"prettier-plugin-astro": "^0.14.1",
|
|
142
|
+
"tailwindcss": "^3.4.7",
|
|
143
|
+
"tsup": "^8.2.3",
|
|
144
|
+
"typescript": "^5.5.4",
|
|
145
|
+
"unocss": "^0.61.6",
|
|
146
|
+
"vitest": "^2.0.4",
|
|
147
|
+
"vue": "^3.4.34"
|
|
156
148
|
}
|
|
157
149
|
}
|