@wongxy/eslint-config 2.0.1 → 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 +83 -98
- package/dist/index.d.cts +627 -131
- package/dist/index.d.ts +627 -129
- package/dist/index.js +78 -90
- package/package.json +9 -11
- 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,69 @@ 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
|
-
name: "wongxy/rules",
|
|
71
|
-
rules
|
|
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
|
+
}]
|
|
67
|
+
})
|
|
72
68
|
});
|
|
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
|
-
};
|
|
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));
|
|
113
104
|
}
|
|
114
|
-
|
|
115
|
-
delete finalOptions.reactnative;
|
|
116
|
-
delete finalOptions.tailwindcss;
|
|
117
|
-
return antfu(finalOptions, ...userConfigs);
|
|
105
|
+
return antfu(options, ...configs, ...userConfigs);
|
|
118
106
|
}
|
|
119
107
|
|
|
120
108
|
//#endregion
|
|
121
|
-
export { wongxy as default
|
|
109
|
+
export { wongxy as default };
|
package/package.json
CHANGED
|
@@ -1,17 +1,15 @@
|
|
|
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
|
],
|
|
@@ -20,9 +18,9 @@
|
|
|
20
18
|
"@next/eslint-plugin-next": "^15.5.2",
|
|
21
19
|
"@unocss/eslint-plugin": "^66.1.2",
|
|
22
20
|
"eslint": "^9.27.0",
|
|
21
|
+
"eslint-plugin-better-tailwindcss": "^3.7.9",
|
|
23
22
|
"eslint-plugin-react-hooks": "^5.2.0",
|
|
24
|
-
"eslint-plugin-react-refresh": "^0.4.20"
|
|
25
|
-
"eslint-plugin-tailwindcss": ">=3.18.0"
|
|
23
|
+
"eslint-plugin-react-refresh": "^0.4.20"
|
|
26
24
|
},
|
|
27
25
|
"dependencies": {
|
|
28
26
|
"@antfu/eslint-config": "^5.2.1",
|
|
@@ -30,8 +28,8 @@
|
|
|
30
28
|
"local-pkg": "^1.1.2"
|
|
31
29
|
},
|
|
32
30
|
"devDependencies": {
|
|
31
|
+
"@antfu/ni": "^26.0.1",
|
|
33
32
|
"@types/eslint": "^9.6.1",
|
|
34
|
-
"@types/eslint-plugin-tailwindcss": "3.17.0",
|
|
35
33
|
"@types/node": "^24.3.0",
|
|
36
34
|
"bumpp": "^10.2.3",
|
|
37
35
|
"eslint": "^9.34.0",
|
|
@@ -44,11 +42,11 @@
|
|
|
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 };
|