@icebreakers/eslint-config 6.0.0 → 7.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/README.md +6 -3
- package/README.zh.md +6 -3
- package/dist/{dist-Cfcd4odI.cjs → dist-BL_Srtot.cjs} +530 -466
- package/dist/{dist-DTWNkNCv.js → dist-CfNAWugK.js} +530 -466
- package/dist/index.cjs +68 -34
- package/dist/index.d.cts +26 -6
- package/dist/index.d.ts +26 -6
- package/dist/index.js +66 -32
- package/dist/{lib-CcedSpss.cjs → lib-ADc7sTOW.cjs} +104 -104
- package/dist/{lib-BOuqso-8.js → lib-BiNYUSxy.js} +104 -104
- package/dist/{modern-y8Mo-zyc.cjs → modern-Dnpu3mfI.cjs} +2 -2
- package/dist/{modern-CoGNcL7O.js → modern-RpY8mk7x.js} +2 -2
- package/index.d.ts +6 -2
- package/package.json +14 -10
package/dist/index.cjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_rolldown_runtime = require("./rolldown-runtime-DzWaZAza.cjs");
|
|
3
|
+
let node_module = require("node:module");
|
|
3
4
|
let node_path = require("node:path");
|
|
4
5
|
node_path = require_rolldown_runtime.__toESM(node_path, 1);
|
|
5
|
-
let node_process = require("node:process");
|
|
6
|
-
node_process = require_rolldown_runtime.__toESM(node_process, 1);
|
|
7
6
|
let node_fs = require("node:fs");
|
|
8
7
|
node_fs = require_rolldown_runtime.__toESM(node_fs, 1);
|
|
9
|
-
let
|
|
8
|
+
let node_process = require("node:process");
|
|
9
|
+
node_process = require_rolldown_runtime.__toESM(node_process, 1);
|
|
10
10
|
let node_url = require("node:url");
|
|
11
11
|
//#region src/antfu.ts
|
|
12
12
|
var antfu_exports = /* @__PURE__ */ require_rolldown_runtime.__exportAll({});
|
|
@@ -99,14 +99,14 @@ function getDefaultTypescriptOptions(opts) {
|
|
|
99
99
|
}
|
|
100
100
|
//#endregion
|
|
101
101
|
//#region src/utils.ts
|
|
102
|
-
const require$
|
|
102
|
+
const require$3 = (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href);
|
|
103
103
|
const PACKAGE_DIR = node_path.default.dirname((0, node_url.fileURLToPath)(require("url").pathToFileURL(__filename).href));
|
|
104
104
|
function isObject(o) {
|
|
105
105
|
return Object.prototype.toString.call(o) === "[object Object]";
|
|
106
106
|
}
|
|
107
107
|
function isPackageAvailable$1(name, searchPaths = [node_process.default.cwd(), PACKAGE_DIR]) {
|
|
108
108
|
try {
|
|
109
|
-
require$
|
|
109
|
+
require$3.resolve(name, { paths: searchPaths });
|
|
110
110
|
return true;
|
|
111
111
|
} catch {
|
|
112
112
|
const packageSegments = name.split("/");
|
|
@@ -128,13 +128,14 @@ function hasAllPackages(names, searchPaths) {
|
|
|
128
128
|
//#endregion
|
|
129
129
|
//#region src/features.ts
|
|
130
130
|
const BETTER_TAILWIND_PACKAGES = ["eslint-plugin-better-tailwindcss"];
|
|
131
|
-
const TAILWIND_PACKAGES = ["eslint-plugin-tailwindcss"];
|
|
131
|
+
const TAILWIND_PACKAGES = ["eslint-plugin-tailwindcss", "tailwindcss"];
|
|
132
132
|
const STYLELINT_BRIDGE_PACKAGES = ["eslint-plugin-better-stylelint"];
|
|
133
133
|
const MDX_PACKAGES = ["eslint-plugin-mdx"];
|
|
134
134
|
const VUE_A11Y_PACKAGES = ["eslint-plugin-vuejs-accessibility"];
|
|
135
135
|
const REACT_A11Y_PACKAGES = ["eslint-plugin-jsx-a11y"];
|
|
136
136
|
const QUERY_PACKAGES = ["@tanstack/eslint-plugin-query"];
|
|
137
|
-
const
|
|
137
|
+
const BETTER_TAILWIND_EXTENSIONS = "js,mjs,cjs,ts,mts,cts,jsx,tsx,vue,html,md,mdx,astro,svelte";
|
|
138
|
+
const BETTER_TAILWIND_FILES = [`**/*.{${BETTER_TAILWIND_EXTENSIONS}}`];
|
|
138
139
|
const BETTER_TAILWIND_IGNORES = [
|
|
139
140
|
"**/*.json",
|
|
140
141
|
"**/*.json5",
|
|
@@ -152,38 +153,66 @@ const BETTER_TAILWIND_IGNORES = [
|
|
|
152
153
|
"**/Gemfile.lock",
|
|
153
154
|
"**/go.sum"
|
|
154
155
|
];
|
|
156
|
+
const BETTER_TAILWIND_SYNTAX_RULES = {
|
|
157
|
+
"better-tailwindcss/no-duplicate-classes": "warn",
|
|
158
|
+
"better-tailwindcss/no-unnecessary-whitespace": "warn"
|
|
159
|
+
};
|
|
160
|
+
const require$2 = (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href);
|
|
155
161
|
function resolveStylelintConfigLoader(moduleUrl = require("url").pathToFileURL(__filename).href) {
|
|
156
162
|
return moduleUrl.endsWith(".ts") ? new URL("./stylelint.ts", moduleUrl).href : new URL("./stylelint.js", moduleUrl).href;
|
|
157
163
|
}
|
|
164
|
+
function resolveDefaultTailwindCssConfigPath() {
|
|
165
|
+
try {
|
|
166
|
+
return require$2.resolve("tailwindcss/index.css");
|
|
167
|
+
} catch {
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
function normalizeGlobPath(filePath) {
|
|
172
|
+
return filePath.replaceAll(node_path.default.sep, "/").replace(/^\.\//, "");
|
|
173
|
+
}
|
|
174
|
+
function resolveBetterTailwindFiles(option) {
|
|
175
|
+
if (option.files?.length) return option.files;
|
|
176
|
+
if (!option.entryPoint || node_path.default.isAbsolute(option.entryPoint)) return BETTER_TAILWIND_FILES;
|
|
177
|
+
const sourceDir = normalizeGlobPath(node_path.default.dirname(option.entryPoint));
|
|
178
|
+
if (!sourceDir || sourceDir === ".") return BETTER_TAILWIND_FILES;
|
|
179
|
+
return [`${sourceDir}/**/*.{${BETTER_TAILWIND_EXTENSIONS}}`];
|
|
180
|
+
}
|
|
181
|
+
function resolveBetterTailwindRules(plugin, option) {
|
|
182
|
+
if (option.rules === "recommended") return plugin.configs.recommended?.rules ?? {};
|
|
183
|
+
return BETTER_TAILWIND_SYNTAX_RULES;
|
|
184
|
+
}
|
|
185
|
+
function resolveBetterTailwindPresets(option) {
|
|
186
|
+
if (!option) return [];
|
|
187
|
+
if (!hasAllPackages(BETTER_TAILWIND_PACKAGES)) return [];
|
|
188
|
+
const betterTailwindcssOption = typeof option === "object" ? option : {};
|
|
189
|
+
return [(0, antfu_exports.interopDefault)(import("eslint-plugin-better-tailwindcss")).then((eslintPluginBetterTailwindcss) => {
|
|
190
|
+
const betterTailwindcssRules = resolveBetterTailwindRules(eslintPluginBetterTailwindcss, betterTailwindcssOption);
|
|
191
|
+
return {
|
|
192
|
+
name: "icebreaker/better-tailwindcss",
|
|
193
|
+
files: resolveBetterTailwindFiles(betterTailwindcssOption),
|
|
194
|
+
ignores: BETTER_TAILWIND_IGNORES,
|
|
195
|
+
plugins: { "better-tailwindcss": eslintPluginBetterTailwindcss },
|
|
196
|
+
rules: betterTailwindcssRules,
|
|
197
|
+
settings: { "better-tailwindcss": {
|
|
198
|
+
cwd: betterTailwindcssOption.cwd,
|
|
199
|
+
entryPoint: betterTailwindcssOption.entryPoint,
|
|
200
|
+
tailwindConfig: betterTailwindcssOption.tailwindConfig
|
|
201
|
+
} }
|
|
202
|
+
};
|
|
203
|
+
})];
|
|
204
|
+
}
|
|
158
205
|
function resolveTailwindPresets(option) {
|
|
159
206
|
if (!option) return [];
|
|
160
|
-
if (typeof option === "object") {
|
|
161
|
-
if (!hasAllPackages(BETTER_TAILWIND_PACKAGES)) return [];
|
|
162
|
-
return [(0, antfu_exports.interopDefault)(import("eslint-plugin-better-tailwindcss")).then((eslintPluginBetterTailwindcss) => {
|
|
163
|
-
const cwd = option.cwd ?? (option.entryPoint ? node_path.default.dirname(option.entryPoint) : void 0) ?? node_process.default.cwd();
|
|
164
|
-
const betterTailwindcssRules = {
|
|
165
|
-
...eslintPluginBetterTailwindcss.configs["recommended-warn"].rules,
|
|
166
|
-
...eslintPluginBetterTailwindcss.configs["recommended-error"].rules
|
|
167
|
-
};
|
|
168
|
-
return {
|
|
169
|
-
name: "icebreaker/better-tailwindcss",
|
|
170
|
-
files: BETTER_TAILWIND_FILES,
|
|
171
|
-
ignores: BETTER_TAILWIND_IGNORES,
|
|
172
|
-
plugins: { "better-tailwindcss": eslintPluginBetterTailwindcss },
|
|
173
|
-
rules: betterTailwindcssRules,
|
|
174
|
-
settings: { "better-tailwindcss": {
|
|
175
|
-
cwd,
|
|
176
|
-
entryPoint: option.entryPoint,
|
|
177
|
-
tailwindConfig: option.tailwindConfig
|
|
178
|
-
} }
|
|
179
|
-
};
|
|
180
|
-
})];
|
|
181
|
-
}
|
|
182
207
|
if (!hasAllPackages(TAILWIND_PACKAGES)) return [];
|
|
208
|
+
const cssConfigPath = resolveDefaultTailwindCssConfigPath();
|
|
183
209
|
return [(0, antfu_exports.interopDefault)(import("eslint-plugin-tailwindcss")).then((tailwind) => {
|
|
184
210
|
const tailwindPlugin = tailwind;
|
|
185
211
|
return tailwindPlugin.configs["flat/recommended"] ?? tailwindPlugin.configs.recommended ?? [];
|
|
186
|
-
}), {
|
|
212
|
+
}), {
|
|
213
|
+
...cssConfigPath ? { settings: { tailwindcss: { cssConfigPath } } } : {},
|
|
214
|
+
rules: { "tailwindcss/no-custom-classname": "off" }
|
|
215
|
+
}];
|
|
187
216
|
}
|
|
188
217
|
function resolveStylelintBridgeOptions(option) {
|
|
189
218
|
const { cwd, ...stylelintConfigOptions } = typeof option === "object" ? option : {};
|
|
@@ -241,10 +270,10 @@ function resolveMdxPresets(isEnabled) {
|
|
|
241
270
|
function resolveAccessibilityPresets(isEnabled, vueOption, reactOption) {
|
|
242
271
|
if (!isEnabled) return [];
|
|
243
272
|
const presets = [];
|
|
244
|
-
if (vueOption && hasAllPackages(VUE_A11Y_PACKAGES)) presets.push((0, antfu_exports.interopDefault)(Promise.resolve().then(() => /* @__PURE__ */ require_rolldown_runtime.__toESM(require("./dist-
|
|
273
|
+
if (vueOption && hasAllPackages(VUE_A11Y_PACKAGES)) presets.push((0, antfu_exports.interopDefault)(Promise.resolve().then(() => /* @__PURE__ */ require_rolldown_runtime.__toESM(require("./dist-BL_Srtot.cjs").default, 1))).then((pluginVueA11y) => {
|
|
245
274
|
return pluginVueA11y.configs["flat/recommended"];
|
|
246
275
|
}));
|
|
247
|
-
if (reactOption && hasAllPackages(REACT_A11Y_PACKAGES)) presets.push((0, antfu_exports.interopDefault)(Promise.resolve().then(() => /* @__PURE__ */ require_rolldown_runtime.__toESM(require("./lib-
|
|
276
|
+
if (reactOption && hasAllPackages(REACT_A11Y_PACKAGES)) presets.push((0, antfu_exports.interopDefault)(Promise.resolve().then(() => /* @__PURE__ */ require_rolldown_runtime.__toESM(require("./lib-ADc7sTOW.cjs").default, 1))).then((jsxA11y) => {
|
|
248
277
|
return jsxA11y.flatConfigs.recommended;
|
|
249
278
|
}));
|
|
250
279
|
return presets;
|
|
@@ -259,7 +288,7 @@ function resolveNestPresets(isEnabled) {
|
|
|
259
288
|
function resolveQueryPresets(isEnabled) {
|
|
260
289
|
if (!isEnabled) return [];
|
|
261
290
|
if (!hasAllPackages(QUERY_PACKAGES)) return [];
|
|
262
|
-
return [(0, antfu_exports.interopDefault)(Promise.resolve().then(() => require("./modern-
|
|
291
|
+
return [(0, antfu_exports.interopDefault)(Promise.resolve().then(() => require("./modern-Dnpu3mfI.cjs"))).then((pluginQuery) => pluginQuery.configs["flat/recommended"])];
|
|
263
292
|
}
|
|
264
293
|
//#endregion
|
|
265
294
|
//#region ../../node_modules/.pnpm/defu@6.1.7/node_modules/defu/dist/defu.mjs
|
|
@@ -456,6 +485,11 @@ function resolveUserOptions(options) {
|
|
|
456
485
|
resolved.miniProgram = true;
|
|
457
486
|
delete resolved.weapp;
|
|
458
487
|
}
|
|
488
|
+
const legacyTailwindcssOption = resolved.tailwindcss;
|
|
489
|
+
if (isObject(legacyTailwindcssOption)) {
|
|
490
|
+
resolved.betterTailwindcss ??= legacyTailwindcssOption;
|
|
491
|
+
delete resolved.tailwindcss;
|
|
492
|
+
}
|
|
459
493
|
const resolvedVue = mergeOptionWithDefaults(resolved.vue, getDefaultVueOptions(options), { postProcess: applyVueVersionSpecificRules });
|
|
460
494
|
if (resolvedVue === void 0) delete resolved.vue;
|
|
461
495
|
else resolved.vue = resolvedVue;
|
|
@@ -521,7 +555,7 @@ function getPresets(options, mode) {
|
|
|
521
555
|
languageOptions: { parser: antfu_exports.parserPlain },
|
|
522
556
|
rules: {}
|
|
523
557
|
});
|
|
524
|
-
presets.push(...resolveStylelintBridgePresets(resolved.stylelint), ...resolveTailwindPresets(resolved.tailwindcss), ...resolveMdxPresets(resolved.mdx), ...resolveNestPresets(resolved.nestjs), ...resolveQueryPresets(resolved.query), ...resolveAccessibilityPresets(resolved.a11y, resolved.vue, resolved.react));
|
|
558
|
+
presets.push(...resolveStylelintBridgePresets(resolved.stylelint), ...resolveTailwindPresets(resolved.tailwindcss), ...resolveBetterTailwindPresets(resolved.betterTailwindcss), ...resolveMdxPresets(resolved.mdx), ...resolveNestPresets(resolved.nestjs), ...resolveQueryPresets(resolved.query), ...resolveAccessibilityPresets(resolved.a11y, resolved.vue, resolved.react));
|
|
525
559
|
return [resolved, ...presets];
|
|
526
560
|
}
|
|
527
561
|
//#endregion
|
package/dist/index.d.cts
CHANGED
|
@@ -1853,7 +1853,7 @@ type CustomRuleVisitorWithExit$1<RuleVisitorType extends RuleVisitor$1> = { [Key
|
|
|
1853
1853
|
type RuleVisitor = RuleVisitor$1;
|
|
1854
1854
|
type CustomRuleVisitorWithExit<RuleVisitorType extends RuleVisitor> = CustomRuleVisitorWithExit$1<RuleVisitorType>;
|
|
1855
1855
|
//#endregion
|
|
1856
|
-
//#region ../../node_modules/.pnpm/eslint@10.
|
|
1856
|
+
//#region ../../node_modules/.pnpm/eslint@10.6.0_jiti@2.7.0/node_modules/eslint/lib/types/index.d.ts
|
|
1857
1857
|
//------------------------------------------------------------------------------
|
|
1858
1858
|
// Exports
|
|
1859
1859
|
//------------------------------------------------------------------------------
|
|
@@ -2708,14 +2708,28 @@ declare namespace ESLint {
|
|
|
2708
2708
|
}
|
|
2709
2709
|
//#endregion
|
|
2710
2710
|
//#region src/types.d.ts
|
|
2711
|
-
interface
|
|
2711
|
+
interface BetterTailwindcssOption {
|
|
2712
2712
|
/**
|
|
2713
2713
|
* Tailwind CSS v4 entry point, e.g. `src/global.css`.
|
|
2714
2714
|
*/
|
|
2715
2715
|
entryPoint?: string;
|
|
2716
|
+
/**
|
|
2717
|
+
* Files that should receive better-tailwindcss rules.
|
|
2718
|
+
* Defaults to the entry point directory for relative entry points, otherwise source-like files.
|
|
2719
|
+
*/
|
|
2720
|
+
files?: string[];
|
|
2721
|
+
/**
|
|
2722
|
+
* Rule preset for object mode.
|
|
2723
|
+
*
|
|
2724
|
+
* `syntax` keeps the fast rules that do not need Tailwind class analysis.
|
|
2725
|
+
* `recommended` enables the full eslint-plugin-better-tailwindcss recommended preset.
|
|
2726
|
+
*
|
|
2727
|
+
* @default 'syntax'
|
|
2728
|
+
*/
|
|
2729
|
+
rules?: 'syntax' | 'recommended';
|
|
2716
2730
|
/**
|
|
2717
2731
|
* Working directory passed to eslint-plugin-better-tailwindcss.
|
|
2718
|
-
* Defaults to
|
|
2732
|
+
* Defaults to ESLint's current working directory.
|
|
2719
2733
|
*/
|
|
2720
2734
|
cwd?: string;
|
|
2721
2735
|
/**
|
|
@@ -2723,7 +2737,8 @@ interface TailwindcssOption {
|
|
|
2723
2737
|
*/
|
|
2724
2738
|
tailwindConfig?: string;
|
|
2725
2739
|
}
|
|
2726
|
-
type
|
|
2740
|
+
type BetterTailwindcssConfig = boolean | BetterTailwindcssOption;
|
|
2741
|
+
type TailwindcssConfig = boolean;
|
|
2727
2742
|
interface UnocssOption {
|
|
2728
2743
|
/**
|
|
2729
2744
|
* UnoCSS config file path, e.g. `uno.config.ts`.
|
|
@@ -2784,10 +2799,15 @@ type UserDefinedOptions = Omit<OptionsConfig, 'formatters' | 'unocss'> & TypedFl
|
|
|
2784
2799
|
*/
|
|
2785
2800
|
miniProgram?: boolean;
|
|
2786
2801
|
/**
|
|
2787
|
-
* Enable
|
|
2802
|
+
* Enable eslint-plugin-tailwindcss support.
|
|
2788
2803
|
* @default false
|
|
2789
2804
|
*/
|
|
2790
2805
|
tailwindcss?: TailwindcssConfig;
|
|
2806
|
+
/**
|
|
2807
|
+
* Enable eslint-plugin-better-tailwindcss support.
|
|
2808
|
+
* @default false
|
|
2809
|
+
*/
|
|
2810
|
+
betterTailwindcss?: BetterTailwindcssConfig;
|
|
2791
2811
|
/**
|
|
2792
2812
|
* Enable UnoCSS support.
|
|
2793
2813
|
* @default false
|
|
@@ -2841,4 +2861,4 @@ type IcebreakerLegacyEslintConfig = ReturnType<typeof icebreakerLegacy>;
|
|
|
2841
2861
|
//#region src/preset.d.ts
|
|
2842
2862
|
declare function getPresets(options?: UserDefinedOptions, mode?: 'legacy'): [UserDefinedOptions, ...UserConfigItem[]];
|
|
2843
2863
|
type parserPlain = import__antfu_eslint_config.parserPlain;
|
|
2844
|
-
export { type ConfigNames, type FlatConfigComposer, IcebreakerEslintConfig, type IcebreakerFormatterOptions, IcebreakerLegacyEslintConfig, type StylelintBridgeConfig, type StylelintBridgeOption, type TailwindcssConfig, type
|
|
2864
|
+
export { type BetterTailwindcssConfig, type BetterTailwindcssOption, type ConfigNames, type FlatConfigComposer, IcebreakerEslintConfig, type IcebreakerFormatterOptions, IcebreakerLegacyEslintConfig, type StylelintBridgeConfig, type StylelintBridgeOption, type TailwindcssConfig, type TypedFlatConfigItem, type UnocssConfig, type UnocssOption, type UserConfigItem, type UserDefinedOptions, getPresets, icebreaker, icebreakerLegacy, parserPlain };
|
package/dist/index.d.ts
CHANGED
|
@@ -1853,7 +1853,7 @@ type CustomRuleVisitorWithExit$1<RuleVisitorType extends RuleVisitor$1> = { [Key
|
|
|
1853
1853
|
type RuleVisitor = RuleVisitor$1;
|
|
1854
1854
|
type CustomRuleVisitorWithExit<RuleVisitorType extends RuleVisitor> = CustomRuleVisitorWithExit$1<RuleVisitorType>;
|
|
1855
1855
|
//#endregion
|
|
1856
|
-
//#region ../../node_modules/.pnpm/eslint@10.
|
|
1856
|
+
//#region ../../node_modules/.pnpm/eslint@10.6.0_jiti@2.7.0/node_modules/eslint/lib/types/index.d.ts
|
|
1857
1857
|
//------------------------------------------------------------------------------
|
|
1858
1858
|
// Exports
|
|
1859
1859
|
//------------------------------------------------------------------------------
|
|
@@ -2708,14 +2708,28 @@ declare namespace ESLint {
|
|
|
2708
2708
|
}
|
|
2709
2709
|
//#endregion
|
|
2710
2710
|
//#region src/types.d.ts
|
|
2711
|
-
interface
|
|
2711
|
+
interface BetterTailwindcssOption {
|
|
2712
2712
|
/**
|
|
2713
2713
|
* Tailwind CSS v4 entry point, e.g. `src/global.css`.
|
|
2714
2714
|
*/
|
|
2715
2715
|
entryPoint?: string;
|
|
2716
|
+
/**
|
|
2717
|
+
* Files that should receive better-tailwindcss rules.
|
|
2718
|
+
* Defaults to the entry point directory for relative entry points, otherwise source-like files.
|
|
2719
|
+
*/
|
|
2720
|
+
files?: string[];
|
|
2721
|
+
/**
|
|
2722
|
+
* Rule preset for object mode.
|
|
2723
|
+
*
|
|
2724
|
+
* `syntax` keeps the fast rules that do not need Tailwind class analysis.
|
|
2725
|
+
* `recommended` enables the full eslint-plugin-better-tailwindcss recommended preset.
|
|
2726
|
+
*
|
|
2727
|
+
* @default 'syntax'
|
|
2728
|
+
*/
|
|
2729
|
+
rules?: 'syntax' | 'recommended';
|
|
2716
2730
|
/**
|
|
2717
2731
|
* Working directory passed to eslint-plugin-better-tailwindcss.
|
|
2718
|
-
* Defaults to
|
|
2732
|
+
* Defaults to ESLint's current working directory.
|
|
2719
2733
|
*/
|
|
2720
2734
|
cwd?: string;
|
|
2721
2735
|
/**
|
|
@@ -2723,7 +2737,8 @@ interface TailwindcssOption {
|
|
|
2723
2737
|
*/
|
|
2724
2738
|
tailwindConfig?: string;
|
|
2725
2739
|
}
|
|
2726
|
-
type
|
|
2740
|
+
type BetterTailwindcssConfig = boolean | BetterTailwindcssOption;
|
|
2741
|
+
type TailwindcssConfig = boolean;
|
|
2727
2742
|
interface UnocssOption {
|
|
2728
2743
|
/**
|
|
2729
2744
|
* UnoCSS config file path, e.g. `uno.config.ts`.
|
|
@@ -2784,10 +2799,15 @@ type UserDefinedOptions = Omit<OptionsConfig, 'formatters' | 'unocss'> & TypedFl
|
|
|
2784
2799
|
*/
|
|
2785
2800
|
miniProgram?: boolean;
|
|
2786
2801
|
/**
|
|
2787
|
-
* Enable
|
|
2802
|
+
* Enable eslint-plugin-tailwindcss support.
|
|
2788
2803
|
* @default false
|
|
2789
2804
|
*/
|
|
2790
2805
|
tailwindcss?: TailwindcssConfig;
|
|
2806
|
+
/**
|
|
2807
|
+
* Enable eslint-plugin-better-tailwindcss support.
|
|
2808
|
+
* @default false
|
|
2809
|
+
*/
|
|
2810
|
+
betterTailwindcss?: BetterTailwindcssConfig;
|
|
2791
2811
|
/**
|
|
2792
2812
|
* Enable UnoCSS support.
|
|
2793
2813
|
* @default false
|
|
@@ -2841,4 +2861,4 @@ type IcebreakerLegacyEslintConfig = ReturnType<typeof icebreakerLegacy>;
|
|
|
2841
2861
|
//#region src/preset.d.ts
|
|
2842
2862
|
declare function getPresets(options?: UserDefinedOptions, mode?: 'legacy'): [UserDefinedOptions, ...UserConfigItem[]];
|
|
2843
2863
|
type parserPlain = import__antfu_eslint_config.parserPlain;
|
|
2844
|
-
export { type ConfigNames, type FlatConfigComposer, IcebreakerEslintConfig, type IcebreakerFormatterOptions, IcebreakerLegacyEslintConfig, type StylelintBridgeConfig, type StylelintBridgeOption, type TailwindcssConfig, type
|
|
2864
|
+
export { type BetterTailwindcssConfig, type BetterTailwindcssOption, type ConfigNames, type FlatConfigComposer, IcebreakerEslintConfig, type IcebreakerFormatterOptions, IcebreakerLegacyEslintConfig, type StylelintBridgeConfig, type StylelintBridgeOption, type TailwindcssConfig, type TypedFlatConfigItem, type UnocssConfig, type UnocssOption, type UserConfigItem, type UserDefinedOptions, getPresets, icebreaker, icebreakerLegacy, parserPlain };
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { i as __reExport, o as __toESM, r as __exportAll } from "./rolldown-runtime-C8SNSOcs.js";
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
3
|
import path from "node:path";
|
|
4
|
-
import process from "node:process";
|
|
5
4
|
import fs from "node:fs";
|
|
5
|
+
import process from "node:process";
|
|
6
6
|
import { fileURLToPath } from "node:url";
|
|
7
7
|
//#region src/antfu.ts
|
|
8
8
|
var antfu_exports = /* @__PURE__ */ __exportAll({});
|
|
@@ -96,14 +96,14 @@ function getDefaultTypescriptOptions(opts) {
|
|
|
96
96
|
}
|
|
97
97
|
//#endregion
|
|
98
98
|
//#region src/utils.ts
|
|
99
|
-
const require$
|
|
99
|
+
const require$2 = createRequire(import.meta.url);
|
|
100
100
|
const PACKAGE_DIR = path.dirname(fileURLToPath(import.meta.url));
|
|
101
101
|
function isObject(o) {
|
|
102
102
|
return Object.prototype.toString.call(o) === "[object Object]";
|
|
103
103
|
}
|
|
104
104
|
function isPackageAvailable$1(name, searchPaths = [process.cwd(), PACKAGE_DIR]) {
|
|
105
105
|
try {
|
|
106
|
-
require$
|
|
106
|
+
require$2.resolve(name, { paths: searchPaths });
|
|
107
107
|
return true;
|
|
108
108
|
} catch {
|
|
109
109
|
const packageSegments = name.split("/");
|
|
@@ -125,13 +125,14 @@ function hasAllPackages(names, searchPaths) {
|
|
|
125
125
|
//#endregion
|
|
126
126
|
//#region src/features.ts
|
|
127
127
|
const BETTER_TAILWIND_PACKAGES = ["eslint-plugin-better-tailwindcss"];
|
|
128
|
-
const TAILWIND_PACKAGES = ["eslint-plugin-tailwindcss"];
|
|
128
|
+
const TAILWIND_PACKAGES = ["eslint-plugin-tailwindcss", "tailwindcss"];
|
|
129
129
|
const STYLELINT_BRIDGE_PACKAGES = ["eslint-plugin-better-stylelint"];
|
|
130
130
|
const MDX_PACKAGES = ["eslint-plugin-mdx"];
|
|
131
131
|
const VUE_A11Y_PACKAGES = ["eslint-plugin-vuejs-accessibility"];
|
|
132
132
|
const REACT_A11Y_PACKAGES = ["eslint-plugin-jsx-a11y"];
|
|
133
133
|
const QUERY_PACKAGES = ["@tanstack/eslint-plugin-query"];
|
|
134
|
-
const
|
|
134
|
+
const BETTER_TAILWIND_EXTENSIONS = "js,mjs,cjs,ts,mts,cts,jsx,tsx,vue,html,md,mdx,astro,svelte";
|
|
135
|
+
const BETTER_TAILWIND_FILES = [`**/*.{${BETTER_TAILWIND_EXTENSIONS}}`];
|
|
135
136
|
const BETTER_TAILWIND_IGNORES = [
|
|
136
137
|
"**/*.json",
|
|
137
138
|
"**/*.json5",
|
|
@@ -149,38 +150,66 @@ const BETTER_TAILWIND_IGNORES = [
|
|
|
149
150
|
"**/Gemfile.lock",
|
|
150
151
|
"**/go.sum"
|
|
151
152
|
];
|
|
153
|
+
const BETTER_TAILWIND_SYNTAX_RULES = {
|
|
154
|
+
"better-tailwindcss/no-duplicate-classes": "warn",
|
|
155
|
+
"better-tailwindcss/no-unnecessary-whitespace": "warn"
|
|
156
|
+
};
|
|
157
|
+
const require$1 = createRequire(import.meta.url);
|
|
152
158
|
function resolveStylelintConfigLoader(moduleUrl = import.meta.url) {
|
|
153
159
|
return moduleUrl.endsWith(".ts") ? new URL("./stylelint.ts", moduleUrl).href : new URL("./stylelint.js", moduleUrl).href;
|
|
154
160
|
}
|
|
161
|
+
function resolveDefaultTailwindCssConfigPath() {
|
|
162
|
+
try {
|
|
163
|
+
return require$1.resolve("tailwindcss/index.css");
|
|
164
|
+
} catch {
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
function normalizeGlobPath(filePath) {
|
|
169
|
+
return filePath.replaceAll(path.sep, "/").replace(/^\.\//, "");
|
|
170
|
+
}
|
|
171
|
+
function resolveBetterTailwindFiles(option) {
|
|
172
|
+
if (option.files?.length) return option.files;
|
|
173
|
+
if (!option.entryPoint || path.isAbsolute(option.entryPoint)) return BETTER_TAILWIND_FILES;
|
|
174
|
+
const sourceDir = normalizeGlobPath(path.dirname(option.entryPoint));
|
|
175
|
+
if (!sourceDir || sourceDir === ".") return BETTER_TAILWIND_FILES;
|
|
176
|
+
return [`${sourceDir}/**/*.{${BETTER_TAILWIND_EXTENSIONS}}`];
|
|
177
|
+
}
|
|
178
|
+
function resolveBetterTailwindRules(plugin, option) {
|
|
179
|
+
if (option.rules === "recommended") return plugin.configs.recommended?.rules ?? {};
|
|
180
|
+
return BETTER_TAILWIND_SYNTAX_RULES;
|
|
181
|
+
}
|
|
182
|
+
function resolveBetterTailwindPresets(option) {
|
|
183
|
+
if (!option) return [];
|
|
184
|
+
if (!hasAllPackages(BETTER_TAILWIND_PACKAGES)) return [];
|
|
185
|
+
const betterTailwindcssOption = typeof option === "object" ? option : {};
|
|
186
|
+
return [(0, antfu_exports.interopDefault)(import("eslint-plugin-better-tailwindcss")).then((eslintPluginBetterTailwindcss) => {
|
|
187
|
+
const betterTailwindcssRules = resolveBetterTailwindRules(eslintPluginBetterTailwindcss, betterTailwindcssOption);
|
|
188
|
+
return {
|
|
189
|
+
name: "icebreaker/better-tailwindcss",
|
|
190
|
+
files: resolveBetterTailwindFiles(betterTailwindcssOption),
|
|
191
|
+
ignores: BETTER_TAILWIND_IGNORES,
|
|
192
|
+
plugins: { "better-tailwindcss": eslintPluginBetterTailwindcss },
|
|
193
|
+
rules: betterTailwindcssRules,
|
|
194
|
+
settings: { "better-tailwindcss": {
|
|
195
|
+
cwd: betterTailwindcssOption.cwd,
|
|
196
|
+
entryPoint: betterTailwindcssOption.entryPoint,
|
|
197
|
+
tailwindConfig: betterTailwindcssOption.tailwindConfig
|
|
198
|
+
} }
|
|
199
|
+
};
|
|
200
|
+
})];
|
|
201
|
+
}
|
|
155
202
|
function resolveTailwindPresets(option) {
|
|
156
203
|
if (!option) return [];
|
|
157
|
-
if (typeof option === "object") {
|
|
158
|
-
if (!hasAllPackages(BETTER_TAILWIND_PACKAGES)) return [];
|
|
159
|
-
return [(0, antfu_exports.interopDefault)(import("eslint-plugin-better-tailwindcss")).then((eslintPluginBetterTailwindcss) => {
|
|
160
|
-
const cwd = option.cwd ?? (option.entryPoint ? path.dirname(option.entryPoint) : void 0) ?? process.cwd();
|
|
161
|
-
const betterTailwindcssRules = {
|
|
162
|
-
...eslintPluginBetterTailwindcss.configs["recommended-warn"].rules,
|
|
163
|
-
...eslintPluginBetterTailwindcss.configs["recommended-error"].rules
|
|
164
|
-
};
|
|
165
|
-
return {
|
|
166
|
-
name: "icebreaker/better-tailwindcss",
|
|
167
|
-
files: BETTER_TAILWIND_FILES,
|
|
168
|
-
ignores: BETTER_TAILWIND_IGNORES,
|
|
169
|
-
plugins: { "better-tailwindcss": eslintPluginBetterTailwindcss },
|
|
170
|
-
rules: betterTailwindcssRules,
|
|
171
|
-
settings: { "better-tailwindcss": {
|
|
172
|
-
cwd,
|
|
173
|
-
entryPoint: option.entryPoint,
|
|
174
|
-
tailwindConfig: option.tailwindConfig
|
|
175
|
-
} }
|
|
176
|
-
};
|
|
177
|
-
})];
|
|
178
|
-
}
|
|
179
204
|
if (!hasAllPackages(TAILWIND_PACKAGES)) return [];
|
|
205
|
+
const cssConfigPath = resolveDefaultTailwindCssConfigPath();
|
|
180
206
|
return [(0, antfu_exports.interopDefault)(import("eslint-plugin-tailwindcss")).then((tailwind) => {
|
|
181
207
|
const tailwindPlugin = tailwind;
|
|
182
208
|
return tailwindPlugin.configs["flat/recommended"] ?? tailwindPlugin.configs.recommended ?? [];
|
|
183
|
-
}), {
|
|
209
|
+
}), {
|
|
210
|
+
...cssConfigPath ? { settings: { tailwindcss: { cssConfigPath } } } : {},
|
|
211
|
+
rules: { "tailwindcss/no-custom-classname": "off" }
|
|
212
|
+
}];
|
|
184
213
|
}
|
|
185
214
|
function resolveStylelintBridgeOptions(option) {
|
|
186
215
|
const { cwd, ...stylelintConfigOptions } = typeof option === "object" ? option : {};
|
|
@@ -238,10 +267,10 @@ function resolveMdxPresets(isEnabled) {
|
|
|
238
267
|
function resolveAccessibilityPresets(isEnabled, vueOption, reactOption) {
|
|
239
268
|
if (!isEnabled) return [];
|
|
240
269
|
const presets = [];
|
|
241
|
-
if (vueOption && hasAllPackages(VUE_A11Y_PACKAGES)) presets.push((0, antfu_exports.interopDefault)(import("./dist-
|
|
270
|
+
if (vueOption && hasAllPackages(VUE_A11Y_PACKAGES)) presets.push((0, antfu_exports.interopDefault)(import("./dist-CfNAWugK.js").then((m) => /* @__PURE__ */ __toESM(m.default, 1))).then((pluginVueA11y) => {
|
|
242
271
|
return pluginVueA11y.configs["flat/recommended"];
|
|
243
272
|
}));
|
|
244
|
-
if (reactOption && hasAllPackages(REACT_A11Y_PACKAGES)) presets.push((0, antfu_exports.interopDefault)(import("./lib-
|
|
273
|
+
if (reactOption && hasAllPackages(REACT_A11Y_PACKAGES)) presets.push((0, antfu_exports.interopDefault)(import("./lib-BiNYUSxy.js").then((m) => /* @__PURE__ */ __toESM(m.default, 1))).then((jsxA11y) => {
|
|
245
274
|
return jsxA11y.flatConfigs.recommended;
|
|
246
275
|
}));
|
|
247
276
|
return presets;
|
|
@@ -256,7 +285,7 @@ function resolveNestPresets(isEnabled) {
|
|
|
256
285
|
function resolveQueryPresets(isEnabled) {
|
|
257
286
|
if (!isEnabled) return [];
|
|
258
287
|
if (!hasAllPackages(QUERY_PACKAGES)) return [];
|
|
259
|
-
return [(0, antfu_exports.interopDefault)(import("./modern-
|
|
288
|
+
return [(0, antfu_exports.interopDefault)(import("./modern-RpY8mk7x.js")).then((pluginQuery) => pluginQuery.configs["flat/recommended"])];
|
|
260
289
|
}
|
|
261
290
|
//#endregion
|
|
262
291
|
//#region ../../node_modules/.pnpm/defu@6.1.7/node_modules/defu/dist/defu.mjs
|
|
@@ -453,6 +482,11 @@ function resolveUserOptions(options) {
|
|
|
453
482
|
resolved.miniProgram = true;
|
|
454
483
|
delete resolved.weapp;
|
|
455
484
|
}
|
|
485
|
+
const legacyTailwindcssOption = resolved.tailwindcss;
|
|
486
|
+
if (isObject(legacyTailwindcssOption)) {
|
|
487
|
+
resolved.betterTailwindcss ??= legacyTailwindcssOption;
|
|
488
|
+
delete resolved.tailwindcss;
|
|
489
|
+
}
|
|
456
490
|
const resolvedVue = mergeOptionWithDefaults(resolved.vue, getDefaultVueOptions(options), { postProcess: applyVueVersionSpecificRules });
|
|
457
491
|
if (resolvedVue === void 0) delete resolved.vue;
|
|
458
492
|
else resolved.vue = resolvedVue;
|
|
@@ -518,7 +552,7 @@ function getPresets(options, mode) {
|
|
|
518
552
|
languageOptions: { parser: antfu_exports.parserPlain },
|
|
519
553
|
rules: {}
|
|
520
554
|
});
|
|
521
|
-
presets.push(...resolveStylelintBridgePresets(resolved.stylelint), ...resolveTailwindPresets(resolved.tailwindcss), ...resolveMdxPresets(resolved.mdx), ...resolveNestPresets(resolved.nestjs), ...resolveQueryPresets(resolved.query), ...resolveAccessibilityPresets(resolved.a11y, resolved.vue, resolved.react));
|
|
555
|
+
presets.push(...resolveStylelintBridgePresets(resolved.stylelint), ...resolveTailwindPresets(resolved.tailwindcss), ...resolveBetterTailwindPresets(resolved.betterTailwindcss), ...resolveMdxPresets(resolved.mdx), ...resolveNestPresets(resolved.nestjs), ...resolveQueryPresets(resolved.query), ...resolveAccessibilityPresets(resolved.a11y, resolved.vue, resolved.react));
|
|
522
556
|
return [resolved, ...presets];
|
|
523
557
|
}
|
|
524
558
|
//#endregion
|