@icebreakers/eslint-config 1.4.6 → 1.5.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 CHANGED
@@ -15,6 +15,29 @@ import { icebreaker } from '@icebreakers/eslint-config'
15
15
  export default icebreaker()
16
16
  ```
17
17
 
18
+ `icebreaker()` returns a `FlatConfigComposer`, so you can opt into extra presets by passing the options documented below and still append workspace-specific rules.
19
+
20
+ ## Available options
21
+
22
+ ```ts
23
+ import { icebreaker } from '@icebreakers/eslint-config'
24
+
25
+ export default icebreaker({
26
+ vue: true,
27
+ typescript: true,
28
+ tailwindcss: {
29
+ tailwindConfig: './tailwind.config.ts',
30
+ },
31
+ mdx: process.env.ENABLE_MDX === 'true',
32
+ a11y: true, // load JSX + Vue accessibility helpers
33
+ })
34
+ ```
35
+
36
+ - `tailwindcss` – enable Tailwind presets (`true`) or provide entry paths for Tailwind v3/v4.
37
+ - `mdx` – enable linting for `.mdx` files with Remark-powered processors.
38
+ - `a11y` – adds accessibility rules for whichever of `vue`/`react` you enable via @antfu.
39
+ - `vue`, `typescript`, `javascript`, `test` – extend the upstream `@antfu/eslint-config` options; the defaults bundle stricter unused checks and Vue fixes for Ionic/Weapp projects.
40
+
18
41
  ## VS Code support
19
42
 
20
43
  Install [VS Code ESLint extension](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint)
package/dist/index.cjs CHANGED
@@ -41,6 +41,99 @@ module.exports = __toCommonJS(index_exports);
41
41
  var antfu_exports = {};
42
42
  __reExport(antfu_exports, require("@antfu/eslint-config"));
43
43
 
44
+ // src/features.ts
45
+ function resolveTailwindPresets(option) {
46
+ if (!option) {
47
+ return [];
48
+ }
49
+ if (typeof option === "object") {
50
+ return [
51
+ (0, antfu_exports.interopDefault)(
52
+ import("eslint-plugin-better-tailwindcss")
53
+ ).then((eslintPluginBetterTailwindcss) => {
54
+ return {
55
+ plugins: {
56
+ "better-tailwindcss": eslintPluginBetterTailwindcss
57
+ },
58
+ rules: {
59
+ ...eslintPluginBetterTailwindcss.configs["recommended-warn"].rules,
60
+ ...eslintPluginBetterTailwindcss.configs["recommended-error"].rules
61
+ },
62
+ settings: {
63
+ "better-tailwindcss": {
64
+ entryPoint: option.entryPoint,
65
+ tailwindConfig: option.tailwindConfig
66
+ }
67
+ }
68
+ };
69
+ })
70
+ ];
71
+ }
72
+ return [
73
+ // @ts-ignore optional dependency shape
74
+ (0, antfu_exports.interopDefault)(
75
+ import("eslint-plugin-tailwindcss")
76
+ ).then((tailwind) => {
77
+ return tailwind.configs["flat/recommended"];
78
+ }),
79
+ {
80
+ rules: {
81
+ "tailwindcss/no-custom-classname": "off"
82
+ }
83
+ }
84
+ ];
85
+ }
86
+ function resolveMdxPresets(isEnabled) {
87
+ if (!isEnabled) {
88
+ return [];
89
+ }
90
+ return [
91
+ (0, antfu_exports.interopDefault)(import("eslint-plugin-mdx")).then((mdx) => {
92
+ return [
93
+ {
94
+ ...mdx.flat,
95
+ processor: mdx.createRemarkProcessor({
96
+ lintCodeBlocks: true,
97
+ languageMapper: {}
98
+ })
99
+ },
100
+ {
101
+ ...mdx.flatCodeBlocks,
102
+ rules: {
103
+ ...mdx.flatCodeBlocks.rules
104
+ }
105
+ }
106
+ ];
107
+ })
108
+ ];
109
+ }
110
+ function resolveAccessibilityPresets(isEnabled, vueOption, reactOption) {
111
+ if (!isEnabled) {
112
+ return [];
113
+ }
114
+ const presets = [];
115
+ if (vueOption) {
116
+ presets.push(
117
+ (0, antfu_exports.interopDefault)(
118
+ import("eslint-plugin-vuejs-accessibility")
119
+ ).then((pluginVueA11y) => {
120
+ return pluginVueA11y.configs["flat/recommended"];
121
+ })
122
+ );
123
+ }
124
+ if (reactOption) {
125
+ presets.push(
126
+ (0, antfu_exports.interopDefault)(
127
+ // @ts-ignore optional dependency shape
128
+ import("eslint-plugin-jsx-a11y")
129
+ ).then((jsxA11y) => {
130
+ return jsxA11y.flatConfigs.recommended;
131
+ })
132
+ );
133
+ }
134
+ return presets;
135
+ }
136
+
44
137
  // ../../node_modules/.pnpm/defu@6.1.4/node_modules/defu/dist/defu.mjs
45
138
  function isPlainObject(value) {
46
139
  if (value === null || typeof value !== "object") {
@@ -240,164 +333,90 @@ function isObject(o) {
240
333
  return Object.prototype.toString.call(o) === "[object Object]";
241
334
  }
242
335
 
243
- // src/preset.ts
244
- function getPresets(options, mode) {
245
- const opts = defu(options, {
246
- formatters: true,
247
- javascript: {
248
- overrides: {
249
- "curly": ["error", "all"],
250
- "no-console": ["warn"]
251
- // 问题在于 auto fix 的时候,会直接 remove 整个 import ,而我们想让用户自己去 remove
252
- // 'unused-imports/no-unused-imports': 'error',
253
- // https://typescript-eslint.io/rules/no-unused-vars/
254
- // https://github.com/antfu/eslint-config/blob/main/src/configs/javascript.ts
255
- // 'no-unused-vars': 'error',
256
- // 'no-undef': 'error',
257
- // 'prefer-const': 'off',
258
- }
259
- },
260
- test: {
261
- overrides: {
262
- "test/prefer-lowercase-title": ["off"]
263
- }
336
+ // src/options.ts
337
+ var BASE_DEFAULTS = {
338
+ formatters: true,
339
+ javascript: {
340
+ overrides: {
341
+ "curly": ["error", "all"],
342
+ "no-console": ["warn"]
343
+ }
344
+ },
345
+ test: {
346
+ overrides: {
347
+ "test/prefer-lowercase-title": ["off"]
264
348
  }
349
+ }
350
+ };
351
+ var BASE_RULES = {
352
+ "unused-imports/no-unused-vars": "off"
353
+ };
354
+ function applyVueVersionSpecificRules(option) {
355
+ if (!option || typeof option !== "object") {
356
+ return;
357
+ }
358
+ const overrides = option.overrides;
359
+ if (!overrides) {
360
+ return;
361
+ }
362
+ if (option.vueVersion === 2) {
363
+ Object.assign(overrides, {
364
+ "vue/no-v-for-template-key-on-child": "off",
365
+ "vue/no-v-for-template-key": "error",
366
+ "vue/no-deprecated-v-bind-sync": "off"
367
+ });
368
+ return;
369
+ }
370
+ Object.assign(overrides, {
371
+ "vue/no-v-for-template-key-on-child": "error",
372
+ "vue/no-v-for-template-key": "off"
265
373
  });
374
+ }
375
+ function resolveUserOptions(options) {
376
+ const resolved = defu(
377
+ {},
378
+ options ?? {},
379
+ BASE_DEFAULTS
380
+ );
266
381
  const vueOptions = getDefaultVueOptions(options);
267
- if (opts.vue === true) {
268
- opts.vue = vueOptions;
269
- } else if (isObject(opts.vue)) {
270
- opts.vue = defu(opts.vue, vueOptions);
382
+ if (resolved.vue === true) {
383
+ resolved.vue = vueOptions;
384
+ } else if (isObject(resolved.vue)) {
385
+ resolved.vue = defu(resolved.vue, vueOptions);
271
386
  }
387
+ applyVueVersionSpecificRules(resolved.vue);
272
388
  const typescriptOptions = getDefaultTypescriptOptions(options);
273
- if (opts.typescript === void 0 || opts.typescript === true) {
274
- opts.typescript = typescriptOptions;
275
- } else if (isObject(opts.typescript)) {
276
- opts.typescript = defu(opts.typescript, typescriptOptions);
277
- }
278
- const {
279
- tailwindcss: enableTailwindcss,
280
- mdx: enableMDX,
281
- a11y: enableA11y,
282
- vue: enableVue,
283
- react: enableReact
284
- // ...opts
285
- } = opts;
286
- const presetRules = {
287
- "unused-imports/no-unused-vars": "off"
288
- };
289
- const isLegacy = mode === "legacy";
290
- if (isLegacy) {
291
- presetRules["perfectionist/sort-imports"] = "off";
389
+ if (resolved.typescript === void 0 || resolved.typescript === true) {
390
+ resolved.typescript = typescriptOptions;
391
+ } else if (isObject(resolved.typescript)) {
392
+ resolved.typescript = defu(resolved.typescript, typescriptOptions);
292
393
  }
293
- if (enableVue) {
294
- if (typeof enableVue === "object") {
295
- const overrides = enableVue.overrides;
296
- if (overrides) {
297
- if (enableVue.vueVersion === 2) {
298
- Object.assign(overrides, {
299
- "vue/no-v-for-template-key-on-child": "off",
300
- "vue/no-v-for-template-key": "error",
301
- "vue/no-deprecated-v-bind-sync": "off"
302
- });
303
- } else {
304
- Object.assign(overrides, {
305
- "vue/no-v-for-template-key-on-child": "error",
306
- "vue/no-v-for-template-key": "off"
307
- });
308
- }
309
- }
310
- }
394
+ return resolved;
395
+ }
396
+ function createBaseRuleSet(isLegacy) {
397
+ if (!isLegacy) {
398
+ return BASE_RULES;
311
399
  }
400
+ return {
401
+ ...BASE_RULES,
402
+ "perfectionist/sort-imports": "off"
403
+ };
404
+ }
405
+
406
+ // src/preset.ts
407
+ function getPresets(options, mode) {
408
+ const resolved = resolveUserOptions(options);
312
409
  const presets = [
313
410
  {
314
- rules: presetRules
411
+ rules: createBaseRuleSet(mode === "legacy")
315
412
  }
316
413
  ];
317
- if (enableTailwindcss) {
318
- if (typeof enableTailwindcss === "object") {
319
- presets.push(
320
- (0, antfu_exports.interopDefault)(
321
- import("eslint-plugin-better-tailwindcss")
322
- ).then((eslintPluginBetterTailwindcss) => {
323
- return {
324
- plugins: {
325
- "better-tailwindcss": eslintPluginBetterTailwindcss
326
- },
327
- rules: {
328
- // enable all recommended rules to report a warning
329
- ...eslintPluginBetterTailwindcss.configs["recommended-warn"].rules,
330
- // enable all recommended rules to report an error
331
- ...eslintPluginBetterTailwindcss.configs["recommended-error"].rules
332
- },
333
- settings: {
334
- "better-tailwindcss": {
335
- // tailwindcss 4: the path to the entry file of the css based tailwind config (eg: `src/global.css`)
336
- entryPoint: enableTailwindcss.entryPoint,
337
- // tailwindcss 3: the path to the tailwind config file (eg: `tailwind.config.js`)
338
- tailwindConfig: enableTailwindcss.tailwindConfig
339
- }
340
- }
341
- };
342
- })
343
- );
344
- } else {
345
- presets.push(
346
- // @ts-ignore
347
- (0, antfu_exports.interopDefault)(
348
- import("eslint-plugin-tailwindcss")
349
- ).then((tailwind) => {
350
- return tailwind.configs["flat/recommended"];
351
- })
352
- );
353
- presets.push({
354
- rules: {
355
- "tailwindcss/no-custom-classname": "off"
356
- }
357
- });
358
- }
359
- }
360
- if (enableMDX) {
361
- presets.push((0, antfu_exports.interopDefault)(import("eslint-plugin-mdx")).then((mdx) => {
362
- return [
363
- {
364
- ...mdx.flat,
365
- processor: mdx.createRemarkProcessor({
366
- lintCodeBlocks: true,
367
- languageMapper: {}
368
- })
369
- },
370
- {
371
- ...mdx.flatCodeBlocks,
372
- rules: {
373
- ...mdx.flatCodeBlocks.rules
374
- }
375
- }
376
- ];
377
- }));
378
- }
379
- if (enableA11y) {
380
- if (enableVue) {
381
- presets.push(
382
- (0, antfu_exports.interopDefault)(
383
- import("eslint-plugin-vuejs-accessibility")
384
- ).then((pluginVueA11y) => {
385
- return pluginVueA11y.configs["flat/recommended"];
386
- })
387
- );
388
- }
389
- if (enableReact) {
390
- presets.push(
391
- (0, antfu_exports.interopDefault)(
392
- // @ts-ignore
393
- import("eslint-plugin-jsx-a11y")
394
- ).then((jsxA11y) => {
395
- return jsxA11y.flatConfigs.recommended;
396
- })
397
- );
398
- }
399
- }
400
- return [opts, ...presets];
414
+ presets.push(
415
+ ...resolveTailwindPresets(resolved.tailwindcss),
416
+ ...resolveMdxPresets(resolved.mdx),
417
+ ...resolveAccessibilityPresets(resolved.a11y, resolved.vue, resolved.react)
418
+ );
419
+ return [resolved, ...presets];
401
420
  }
402
421
 
403
422
  // src/factory.ts
package/dist/index.d.cts CHANGED
@@ -4,21 +4,23 @@ import { FlatConfigComposer } from 'eslint-flat-config-utils';
4
4
  export { FlatConfigComposer } from 'eslint-flat-config-utils';
5
5
  import { Linter } from 'eslint';
6
6
 
7
+ interface TailwindcssOption {
8
+ /**
9
+ * Tailwind CSS v4 entry point, e.g. `src/global.css`.
10
+ */
11
+ entryPoint?: string;
12
+ /**
13
+ * Tailwind CSS v3 config file path, e.g. `tailwind.config.js`.
14
+ */
15
+ tailwindConfig?: string;
16
+ }
17
+ type TailwindcssConfig = boolean | TailwindcssOption;
7
18
  type UserDefinedOptions = OptionsConfig & TypedFlatConfigItem & {
8
19
  /**
9
20
  * Enable TailwindCSS support
10
21
  * @default false
11
22
  */
12
- tailwindcss?: boolean | {
13
- /**
14
- * tailwindcss 4: the path to the entry file of the css based tailwind config (eg: `src/global.css`)
15
- */
16
- entryPoint?: string;
17
- /**
18
- * tailwindcss 3: the path to the tailwind config file (eg: `tailwind.config.js`)
19
- */
20
- tailwindConfig?: string;
21
- };
23
+ tailwindcss?: TailwindcssConfig;
22
24
  /**
23
25
  * Enable MDX support
24
26
  * @default false
@@ -52,4 +54,4 @@ declare function icebreakerLegacy(options?: UserDefinedOptions, ...userConfigs:
52
54
 
53
55
  declare function getPresets(options?: UserDefinedOptions, mode?: 'legacy'): [UserDefinedOptions, ...UserConfigItem[]];
54
56
 
55
- export { type UserConfigItem, type UserDefinedOptions, getPresets, icebreaker, icebreakerLegacy };
57
+ export { type TailwindcssConfig, type TailwindcssOption, type UserConfigItem, type UserDefinedOptions, getPresets, icebreaker, icebreakerLegacy };
package/dist/index.d.ts CHANGED
@@ -4,21 +4,23 @@ import { FlatConfigComposer } from 'eslint-flat-config-utils';
4
4
  export { FlatConfigComposer } from 'eslint-flat-config-utils';
5
5
  import { Linter } from 'eslint';
6
6
 
7
+ interface TailwindcssOption {
8
+ /**
9
+ * Tailwind CSS v4 entry point, e.g. `src/global.css`.
10
+ */
11
+ entryPoint?: string;
12
+ /**
13
+ * Tailwind CSS v3 config file path, e.g. `tailwind.config.js`.
14
+ */
15
+ tailwindConfig?: string;
16
+ }
17
+ type TailwindcssConfig = boolean | TailwindcssOption;
7
18
  type UserDefinedOptions = OptionsConfig & TypedFlatConfigItem & {
8
19
  /**
9
20
  * Enable TailwindCSS support
10
21
  * @default false
11
22
  */
12
- tailwindcss?: boolean | {
13
- /**
14
- * tailwindcss 4: the path to the entry file of the css based tailwind config (eg: `src/global.css`)
15
- */
16
- entryPoint?: string;
17
- /**
18
- * tailwindcss 3: the path to the tailwind config file (eg: `tailwind.config.js`)
19
- */
20
- tailwindConfig?: string;
21
- };
23
+ tailwindcss?: TailwindcssConfig;
22
24
  /**
23
25
  * Enable MDX support
24
26
  * @default false
@@ -52,4 +54,4 @@ declare function icebreakerLegacy(options?: UserDefinedOptions, ...userConfigs:
52
54
 
53
55
  declare function getPresets(options?: UserDefinedOptions, mode?: 'legacy'): [UserDefinedOptions, ...UserConfigItem[]];
54
56
 
55
- export { type UserConfigItem, type UserDefinedOptions, getPresets, icebreaker, icebreakerLegacy };
57
+ export { type TailwindcssConfig, type TailwindcssOption, type UserConfigItem, type UserDefinedOptions, getPresets, icebreaker, icebreakerLegacy };
package/dist/index.js CHANGED
@@ -17,6 +17,99 @@ var antfu_exports = {};
17
17
  __reExport(antfu_exports, eslint_config_star);
18
18
  import * as eslint_config_star from "@antfu/eslint-config";
19
19
 
20
+ // src/features.ts
21
+ function resolveTailwindPresets(option) {
22
+ if (!option) {
23
+ return [];
24
+ }
25
+ if (typeof option === "object") {
26
+ return [
27
+ (0, antfu_exports.interopDefault)(
28
+ import("eslint-plugin-better-tailwindcss")
29
+ ).then((eslintPluginBetterTailwindcss) => {
30
+ return {
31
+ plugins: {
32
+ "better-tailwindcss": eslintPluginBetterTailwindcss
33
+ },
34
+ rules: {
35
+ ...eslintPluginBetterTailwindcss.configs["recommended-warn"].rules,
36
+ ...eslintPluginBetterTailwindcss.configs["recommended-error"].rules
37
+ },
38
+ settings: {
39
+ "better-tailwindcss": {
40
+ entryPoint: option.entryPoint,
41
+ tailwindConfig: option.tailwindConfig
42
+ }
43
+ }
44
+ };
45
+ })
46
+ ];
47
+ }
48
+ return [
49
+ // @ts-ignore optional dependency shape
50
+ (0, antfu_exports.interopDefault)(
51
+ import("eslint-plugin-tailwindcss")
52
+ ).then((tailwind) => {
53
+ return tailwind.configs["flat/recommended"];
54
+ }),
55
+ {
56
+ rules: {
57
+ "tailwindcss/no-custom-classname": "off"
58
+ }
59
+ }
60
+ ];
61
+ }
62
+ function resolveMdxPresets(isEnabled) {
63
+ if (!isEnabled) {
64
+ return [];
65
+ }
66
+ return [
67
+ (0, antfu_exports.interopDefault)(import("eslint-plugin-mdx")).then((mdx) => {
68
+ return [
69
+ {
70
+ ...mdx.flat,
71
+ processor: mdx.createRemarkProcessor({
72
+ lintCodeBlocks: true,
73
+ languageMapper: {}
74
+ })
75
+ },
76
+ {
77
+ ...mdx.flatCodeBlocks,
78
+ rules: {
79
+ ...mdx.flatCodeBlocks.rules
80
+ }
81
+ }
82
+ ];
83
+ })
84
+ ];
85
+ }
86
+ function resolveAccessibilityPresets(isEnabled, vueOption, reactOption) {
87
+ if (!isEnabled) {
88
+ return [];
89
+ }
90
+ const presets = [];
91
+ if (vueOption) {
92
+ presets.push(
93
+ (0, antfu_exports.interopDefault)(
94
+ import("eslint-plugin-vuejs-accessibility")
95
+ ).then((pluginVueA11y) => {
96
+ return pluginVueA11y.configs["flat/recommended"];
97
+ })
98
+ );
99
+ }
100
+ if (reactOption) {
101
+ presets.push(
102
+ (0, antfu_exports.interopDefault)(
103
+ // @ts-ignore optional dependency shape
104
+ import("eslint-plugin-jsx-a11y")
105
+ ).then((jsxA11y) => {
106
+ return jsxA11y.flatConfigs.recommended;
107
+ })
108
+ );
109
+ }
110
+ return presets;
111
+ }
112
+
20
113
  // ../../node_modules/.pnpm/defu@6.1.4/node_modules/defu/dist/defu.mjs
21
114
  function isPlainObject(value) {
22
115
  if (value === null || typeof value !== "object") {
@@ -216,164 +309,90 @@ function isObject(o) {
216
309
  return Object.prototype.toString.call(o) === "[object Object]";
217
310
  }
218
311
 
219
- // src/preset.ts
220
- function getPresets(options, mode) {
221
- const opts = defu(options, {
222
- formatters: true,
223
- javascript: {
224
- overrides: {
225
- "curly": ["error", "all"],
226
- "no-console": ["warn"]
227
- // 问题在于 auto fix 的时候,会直接 remove 整个 import ,而我们想让用户自己去 remove
228
- // 'unused-imports/no-unused-imports': 'error',
229
- // https://typescript-eslint.io/rules/no-unused-vars/
230
- // https://github.com/antfu/eslint-config/blob/main/src/configs/javascript.ts
231
- // 'no-unused-vars': 'error',
232
- // 'no-undef': 'error',
233
- // 'prefer-const': 'off',
234
- }
235
- },
236
- test: {
237
- overrides: {
238
- "test/prefer-lowercase-title": ["off"]
239
- }
312
+ // src/options.ts
313
+ var BASE_DEFAULTS = {
314
+ formatters: true,
315
+ javascript: {
316
+ overrides: {
317
+ "curly": ["error", "all"],
318
+ "no-console": ["warn"]
319
+ }
320
+ },
321
+ test: {
322
+ overrides: {
323
+ "test/prefer-lowercase-title": ["off"]
240
324
  }
325
+ }
326
+ };
327
+ var BASE_RULES = {
328
+ "unused-imports/no-unused-vars": "off"
329
+ };
330
+ function applyVueVersionSpecificRules(option) {
331
+ if (!option || typeof option !== "object") {
332
+ return;
333
+ }
334
+ const overrides = option.overrides;
335
+ if (!overrides) {
336
+ return;
337
+ }
338
+ if (option.vueVersion === 2) {
339
+ Object.assign(overrides, {
340
+ "vue/no-v-for-template-key-on-child": "off",
341
+ "vue/no-v-for-template-key": "error",
342
+ "vue/no-deprecated-v-bind-sync": "off"
343
+ });
344
+ return;
345
+ }
346
+ Object.assign(overrides, {
347
+ "vue/no-v-for-template-key-on-child": "error",
348
+ "vue/no-v-for-template-key": "off"
241
349
  });
350
+ }
351
+ function resolveUserOptions(options) {
352
+ const resolved = defu(
353
+ {},
354
+ options ?? {},
355
+ BASE_DEFAULTS
356
+ );
242
357
  const vueOptions = getDefaultVueOptions(options);
243
- if (opts.vue === true) {
244
- opts.vue = vueOptions;
245
- } else if (isObject(opts.vue)) {
246
- opts.vue = defu(opts.vue, vueOptions);
358
+ if (resolved.vue === true) {
359
+ resolved.vue = vueOptions;
360
+ } else if (isObject(resolved.vue)) {
361
+ resolved.vue = defu(resolved.vue, vueOptions);
247
362
  }
363
+ applyVueVersionSpecificRules(resolved.vue);
248
364
  const typescriptOptions = getDefaultTypescriptOptions(options);
249
- if (opts.typescript === void 0 || opts.typescript === true) {
250
- opts.typescript = typescriptOptions;
251
- } else if (isObject(opts.typescript)) {
252
- opts.typescript = defu(opts.typescript, typescriptOptions);
253
- }
254
- const {
255
- tailwindcss: enableTailwindcss,
256
- mdx: enableMDX,
257
- a11y: enableA11y,
258
- vue: enableVue,
259
- react: enableReact
260
- // ...opts
261
- } = opts;
262
- const presetRules = {
263
- "unused-imports/no-unused-vars": "off"
264
- };
265
- const isLegacy = mode === "legacy";
266
- if (isLegacy) {
267
- presetRules["perfectionist/sort-imports"] = "off";
365
+ if (resolved.typescript === void 0 || resolved.typescript === true) {
366
+ resolved.typescript = typescriptOptions;
367
+ } else if (isObject(resolved.typescript)) {
368
+ resolved.typescript = defu(resolved.typescript, typescriptOptions);
268
369
  }
269
- if (enableVue) {
270
- if (typeof enableVue === "object") {
271
- const overrides = enableVue.overrides;
272
- if (overrides) {
273
- if (enableVue.vueVersion === 2) {
274
- Object.assign(overrides, {
275
- "vue/no-v-for-template-key-on-child": "off",
276
- "vue/no-v-for-template-key": "error",
277
- "vue/no-deprecated-v-bind-sync": "off"
278
- });
279
- } else {
280
- Object.assign(overrides, {
281
- "vue/no-v-for-template-key-on-child": "error",
282
- "vue/no-v-for-template-key": "off"
283
- });
284
- }
285
- }
286
- }
370
+ return resolved;
371
+ }
372
+ function createBaseRuleSet(isLegacy) {
373
+ if (!isLegacy) {
374
+ return BASE_RULES;
287
375
  }
376
+ return {
377
+ ...BASE_RULES,
378
+ "perfectionist/sort-imports": "off"
379
+ };
380
+ }
381
+
382
+ // src/preset.ts
383
+ function getPresets(options, mode) {
384
+ const resolved = resolveUserOptions(options);
288
385
  const presets = [
289
386
  {
290
- rules: presetRules
387
+ rules: createBaseRuleSet(mode === "legacy")
291
388
  }
292
389
  ];
293
- if (enableTailwindcss) {
294
- if (typeof enableTailwindcss === "object") {
295
- presets.push(
296
- (0, antfu_exports.interopDefault)(
297
- import("eslint-plugin-better-tailwindcss")
298
- ).then((eslintPluginBetterTailwindcss) => {
299
- return {
300
- plugins: {
301
- "better-tailwindcss": eslintPluginBetterTailwindcss
302
- },
303
- rules: {
304
- // enable all recommended rules to report a warning
305
- ...eslintPluginBetterTailwindcss.configs["recommended-warn"].rules,
306
- // enable all recommended rules to report an error
307
- ...eslintPluginBetterTailwindcss.configs["recommended-error"].rules
308
- },
309
- settings: {
310
- "better-tailwindcss": {
311
- // tailwindcss 4: the path to the entry file of the css based tailwind config (eg: `src/global.css`)
312
- entryPoint: enableTailwindcss.entryPoint,
313
- // tailwindcss 3: the path to the tailwind config file (eg: `tailwind.config.js`)
314
- tailwindConfig: enableTailwindcss.tailwindConfig
315
- }
316
- }
317
- };
318
- })
319
- );
320
- } else {
321
- presets.push(
322
- // @ts-ignore
323
- (0, antfu_exports.interopDefault)(
324
- import("eslint-plugin-tailwindcss")
325
- ).then((tailwind) => {
326
- return tailwind.configs["flat/recommended"];
327
- })
328
- );
329
- presets.push({
330
- rules: {
331
- "tailwindcss/no-custom-classname": "off"
332
- }
333
- });
334
- }
335
- }
336
- if (enableMDX) {
337
- presets.push((0, antfu_exports.interopDefault)(import("eslint-plugin-mdx")).then((mdx) => {
338
- return [
339
- {
340
- ...mdx.flat,
341
- processor: mdx.createRemarkProcessor({
342
- lintCodeBlocks: true,
343
- languageMapper: {}
344
- })
345
- },
346
- {
347
- ...mdx.flatCodeBlocks,
348
- rules: {
349
- ...mdx.flatCodeBlocks.rules
350
- }
351
- }
352
- ];
353
- }));
354
- }
355
- if (enableA11y) {
356
- if (enableVue) {
357
- presets.push(
358
- (0, antfu_exports.interopDefault)(
359
- import("eslint-plugin-vuejs-accessibility")
360
- ).then((pluginVueA11y) => {
361
- return pluginVueA11y.configs["flat/recommended"];
362
- })
363
- );
364
- }
365
- if (enableReact) {
366
- presets.push(
367
- (0, antfu_exports.interopDefault)(
368
- // @ts-ignore
369
- import("eslint-plugin-jsx-a11y")
370
- ).then((jsxA11y) => {
371
- return jsxA11y.flatConfigs.recommended;
372
- })
373
- );
374
- }
375
- }
376
- return [opts, ...presets];
390
+ presets.push(
391
+ ...resolveTailwindPresets(resolved.tailwindcss),
392
+ ...resolveMdxPresets(resolved.mdx),
393
+ ...resolveAccessibilityPresets(resolved.a11y, resolved.vue, resolved.react)
394
+ );
395
+ return [resolved, ...presets];
377
396
  }
378
397
 
379
398
  // src/factory.ts
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@icebreakers/eslint-config",
3
3
  "type": "module",
4
- "version": "1.4.6",
4
+ "version": "1.5.0",
5
5
  "description": "icebreakers's eslint config",
6
6
  "author": "ice breaker <1324318532@qq.com>",
7
7
  "license": "MIT",