@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.cjs
CHANGED
|
@@ -1,152 +1,135 @@
|
|
|
1
|
-
|
|
1
|
+
//#region rolldown:runtime
|
|
2
2
|
var __create = Object.create;
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
8
|
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
10
|
+
key = keys[i];
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
12
|
+
get: ((k) => from[k]).bind(null, key),
|
|
13
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
19
17
|
};
|
|
20
|
-
var
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
-
mod
|
|
28
|
-
));
|
|
29
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
19
|
+
value: mod,
|
|
20
|
+
enumerable: true
|
|
21
|
+
}) : target, mod));
|
|
30
22
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
var import_eslint_config = require("@antfu/eslint-config");
|
|
39
|
-
var import_local_pkg = require("local-pkg");
|
|
23
|
+
//#endregion
|
|
24
|
+
let __antfu_eslint_config = require("@antfu/eslint-config");
|
|
25
|
+
__antfu_eslint_config = __toESM(__antfu_eslint_config);
|
|
26
|
+
let local_pkg = require("local-pkg");
|
|
27
|
+
local_pkg = __toESM(local_pkg);
|
|
28
|
+
let eslint_plugin_better_tailwindcss = require("eslint-plugin-better-tailwindcss");
|
|
29
|
+
eslint_plugin_better_tailwindcss = __toESM(eslint_plugin_better_tailwindcss);
|
|
40
30
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
// 'tw/no-custom-classname': 'warn',
|
|
65
|
-
"tw/no-contradicting-classname": "error",
|
|
66
|
-
// 'tw/no-unnecessary-arbitrary-value': 'warn',
|
|
67
|
-
...overrides
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
];
|
|
31
|
+
//#region src/tailwindcss.ts
|
|
32
|
+
async function tailwindcss(options = {}) {
|
|
33
|
+
const { overrides = {}, settings } = options;
|
|
34
|
+
const rules = {
|
|
35
|
+
"tw/enforce-consistent-class-order": "warn",
|
|
36
|
+
"tw/enforce-consistent-line-wrapping": ["warn", { printWidth: 100 }],
|
|
37
|
+
"tw/no-duplicate-classes": "warn",
|
|
38
|
+
"tw/no-unnecessary-whitespace": "warn",
|
|
39
|
+
"tw/no-conflicting-classes": "warn",
|
|
40
|
+
"tw/no-unregistered-classes": "warn"
|
|
41
|
+
};
|
|
42
|
+
return [{
|
|
43
|
+
name: "wongxy/tailwindcss/setup",
|
|
44
|
+
plugins: { tw: eslint_plugin_better_tailwindcss.default },
|
|
45
|
+
languageOptions: { parserOptions: { ecmaFeatures: { jsx: true } } },
|
|
46
|
+
...!!settings && { settings: { "better-tailwindcss": settings } }
|
|
47
|
+
}, {
|
|
48
|
+
name: "wongxy/tailwindcss/rules",
|
|
49
|
+
rules: {
|
|
50
|
+
...rules,
|
|
51
|
+
...overrides
|
|
52
|
+
}
|
|
53
|
+
}];
|
|
71
54
|
}
|
|
72
55
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
tailwindcss: options.tailwindcss ?? (0, import_local_pkg.isPackageExists)("tailwindcss")
|
|
90
|
-
};
|
|
91
|
-
const rules = {
|
|
92
|
-
"no-console": "off",
|
|
93
|
-
"no-alert": "off",
|
|
94
|
-
"no-multiple-empty-lines": "warn",
|
|
95
|
-
"antfu/top-level-function": "off",
|
|
96
|
-
"antfu/if-newline": "off",
|
|
97
|
-
// 'import/order': ['error', { 'newlines-between': 'always' }],
|
|
98
|
-
"style/brace-style": ["error", "1tbs", { allowSingleLine: true }]
|
|
99
|
-
};
|
|
100
|
-
for (const key in finalOptions.rules)
|
|
101
|
-
delete rules[key];
|
|
102
|
-
userConfigs.splice(0, 0, { name: "wongxy/rules", rules });
|
|
103
|
-
if (finalOptions.vue) {
|
|
104
|
-
const vue = typeof finalOptions.vue === "object" ? finalOptions.vue : {};
|
|
105
|
-
finalOptions.vue = {
|
|
106
|
-
...vue,
|
|
107
|
-
overrides: {
|
|
108
|
-
"vue/singleline-html-element-content-newline": "off",
|
|
109
|
-
"vue/valid-template-root": "off",
|
|
110
|
-
"vue/block-order": ["warn", { order: [["script", "template"], "style"] }],
|
|
111
|
-
"vue/custom-event-name-casing": "off",
|
|
112
|
-
...vue.overrides
|
|
113
|
-
}
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
if (finalOptions.react) {
|
|
117
|
-
const react = typeof finalOptions.react === "object" ? finalOptions.react : {};
|
|
118
|
-
finalOptions.react = {
|
|
119
|
-
...react,
|
|
120
|
-
overrides: {
|
|
121
|
-
"react/prefer-destructuring-assignment": "off",
|
|
122
|
-
...react.overrides
|
|
123
|
-
}
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
if (finalOptions.typescript) {
|
|
127
|
-
const typescript = typeof finalOptions.typescript === "object" ? finalOptions.typescript : {};
|
|
128
|
-
finalOptions.typescript = {
|
|
129
|
-
...typescript,
|
|
130
|
-
overrides: {
|
|
131
|
-
"ts/consistent-type-imports": ["error", { disallowTypeAnnotations: false, fixStyle: "inline-type-imports", prefer: "type-imports" }],
|
|
132
|
-
...finalOptions.reactnative ? {
|
|
133
|
-
"ts/no-require-imports": "off",
|
|
134
|
-
"ts/no-use-before-define": "off"
|
|
135
|
-
} : void 0,
|
|
136
|
-
...typescript.overrides
|
|
137
|
-
}
|
|
138
|
-
};
|
|
139
|
-
}
|
|
140
|
-
if (finalOptions.tailwindcss) {
|
|
141
|
-
userConfigs.splice(0, 0, tailwindcss({
|
|
142
|
-
overrides: typeof finalOptions.tailwindcss === "object" ? finalOptions.tailwindcss.overrides : void 0
|
|
143
|
-
}));
|
|
144
|
-
}
|
|
145
|
-
delete finalOptions.reactnative;
|
|
146
|
-
delete finalOptions.tailwindcss;
|
|
147
|
-
return (0, import_eslint_config.antfu)(finalOptions, ...userConfigs);
|
|
56
|
+
//#endregion
|
|
57
|
+
//#region src/index.ts
|
|
58
|
+
const VuePackages = [
|
|
59
|
+
"vue",
|
|
60
|
+
"nuxt",
|
|
61
|
+
"vitepress",
|
|
62
|
+
"@slidev/cli"
|
|
63
|
+
];
|
|
64
|
+
const ReactPackages = [
|
|
65
|
+
"react",
|
|
66
|
+
"react-native",
|
|
67
|
+
"react-dom",
|
|
68
|
+
"next"
|
|
69
|
+
];
|
|
70
|
+
function resolveRules(overrides, rules) {
|
|
71
|
+
return Object.fromEntries(Object.entries(rules).filter(([k]) => !overrides[k]));
|
|
148
72
|
}
|
|
149
|
-
|
|
150
|
-
0
|
|
151
|
-
|
|
152
|
-
|
|
73
|
+
function wongxy(options = {}, ...userConfigs) {
|
|
74
|
+
const { react: enableReact = ReactPackages.some((i) => (0, local_pkg.isPackageExists)(i)), typescript: enableTypeScript = (0, local_pkg.isPackageExists)("typescript"), vue: enableVue = VuePackages.some((i) => (0, local_pkg.isPackageExists)(i)), tailwindcss: enableTailwind = (0, local_pkg.isPackageExists)("tailwindcss"), reactnative: enableReactNative = (0, local_pkg.isPackageExists)("react-native") } = options;
|
|
75
|
+
const configs = [];
|
|
76
|
+
configs.push({
|
|
77
|
+
name: "wongxy/common",
|
|
78
|
+
rules: resolveRules(options.rules ?? {}, {
|
|
79
|
+
"no-console": "off",
|
|
80
|
+
"no-alert": "off",
|
|
81
|
+
"no-multiple-empty-lines": "warn",
|
|
82
|
+
"antfu/top-level-function": "off",
|
|
83
|
+
"antfu/if-newline": "off",
|
|
84
|
+
"style/brace-style": [
|
|
85
|
+
"error",
|
|
86
|
+
"1tbs",
|
|
87
|
+
{ allowSingleLine: true }
|
|
88
|
+
],
|
|
89
|
+
"perfectionist/sort-jsx-props": ["warn", {
|
|
90
|
+
order: "asc",
|
|
91
|
+
type: "natural"
|
|
92
|
+
}]
|
|
93
|
+
})
|
|
94
|
+
});
|
|
95
|
+
if (enableVue) configs.push({
|
|
96
|
+
name: "wongxy/vue",
|
|
97
|
+
files: [__antfu_eslint_config.GLOB_VUE],
|
|
98
|
+
rules: resolveRules((0, __antfu_eslint_config.getOverrides)(options, "vue"), {
|
|
99
|
+
"vue/singleline-html-element-content-newline": "off",
|
|
100
|
+
"vue/valid-template-root": "off",
|
|
101
|
+
"vue/block-order": ["warn", { order: [["script", "template"], "style"] }],
|
|
102
|
+
"vue/custom-event-name-casing": "off"
|
|
103
|
+
})
|
|
104
|
+
});
|
|
105
|
+
if (enableReact) configs.push({
|
|
106
|
+
name: "wongxy/react",
|
|
107
|
+
files: [__antfu_eslint_config.GLOB_SRC],
|
|
108
|
+
rules: resolveRules((0, __antfu_eslint_config.getOverrides)(options, "react"), { "react/prefer-destructuring-assignment": "off" })
|
|
109
|
+
});
|
|
110
|
+
if (enableTypeScript) configs.push({
|
|
111
|
+
name: "wongxy/typescript",
|
|
112
|
+
files: [__antfu_eslint_config.GLOB_TS, __antfu_eslint_config.GLOB_TSX],
|
|
113
|
+
rules: resolveRules((0, __antfu_eslint_config.getOverrides)(options, "typescript"), { "ts/consistent-type-imports": ["error", {
|
|
114
|
+
disallowTypeAnnotations: false,
|
|
115
|
+
fixStyle: "inline-type-imports",
|
|
116
|
+
prefer: "type-imports"
|
|
117
|
+
}] })
|
|
118
|
+
});
|
|
119
|
+
if (enableReactNative) configs.push({
|
|
120
|
+
name: "wongxy/reactnative",
|
|
121
|
+
files: [__antfu_eslint_config.GLOB_TS, __antfu_eslint_config.GLOB_TSX],
|
|
122
|
+
rules: resolveRules((0, __antfu_eslint_config.getOverrides)(options, "typescript"), {
|
|
123
|
+
"ts/no-require-imports": "off",
|
|
124
|
+
"ts/no-use-before-define": "off"
|
|
125
|
+
})
|
|
126
|
+
});
|
|
127
|
+
if (enableTailwind) {
|
|
128
|
+
const tw = typeof options.tailwindcss === "object" ? options.tailwindcss : void 0;
|
|
129
|
+
configs.push(tailwindcss(tw));
|
|
130
|
+
}
|
|
131
|
+
return (0, __antfu_eslint_config.antfu)(options, ...configs, ...userConfigs);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
//#endregion
|
|
135
|
+
module.exports = wongxy;
|