@cany748/eslint-config 3.0.3 → 3.0.5
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.d.ts +661 -507
- package/dist/index.js +106 -77
- package/package.json +36 -38
- package/dist/index.cjs +0 -1323
- package/dist/index.d.cts +0 -10765
package/dist/index.js
CHANGED
|
@@ -15,10 +15,6 @@ function comments() {
|
|
|
15
15
|
];
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
// src/configs/formatters.ts
|
|
19
|
-
import pluginPrettier from "eslint-plugin-prettier";
|
|
20
|
-
import configPrettier from "eslint-plugin-prettier/recommended";
|
|
21
|
-
|
|
22
18
|
// src/globs.ts
|
|
23
19
|
var GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
|
|
24
20
|
var GLOB_SRC = "**/*.?([cm])[jt]s?(x)";
|
|
@@ -104,6 +100,63 @@ var GLOB_EXCLUDE = [
|
|
|
104
100
|
"**/components.d.ts"
|
|
105
101
|
];
|
|
106
102
|
|
|
103
|
+
// src/configs/disables.ts
|
|
104
|
+
function disables() {
|
|
105
|
+
return [
|
|
106
|
+
{
|
|
107
|
+
files: [`**/scripts/${GLOB_SRC}`],
|
|
108
|
+
name: "disables/scripts",
|
|
109
|
+
rules: {
|
|
110
|
+
"no-console": "off",
|
|
111
|
+
"@typescript-eslint/explicit-function-return-type": "off"
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
files: [`**/cli/${GLOB_SRC}`, `**/cli.${GLOB_SRC_EXT}`],
|
|
116
|
+
name: "disables/cli",
|
|
117
|
+
rules: {
|
|
118
|
+
"no-console": "off"
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
files: ["**/*.d.?([cm])ts"],
|
|
123
|
+
name: "disables/dts",
|
|
124
|
+
rules: {
|
|
125
|
+
"@eslint-community/eslint-comments/no-unlimited-disable": "off",
|
|
126
|
+
"import/no-duplicates": "off",
|
|
127
|
+
"no-restricted-syntax": "off",
|
|
128
|
+
"unused-imports/no-unused-vars": "off"
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
files: ["**/*.{test,spec}.([tj])s?(x)"],
|
|
133
|
+
name: "disables/test",
|
|
134
|
+
rules: {
|
|
135
|
+
"no-unused-expressions": "off"
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
files: ["**/*.js", "**/*.cjs"],
|
|
140
|
+
name: "disables/cjs",
|
|
141
|
+
rules: {
|
|
142
|
+
"@typescript-eslint/no-require-imports": "off"
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
files: [`**/*.config.${GLOB_SRC_EXT}`, `**/*.config.*.${GLOB_SRC_EXT}`],
|
|
147
|
+
name: "disables/config-files",
|
|
148
|
+
rules: {
|
|
149
|
+
"no-console": "off",
|
|
150
|
+
"@typescript-eslint/explicit-function-return-type": "off"
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
];
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// src/configs/formatters.ts
|
|
157
|
+
import pluginPrettier from "eslint-plugin-prettier";
|
|
158
|
+
import configPrettier from "eslint-plugin-prettier/recommended";
|
|
159
|
+
|
|
107
160
|
// src/utils.ts
|
|
108
161
|
var parserPlain = {
|
|
109
162
|
meta: {
|
|
@@ -136,8 +189,14 @@ async function interopDefault(m) {
|
|
|
136
189
|
const resolved = await m;
|
|
137
190
|
return resolved.default || resolved;
|
|
138
191
|
}
|
|
192
|
+
function isInGitHooksOrLintStaged() {
|
|
193
|
+
return !!// eslint-disable-next-line no-constant-binary-expression
|
|
194
|
+
(process.env.GIT_PARAMS || process.env.VSCODE_GIT_COMMAND || process.env.npm_lifecycle_script?.startsWith("lint-staged"));
|
|
195
|
+
}
|
|
139
196
|
function isInEditorEnv() {
|
|
140
|
-
|
|
197
|
+
if (process.env.CI) return false;
|
|
198
|
+
if (isInGitHooksOrLintStaged()) return false;
|
|
199
|
+
return !!(process.env.VSCODE_PID || process.env.VSCODE_CWD || process.env.JETBRAINS_IDE || process.env.VIM || process.env.NVIM);
|
|
141
200
|
}
|
|
142
201
|
|
|
143
202
|
// src/configs/formatters.ts
|
|
@@ -233,10 +292,10 @@ function formatters(options = true) {
|
|
|
233
292
|
}
|
|
234
293
|
|
|
235
294
|
// src/configs/ignores.ts
|
|
236
|
-
function ignores() {
|
|
295
|
+
function ignores(userIgnores = []) {
|
|
237
296
|
return [
|
|
238
297
|
{
|
|
239
|
-
ignores: GLOB_EXCLUDE
|
|
298
|
+
ignores: [...GLOB_EXCLUDE, ...userIgnores]
|
|
240
299
|
}
|
|
241
300
|
];
|
|
242
301
|
}
|
|
@@ -440,13 +499,7 @@ function javascript(options = {}) {
|
|
|
440
499
|
allowUnboundThis: true
|
|
441
500
|
}
|
|
442
501
|
],
|
|
443
|
-
"prefer-const": [
|
|
444
|
-
"error",
|
|
445
|
-
{
|
|
446
|
-
destructuring: "all",
|
|
447
|
-
ignoreReadBeforeAssign: true
|
|
448
|
-
}
|
|
449
|
-
],
|
|
502
|
+
"prefer-const": isInEditor ? "warn" : ["error", { destructuring: "all", ignoreReadBeforeAssign: true }],
|
|
450
503
|
"prefer-exponentiation-operator": "error",
|
|
451
504
|
"prefer-promise-reject-errors": "error",
|
|
452
505
|
"prefer-regex-literals": ["error", { disallowRedundantWrapping: true }],
|
|
@@ -467,7 +520,7 @@ function javascript(options = {}) {
|
|
|
467
520
|
],
|
|
468
521
|
"symbol-description": "error",
|
|
469
522
|
"unicode-bom": ["error", "never"],
|
|
470
|
-
"unused-imports/no-unused-imports": isInEditor ? "
|
|
523
|
+
"unused-imports/no-unused-imports": isInEditor ? "warn" : "error",
|
|
471
524
|
"unused-imports/no-unused-vars": [
|
|
472
525
|
"error",
|
|
473
526
|
{
|
|
@@ -484,20 +537,6 @@ function javascript(options = {}) {
|
|
|
484
537
|
yoda: ["error", "never"],
|
|
485
538
|
...overrides
|
|
486
539
|
}
|
|
487
|
-
},
|
|
488
|
-
{
|
|
489
|
-
files: [`scripts/${GLOB_SRC}`, `cli.${GLOB_SRC_EXT}`],
|
|
490
|
-
name: "javascript/disables/cli",
|
|
491
|
-
rules: {
|
|
492
|
-
"no-console": "off"
|
|
493
|
-
}
|
|
494
|
-
},
|
|
495
|
-
{
|
|
496
|
-
files: ["**/*.{test,spec}.js?(x)"],
|
|
497
|
-
name: "javascript/disables/test",
|
|
498
|
-
rules: {
|
|
499
|
-
"no-unused-expressions": "off"
|
|
500
|
-
}
|
|
501
540
|
}
|
|
502
541
|
];
|
|
503
542
|
}
|
|
@@ -555,6 +594,23 @@ function node() {
|
|
|
555
594
|
];
|
|
556
595
|
}
|
|
557
596
|
|
|
597
|
+
// src/configs/regexp.ts
|
|
598
|
+
import { configs } from "eslint-plugin-regexp";
|
|
599
|
+
function regexp(options = {}) {
|
|
600
|
+
const config = configs["flat/recommended"];
|
|
601
|
+
return [
|
|
602
|
+
{
|
|
603
|
+
...config,
|
|
604
|
+
name: "regexp",
|
|
605
|
+
rules: {
|
|
606
|
+
...config.rules,
|
|
607
|
+
"regexp/no-obscure-range": "off",
|
|
608
|
+
...options.overrides
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
];
|
|
612
|
+
}
|
|
613
|
+
|
|
558
614
|
// src/configs/sort.ts
|
|
559
615
|
function sortPackageJson() {
|
|
560
616
|
return [
|
|
@@ -801,9 +857,11 @@ async function test(options = {}) {
|
|
|
801
857
|
"test/consistent-test-it": ["error", { fn: "it", withinDescribe: "it" }],
|
|
802
858
|
"test/no-identical-title": "error",
|
|
803
859
|
"test/no-import-node-test": "error",
|
|
804
|
-
"test/no-only-tests": isInEditor ? "
|
|
860
|
+
"test/no-only-tests": isInEditor ? "warn" : "error",
|
|
805
861
|
"test/prefer-hooks-in-order": "error",
|
|
806
862
|
"test/prefer-lowercase-title": "error",
|
|
863
|
+
"no-unused-expressions": "off",
|
|
864
|
+
"n/prefer-global/process": "off",
|
|
807
865
|
"@typescript-eslint/explicit-function-return-type": "off",
|
|
808
866
|
...overrides
|
|
809
867
|
}
|
|
@@ -883,7 +941,7 @@ async function typescript(options = {}) {
|
|
|
883
941
|
"no-invalid-this": "off",
|
|
884
942
|
"@typescript-eslint/no-invalid-this": "error",
|
|
885
943
|
"no-redeclare": "off",
|
|
886
|
-
"@typescript-eslint/no-redeclare": "error",
|
|
944
|
+
"@typescript-eslint/no-redeclare": ["error", { builtinGlobals: false }],
|
|
887
945
|
"no-unused-expressions": "off",
|
|
888
946
|
"@typescript-eslint/no-unused-expressions": ["error", { allowShortCircuit: true, allowTernary: true, allowTaggedTemplates: true }],
|
|
889
947
|
"no-use-before-define": "off",
|
|
@@ -921,32 +979,7 @@ async function typescript(options = {}) {
|
|
|
921
979
|
...overridesTypeAware
|
|
922
980
|
}
|
|
923
981
|
}
|
|
924
|
-
] : []
|
|
925
|
-
{
|
|
926
|
-
files: ["**/*.d.?([cm])ts"],
|
|
927
|
-
name: "typescript/disables/dts",
|
|
928
|
-
rules: {
|
|
929
|
-
"eslint-comments/no-unlimited-disable": "off",
|
|
930
|
-
"import/no-duplicates": "off",
|
|
931
|
-
"no-restricted-syntax": "off",
|
|
932
|
-
"unused-imports/no-unused-vars": "off"
|
|
933
|
-
}
|
|
934
|
-
},
|
|
935
|
-
{
|
|
936
|
-
files: ["**/*.{test,spec}.ts?(x)"],
|
|
937
|
-
name: "typescript/disables/test",
|
|
938
|
-
rules: {
|
|
939
|
-
"no-unused-expressions": "off"
|
|
940
|
-
}
|
|
941
|
-
},
|
|
942
|
-
{
|
|
943
|
-
files: ["**/*.js", "**/*.cjs"],
|
|
944
|
-
name: "typescript/disables/cjs",
|
|
945
|
-
rules: {
|
|
946
|
-
"@typescript-eslint/no-require-imports": "off",
|
|
947
|
-
"@typescript-eslint/no-var-requires": "off"
|
|
948
|
-
}
|
|
949
|
-
}
|
|
982
|
+
] : []
|
|
950
983
|
];
|
|
951
984
|
}
|
|
952
985
|
|
|
@@ -967,6 +1000,7 @@ function unicorn() {
|
|
|
967
1000
|
"unicorn/no-array-callback-reference": "off",
|
|
968
1001
|
"unicorn/no-null": "off",
|
|
969
1002
|
"unicorn/prefer-string-replace-all": "off",
|
|
1003
|
+
"unicorn/prefer-structured-clone": "off",
|
|
970
1004
|
"unicorn/prefer-top-level-await": "off",
|
|
971
1005
|
"unicorn/prevent-abbreviations": "off"
|
|
972
1006
|
}
|
|
@@ -1065,35 +1099,18 @@ async function vue(options = {}) {
|
|
|
1065
1099
|
"vue/prefer-template": "error",
|
|
1066
1100
|
"vue/padding-line-between-blocks": ["error", "always"],
|
|
1067
1101
|
"vue/component-tags-order": "off",
|
|
1102
|
+
"@typescript-eslint/explicit-function-return-type": "off",
|
|
1068
1103
|
...overrides
|
|
1069
1104
|
}
|
|
1070
1105
|
}
|
|
1071
1106
|
];
|
|
1072
1107
|
}
|
|
1073
1108
|
|
|
1074
|
-
// src/configs/regexp.ts
|
|
1075
|
-
import { configs } from "eslint-plugin-regexp";
|
|
1076
|
-
function regexp(options = {}) {
|
|
1077
|
-
const config = configs["flat/recommended"];
|
|
1078
|
-
return [
|
|
1079
|
-
{
|
|
1080
|
-
...config,
|
|
1081
|
-
name: "regexp",
|
|
1082
|
-
rules: {
|
|
1083
|
-
...config.rules,
|
|
1084
|
-
...options.overrides
|
|
1085
|
-
}
|
|
1086
|
-
}
|
|
1087
|
-
];
|
|
1088
|
-
}
|
|
1089
|
-
|
|
1090
1109
|
// src/factory.ts
|
|
1091
1110
|
import { isPackageExists } from "local-pkg";
|
|
1092
1111
|
import { FlatConfigComposer } from "eslint-flat-config-utils";
|
|
1093
1112
|
var flatConfigProps = [
|
|
1094
1113
|
"name",
|
|
1095
|
-
"files",
|
|
1096
|
-
"ignores",
|
|
1097
1114
|
"languageOptions",
|
|
1098
1115
|
"linterOptions",
|
|
1099
1116
|
"processor",
|
|
@@ -1107,7 +1124,6 @@ var factoryConfig = function(options = {}, ...userConfigs) {
|
|
|
1107
1124
|
componentExts = [],
|
|
1108
1125
|
formatters: enableFormatters = true,
|
|
1109
1126
|
gitignore: enableGitignore = true,
|
|
1110
|
-
isInEditor = isInEditorEnv(),
|
|
1111
1127
|
jsonc: enableJSONC = true,
|
|
1112
1128
|
regexp: enableRegexp = true,
|
|
1113
1129
|
test: enableTest = true,
|
|
@@ -1115,6 +1131,11 @@ var factoryConfig = function(options = {}, ...userConfigs) {
|
|
|
1115
1131
|
unocss: enableUnoCSS = isPackageExists("unocss"),
|
|
1116
1132
|
vue: enableVue = VuePackages.some((i) => isPackageExists(i))
|
|
1117
1133
|
} = options;
|
|
1134
|
+
let isInEditor = options.isInEditor;
|
|
1135
|
+
if (isInEditor == null) {
|
|
1136
|
+
isInEditor = isInEditorEnv();
|
|
1137
|
+
if (isInEditor) console.log("[@cany748/eslint-config] Detected running in editor, some rules are disabled.");
|
|
1138
|
+
}
|
|
1118
1139
|
const configs2 = [];
|
|
1119
1140
|
if (enableGitignore) {
|
|
1120
1141
|
if (typeof enableGitignore === "boolean") {
|
|
@@ -1125,7 +1146,7 @@ var factoryConfig = function(options = {}, ...userConfigs) {
|
|
|
1125
1146
|
}
|
|
1126
1147
|
configs2.push(
|
|
1127
1148
|
comments(),
|
|
1128
|
-
ignores(),
|
|
1149
|
+
ignores(options.ignores),
|
|
1129
1150
|
imports(),
|
|
1130
1151
|
javascript({
|
|
1131
1152
|
isInEditor,
|
|
@@ -1174,6 +1195,12 @@ var factoryConfig = function(options = {}, ...userConfigs) {
|
|
|
1174
1195
|
if (enableFormatters) {
|
|
1175
1196
|
configs2.push(formatters(enableFormatters));
|
|
1176
1197
|
}
|
|
1198
|
+
configs2.push(disables());
|
|
1199
|
+
if ("files" in options) {
|
|
1200
|
+
throw new Error(
|
|
1201
|
+
'[@cany748/eslint-config] The first argument should not contain the "files" property as the options are supposed to be global. Place it in the second or later config instead.'
|
|
1202
|
+
);
|
|
1203
|
+
}
|
|
1177
1204
|
const fusedConfig = flatConfigProps.reduce((acc, key) => {
|
|
1178
1205
|
if (key in options) acc[key] = options[key];
|
|
1179
1206
|
return acc;
|
|
@@ -1215,12 +1242,14 @@ export {
|
|
|
1215
1242
|
GLOB_YAML,
|
|
1216
1243
|
combine,
|
|
1217
1244
|
comments,
|
|
1245
|
+
disables,
|
|
1218
1246
|
factoryConfig,
|
|
1219
1247
|
formatters,
|
|
1220
1248
|
ignores,
|
|
1221
1249
|
imports,
|
|
1222
1250
|
interopDefault,
|
|
1223
1251
|
isInEditorEnv,
|
|
1252
|
+
isInGitHooksOrLintStaged,
|
|
1224
1253
|
javascript,
|
|
1225
1254
|
jsonc,
|
|
1226
1255
|
node,
|
package/package.json
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cany748/eslint-config",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "3.0.
|
|
4
|
+
"version": "3.0.5",
|
|
5
5
|
"exports": {
|
|
6
|
-
".":
|
|
7
|
-
"import": "./dist/index.js",
|
|
8
|
-
"require": "./dist/index.cjs"
|
|
9
|
-
}
|
|
6
|
+
".": "./dist/index.js"
|
|
10
7
|
},
|
|
11
8
|
"main": "./dist/index.js",
|
|
12
9
|
"types": "./dist/index.d.ts",
|
|
@@ -14,9 +11,9 @@
|
|
|
14
11
|
"dist"
|
|
15
12
|
],
|
|
16
13
|
"peerDependencies": {
|
|
17
|
-
"@unocss/eslint-plugin": "^
|
|
18
|
-
"eslint-plugin-vue": "^9.
|
|
19
|
-
"typescript-eslint": "^8.
|
|
14
|
+
"@unocss/eslint-plugin": "^65.5.0",
|
|
15
|
+
"eslint-plugin-vue": "^9.32.0",
|
|
16
|
+
"typescript-eslint": "^8.25.0"
|
|
20
17
|
},
|
|
21
18
|
"peerDependenciesMeta": {
|
|
22
19
|
"@unocss/eslint-plugin": {
|
|
@@ -30,50 +27,51 @@
|
|
|
30
27
|
}
|
|
31
28
|
},
|
|
32
29
|
"dependencies": {
|
|
33
|
-
"@eslint-community/eslint-plugin-eslint-comments": "^4.4.
|
|
34
|
-
"@vitest/eslint-plugin": "^1.1.
|
|
35
|
-
"eslint": "^9.
|
|
36
|
-
"eslint-config-flat-gitignore": "^
|
|
37
|
-
"eslint-config-prettier": "^
|
|
38
|
-
"eslint-flat-config-utils": "^0.
|
|
39
|
-
"eslint-plugin-import-x": "^4.
|
|
40
|
-
"eslint-plugin-jsonc": "^2.
|
|
41
|
-
"eslint-plugin-n": "^17.
|
|
30
|
+
"@eslint-community/eslint-plugin-eslint-comments": "^4.4.1",
|
|
31
|
+
"@vitest/eslint-plugin": "^1.1.35",
|
|
32
|
+
"eslint": "^9.21.0",
|
|
33
|
+
"eslint-config-flat-gitignore": "^2.1.0",
|
|
34
|
+
"eslint-config-prettier": "^10.0.2",
|
|
35
|
+
"eslint-flat-config-utils": "^2.0.1",
|
|
36
|
+
"eslint-plugin-import-x": "^4.6.1",
|
|
37
|
+
"eslint-plugin-jsonc": "^2.19.1",
|
|
38
|
+
"eslint-plugin-n": "^17.15.1",
|
|
42
39
|
"eslint-plugin-no-only-tests": "^3.3.0",
|
|
43
|
-
"eslint-plugin-prettier": "^5.2.
|
|
44
|
-
"eslint-plugin-regexp": "^2.
|
|
45
|
-
"eslint-plugin-unicorn": "^
|
|
46
|
-
"eslint-plugin-unused-imports": "^4.1.
|
|
47
|
-
"globals": "^
|
|
40
|
+
"eslint-plugin-prettier": "^5.2.3",
|
|
41
|
+
"eslint-plugin-regexp": "^2.7.0",
|
|
42
|
+
"eslint-plugin-unicorn": "^57.0.0",
|
|
43
|
+
"eslint-plugin-unused-imports": "^4.1.4",
|
|
44
|
+
"globals": "^16.0.0",
|
|
45
|
+
"jiti": "^2.4.2",
|
|
48
46
|
"jsonc-eslint-parser": "^2.4.0",
|
|
49
|
-
"local-pkg": "^
|
|
50
|
-
"prettier": "^3.
|
|
47
|
+
"local-pkg": "^1.1.0",
|
|
48
|
+
"prettier": "^3.5.2"
|
|
51
49
|
},
|
|
52
50
|
"devDependencies": {
|
|
53
|
-
"@types/node": "^22.5
|
|
54
|
-
"@unocss/eslint-plugin": "^
|
|
55
|
-
"bumpp": "^
|
|
56
|
-
"eslint-plugin-vue": "^9.
|
|
57
|
-
"eslint-typegen": "^0.
|
|
58
|
-
"esno": "^4.
|
|
59
|
-
"lint-staged": "^15.
|
|
51
|
+
"@types/node": "^22.13.5",
|
|
52
|
+
"@unocss/eslint-plugin": "^65.5.0",
|
|
53
|
+
"bumpp": "^10.0.3",
|
|
54
|
+
"eslint-plugin-vue": "^9.32.0",
|
|
55
|
+
"eslint-typegen": "^2.0.0",
|
|
56
|
+
"esno": "^4.8.0",
|
|
57
|
+
"lint-staged": "^15.4.3",
|
|
60
58
|
"simple-git-hooks": "^2.11.1",
|
|
61
|
-
"tsup": "^8.
|
|
62
|
-
"typescript": "^5.
|
|
63
|
-
"typescript-eslint": "^8.
|
|
59
|
+
"tsup": "^8.4.0",
|
|
60
|
+
"typescript": "^5.7.3",
|
|
61
|
+
"typescript-eslint": "^8.25.0"
|
|
64
62
|
},
|
|
65
63
|
"simple-git-hooks": {
|
|
66
64
|
"pre-commit": "pnpm lint-staged"
|
|
67
65
|
},
|
|
68
66
|
"lint-staged": {
|
|
69
|
-
"*": "eslint --fix
|
|
67
|
+
"*": "eslint --fix"
|
|
70
68
|
},
|
|
71
69
|
"scripts": {
|
|
72
|
-
"build": "pnpm typegen && tsup --
|
|
70
|
+
"build": "pnpm typegen && tsup --clean --dts",
|
|
73
71
|
"typegen": "esno scripts/typegen.ts",
|
|
74
72
|
"dev": "npx @eslint/config-inspector --config eslint.config.ts",
|
|
75
|
-
"lint": "eslint
|
|
76
|
-
"lint:fix": "eslint
|
|
73
|
+
"lint": "eslint",
|
|
74
|
+
"lint:fix": "eslint --fix",
|
|
77
75
|
"release": "bumpp && pnpm publish",
|
|
78
76
|
"typecheck": "tsc --noEmit"
|
|
79
77
|
}
|