@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.cjs
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
1
|
//#region rolldown:runtime
|
|
3
2
|
var __create = Object.create;
|
|
4
3
|
var __defProp = Object.defineProperty;
|
|
@@ -6,12 +5,6 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
6
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
8
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
-
var __export = (target, all) => {
|
|
10
|
-
for (var name in all) __defProp(target, name, {
|
|
11
|
-
get: all[name],
|
|
12
|
-
enumerable: true
|
|
13
|
-
});
|
|
14
|
-
};
|
|
15
8
|
var __copyProps = (to, from, except, desc) => {
|
|
16
9
|
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
17
10
|
key = keys[i];
|
|
@@ -22,31 +15,39 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
22
15
|
}
|
|
23
16
|
return to;
|
|
24
17
|
};
|
|
25
|
-
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
26
18
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
27
19
|
value: mod,
|
|
28
20
|
enumerable: true
|
|
29
21
|
}) : target, mod));
|
|
30
22
|
|
|
31
23
|
//#endregion
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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);
|
|
35
30
|
|
|
36
31
|
//#region src/tailwindcss.ts
|
|
37
|
-
async function tailwindcss(options) {
|
|
38
|
-
const { overrides = {} } = options
|
|
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
|
+
};
|
|
39
42
|
return [{
|
|
40
|
-
name: "wongxy/tailwindcss",
|
|
41
|
-
plugins: { tw:
|
|
43
|
+
name: "wongxy/tailwindcss/setup",
|
|
44
|
+
plugins: { tw: eslint_plugin_better_tailwindcss.default },
|
|
42
45
|
languageOptions: { parserOptions: { ecmaFeatures: { jsx: true } } },
|
|
46
|
+
...!!settings && { settings: { "better-tailwindcss": settings } }
|
|
47
|
+
}, {
|
|
48
|
+
name: "wongxy/tailwindcss/rules",
|
|
43
49
|
rules: {
|
|
44
|
-
|
|
45
|
-
"tw/enforces-negative-arbitrary-values": "warn",
|
|
46
|
-
"tw/enforces-shorthand": "warn",
|
|
47
|
-
"tw/migration-from-tailwind-2": "warn",
|
|
48
|
-
"tw/no-arbitrary-value": "off",
|
|
49
|
-
"tw/no-contradicting-classname": "error",
|
|
50
|
+
...rules,
|
|
50
51
|
...overrides
|
|
51
52
|
}
|
|
52
53
|
}];
|
|
@@ -54,11 +55,6 @@ async function tailwindcss(options) {
|
|
|
54
55
|
|
|
55
56
|
//#endregion
|
|
56
57
|
//#region src/index.ts
|
|
57
|
-
var src_exports = {};
|
|
58
|
-
__export(src_exports, {
|
|
59
|
-
default: () => wongxy,
|
|
60
|
-
tailwindcss: () => tailwindcss
|
|
61
|
-
});
|
|
62
58
|
const VuePackages = [
|
|
63
59
|
"vue",
|
|
64
60
|
"nuxt",
|
|
@@ -71,80 +67,80 @@ const ReactPackages = [
|
|
|
71
67
|
"react-dom",
|
|
72
68
|
"next"
|
|
73
69
|
];
|
|
74
|
-
function
|
|
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
|
-
|
|
70
|
+
function resolveRules(overrides, rules) {
|
|
71
|
+
return Object.fromEntries(Object.entries(rules).filter(([k]) => !overrides[k]));
|
|
72
|
+
}
|
|
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
|
+
groups: [
|
|
93
|
+
"reserved-first",
|
|
94
|
+
"reserved-second",
|
|
95
|
+
"unknown",
|
|
96
|
+
"reserved-last"
|
|
97
|
+
],
|
|
98
|
+
customGroups: {
|
|
99
|
+
"reserved-first": ["key", "ref"],
|
|
100
|
+
"reserved-second": ["id", "name"],
|
|
101
|
+
"reserved-last": ["asChild"]
|
|
102
|
+
}
|
|
103
|
+
}]
|
|
104
|
+
})
|
|
100
105
|
});
|
|
101
|
-
if (
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
"ts/no-use-before-define": "off"
|
|
137
|
-
} : void 0,
|
|
138
|
-
...typescript.overrides
|
|
139
|
-
}
|
|
140
|
-
};
|
|
106
|
+
if (enableVue) configs.push({
|
|
107
|
+
name: "wongxy/vue",
|
|
108
|
+
files: [__antfu_eslint_config.GLOB_VUE],
|
|
109
|
+
rules: resolveRules((0, __antfu_eslint_config.getOverrides)(options, "vue"), {
|
|
110
|
+
"vue/singleline-html-element-content-newline": "off",
|
|
111
|
+
"vue/valid-template-root": "off",
|
|
112
|
+
"vue/block-order": ["warn", { order: [["script", "template"], "style"] }],
|
|
113
|
+
"vue/custom-event-name-casing": "off"
|
|
114
|
+
})
|
|
115
|
+
});
|
|
116
|
+
if (enableReact) configs.push({
|
|
117
|
+
name: "wongxy/react",
|
|
118
|
+
files: [__antfu_eslint_config.GLOB_SRC],
|
|
119
|
+
rules: resolveRules((0, __antfu_eslint_config.getOverrides)(options, "react"), { "react/prefer-destructuring-assignment": "off" })
|
|
120
|
+
});
|
|
121
|
+
if (enableTypeScript) configs.push({
|
|
122
|
+
name: "wongxy/typescript",
|
|
123
|
+
files: [__antfu_eslint_config.GLOB_TS, __antfu_eslint_config.GLOB_TSX],
|
|
124
|
+
rules: resolveRules((0, __antfu_eslint_config.getOverrides)(options, "typescript"), { "ts/consistent-type-imports": ["error", {
|
|
125
|
+
disallowTypeAnnotations: false,
|
|
126
|
+
fixStyle: "inline-type-imports",
|
|
127
|
+
prefer: "type-imports"
|
|
128
|
+
}] })
|
|
129
|
+
});
|
|
130
|
+
if (enableReactNative) configs.push({
|
|
131
|
+
name: "wongxy/reactnative",
|
|
132
|
+
files: [__antfu_eslint_config.GLOB_TS, __antfu_eslint_config.GLOB_TSX],
|
|
133
|
+
rules: resolveRules((0, __antfu_eslint_config.getOverrides)(options, "typescript"), {
|
|
134
|
+
"ts/no-require-imports": "off",
|
|
135
|
+
"ts/no-use-before-define": "off"
|
|
136
|
+
})
|
|
137
|
+
});
|
|
138
|
+
if (enableTailwind) {
|
|
139
|
+
const tw = typeof options.tailwindcss === "object" ? options.tailwindcss : void 0;
|
|
140
|
+
configs.push(tailwindcss(tw));
|
|
141
141
|
}
|
|
142
|
-
|
|
143
|
-
delete finalOptions.reactnative;
|
|
144
|
-
delete finalOptions.tailwindcss;
|
|
145
|
-
return (0, __antfu_eslint_config.antfu)(finalOptions, ...userConfigs);
|
|
142
|
+
return (0, __antfu_eslint_config.antfu)(options, ...configs, ...userConfigs);
|
|
146
143
|
}
|
|
147
144
|
|
|
148
145
|
//#endregion
|
|
149
|
-
exports
|
|
150
|
-
exports.tailwindcss = tailwindcss;
|
|
146
|
+
module.exports = wongxy;
|