@icebreakers/eslint-config 1.6.28 → 1.6.30
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 +384 -613
- package/dist/index.d.cts +2947 -38
- package/dist/index.d.ts +2947 -38
- package/dist/index.js +374 -585
- package/index.d.ts +54 -0
- package/package.json +16 -16
package/dist/index.cjs
CHANGED
|
@@ -1,678 +1,449 @@
|
|
|
1
|
-
"
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
//#region \0rolldown/runtime.js
|
|
2
3
|
var __create = Object.create;
|
|
3
4
|
var __defProp = Object.defineProperty;
|
|
4
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
7
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
8
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
var __exportAll = (all, no_symbols) => {
|
|
10
|
+
let target = {};
|
|
11
|
+
for (var name in all) __defProp(target, name, {
|
|
12
|
+
get: all[name],
|
|
13
|
+
enumerable: true
|
|
14
|
+
});
|
|
15
|
+
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
16
|
+
return target;
|
|
11
17
|
};
|
|
12
18
|
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
20
|
+
key = keys[i];
|
|
21
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
22
|
+
get: ((k) => from[k]).bind(null, key),
|
|
23
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
return to;
|
|
19
27
|
};
|
|
20
28
|
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
21
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
)
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
icebreaker: () => icebreaker,
|
|
36
|
-
icebreakerLegacy: () => icebreakerLegacy
|
|
37
|
-
});
|
|
38
|
-
module.exports = __toCommonJS(index_exports);
|
|
39
|
-
|
|
40
|
-
// ../../node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.6_tsx@4.21.0_typescript@5.9.3_yaml@2.8.2/node_modules/tsup/assets/cjs_shims.js
|
|
41
|
-
var getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.tagName.toUpperCase() === "SCRIPT" ? document.currentScript.src : new URL("main.js", document.baseURI).href;
|
|
42
|
-
var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
|
|
43
|
-
|
|
44
|
-
// src/antfu.ts
|
|
45
|
-
var antfu_exports = {};
|
|
29
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
30
|
+
value: mod,
|
|
31
|
+
enumerable: true
|
|
32
|
+
}) : target, mod));
|
|
33
|
+
//#endregion
|
|
34
|
+
let node_fs = require("node:fs");
|
|
35
|
+
node_fs = __toESM(node_fs);
|
|
36
|
+
let node_module = require("node:module");
|
|
37
|
+
let node_path = require("node:path");
|
|
38
|
+
node_path = __toESM(node_path);
|
|
39
|
+
let node_process = require("node:process");
|
|
40
|
+
node_process = __toESM(node_process);
|
|
41
|
+
//#region src/antfu.ts
|
|
42
|
+
var antfu_exports = /* @__PURE__ */ __exportAll({});
|
|
46
43
|
__reExport(antfu_exports, require("@antfu/eslint-config"));
|
|
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
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
44
|
+
//#endregion
|
|
45
|
+
//#region src/defaults.ts
|
|
46
|
+
const INLINE_ELEMENTS = [
|
|
47
|
+
"a",
|
|
48
|
+
"abbr",
|
|
49
|
+
"audio",
|
|
50
|
+
"b",
|
|
51
|
+
"bdi",
|
|
52
|
+
"bdo",
|
|
53
|
+
"canvas",
|
|
54
|
+
"cite",
|
|
55
|
+
"code",
|
|
56
|
+
"data",
|
|
57
|
+
"del",
|
|
58
|
+
"dfn",
|
|
59
|
+
"em",
|
|
60
|
+
"i",
|
|
61
|
+
"iframe",
|
|
62
|
+
"ins",
|
|
63
|
+
"kbd",
|
|
64
|
+
"label",
|
|
65
|
+
"map",
|
|
66
|
+
"mark",
|
|
67
|
+
"noscript",
|
|
68
|
+
"object",
|
|
69
|
+
"output",
|
|
70
|
+
"picture",
|
|
71
|
+
"q",
|
|
72
|
+
"ruby",
|
|
73
|
+
"s",
|
|
74
|
+
"samp",
|
|
75
|
+
"small",
|
|
76
|
+
"span",
|
|
77
|
+
"strong",
|
|
78
|
+
"sub",
|
|
79
|
+
"sup",
|
|
80
|
+
"svg",
|
|
81
|
+
"time",
|
|
82
|
+
"u",
|
|
83
|
+
"var",
|
|
84
|
+
"video"
|
|
88
85
|
];
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
allowDeclarations: true,
|
|
110
|
-
allowDefinitionFiles: true
|
|
111
|
-
}
|
|
112
|
-
],
|
|
113
|
-
"ts/ban-types": [
|
|
114
|
-
"error",
|
|
115
|
-
{
|
|
116
|
-
extendDefaults: true,
|
|
117
|
-
types: {
|
|
118
|
-
Function: false
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
]
|
|
86
|
+
const nestjsTypeScriptRules = {
|
|
87
|
+
"ts/explicit-function-return-type": "off",
|
|
88
|
+
"ts/explicit-module-boundary-types": "off",
|
|
89
|
+
"ts/no-explicit-any": "off",
|
|
90
|
+
"ts/no-parameter-properties": "off",
|
|
91
|
+
"ts/no-empty-function": ["error", { allow: [
|
|
92
|
+
"decoratedFunctions",
|
|
93
|
+
"overrideMethods",
|
|
94
|
+
"private-constructors",
|
|
95
|
+
"protected-constructors"
|
|
96
|
+
] }],
|
|
97
|
+
"ts/no-empty-interface": "off",
|
|
98
|
+
"ts/no-namespace": ["error", {
|
|
99
|
+
allowDeclarations: true,
|
|
100
|
+
allowDefinitionFiles: true
|
|
101
|
+
}],
|
|
102
|
+
"ts/ban-types": ["error", {
|
|
103
|
+
extendDefaults: true,
|
|
104
|
+
types: { Function: false }
|
|
105
|
+
}]
|
|
122
106
|
};
|
|
123
107
|
function getDefaultVueOptions(opts) {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
if (opts?.ionic) {
|
|
144
|
-
overrides["vue/no-deprecated-slot-attribute"] = "off";
|
|
145
|
-
}
|
|
146
|
-
if (opts?.weapp) {
|
|
147
|
-
overrides["vue/singleline-html-element-content-newline"] = [
|
|
148
|
-
"warn",
|
|
149
|
-
{
|
|
150
|
-
ignoreWhenNoAttributes: true,
|
|
151
|
-
ignoreWhenEmpty: true,
|
|
152
|
-
ignores: [
|
|
153
|
-
// 小程序标签
|
|
154
|
-
"text",
|
|
155
|
-
...INLINE_ELEMENTS
|
|
156
|
-
],
|
|
157
|
-
externalIgnores: []
|
|
158
|
-
}
|
|
159
|
-
];
|
|
160
|
-
}
|
|
161
|
-
const vueOptions = {
|
|
162
|
-
overrides
|
|
163
|
-
};
|
|
164
|
-
return vueOptions;
|
|
108
|
+
const overrides = {
|
|
109
|
+
"vue/attribute-hyphenation": "off",
|
|
110
|
+
"vue/v-on-event-hyphenation": "off",
|
|
111
|
+
"vue/custom-event-name-casing": "off",
|
|
112
|
+
"vue/no-mutating-props": "warn",
|
|
113
|
+
"vue/no-useless-v-bind": ["error", {
|
|
114
|
+
ignoreIncludesComment: false,
|
|
115
|
+
ignoreStringEscape: true
|
|
116
|
+
}],
|
|
117
|
+
"vue/no-unused-refs": "warn"
|
|
118
|
+
};
|
|
119
|
+
if (opts?.ionic) overrides["vue/no-deprecated-slot-attribute"] = "off";
|
|
120
|
+
if (opts?.weapp) overrides["vue/singleline-html-element-content-newline"] = ["warn", {
|
|
121
|
+
ignoreWhenNoAttributes: true,
|
|
122
|
+
ignoreWhenEmpty: true,
|
|
123
|
+
ignores: ["text", ...INLINE_ELEMENTS],
|
|
124
|
+
externalIgnores: []
|
|
125
|
+
}];
|
|
126
|
+
return { overrides };
|
|
165
127
|
}
|
|
166
128
|
function getDefaultTypescriptOptions(opts) {
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
allowTernary: true
|
|
188
|
-
}
|
|
189
|
-
]
|
|
190
|
-
};
|
|
191
|
-
if (opts?.nestjs) {
|
|
192
|
-
Object.assign(overrides, nestjsTypeScriptRules);
|
|
193
|
-
}
|
|
194
|
-
const typescriptOptions = {
|
|
195
|
-
overrides
|
|
196
|
-
};
|
|
197
|
-
return typescriptOptions;
|
|
129
|
+
const overrides = {
|
|
130
|
+
"ts/no-unused-vars": ["error", {
|
|
131
|
+
args: "all",
|
|
132
|
+
argsIgnorePattern: "^_",
|
|
133
|
+
caughtErrors: "all",
|
|
134
|
+
caughtErrorsIgnorePattern: "^_",
|
|
135
|
+
destructuredArrayIgnorePattern: "^_",
|
|
136
|
+
varsIgnorePattern: "^_",
|
|
137
|
+
ignoreRestSiblings: true
|
|
138
|
+
}],
|
|
139
|
+
"ts/prefer-ts-expect-error": "off",
|
|
140
|
+
"ts/ban-ts-comment": "off",
|
|
141
|
+
"ts/no-use-before-define": "warn",
|
|
142
|
+
"ts/no-unused-expressions": ["error", {
|
|
143
|
+
allowShortCircuit: true,
|
|
144
|
+
allowTernary: true
|
|
145
|
+
}]
|
|
146
|
+
};
|
|
147
|
+
if (opts?.nestjs) Object.assign(overrides, nestjsTypeScriptRules);
|
|
148
|
+
return { overrides };
|
|
198
149
|
}
|
|
199
|
-
|
|
200
|
-
|
|
150
|
+
//#endregion
|
|
151
|
+
//#region src/features.ts
|
|
201
152
|
function resolveTailwindPresets(option) {
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
"better-tailwindcss": {
|
|
222
|
-
entryPoint: option.entryPoint,
|
|
223
|
-
tailwindConfig: option.tailwindConfig
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
};
|
|
227
|
-
})
|
|
228
|
-
];
|
|
229
|
-
}
|
|
230
|
-
return [
|
|
231
|
-
// @ts-ignore optional dependency shape
|
|
232
|
-
(0, antfu_exports.interopDefault)(
|
|
233
|
-
import("eslint-plugin-tailwindcss")
|
|
234
|
-
).then((tailwind) => {
|
|
235
|
-
return tailwind.configs["flat/recommended"];
|
|
236
|
-
}),
|
|
237
|
-
{
|
|
238
|
-
rules: {
|
|
239
|
-
"tailwindcss/no-custom-classname": "off"
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
];
|
|
153
|
+
if (!option) return [];
|
|
154
|
+
if (typeof option === "object") return [(0, antfu_exports.interopDefault)(import("eslint-plugin-better-tailwindcss")).then((eslintPluginBetterTailwindcss) => {
|
|
155
|
+
const betterTailwindcssRules = {
|
|
156
|
+
...eslintPluginBetterTailwindcss.configs["recommended-warn"].rules,
|
|
157
|
+
...eslintPluginBetterTailwindcss.configs["recommended-error"].rules
|
|
158
|
+
};
|
|
159
|
+
return {
|
|
160
|
+
name: "icebreaker/better-tailwindcss",
|
|
161
|
+
plugins: { "better-tailwindcss": eslintPluginBetterTailwindcss },
|
|
162
|
+
rules: betterTailwindcssRules,
|
|
163
|
+
settings: { "better-tailwindcss": {
|
|
164
|
+
entryPoint: option.entryPoint,
|
|
165
|
+
tailwindConfig: option.tailwindConfig
|
|
166
|
+
} }
|
|
167
|
+
};
|
|
168
|
+
})];
|
|
169
|
+
return [(0, antfu_exports.interopDefault)(import("eslint-plugin-tailwindcss")).then((tailwind) => {
|
|
170
|
+
return tailwind.configs["flat/recommended"];
|
|
171
|
+
}), { rules: { "tailwindcss/no-custom-classname": "off" } }];
|
|
243
172
|
}
|
|
244
173
|
function resolveMdxPresets(isEnabled) {
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
{
|
|
259
|
-
...mdx.flatCodeBlocks,
|
|
260
|
-
rules: {
|
|
261
|
-
...mdx.flatCodeBlocks.rules
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
];
|
|
265
|
-
})
|
|
266
|
-
];
|
|
174
|
+
if (!isEnabled) return [];
|
|
175
|
+
return [(0, antfu_exports.interopDefault)(import("eslint-plugin-mdx")).then((mdx) => {
|
|
176
|
+
return [{
|
|
177
|
+
...mdx.flat,
|
|
178
|
+
processor: mdx.createRemarkProcessor({
|
|
179
|
+
lintCodeBlocks: true,
|
|
180
|
+
languageMapper: {}
|
|
181
|
+
})
|
|
182
|
+
}, {
|
|
183
|
+
...mdx.flatCodeBlocks,
|
|
184
|
+
rules: { ...mdx.flatCodeBlocks.rules }
|
|
185
|
+
}];
|
|
186
|
+
})];
|
|
267
187
|
}
|
|
268
188
|
function resolveAccessibilityPresets(isEnabled, vueOption, reactOption) {
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
return pluginVueA11y.configs["flat/recommended"];
|
|
279
|
-
})
|
|
280
|
-
);
|
|
281
|
-
}
|
|
282
|
-
if (reactOption) {
|
|
283
|
-
presets.push(
|
|
284
|
-
(0, antfu_exports.interopDefault)(
|
|
285
|
-
// @ts-ignore optional dependency shape
|
|
286
|
-
import("eslint-plugin-jsx-a11y")
|
|
287
|
-
).then((jsxA11y) => {
|
|
288
|
-
return jsxA11y.flatConfigs.recommended;
|
|
289
|
-
})
|
|
290
|
-
);
|
|
291
|
-
}
|
|
292
|
-
return presets;
|
|
189
|
+
if (!isEnabled) return [];
|
|
190
|
+
const presets = [];
|
|
191
|
+
if (vueOption) presets.push((0, antfu_exports.interopDefault)(import("eslint-plugin-vuejs-accessibility")).then((pluginVueA11y) => {
|
|
192
|
+
return pluginVueA11y.configs["flat/recommended"];
|
|
193
|
+
}));
|
|
194
|
+
if (reactOption) presets.push((0, antfu_exports.interopDefault)(import("eslint-plugin-jsx-a11y")).then((jsxA11y) => {
|
|
195
|
+
return jsxA11y.flatConfigs.recommended;
|
|
196
|
+
}));
|
|
197
|
+
return presets;
|
|
293
198
|
}
|
|
294
199
|
function resolveNestPresets(isEnabled) {
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
rules: nestjsTypeScriptRules
|
|
301
|
-
}];
|
|
200
|
+
if (!isEnabled) return [];
|
|
201
|
+
return [{
|
|
202
|
+
name: "icebreaker/nestjs/rules",
|
|
203
|
+
rules: nestjsTypeScriptRules
|
|
204
|
+
}];
|
|
302
205
|
}
|
|
303
206
|
function resolveQueryPresets(isEnabled) {
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
}
|
|
307
|
-
return [
|
|
308
|
-
(0, antfu_exports.interopDefault)(
|
|
309
|
-
import("@tanstack/eslint-plugin-query")
|
|
310
|
-
).then((pluginQuery) => pluginQuery.configs["flat/recommended"])
|
|
311
|
-
];
|
|
207
|
+
if (!isEnabled) return [];
|
|
208
|
+
return [(0, antfu_exports.interopDefault)(import("@tanstack/eslint-plugin-query")).then((pluginQuery) => pluginQuery.configs["flat/recommended"])];
|
|
312
209
|
}
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
var import_node_fs = __toESM(require("fs"), 1);
|
|
316
|
-
var import_node_module = require("module");
|
|
317
|
-
var import_node_path = __toESM(require("path"), 1);
|
|
318
|
-
var import_node_process = __toESM(require("process"), 1);
|
|
319
|
-
|
|
320
|
-
// ../../node_modules/.pnpm/defu@6.1.4/node_modules/defu/dist/defu.mjs
|
|
210
|
+
//#endregion
|
|
211
|
+
//#region ../../node_modules/.pnpm/defu@6.1.4/node_modules/defu/dist/defu.mjs
|
|
321
212
|
function isPlainObject(value) {
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
}
|
|
329
|
-
if (Symbol.iterator in value) {
|
|
330
|
-
return false;
|
|
331
|
-
}
|
|
332
|
-
if (Symbol.toStringTag in value) {
|
|
333
|
-
return Object.prototype.toString.call(value) === "[object Module]";
|
|
334
|
-
}
|
|
335
|
-
return true;
|
|
213
|
+
if (value === null || typeof value !== "object") return false;
|
|
214
|
+
const prototype = Object.getPrototypeOf(value);
|
|
215
|
+
if (prototype !== null && prototype !== Object.prototype && Object.getPrototypeOf(prototype) !== null) return false;
|
|
216
|
+
if (Symbol.iterator in value) return false;
|
|
217
|
+
if (Symbol.toStringTag in value) return Object.prototype.toString.call(value) === "[object Module]";
|
|
218
|
+
return true;
|
|
336
219
|
}
|
|
337
220
|
function _defu(baseObject, defaults, namespace = ".", merger) {
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
if (merger && merger(object, key, value, namespace)) {
|
|
351
|
-
continue;
|
|
352
|
-
}
|
|
353
|
-
if (Array.isArray(value) && Array.isArray(object[key])) {
|
|
354
|
-
object[key] = [...value, ...object[key]];
|
|
355
|
-
} else if (isPlainObject(value) && isPlainObject(object[key])) {
|
|
356
|
-
object[key] = _defu(
|
|
357
|
-
value,
|
|
358
|
-
object[key],
|
|
359
|
-
(namespace ? `${namespace}.` : "") + key.toString(),
|
|
360
|
-
merger
|
|
361
|
-
);
|
|
362
|
-
} else {
|
|
363
|
-
object[key] = value;
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
return object;
|
|
221
|
+
if (!isPlainObject(defaults)) return _defu(baseObject, {}, namespace, merger);
|
|
222
|
+
const object = Object.assign({}, defaults);
|
|
223
|
+
for (const key in baseObject) {
|
|
224
|
+
if (key === "__proto__" || key === "constructor") continue;
|
|
225
|
+
const value = baseObject[key];
|
|
226
|
+
if (value === null || value === void 0) continue;
|
|
227
|
+
if (merger && merger(object, key, value, namespace)) continue;
|
|
228
|
+
if (Array.isArray(value) && Array.isArray(object[key])) object[key] = [...value, ...object[key]];
|
|
229
|
+
else if (isPlainObject(value) && isPlainObject(object[key])) object[key] = _defu(value, object[key], (namespace ? `${namespace}.` : "") + key.toString(), merger);
|
|
230
|
+
else object[key] = value;
|
|
231
|
+
}
|
|
232
|
+
return object;
|
|
367
233
|
}
|
|
368
234
|
function createDefu(merger) {
|
|
369
|
-
|
|
370
|
-
// eslint-disable-next-line unicorn/no-array-reduce
|
|
371
|
-
arguments_.reduce((p, c) => _defu(p, c, "", merger), {})
|
|
372
|
-
);
|
|
235
|
+
return (...arguments_) => arguments_.reduce((p, c) => _defu(p, c, "", merger), {});
|
|
373
236
|
}
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
237
|
+
const defu = createDefu();
|
|
238
|
+
createDefu((object, key, currentValue) => {
|
|
239
|
+
if (object[key] !== void 0 && typeof currentValue === "function") {
|
|
240
|
+
object[key] = currentValue(object[key]);
|
|
241
|
+
return true;
|
|
242
|
+
}
|
|
380
243
|
});
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
244
|
+
createDefu((object, key, currentValue) => {
|
|
245
|
+
if (Array.isArray(object[key]) && typeof currentValue === "function") {
|
|
246
|
+
object[key] = currentValue(object[key]);
|
|
247
|
+
return true;
|
|
248
|
+
}
|
|
386
249
|
});
|
|
387
|
-
|
|
388
|
-
|
|
250
|
+
//#endregion
|
|
251
|
+
//#region src/utils.ts
|
|
389
252
|
function isObject(o) {
|
|
390
|
-
|
|
253
|
+
return Object.prototype.toString.call(o) === "[object Object]";
|
|
391
254
|
}
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
},
|
|
403
|
-
test: {
|
|
404
|
-
overrides: {
|
|
405
|
-
"test/prefer-lowercase-title": ["off"]
|
|
406
|
-
}
|
|
407
|
-
}
|
|
255
|
+
//#endregion
|
|
256
|
+
//#region src/options.ts
|
|
257
|
+
const BASE_DEFAULTS = {
|
|
258
|
+
formatters: true,
|
|
259
|
+
pnpm: false,
|
|
260
|
+
javascript: { overrides: {
|
|
261
|
+
"curly": ["error", "all"],
|
|
262
|
+
"no-console": ["warn"]
|
|
263
|
+
} },
|
|
264
|
+
test: { overrides: { "test/prefer-lowercase-title": ["off"] } }
|
|
408
265
|
};
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
"pnpm/json-enforce-catalog": "off",
|
|
422
|
-
"pnpm/json-prefer-workspace-settings": "off",
|
|
423
|
-
"pnpm/json-valid-catalog": "off",
|
|
424
|
-
"pnpm/yaml-enforce-settings": "off",
|
|
425
|
-
"pnpm/yaml-no-duplicate-catalog-item": "off",
|
|
426
|
-
"pnpm/yaml-no-unused-catalog-item": "off",
|
|
427
|
-
"unused-imports/no-unused-vars": "off",
|
|
428
|
-
"unicorn/prefer-number-properties": "warn"
|
|
266
|
+
const BASE_RULES = {
|
|
267
|
+
"dot-notation": "off",
|
|
268
|
+
"e18e/ban-dependencies": "warn",
|
|
269
|
+
"e18e/prefer-array-to-sorted": "off",
|
|
270
|
+
"pnpm/json-enforce-catalog": "off",
|
|
271
|
+
"pnpm/json-prefer-workspace-settings": "off",
|
|
272
|
+
"pnpm/json-valid-catalog": "off",
|
|
273
|
+
"pnpm/yaml-enforce-settings": "off",
|
|
274
|
+
"pnpm/yaml-no-duplicate-catalog-item": "off",
|
|
275
|
+
"pnpm/yaml-no-unused-catalog-item": "off",
|
|
276
|
+
"unused-imports/no-unused-vars": "off",
|
|
277
|
+
"unicorn/prefer-number-properties": "warn"
|
|
429
278
|
};
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
"**.*",
|
|
440
|
-
"**/*.*"
|
|
279
|
+
const require$1 = (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href);
|
|
280
|
+
const ANTFU_PACKAGE_DIR = node_path.default.dirname(require$1.resolve("@antfu/eslint-config/package.json"));
|
|
281
|
+
const GENERAL_EDITORCONFIG_SECTIONS = new Set([
|
|
282
|
+
"*",
|
|
283
|
+
"**",
|
|
284
|
+
"**/*",
|
|
285
|
+
"*.*",
|
|
286
|
+
"**.*",
|
|
287
|
+
"**/*.*"
|
|
441
288
|
]);
|
|
442
|
-
|
|
289
|
+
const NEWLINE_PATTERN = /\r?\n/u;
|
|
443
290
|
function mergeOptionWithDefaults(input, defaults, options = {}) {
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
return input;
|
|
291
|
+
const { postProcess, useDefaultWhenUndefined = false } = options;
|
|
292
|
+
if (input === true || useDefaultWhenUndefined && input === void 0) {
|
|
293
|
+
postProcess?.(defaults);
|
|
294
|
+
return defaults;
|
|
295
|
+
}
|
|
296
|
+
if (isObject(input)) {
|
|
297
|
+
const merged = defu(input, defaults);
|
|
298
|
+
postProcess?.(merged);
|
|
299
|
+
return merged;
|
|
300
|
+
}
|
|
301
|
+
return input;
|
|
456
302
|
}
|
|
457
303
|
function applyVueVersionSpecificRules(option) {
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
Object.assign(overrides, {
|
|
474
|
-
"vue/no-v-for-template-key-on-child": "error",
|
|
475
|
-
"vue/no-v-for-template-key": "off"
|
|
476
|
-
});
|
|
304
|
+
if (!option || typeof option !== "object") return;
|
|
305
|
+
const overrides = option.overrides;
|
|
306
|
+
if (!overrides) return;
|
|
307
|
+
if (option.vueVersion === 2) {
|
|
308
|
+
Object.assign(overrides, {
|
|
309
|
+
"vue/no-v-for-template-key-on-child": "off",
|
|
310
|
+
"vue/no-v-for-template-key": "error",
|
|
311
|
+
"vue/no-deprecated-v-bind-sync": "off"
|
|
312
|
+
});
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
Object.assign(overrides, {
|
|
316
|
+
"vue/no-v-for-template-key-on-child": "error",
|
|
317
|
+
"vue/no-v-for-template-key": "off"
|
|
318
|
+
});
|
|
477
319
|
}
|
|
478
320
|
function isPackageAvailable(name, paths) {
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
321
|
+
try {
|
|
322
|
+
require$1.resolve(name, paths ? { paths } : void 0);
|
|
323
|
+
return true;
|
|
324
|
+
} catch {
|
|
325
|
+
return false;
|
|
326
|
+
}
|
|
485
327
|
}
|
|
486
|
-
function getDefaultFormatterOptions(cwd =
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
328
|
+
function getDefaultFormatterOptions(cwd = node_process.default.cwd()) {
|
|
329
|
+
const hasXmlPlugin = isPackageAvailable("@prettier/plugin-xml", [ANTFU_PACKAGE_DIR]);
|
|
330
|
+
return {
|
|
331
|
+
astro: isPackageAvailable("prettier-plugin-astro", [ANTFU_PACKAGE_DIR]),
|
|
332
|
+
css: true,
|
|
333
|
+
graphql: true,
|
|
334
|
+
html: true,
|
|
335
|
+
markdown: true,
|
|
336
|
+
slidev: isPackageAvailable("@slidev/cli", [cwd]),
|
|
337
|
+
svg: hasXmlPlugin,
|
|
338
|
+
xml: hasXmlPlugin
|
|
339
|
+
};
|
|
498
340
|
}
|
|
499
341
|
function normalizeEditorConfigEndOfLine(value) {
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
return void 0;
|
|
507
|
-
}
|
|
342
|
+
switch (value.trim().toLowerCase()) {
|
|
343
|
+
case "cr":
|
|
344
|
+
case "crlf":
|
|
345
|
+
case "lf": return value.trim().toLowerCase();
|
|
346
|
+
default: return;
|
|
347
|
+
}
|
|
508
348
|
}
|
|
509
349
|
function isGeneralEditorConfigSection(section) {
|
|
510
|
-
|
|
350
|
+
return GENERAL_EDITORCONFIG_SECTIONS.has(section.trim());
|
|
511
351
|
}
|
|
512
352
|
function parseEditorConfig(filePath) {
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
continue;
|
|
542
|
-
}
|
|
543
|
-
if (!currentSection || isGeneralEditorConfigSection(currentSection)) {
|
|
544
|
-
endOfLine = normalized;
|
|
545
|
-
}
|
|
546
|
-
}
|
|
547
|
-
return endOfLine ? {
|
|
548
|
-
endOfLine,
|
|
549
|
-
isRoot
|
|
550
|
-
} : {
|
|
551
|
-
isRoot
|
|
552
|
-
};
|
|
353
|
+
const lines = node_fs.default.readFileSync(filePath, "utf8").split(NEWLINE_PATTERN);
|
|
354
|
+
let currentSection;
|
|
355
|
+
let endOfLine;
|
|
356
|
+
let isRoot = false;
|
|
357
|
+
for (const rawLine of lines) {
|
|
358
|
+
const line = rawLine.trim();
|
|
359
|
+
if (!line || line.startsWith("#") || line.startsWith(";")) continue;
|
|
360
|
+
if (line.startsWith("[") && line.endsWith("]")) {
|
|
361
|
+
currentSection = line.slice(1, -1).trim();
|
|
362
|
+
continue;
|
|
363
|
+
}
|
|
364
|
+
const separatorIndex = line.indexOf("=");
|
|
365
|
+
if (separatorIndex === -1) continue;
|
|
366
|
+
const key = line.slice(0, separatorIndex).trim().toLowerCase();
|
|
367
|
+
const value = line.slice(separatorIndex + 1).trim();
|
|
368
|
+
if (!currentSection && key === "root") {
|
|
369
|
+
isRoot = value.toLowerCase() === "true";
|
|
370
|
+
continue;
|
|
371
|
+
}
|
|
372
|
+
if (key !== "end_of_line") continue;
|
|
373
|
+
const normalized = normalizeEditorConfigEndOfLine(value);
|
|
374
|
+
if (!normalized) continue;
|
|
375
|
+
if (!currentSection || isGeneralEditorConfigSection(currentSection)) endOfLine = normalized;
|
|
376
|
+
}
|
|
377
|
+
return endOfLine ? {
|
|
378
|
+
endOfLine,
|
|
379
|
+
isRoot
|
|
380
|
+
} : { isRoot };
|
|
553
381
|
}
|
|
554
|
-
function inferPrettierEndOfLineFromEditorConfig(cwd =
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
const parsed = parseEditorConfig(filePath);
|
|
574
|
-
if (parsed.endOfLine) {
|
|
575
|
-
endOfLine = parsed.endOfLine;
|
|
576
|
-
}
|
|
577
|
-
}
|
|
578
|
-
return endOfLine;
|
|
382
|
+
function inferPrettierEndOfLineFromEditorConfig(cwd = node_process.default.cwd()) {
|
|
383
|
+
const configs = [];
|
|
384
|
+
let currentDir = node_path.default.resolve(cwd);
|
|
385
|
+
while (true) {
|
|
386
|
+
const editorConfigPath = node_path.default.join(currentDir, ".editorconfig");
|
|
387
|
+
if (node_fs.default.existsSync(editorConfigPath)) {
|
|
388
|
+
configs.push(editorConfigPath);
|
|
389
|
+
if (parseEditorConfig(editorConfigPath).isRoot) break;
|
|
390
|
+
}
|
|
391
|
+
const parentDir = node_path.default.dirname(currentDir);
|
|
392
|
+
if (parentDir === currentDir) break;
|
|
393
|
+
currentDir = parentDir;
|
|
394
|
+
}
|
|
395
|
+
let endOfLine;
|
|
396
|
+
for (const filePath of configs.reverse()) {
|
|
397
|
+
const parsed = parseEditorConfig(filePath);
|
|
398
|
+
if (parsed.endOfLine) endOfLine = parsed.endOfLine;
|
|
399
|
+
}
|
|
400
|
+
return endOfLine;
|
|
579
401
|
}
|
|
580
|
-
function resolveFormattersOption(input, cwd =
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
endOfLine: inferredEndOfLine
|
|
590
|
-
}
|
|
591
|
-
},
|
|
592
|
-
defaults
|
|
593
|
-
) : defaults;
|
|
594
|
-
if (input === void 0) {
|
|
595
|
-
return inferredEndOfLine ? defaultsWithPrettier : true;
|
|
596
|
-
}
|
|
597
|
-
if (input === true) {
|
|
598
|
-
return defaultsWithPrettier;
|
|
599
|
-
}
|
|
600
|
-
if (isObject(input)) {
|
|
601
|
-
return defu(input, defaultsWithPrettier);
|
|
602
|
-
}
|
|
603
|
-
return defaultsWithPrettier;
|
|
402
|
+
function resolveFormattersOption(input, cwd = node_process.default.cwd()) {
|
|
403
|
+
if (input === false) return false;
|
|
404
|
+
const defaults = getDefaultFormatterOptions(cwd);
|
|
405
|
+
const inferredEndOfLine = inferPrettierEndOfLineFromEditorConfig(cwd);
|
|
406
|
+
const defaultsWithPrettier = inferredEndOfLine ? defu({ prettierOptions: { endOfLine: inferredEndOfLine } }, defaults) : defaults;
|
|
407
|
+
if (input === void 0) return inferredEndOfLine ? defaultsWithPrettier : true;
|
|
408
|
+
if (input === true) return defaultsWithPrettier;
|
|
409
|
+
if (isObject(input)) return defu(input, defaultsWithPrettier);
|
|
410
|
+
return defaultsWithPrettier;
|
|
604
411
|
}
|
|
605
412
|
function resolveUserOptions(options) {
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
postProcess: applyVueVersionSpecificRules
|
|
616
|
-
}
|
|
617
|
-
);
|
|
618
|
-
if (resolvedVue === void 0) {
|
|
619
|
-
delete resolved.vue;
|
|
620
|
-
} else {
|
|
621
|
-
resolved.vue = resolvedVue;
|
|
622
|
-
}
|
|
623
|
-
const resolvedTypescript = mergeOptionWithDefaults(
|
|
624
|
-
resolved.typescript,
|
|
625
|
-
getDefaultTypescriptOptions(options),
|
|
626
|
-
{
|
|
627
|
-
useDefaultWhenUndefined: true
|
|
628
|
-
}
|
|
629
|
-
);
|
|
630
|
-
if (resolvedTypescript === void 0) {
|
|
631
|
-
delete resolved.typescript;
|
|
632
|
-
} else {
|
|
633
|
-
resolved.typescript = resolvedTypescript;
|
|
634
|
-
}
|
|
635
|
-
resolved.formatters = resolveFormattersOption(options?.formatters);
|
|
636
|
-
return resolved;
|
|
413
|
+
const resolved = defu({}, options ?? {}, BASE_DEFAULTS);
|
|
414
|
+
const resolvedVue = mergeOptionWithDefaults(resolved.vue, getDefaultVueOptions(options), { postProcess: applyVueVersionSpecificRules });
|
|
415
|
+
if (resolvedVue === void 0) delete resolved.vue;
|
|
416
|
+
else resolved.vue = resolvedVue;
|
|
417
|
+
const resolvedTypescript = mergeOptionWithDefaults(resolved.typescript, getDefaultTypescriptOptions(options), { useDefaultWhenUndefined: true });
|
|
418
|
+
if (resolvedTypescript === void 0) delete resolved.typescript;
|
|
419
|
+
else resolved.typescript = resolvedTypescript;
|
|
420
|
+
resolved.formatters = resolveFormattersOption(options?.formatters);
|
|
421
|
+
return resolved;
|
|
637
422
|
}
|
|
638
423
|
function createBaseRuleSet(isLegacy) {
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
"perfectionist/sort-imports": "off"
|
|
645
|
-
};
|
|
424
|
+
if (!isLegacy) return BASE_RULES;
|
|
425
|
+
return {
|
|
426
|
+
...BASE_RULES,
|
|
427
|
+
"perfectionist/sort-imports": "off"
|
|
428
|
+
};
|
|
646
429
|
}
|
|
647
|
-
|
|
648
|
-
|
|
430
|
+
//#endregion
|
|
431
|
+
//#region src/preset.ts
|
|
649
432
|
function getPresets(options, mode) {
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
}
|
|
655
|
-
];
|
|
656
|
-
presets.push(
|
|
657
|
-
...resolveTailwindPresets(resolved.tailwindcss),
|
|
658
|
-
...resolveMdxPresets(resolved.mdx),
|
|
659
|
-
...resolveNestPresets(resolved.nestjs),
|
|
660
|
-
...resolveQueryPresets(resolved.query),
|
|
661
|
-
...resolveAccessibilityPresets(resolved.a11y, resolved.vue, resolved.react)
|
|
662
|
-
);
|
|
663
|
-
return [resolved, ...presets];
|
|
433
|
+
const resolved = resolveUserOptions(options);
|
|
434
|
+
const presets = [{ rules: createBaseRuleSet(mode === "legacy") }];
|
|
435
|
+
presets.push(...resolveTailwindPresets(resolved.tailwindcss), ...resolveMdxPresets(resolved.mdx), ...resolveNestPresets(resolved.nestjs), ...resolveQueryPresets(resolved.query), ...resolveAccessibilityPresets(resolved.a11y, resolved.vue, resolved.react));
|
|
436
|
+
return [resolved, ...presets];
|
|
664
437
|
}
|
|
665
|
-
|
|
666
|
-
|
|
438
|
+
//#endregion
|
|
439
|
+
//#region src/factory.ts
|
|
667
440
|
function icebreaker(options = {}, ...userConfigs) {
|
|
668
|
-
|
|
441
|
+
return (0, antfu_exports.antfu)(...getPresets(options), ...userConfigs);
|
|
669
442
|
}
|
|
670
443
|
function icebreakerLegacy(options = {}, ...userConfigs) {
|
|
671
|
-
|
|
444
|
+
return (0, antfu_exports.antfu)(...getPresets(options, "legacy"), ...userConfigs);
|
|
672
445
|
}
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
icebreakerLegacy
|
|
678
|
-
});
|
|
446
|
+
//#endregion
|
|
447
|
+
exports.getPresets = getPresets;
|
|
448
|
+
exports.icebreaker = icebreaker;
|
|
449
|
+
exports.icebreakerLegacy = icebreakerLegacy;
|