@wongxy/eslint-config 2.0.1 → 3.0.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/dist/index.cjs +94 -98
- package/dist/index.d.cts +627 -132
- package/dist/index.d.ts +627 -130
- package/dist/index.js +89 -90
- package/package.json +21 -23
- package/dist/chunk-CHLpw0oG.js +0 -25
package/dist/index.js
CHANGED
|
@@ -1,24 +1,27 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { antfu } from "@antfu/eslint-config";
|
|
1
|
+
import { GLOB_SRC, GLOB_TS, GLOB_TSX, GLOB_VUE, antfu, getOverrides } from "@antfu/eslint-config";
|
|
3
2
|
import { isPackageExists } from "local-pkg";
|
|
4
|
-
import pluginTailwind from "eslint-plugin-tailwindcss";
|
|
5
|
-
|
|
6
|
-
export * from "@antfu/eslint-config"
|
|
3
|
+
import pluginTailwind from "eslint-plugin-better-tailwindcss";
|
|
7
4
|
|
|
8
5
|
//#region src/tailwindcss.ts
|
|
9
|
-
async function tailwindcss(options) {
|
|
10
|
-
const { overrides = {} } = options
|
|
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
|
+
};
|
|
11
16
|
return [{
|
|
12
|
-
name: "wongxy/tailwindcss",
|
|
17
|
+
name: "wongxy/tailwindcss/setup",
|
|
13
18
|
plugins: { tw: pluginTailwind },
|
|
14
19
|
languageOptions: { parserOptions: { ecmaFeatures: { jsx: true } } },
|
|
20
|
+
...!!settings && { settings: { "better-tailwindcss": settings } }
|
|
21
|
+
}, {
|
|
22
|
+
name: "wongxy/tailwindcss/rules",
|
|
15
23
|
rules: {
|
|
16
|
-
|
|
17
|
-
"tw/enforces-negative-arbitrary-values": "warn",
|
|
18
|
-
"tw/enforces-shorthand": "warn",
|
|
19
|
-
"tw/migration-from-tailwind-2": "warn",
|
|
20
|
-
"tw/no-arbitrary-value": "off",
|
|
21
|
-
"tw/no-contradicting-classname": "error",
|
|
24
|
+
...rules,
|
|
22
25
|
...overrides
|
|
23
26
|
}
|
|
24
27
|
}];
|
|
@@ -26,11 +29,6 @@ async function tailwindcss(options) {
|
|
|
26
29
|
|
|
27
30
|
//#endregion
|
|
28
31
|
//#region src/index.ts
|
|
29
|
-
var src_exports = {};
|
|
30
|
-
__export(src_exports, {
|
|
31
|
-
default: () => wongxy,
|
|
32
|
-
tailwindcss: () => tailwindcss
|
|
33
|
-
});
|
|
34
32
|
const VuePackages = [
|
|
35
33
|
"vue",
|
|
36
34
|
"nuxt",
|
|
@@ -43,79 +41,80 @@ const ReactPackages = [
|
|
|
43
41
|
"react-dom",
|
|
44
42
|
"next"
|
|
45
43
|
];
|
|
46
|
-
function
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
44
|
+
function resolveRules(overrides, rules) {
|
|
45
|
+
return Object.fromEntries(Object.entries(rules).filter(([k]) => !overrides[k]));
|
|
46
|
+
}
|
|
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
|
+
groups: [
|
|
67
|
+
"reserved-first",
|
|
68
|
+
"reserved-second",
|
|
69
|
+
"unknown",
|
|
70
|
+
"reserved-last"
|
|
71
|
+
],
|
|
72
|
+
customGroups: {
|
|
73
|
+
"reserved-first": ["key", "ref"],
|
|
74
|
+
"reserved-second": ["id", "name"],
|
|
75
|
+
"reserved-last": ["asChild"]
|
|
76
|
+
}
|
|
77
|
+
}]
|
|
78
|
+
})
|
|
72
79
|
});
|
|
73
|
-
if (
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
"ts/no-use-before-define": "off"
|
|
109
|
-
} : void 0,
|
|
110
|
-
...typescript.overrides
|
|
111
|
-
}
|
|
112
|
-
};
|
|
80
|
+
if (enableVue) configs.push({
|
|
81
|
+
name: "wongxy/vue",
|
|
82
|
+
files: [GLOB_VUE],
|
|
83
|
+
rules: resolveRules(getOverrides(options, "vue"), {
|
|
84
|
+
"vue/singleline-html-element-content-newline": "off",
|
|
85
|
+
"vue/valid-template-root": "off",
|
|
86
|
+
"vue/block-order": ["warn", { order: [["script", "template"], "style"] }],
|
|
87
|
+
"vue/custom-event-name-casing": "off"
|
|
88
|
+
})
|
|
89
|
+
});
|
|
90
|
+
if (enableReact) configs.push({
|
|
91
|
+
name: "wongxy/react",
|
|
92
|
+
files: [GLOB_SRC],
|
|
93
|
+
rules: resolveRules(getOverrides(options, "react"), { "react/prefer-destructuring-assignment": "off" })
|
|
94
|
+
});
|
|
95
|
+
if (enableTypeScript) configs.push({
|
|
96
|
+
name: "wongxy/typescript",
|
|
97
|
+
files: [GLOB_TS, GLOB_TSX],
|
|
98
|
+
rules: resolveRules(getOverrides(options, "typescript"), { "ts/consistent-type-imports": ["error", {
|
|
99
|
+
disallowTypeAnnotations: false,
|
|
100
|
+
fixStyle: "inline-type-imports",
|
|
101
|
+
prefer: "type-imports"
|
|
102
|
+
}] })
|
|
103
|
+
});
|
|
104
|
+
if (enableReactNative) configs.push({
|
|
105
|
+
name: "wongxy/reactnative",
|
|
106
|
+
files: [GLOB_TS, GLOB_TSX],
|
|
107
|
+
rules: resolveRules(getOverrides(options, "typescript"), {
|
|
108
|
+
"ts/no-require-imports": "off",
|
|
109
|
+
"ts/no-use-before-define": "off"
|
|
110
|
+
})
|
|
111
|
+
});
|
|
112
|
+
if (enableTailwind) {
|
|
113
|
+
const tw = typeof options.tailwindcss === "object" ? options.tailwindcss : void 0;
|
|
114
|
+
configs.push(tailwindcss(tw));
|
|
113
115
|
}
|
|
114
|
-
|
|
115
|
-
delete finalOptions.reactnative;
|
|
116
|
-
delete finalOptions.tailwindcss;
|
|
117
|
-
return antfu(finalOptions, ...userConfigs);
|
|
116
|
+
return antfu(options, ...configs, ...userConfigs);
|
|
118
117
|
}
|
|
119
118
|
|
|
120
119
|
//#endregion
|
|
121
|
-
export { wongxy as default
|
|
120
|
+
export { wongxy as default };
|
package/package.json
CHANGED
|
@@ -1,54 +1,52 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wongxy/eslint-config",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "3.0.1",
|
|
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
|
-
"@eslint-react/eslint-plugin": "^
|
|
20
|
-
"@next/eslint-plugin-next": "^
|
|
21
|
-
"@unocss/eslint-plugin": "^66.
|
|
22
|
-
"eslint": "^9.
|
|
23
|
-
"eslint-plugin-
|
|
24
|
-
"eslint-plugin-react-
|
|
25
|
-
"eslint-plugin-
|
|
17
|
+
"@eslint-react/eslint-plugin": "^2.3.1",
|
|
18
|
+
"@next/eslint-plugin-next": "^16.0.1",
|
|
19
|
+
"@unocss/eslint-plugin": "^66.5.4",
|
|
20
|
+
"eslint": "^9.39.1",
|
|
21
|
+
"eslint-plugin-better-tailwindcss": "^3.7.10",
|
|
22
|
+
"eslint-plugin-react-hooks": "^7.0.1",
|
|
23
|
+
"eslint-plugin-react-refresh": "^0.4.24"
|
|
26
24
|
},
|
|
27
25
|
"dependencies": {
|
|
28
|
-
"@antfu/eslint-config": "^
|
|
29
|
-
"eslint-flat-config-utils": "^2.1.
|
|
26
|
+
"@antfu/eslint-config": "^6.2.0",
|
|
27
|
+
"eslint-flat-config-utils": "^2.1.4",
|
|
30
28
|
"local-pkg": "^1.1.2"
|
|
31
29
|
},
|
|
32
30
|
"devDependencies": {
|
|
31
|
+
"@antfu/ni": "^27.0.1",
|
|
33
32
|
"@types/eslint": "^9.6.1",
|
|
34
|
-
"@types/
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"eslint": "^9.34.0",
|
|
33
|
+
"@types/node": "^24.10.0",
|
|
34
|
+
"bumpp": "^10.3.1",
|
|
35
|
+
"eslint": "^9.39.1",
|
|
38
36
|
"eslint-typegen": "^2.3.0",
|
|
39
37
|
"esno": "^4.8.0",
|
|
40
|
-
"tsdown": "^0.
|
|
41
|
-
"typescript": "5.9.
|
|
38
|
+
"tsdown": "^0.15.12",
|
|
39
|
+
"typescript": "^5.9.3"
|
|
42
40
|
},
|
|
43
41
|
"scripts": {
|
|
44
42
|
"build": "nr typegen && tsdown --clean --dts",
|
|
45
43
|
"stub": "tsdown --format esm",
|
|
46
44
|
"watch": "tsdown --watch",
|
|
47
|
-
"lint": "pnpm run stub && eslint .",
|
|
48
45
|
"dev": "tsdown --watch & eslint-flat-config-viewer",
|
|
49
|
-
"lint:fix": "
|
|
46
|
+
"lint:fix": "eslint . --fix",
|
|
47
|
+
"lint": "eslint .",
|
|
50
48
|
"release": "bumpp && pnpm publish",
|
|
51
|
-
"inspect": "
|
|
49
|
+
"inspect": "nlx @eslint/config-inspector",
|
|
52
50
|
"typegen": "esno scripts/typegen.ts",
|
|
53
51
|
"typecheck": "tsc --noEmit"
|
|
54
52
|
}
|
package/dist/chunk-CHLpw0oG.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
//#region rolldown:runtime
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all) __defProp(target, name, {
|
|
8
|
-
get: all[name],
|
|
9
|
-
enumerable: true
|
|
10
|
-
});
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
14
|
-
key = keys[i];
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
16
|
-
get: ((k) => from[k]).bind(null, key),
|
|
17
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
return to;
|
|
21
|
-
};
|
|
22
|
-
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
23
|
-
|
|
24
|
-
//#endregion
|
|
25
|
-
export { __export, __reExport };
|