@wongxy/eslint-config 2.0.0 → 3.0.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 +122 -139
- package/dist/index.d.cts +655 -156
- package/dist/index.d.ts +656 -156
- package/dist/index.js +104 -135
- package/package.json +23 -22
package/dist/index.js
CHANGED
|
@@ -1,140 +1,109 @@
|
|
|
1
|
-
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
18
|
-
|
|
19
|
-
// src/index.ts
|
|
20
|
-
var index_exports = {};
|
|
21
|
-
__export(index_exports, {
|
|
22
|
-
default: () => wongxy,
|
|
23
|
-
tailwindcss: () => tailwindcss
|
|
24
|
-
});
|
|
25
|
-
import { antfu } from "@antfu/eslint-config";
|
|
1
|
+
import { GLOB_SRC, GLOB_TS, GLOB_TSX, GLOB_VUE, antfu, getOverrides } from "@antfu/eslint-config";
|
|
26
2
|
import { isPackageExists } from "local-pkg";
|
|
3
|
+
import pluginTailwind from "eslint-plugin-better-tailwindcss";
|
|
27
4
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
// 'tw/no-custom-classname': 'warn',
|
|
52
|
-
"tw/no-contradicting-classname": "error",
|
|
53
|
-
// 'tw/no-unnecessary-arbitrary-value': 'warn',
|
|
54
|
-
...overrides
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
];
|
|
5
|
+
//#region src/tailwindcss.ts
|
|
6
|
+
async function tailwindcss(options = {}) {
|
|
7
|
+
const { overrides = {}, settings } = options;
|
|
8
|
+
const rules = {
|
|
9
|
+
"tw/enforce-consistent-class-order": "warn",
|
|
10
|
+
"tw/enforce-consistent-line-wrapping": ["warn", { printWidth: 100 }],
|
|
11
|
+
"tw/no-duplicate-classes": "warn",
|
|
12
|
+
"tw/no-unnecessary-whitespace": "warn",
|
|
13
|
+
"tw/no-conflicting-classes": "warn",
|
|
14
|
+
"tw/no-unregistered-classes": "warn"
|
|
15
|
+
};
|
|
16
|
+
return [{
|
|
17
|
+
name: "wongxy/tailwindcss/setup",
|
|
18
|
+
plugins: { tw: pluginTailwind },
|
|
19
|
+
languageOptions: { parserOptions: { ecmaFeatures: { jsx: true } } },
|
|
20
|
+
...!!settings && { settings: { "better-tailwindcss": settings } }
|
|
21
|
+
}, {
|
|
22
|
+
name: "wongxy/tailwindcss/rules",
|
|
23
|
+
rules: {
|
|
24
|
+
...rules,
|
|
25
|
+
...overrides
|
|
26
|
+
}
|
|
27
|
+
}];
|
|
58
28
|
}
|
|
59
29
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
reactnative: options.reactnative ?? isPackageExists("react-native"),
|
|
77
|
-
tailwindcss: options.tailwindcss ?? isPackageExists("tailwindcss")
|
|
78
|
-
};
|
|
79
|
-
const rules = {
|
|
80
|
-
"no-console": "off",
|
|
81
|
-
"no-alert": "off",
|
|
82
|
-
"no-multiple-empty-lines": "warn",
|
|
83
|
-
"antfu/top-level-function": "off",
|
|
84
|
-
"antfu/if-newline": "off",
|
|
85
|
-
// 'import/order': ['error', { 'newlines-between': 'always' }],
|
|
86
|
-
"style/brace-style": ["error", "1tbs", { allowSingleLine: true }]
|
|
87
|
-
};
|
|
88
|
-
for (const key in finalOptions.rules)
|
|
89
|
-
delete rules[key];
|
|
90
|
-
userConfigs.splice(0, 0, { name: "wongxy/rules", rules });
|
|
91
|
-
if (finalOptions.vue) {
|
|
92
|
-
const vue = typeof finalOptions.vue === "object" ? finalOptions.vue : {};
|
|
93
|
-
finalOptions.vue = {
|
|
94
|
-
...vue,
|
|
95
|
-
overrides: {
|
|
96
|
-
"vue/singleline-html-element-content-newline": "off",
|
|
97
|
-
"vue/valid-template-root": "off",
|
|
98
|
-
"vue/block-order": ["warn", { order: [["script", "template"], "style"] }],
|
|
99
|
-
"vue/custom-event-name-casing": "off",
|
|
100
|
-
...vue.overrides
|
|
101
|
-
}
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
if (finalOptions.react) {
|
|
105
|
-
const react = typeof finalOptions.react === "object" ? finalOptions.react : {};
|
|
106
|
-
finalOptions.react = {
|
|
107
|
-
...react,
|
|
108
|
-
overrides: {
|
|
109
|
-
"react/prefer-destructuring-assignment": "off",
|
|
110
|
-
...react.overrides
|
|
111
|
-
}
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
if (finalOptions.typescript) {
|
|
115
|
-
const typescript = typeof finalOptions.typescript === "object" ? finalOptions.typescript : {};
|
|
116
|
-
finalOptions.typescript = {
|
|
117
|
-
...typescript,
|
|
118
|
-
overrides: {
|
|
119
|
-
"ts/consistent-type-imports": ["error", { disallowTypeAnnotations: false, fixStyle: "inline-type-imports", prefer: "type-imports" }],
|
|
120
|
-
...finalOptions.reactnative ? {
|
|
121
|
-
"ts/no-require-imports": "off",
|
|
122
|
-
"ts/no-use-before-define": "off"
|
|
123
|
-
} : void 0,
|
|
124
|
-
...typescript.overrides
|
|
125
|
-
}
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
if (finalOptions.tailwindcss) {
|
|
129
|
-
userConfigs.splice(0, 0, tailwindcss({
|
|
130
|
-
overrides: typeof finalOptions.tailwindcss === "object" ? finalOptions.tailwindcss.overrides : void 0
|
|
131
|
-
}));
|
|
132
|
-
}
|
|
133
|
-
delete finalOptions.reactnative;
|
|
134
|
-
delete finalOptions.tailwindcss;
|
|
135
|
-
return antfu(finalOptions, ...userConfigs);
|
|
30
|
+
//#endregion
|
|
31
|
+
//#region src/index.ts
|
|
32
|
+
const VuePackages = [
|
|
33
|
+
"vue",
|
|
34
|
+
"nuxt",
|
|
35
|
+
"vitepress",
|
|
36
|
+
"@slidev/cli"
|
|
37
|
+
];
|
|
38
|
+
const ReactPackages = [
|
|
39
|
+
"react",
|
|
40
|
+
"react-native",
|
|
41
|
+
"react-dom",
|
|
42
|
+
"next"
|
|
43
|
+
];
|
|
44
|
+
function resolveRules(overrides, rules) {
|
|
45
|
+
return Object.fromEntries(Object.entries(rules).filter(([k]) => !overrides[k]));
|
|
136
46
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
47
|
+
function wongxy(options = {}, ...userConfigs) {
|
|
48
|
+
const { react: enableReact = ReactPackages.some((i) => isPackageExists(i)), typescript: enableTypeScript = isPackageExists("typescript"), vue: enableVue = VuePackages.some((i) => isPackageExists(i)), tailwindcss: enableTailwind = isPackageExists("tailwindcss"), reactnative: enableReactNative = isPackageExists("react-native") } = options;
|
|
49
|
+
const configs = [];
|
|
50
|
+
configs.push({
|
|
51
|
+
name: "wongxy/common",
|
|
52
|
+
rules: resolveRules(options.rules ?? {}, {
|
|
53
|
+
"no-console": "off",
|
|
54
|
+
"no-alert": "off",
|
|
55
|
+
"no-multiple-empty-lines": "warn",
|
|
56
|
+
"antfu/top-level-function": "off",
|
|
57
|
+
"antfu/if-newline": "off",
|
|
58
|
+
"style/brace-style": [
|
|
59
|
+
"error",
|
|
60
|
+
"1tbs",
|
|
61
|
+
{ allowSingleLine: true }
|
|
62
|
+
],
|
|
63
|
+
"perfectionist/sort-jsx-props": ["warn", {
|
|
64
|
+
order: "asc",
|
|
65
|
+
type: "natural"
|
|
66
|
+
}]
|
|
67
|
+
})
|
|
68
|
+
});
|
|
69
|
+
if (enableVue) configs.push({
|
|
70
|
+
name: "wongxy/vue",
|
|
71
|
+
files: [GLOB_VUE],
|
|
72
|
+
rules: resolveRules(getOverrides(options, "vue"), {
|
|
73
|
+
"vue/singleline-html-element-content-newline": "off",
|
|
74
|
+
"vue/valid-template-root": "off",
|
|
75
|
+
"vue/block-order": ["warn", { order: [["script", "template"], "style"] }],
|
|
76
|
+
"vue/custom-event-name-casing": "off"
|
|
77
|
+
})
|
|
78
|
+
});
|
|
79
|
+
if (enableReact) configs.push({
|
|
80
|
+
name: "wongxy/react",
|
|
81
|
+
files: [GLOB_SRC],
|
|
82
|
+
rules: resolveRules(getOverrides(options, "react"), { "react/prefer-destructuring-assignment": "off" })
|
|
83
|
+
});
|
|
84
|
+
if (enableTypeScript) configs.push({
|
|
85
|
+
name: "wongxy/typescript",
|
|
86
|
+
files: [GLOB_TS, GLOB_TSX],
|
|
87
|
+
rules: resolveRules(getOverrides(options, "typescript"), { "ts/consistent-type-imports": ["error", {
|
|
88
|
+
disallowTypeAnnotations: false,
|
|
89
|
+
fixStyle: "inline-type-imports",
|
|
90
|
+
prefer: "type-imports"
|
|
91
|
+
}] })
|
|
92
|
+
});
|
|
93
|
+
if (enableReactNative) configs.push({
|
|
94
|
+
name: "wongxy/reactnative",
|
|
95
|
+
files: [GLOB_TS, GLOB_TSX],
|
|
96
|
+
rules: resolveRules(getOverrides(options, "typescript"), {
|
|
97
|
+
"ts/no-require-imports": "off",
|
|
98
|
+
"ts/no-use-before-define": "off"
|
|
99
|
+
})
|
|
100
|
+
});
|
|
101
|
+
if (enableTailwind) {
|
|
102
|
+
const tw = typeof options.tailwindcss === "object" ? options.tailwindcss : void 0;
|
|
103
|
+
configs.push(tailwindcss(tw));
|
|
104
|
+
}
|
|
105
|
+
return antfu(options, ...configs, ...userConfigs);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
//#endregion
|
|
109
|
+
export { wongxy as default };
|
package/package.json
CHANGED
|
@@ -1,51 +1,52 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wongxy/eslint-config",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "3.0.0",
|
|
5
5
|
"description": "xiyaowong's eslint config",
|
|
6
6
|
"author": "xiyaowong (https://github.com/xiyaowong)",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"exports": {
|
|
9
|
-
".":
|
|
10
|
-
"import": "./dist/index.js",
|
|
11
|
-
"require": "./dist/index.cjs"
|
|
12
|
-
}
|
|
9
|
+
".": "./dist/index.js"
|
|
13
10
|
},
|
|
14
11
|
"main": "dist/index.js",
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
15
13
|
"files": [
|
|
16
14
|
"dist"
|
|
17
15
|
],
|
|
18
16
|
"peerDependencies": {
|
|
19
17
|
"@eslint-react/eslint-plugin": "^1.49.0",
|
|
18
|
+
"@next/eslint-plugin-next": "^15.5.2",
|
|
20
19
|
"@unocss/eslint-plugin": "^66.1.2",
|
|
21
20
|
"eslint": "^9.27.0",
|
|
21
|
+
"eslint-plugin-better-tailwindcss": "^3.7.9",
|
|
22
22
|
"eslint-plugin-react-hooks": "^5.2.0",
|
|
23
|
-
"eslint-plugin-react-refresh": "^0.4.20"
|
|
24
|
-
"eslint-plugin-tailwindcss": ">=3.18.0"
|
|
23
|
+
"eslint-plugin-react-refresh": "^0.4.20"
|
|
25
24
|
},
|
|
26
25
|
"dependencies": {
|
|
27
|
-
"@antfu/eslint-config": "^
|
|
28
|
-
"
|
|
26
|
+
"@antfu/eslint-config": "^5.2.1",
|
|
27
|
+
"eslint-flat-config-utils": "^2.1.1",
|
|
28
|
+
"local-pkg": "^1.1.2"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
+
"@antfu/ni": "^26.0.1",
|
|
31
32
|
"@types/eslint": "^9.6.1",
|
|
32
|
-
"@types/
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"eslint": "^
|
|
36
|
-
"eslint-typegen": "^2.2.0",
|
|
33
|
+
"@types/node": "^24.3.0",
|
|
34
|
+
"bumpp": "^10.2.3",
|
|
35
|
+
"eslint": "^9.34.0",
|
|
36
|
+
"eslint-typegen": "^2.3.0",
|
|
37
37
|
"esno": "^4.8.0",
|
|
38
|
-
"
|
|
39
|
-
"typescript": "5.
|
|
38
|
+
"tsdown": "^0.14.2",
|
|
39
|
+
"typescript": "5.9.2"
|
|
40
40
|
},
|
|
41
41
|
"scripts": {
|
|
42
|
-
"build": "nr typegen &&
|
|
43
|
-
"stub": "
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"lint:fix": "
|
|
42
|
+
"build": "nr typegen && tsdown --clean --dts",
|
|
43
|
+
"stub": "tsdown --format esm",
|
|
44
|
+
"watch": "tsdown --watch",
|
|
45
|
+
"dev": "tsdown --watch & eslint-flat-config-viewer",
|
|
46
|
+
"lint:fix": "eslint . --fix",
|
|
47
|
+
"lint": "eslint .",
|
|
47
48
|
"release": "bumpp && pnpm publish",
|
|
48
|
-
"inspect": "
|
|
49
|
+
"inspect": "nlx @eslint/config-inspector",
|
|
49
50
|
"typegen": "esno scripts/typegen.ts",
|
|
50
51
|
"typecheck": "tsc --noEmit"
|
|
51
52
|
}
|