@vida0905/eslint-config 2.10.0 → 2.11.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/bin/index.mjs +1 -1
- package/dist/index.d.mts +0 -94
- package/dist/index.mjs +27 -24
- package/package.json +14 -11
- package/dist/cli/index.mjs +0 -107
package/bin/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import '
|
|
2
|
+
import '@antfu/eslint-config/cli.mjs'
|
package/dist/index.d.mts
CHANGED
|
@@ -15,79 +15,6 @@ interface RuleOptions {
|
|
|
15
15
|
* @see https://github.com/azat-io/eslint-plugin-de-morgan/blob/main/docs/no-negated-disjunction.md
|
|
16
16
|
*/
|
|
17
17
|
'de-morgan/no-negated-disjunction'?: Linter.RuleEntry<[]>;
|
|
18
|
-
/**
|
|
19
|
-
* Bans a list of dependencies from being used
|
|
20
|
-
* @see https://github.com/es-tooling/eslint-plugin-depend/blob/main/docs/rules/ban-dependencies.md
|
|
21
|
-
*/
|
|
22
|
-
'e18e/ban-dependencies'?: Linter.RuleEntry<E18EBanDependencies>;
|
|
23
|
-
/**
|
|
24
|
-
* Prefer optimized alternatives to `indexOf()` equality checks
|
|
25
|
-
*/
|
|
26
|
-
'e18e/no-indexof-equality'?: Linter.RuleEntry<[]>;
|
|
27
|
-
/**
|
|
28
|
-
* Prefer Array.prototype.at() over length-based indexing
|
|
29
|
-
*/
|
|
30
|
-
'e18e/prefer-array-at'?: Linter.RuleEntry<[]>;
|
|
31
|
-
/**
|
|
32
|
-
* Prefer Array.prototype.fill() over Array.from or map with constant values
|
|
33
|
-
*/
|
|
34
|
-
'e18e/prefer-array-fill'?: Linter.RuleEntry<[]>;
|
|
35
|
-
/**
|
|
36
|
-
* Prefer Array.from(iterable, mapper) over [...iterable].map(mapper) to avoid intermediate array allocation
|
|
37
|
-
*/
|
|
38
|
-
'e18e/prefer-array-from-map'?: Linter.RuleEntry<[]>;
|
|
39
|
-
/**
|
|
40
|
-
* Prefer Array.some() over Array.find() when checking for element existence
|
|
41
|
-
*/
|
|
42
|
-
'e18e/prefer-array-some'?: Linter.RuleEntry<[]>;
|
|
43
|
-
/**
|
|
44
|
-
* Prefer Array.prototype.toReversed() over copying and reversing arrays
|
|
45
|
-
*/
|
|
46
|
-
'e18e/prefer-array-to-reversed'?: Linter.RuleEntry<[]>;
|
|
47
|
-
/**
|
|
48
|
-
* Prefer Array.prototype.toSorted() over copying and sorting arrays
|
|
49
|
-
*/
|
|
50
|
-
'e18e/prefer-array-to-sorted'?: Linter.RuleEntry<[]>;
|
|
51
|
-
/**
|
|
52
|
-
* Prefer Array.prototype.toSpliced() over copying and splicing arrays
|
|
53
|
-
*/
|
|
54
|
-
'e18e/prefer-array-to-spliced'?: Linter.RuleEntry<[]>;
|
|
55
|
-
/**
|
|
56
|
-
* Prefer Date.now() over new Date().getTime() and +new Date()
|
|
57
|
-
*/
|
|
58
|
-
'e18e/prefer-date-now'?: Linter.RuleEntry<[]>;
|
|
59
|
-
/**
|
|
60
|
-
* Prefer the exponentiation operator ** over Math.pow()
|
|
61
|
-
*/
|
|
62
|
-
'e18e/prefer-exponentiation-operator'?: Linter.RuleEntry<[]>;
|
|
63
|
-
/**
|
|
64
|
-
* Prefer .includes() over indexOf() comparisons for arrays and strings
|
|
65
|
-
*/
|
|
66
|
-
'e18e/prefer-includes'?: Linter.RuleEntry<[]>;
|
|
67
|
-
/**
|
|
68
|
-
* Prefer nullish coalescing operator (?? and ??=) over verbose null checks
|
|
69
|
-
*/
|
|
70
|
-
'e18e/prefer-nullish-coalescing'?: Linter.RuleEntry<[]>;
|
|
71
|
-
/**
|
|
72
|
-
* Prefer Object.hasOwn() over Object.prototype.hasOwnProperty.call() and obj.hasOwnProperty()
|
|
73
|
-
*/
|
|
74
|
-
'e18e/prefer-object-has-own'?: Linter.RuleEntry<[]>;
|
|
75
|
-
/**
|
|
76
|
-
* prefer `RegExp.test()` over `String.match()` and `RegExp.exec()` when only checking for match existence
|
|
77
|
-
*/
|
|
78
|
-
'e18e/prefer-regex-test'?: Linter.RuleEntry<[]>;
|
|
79
|
-
/**
|
|
80
|
-
* Prefer spread syntax over Array.concat(), Array.from(), Object.assign({}, ...), and Function.apply()
|
|
81
|
-
*/
|
|
82
|
-
'e18e/prefer-spread-syntax'?: Linter.RuleEntry<[]>;
|
|
83
|
-
/**
|
|
84
|
-
* Prefer passing function and arguments directly to setTimeout/setInterval instead of wrapping in an arrow function or using bind
|
|
85
|
-
*/
|
|
86
|
-
'e18e/prefer-timer-args'?: Linter.RuleEntry<[]>;
|
|
87
|
-
/**
|
|
88
|
-
* Prefer URL.canParse() over try-catch blocks for URL validation
|
|
89
|
-
*/
|
|
90
|
-
'e18e/prefer-url-canparse'?: Linter.RuleEntry<[]>;
|
|
91
18
|
/**
|
|
92
19
|
* Prefer recommended order of Nuxt config properties
|
|
93
20
|
* @see https://eslint.nuxt.com/packages/plugin#nuxtnuxt-config-keys-order
|
|
@@ -99,13 +26,6 @@ interface RuleOptions {
|
|
|
99
26
|
*/
|
|
100
27
|
'nuxt/prefer-import-meta'?: Linter.RuleEntry<[]>;
|
|
101
28
|
}
|
|
102
|
-
/* ======= Declarations ======= */
|
|
103
|
-
// ----- e18e/ban-dependencies -----
|
|
104
|
-
type E18EBanDependencies = [] | [{
|
|
105
|
-
presets?: string[];
|
|
106
|
-
modules?: string[];
|
|
107
|
-
allowed?: string[];
|
|
108
|
-
}]; // Names of all the configs
|
|
109
29
|
//#endregion
|
|
110
30
|
//#region src/types.d.ts
|
|
111
31
|
interface Rules extends RuleOptions {}
|
|
@@ -121,20 +41,6 @@ interface OptionsOverrides {
|
|
|
121
41
|
overrides?: TypedFlatConfigItem$1["rules"];
|
|
122
42
|
}
|
|
123
43
|
type OptionsConfig$1 = Omit<OptionsConfig, "overrides"> & {
|
|
124
|
-
/**
|
|
125
|
-
* Enable de-morgan rules.
|
|
126
|
-
*
|
|
127
|
-
* @see https://github.com/azat-io/eslint-plugin-de-morgan
|
|
128
|
-
* @default true
|
|
129
|
-
*/
|
|
130
|
-
deMorgan?: boolean | OptionsFiles;
|
|
131
|
-
/**
|
|
132
|
-
* Enable e18e rules.
|
|
133
|
-
*
|
|
134
|
-
* @see https://github.com/e18e/eslint-plugin
|
|
135
|
-
* @default true
|
|
136
|
-
*/
|
|
137
|
-
e18e?: boolean | OptionsOverrides & OptionsFiles;
|
|
138
44
|
/**
|
|
139
45
|
* Enable Nuxt.js rules.
|
|
140
46
|
*
|
package/dist/index.mjs
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
import antfu, { GLOB_SRC, ensurePackages, interopDefault } from "@antfu/eslint-config";
|
|
2
2
|
import { isPackageExists } from "local-pkg";
|
|
3
3
|
export * from "@antfu/eslint-config";
|
|
4
|
+
//#region node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/predicate/isPrimitive.mjs
|
|
4
5
|
function isPrimitive(value) {
|
|
5
6
|
return value == null || typeof value !== "object" && typeof value !== "function";
|
|
6
7
|
}
|
|
8
|
+
//#endregion
|
|
9
|
+
//#region node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/predicate/isTypedArray.mjs
|
|
7
10
|
function isTypedArray(x) {
|
|
8
11
|
return ArrayBuffer.isView(x) && !(x instanceof DataView);
|
|
9
12
|
}
|
|
13
|
+
//#endregion
|
|
14
|
+
//#region node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/object/clone.mjs
|
|
10
15
|
function clone(obj) {
|
|
11
16
|
if (isPrimitive(obj)) return obj;
|
|
12
17
|
if (Array.isArray(obj) || isTypedArray(obj) || obj instanceof ArrayBuffer || typeof SharedArrayBuffer !== "undefined" && obj instanceof SharedArrayBuffer) return obj.slice(0);
|
|
@@ -38,15 +43,21 @@ function clone(obj) {
|
|
|
38
43
|
}
|
|
39
44
|
return obj;
|
|
40
45
|
}
|
|
46
|
+
//#endregion
|
|
47
|
+
//#region node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/predicate/isPlainObject.mjs
|
|
41
48
|
function isPlainObject(value) {
|
|
42
49
|
if (!value || typeof value !== "object") return false;
|
|
43
50
|
const proto = Object.getPrototypeOf(value);
|
|
44
51
|
if (!(proto === null || proto === Object.prototype || Object.getPrototypeOf(proto) === null)) return false;
|
|
45
52
|
return Object.prototype.toString.call(value) === "[object Object]";
|
|
46
53
|
}
|
|
54
|
+
//#endregion
|
|
55
|
+
//#region node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/_internal/isUnsafeProperty.mjs
|
|
47
56
|
function isUnsafeProperty(key) {
|
|
48
57
|
return key === "__proto__";
|
|
49
58
|
}
|
|
59
|
+
//#endregion
|
|
60
|
+
//#region node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/object/mergeWith.mjs
|
|
50
61
|
function mergeWith(target, source, merge) {
|
|
51
62
|
const sourceKeys = Object.keys(source);
|
|
52
63
|
for (let i = 0; i < sourceKeys.length; i++) {
|
|
@@ -64,6 +75,8 @@ function mergeWith(target, source, merge) {
|
|
|
64
75
|
}
|
|
65
76
|
return target;
|
|
66
77
|
}
|
|
78
|
+
//#endregion
|
|
79
|
+
//#region node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/object/toMerged.mjs
|
|
67
80
|
function toMerged(target, source) {
|
|
68
81
|
return mergeWith(clone(target), source, function mergeRecursively(targetValue, sourceValue) {
|
|
69
82
|
if (Array.isArray(sourceValue)) if (Array.isArray(targetValue)) return mergeWith(clone(targetValue), sourceValue, mergeRecursively);
|
|
@@ -72,27 +85,16 @@ function toMerged(target, source) {
|
|
|
72
85
|
else return mergeWith({}, sourceValue, mergeRecursively);
|
|
73
86
|
});
|
|
74
87
|
}
|
|
75
|
-
|
|
76
|
-
|
|
88
|
+
//#endregion
|
|
89
|
+
//#region src/configs/de-morgan.ts
|
|
90
|
+
async function deMorgan() {
|
|
77
91
|
return [{
|
|
78
92
|
name: "vida/de-morgan/rules",
|
|
79
|
-
files,
|
|
80
93
|
...(await interopDefault(import("eslint-plugin-de-morgan"))).configs.recommended
|
|
81
94
|
}];
|
|
82
95
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
const recommendedConfig = (await interopDefault(import("@e18e/eslint-plugin"))).configs.recommended;
|
|
86
|
-
return [{
|
|
87
|
-
name: "vida/e18e/rules",
|
|
88
|
-
files,
|
|
89
|
-
...recommendedConfig,
|
|
90
|
-
rules: {
|
|
91
|
-
...recommendedConfig.rules,
|
|
92
|
-
...overrides
|
|
93
|
-
}
|
|
94
|
-
}];
|
|
95
|
-
}
|
|
96
|
+
//#endregion
|
|
97
|
+
//#region src/configs/nuxt.ts
|
|
96
98
|
async function nuxt(options = {}) {
|
|
97
99
|
const { files = [GLOB_SRC], overrides = {} } = options;
|
|
98
100
|
await ensurePackages(["@nuxt/eslint-plugin"]);
|
|
@@ -110,6 +112,8 @@ async function nuxt(options = {}) {
|
|
|
110
112
|
}
|
|
111
113
|
}];
|
|
112
114
|
}
|
|
115
|
+
//#endregion
|
|
116
|
+
//#region src/overrides/index.ts
|
|
113
117
|
const antfuOverrides = Object.freeze({
|
|
114
118
|
javascript: { overrides: {
|
|
115
119
|
"arrow-body-style": ["error", "as-needed"],
|
|
@@ -170,11 +174,11 @@ const antfuOverrides = Object.freeze({
|
|
|
170
174
|
"vue/prefer-use-template-ref": ["error"]
|
|
171
175
|
} }
|
|
172
176
|
});
|
|
177
|
+
//#endregion
|
|
178
|
+
//#region src/index.ts
|
|
173
179
|
const defaultOptions = {
|
|
174
|
-
deMorgan: true,
|
|
175
|
-
e18e: true,
|
|
176
180
|
nuxt: isPackageExists("nuxt"),
|
|
177
|
-
typescript: isPackageExists("typescript"),
|
|
181
|
+
typescript: isPackageExists("typescript") || isPackageExists("@typescript/native-preview"),
|
|
178
182
|
vue: [
|
|
179
183
|
"vue",
|
|
180
184
|
"nuxt",
|
|
@@ -184,10 +188,9 @@ const defaultOptions = {
|
|
|
184
188
|
};
|
|
185
189
|
function defineConfig(options = {}, ...userConfigs) {
|
|
186
190
|
options = toMerged(defaultOptions, options);
|
|
187
|
-
const {
|
|
191
|
+
const { nuxt: enableNuxt } = options;
|
|
188
192
|
const configs = [];
|
|
189
|
-
|
|
190
|
-
if (enableE18e) configs.push(e18e());
|
|
193
|
+
configs.push(deMorgan());
|
|
191
194
|
if (enableNuxt) configs.push(nuxt());
|
|
192
195
|
return antfu(applyOptions(options), ...configs, ...userConfigs);
|
|
193
196
|
}
|
|
@@ -200,5 +203,5 @@ function applyOptions(options) {
|
|
|
200
203
|
}
|
|
201
204
|
return options;
|
|
202
205
|
}
|
|
203
|
-
|
|
204
|
-
export { applyOptions,
|
|
206
|
+
//#endregion
|
|
207
|
+
export { applyOptions, defineConfig as default, defineConfig };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vida0905/eslint-config",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.11.0",
|
|
5
5
|
"description": "Vida Xie's ESLint Config",
|
|
6
6
|
"author": "Vida Xie <vida_2020@163.com> (https://github.com/9romise/)",
|
|
7
7
|
"license": "MIT",
|
|
@@ -40,21 +40,21 @@
|
|
|
40
40
|
}
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@antfu/eslint-config": "^7.
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"eslint-flat-config-utils": "^3.0.0",
|
|
47
|
-
"eslint-plugin-de-morgan": "^2.0.0",
|
|
43
|
+
"@antfu/eslint-config": "^7.7.0",
|
|
44
|
+
"eslint-flat-config-utils": "^3.0.2",
|
|
45
|
+
"eslint-plugin-de-morgan": "^2.1.1",
|
|
48
46
|
"local-pkg": "^1.1.2"
|
|
49
47
|
},
|
|
50
48
|
"devDependencies": {
|
|
51
|
-
"@
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"eslint
|
|
49
|
+
"@arethetypeswrong/core": "^0.18.2",
|
|
50
|
+
"@types/node": "^25.4.0",
|
|
51
|
+
"es-toolkit": "^1.45.1",
|
|
52
|
+
"eslint": "^10.0.3",
|
|
53
|
+
"eslint-typegen": "^2.3.1",
|
|
55
54
|
"husky": "^9.1.7",
|
|
56
55
|
"nano-staged": "^0.9.0",
|
|
57
|
-
"
|
|
56
|
+
"publint": "^0.3.18",
|
|
57
|
+
"tsdown": "^0.21.1",
|
|
58
58
|
"tsx": "^4.21.0",
|
|
59
59
|
"typescript": "^5.9.3",
|
|
60
60
|
"vitest": "^4.0.18"
|
|
@@ -62,6 +62,9 @@
|
|
|
62
62
|
"nano-staged": {
|
|
63
63
|
"*": "eslint --fix"
|
|
64
64
|
},
|
|
65
|
+
"inlinedDependencies": {
|
|
66
|
+
"es-toolkit": "1.45.1"
|
|
67
|
+
},
|
|
65
68
|
"scripts": {
|
|
66
69
|
"dev": "tsdown --watch",
|
|
67
70
|
"build": "tsdown",
|
package/dist/cli/index.mjs
DELETED
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import process from "node:process";
|
|
2
|
-
import { cac } from "cac";
|
|
3
|
-
import fs from "node:fs";
|
|
4
|
-
import fsp from "node:fs/promises";
|
|
5
|
-
import path from "node:path";
|
|
6
|
-
import { styleText } from "node:util";
|
|
7
|
-
|
|
8
|
-
//#region package.json
|
|
9
|
-
var version = "2.10.0";
|
|
10
|
-
|
|
11
|
-
//#endregion
|
|
12
|
-
//#region src/cli/constants.ts
|
|
13
|
-
const vscodeSettingsString = `
|
|
14
|
-
// Disable the default formatter, use eslint instead
|
|
15
|
-
"prettier.enable": false,
|
|
16
|
-
"editor.formatOnSave": false,
|
|
17
|
-
|
|
18
|
-
// Auto fix
|
|
19
|
-
"editor.codeActionsOnSave": {
|
|
20
|
-
"source.fixAll.eslint": "explicit",
|
|
21
|
-
"source.organizeImports": "never"
|
|
22
|
-
},
|
|
23
|
-
|
|
24
|
-
// Silent the stylistic rules in you IDE, but still auto fix them
|
|
25
|
-
"eslint.rules.customizations": [
|
|
26
|
-
{ "rule": "style/*", "severity": "off", "fixable": true },
|
|
27
|
-
{ "rule": "format/*", "severity": "off", "fixable": true },
|
|
28
|
-
{ "rule": "*-indent", "severity": "off", "fixable": true },
|
|
29
|
-
{ "rule": "*-spacing", "severity": "off", "fixable": true },
|
|
30
|
-
{ "rule": "*-spaces", "severity": "off", "fixable": true },
|
|
31
|
-
{ "rule": "*-order", "severity": "off", "fixable": true },
|
|
32
|
-
{ "rule": "*-dangle", "severity": "off", "fixable": true },
|
|
33
|
-
{ "rule": "*-newline", "severity": "off", "fixable": true },
|
|
34
|
-
{ "rule": "*quotes", "severity": "off", "fixable": true },
|
|
35
|
-
{ "rule": "*semi", "severity": "off", "fixable": true }
|
|
36
|
-
],
|
|
37
|
-
|
|
38
|
-
// Enable eslint for all supported languages
|
|
39
|
-
"eslint.validate": [
|
|
40
|
-
"javascript",
|
|
41
|
-
"javascriptreact",
|
|
42
|
-
"typescript",
|
|
43
|
-
"typescriptreact",
|
|
44
|
-
"vue",
|
|
45
|
-
"html",
|
|
46
|
-
"markdown",
|
|
47
|
-
"json",
|
|
48
|
-
"json5",
|
|
49
|
-
"jsonc",
|
|
50
|
-
"yaml",
|
|
51
|
-
"toml",
|
|
52
|
-
"xml",
|
|
53
|
-
"gql",
|
|
54
|
-
"graphql",
|
|
55
|
-
"astro",
|
|
56
|
-
"svelte",
|
|
57
|
-
"css",
|
|
58
|
-
"less",
|
|
59
|
-
"scss",
|
|
60
|
-
"pcss",
|
|
61
|
-
"postcss"
|
|
62
|
-
]
|
|
63
|
-
`;
|
|
64
|
-
|
|
65
|
-
//#endregion
|
|
66
|
-
//#region src/cli/update/update-vscode-settings.ts
|
|
67
|
-
async function updateVSCodeSettings() {
|
|
68
|
-
const cwd = process.cwd();
|
|
69
|
-
const dotVscodePath = path.join(cwd, ".vscode");
|
|
70
|
-
const settingsPath = path.join(dotVscodePath, "settings.json");
|
|
71
|
-
if (!fs.existsSync(dotVscodePath)) await fsp.mkdir(dotVscodePath, { recursive: true });
|
|
72
|
-
if (!fs.existsSync(settingsPath)) {
|
|
73
|
-
await fsp.writeFile(settingsPath, `{${vscodeSettingsString}}\n`, "utf-8");
|
|
74
|
-
console.log(styleText("green", "Created .vscode/settings.json"));
|
|
75
|
-
} else {
|
|
76
|
-
let settingsContent = await fsp.readFile(settingsPath, "utf8");
|
|
77
|
-
settingsContent = settingsContent.trim().replace(/\s*\}$/, "");
|
|
78
|
-
settingsContent += settingsContent.endsWith(",") || settingsContent.endsWith("{") ? "" : ",";
|
|
79
|
-
settingsContent += `${vscodeSettingsString}}\n`;
|
|
80
|
-
await fsp.writeFile(settingsPath, settingsContent, "utf-8");
|
|
81
|
-
console.log(styleText("green", "Updated .vscode/settings.json"));
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
//#endregion
|
|
86
|
-
//#region src/cli/update/index.ts
|
|
87
|
-
async function update(files = []) {
|
|
88
|
-
if (files.includes("vscode")) await updateVSCodeSettings();
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
//#endregion
|
|
92
|
-
//#region src/cli/index.ts
|
|
93
|
-
const cli = cac("@vida0905/eslint-config");
|
|
94
|
-
cli.command("update [...files]", "Update configuration files for specified files").alias("up").option("vscode", "Update .vscode/settings.json").action(async (files) => {
|
|
95
|
-
try {
|
|
96
|
-
await update(files);
|
|
97
|
-
} catch (error) {
|
|
98
|
-
console.error(`✘ ${String(error)}`);
|
|
99
|
-
process.exit(1);
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
cli.help();
|
|
103
|
-
cli.version(version);
|
|
104
|
-
cli.parse();
|
|
105
|
-
|
|
106
|
-
//#endregion
|
|
107
|
-
export { };
|