@icebreakers/eslint-config 0.5.3 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -32,11 +32,15 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
32
32
  var src_exports = {};
33
33
  __export(src_exports, {
34
34
  getPresets: () => getPresets,
35
- getRestConfigAndPresets: () => getRestConfigAndPresets,
36
- icebreaker: () => icebreaker
35
+ icebreaker: () => icebreaker,
36
+ icebreakerLegacy: () => icebreakerLegacy
37
37
  });
38
38
  module.exports = __toCommonJS(src_exports);
39
39
 
40
+ // src/antfu.ts
41
+ var antfu_exports = {};
42
+ __reExport(antfu_exports, require("@antfu/eslint-config"));
43
+
40
44
  // ../../node_modules/.pnpm/defu@6.1.4/node_modules/defu/dist/defu.mjs
41
45
  function isPlainObject(value) {
42
46
  if (value === null || typeof value !== "object") {
@@ -105,12 +109,93 @@ var defuArrayFn = createDefu((object, key, currentValue) => {
105
109
  }
106
110
  });
107
111
 
108
- // src/antfu.ts
109
- var antfu_exports = {};
110
- __reExport(antfu_exports, require("@antfu/eslint-config"));
112
+ // src/defaults.ts
113
+ function getDefaultVueOptions() {
114
+ const vueOptions = {
115
+ overrides: {
116
+ "vue/attribute-hyphenation": "off",
117
+ "vue/v-on-event-hyphenation": "off",
118
+ "vue/custom-event-name-casing": "off",
119
+ "vue/no-mutating-props": "warn",
120
+ // https://eslint.vuejs.org/rules/no-useless-v-bind.html
121
+ "vue/no-useless-v-bind": [
122
+ "error",
123
+ {
124
+ // 不允许注释
125
+ ignoreIncludesComment: false,
126
+ // 允许在里面使用转义
127
+ // 比如 v-bind:foo="'bar\nbaz'"
128
+ ignoreStringEscape: true
129
+ }
130
+ ],
131
+ // https://eslint.vuejs.org/rules/no-unused-refs.html
132
+ "vue/no-unused-refs": "warn"
133
+ }
134
+ };
135
+ return vueOptions;
136
+ }
137
+ function getDefaultTypescriptOptions() {
138
+ const typescriptOptions = {
139
+ overrides: {
140
+ "ts/no-unused-vars": [
141
+ "error",
142
+ {
143
+ args: "all",
144
+ argsIgnorePattern: "^_",
145
+ caughtErrors: "all",
146
+ caughtErrorsIgnorePattern: "^_",
147
+ destructuredArrayIgnorePattern: "^_",
148
+ varsIgnorePattern: "^_",
149
+ ignoreRestSiblings: true
150
+ }
151
+ ],
152
+ "ts/prefer-ts-expect-error": "off",
153
+ "ts/ban-ts-comment": "off",
154
+ "ts/no-use-before-define": "warn",
155
+ "ts/no-unused-expressions": [
156
+ "error",
157
+ {
158
+ allowShortCircuit: true,
159
+ allowTernary: true
160
+ }
161
+ ]
162
+ }
163
+ };
164
+ return typescriptOptions;
165
+ }
166
+
167
+ // src/utils.ts
168
+ function isObject(o) {
169
+ return Object.prototype.toString.call(o) === "[object Object]";
170
+ }
111
171
 
112
172
  // src/preset.ts
113
- function getPresets(options) {
173
+ function getPresets(options, mode) {
174
+ const opts = defu(options, {
175
+ formatters: true,
176
+ javascript: {
177
+ overrides: {
178
+ "curly": ["error", "all"],
179
+ "no-console": ["warn"],
180
+ // 问题在于 auto fix 的时候,会直接 remove 整个 import ,而我们想让用户自己去 remove
181
+ // 'unused-imports/no-unused-imports': 'error',
182
+ // https://typescript-eslint.io/rules/no-unused-vars/
183
+ "no-unused-vars": "off"
184
+ }
185
+ }
186
+ });
187
+ const vueOptions = getDefaultVueOptions();
188
+ if (opts.vue === true) {
189
+ opts.vue = vueOptions;
190
+ } else if (isObject(opts.vue)) {
191
+ opts.vue = defu(opts.vue, vueOptions);
192
+ }
193
+ const typescriptOptions = getDefaultTypescriptOptions();
194
+ if (opts.typescript === void 0 || opts.typescript === true) {
195
+ opts.typescript = typescriptOptions;
196
+ } else if (isObject(opts.typescript)) {
197
+ opts.typescript = defu(opts.typescript, typescriptOptions);
198
+ }
114
199
  const {
115
200
  tailwindcss: enableTailwindcss,
116
201
  mdx: enableMDX,
@@ -118,35 +203,30 @@ function getPresets(options) {
118
203
  vue: enableVue,
119
204
  react: enableReact
120
205
  // ...opts
121
- } = options;
206
+ } = opts;
122
207
  const presetRules = {
123
- "curly": ["error", "all"],
124
- "no-console": ["warn"],
125
- // 问题在于 auto fix 的时候,会直接 remove 整个 import ,而我们想让用户自己去 remove
126
- // 'unused-imports/no-unused-imports': 'error',
127
- // https://typescript-eslint.io/rules/no-unused-vars/
128
- "no-unused-vars": "off",
129
208
  "unused-imports/no-unused-vars": "off"
130
209
  };
210
+ const isLegacy = mode === "legacy";
211
+ if (isLegacy) {
212
+ presetRules["perfectionist/sort-imports"] = "off";
213
+ }
131
214
  if (enableVue) {
132
- Object.assign(presetRules, {
133
- "vue/attribute-hyphenation": "off",
134
- "vue/v-on-event-hyphenation": "off",
135
- "vue/custom-event-name-casing": "off",
136
- "vue/no-mutating-props": "warn"
137
- });
138
215
  if (typeof enableVue === "object") {
139
- if (enableVue.vueVersion === 2) {
140
- Object.assign(presetRules, {
141
- "vue/no-v-for-template-key-on-child": "off",
142
- "vue/no-v-for-template-key": "error",
143
- "vue/no-deprecated-v-bind-sync": "off"
144
- });
145
- } else {
146
- Object.assign(presetRules, {
147
- "vue/no-v-for-template-key-on-child": "error",
148
- "vue/no-v-for-template-key": "off"
149
- });
216
+ const overrides = enableVue.overrides;
217
+ if (overrides) {
218
+ if (enableVue.vueVersion === 2) {
219
+ Object.assign(overrides, {
220
+ "vue/no-v-for-template-key-on-child": "off",
221
+ "vue/no-v-for-template-key": "error",
222
+ "vue/no-deprecated-v-bind-sync": "off"
223
+ });
224
+ } else {
225
+ Object.assign(overrides, {
226
+ "vue/no-v-for-template-key-on-child": "error",
227
+ "vue/no-v-for-template-key": "off"
228
+ });
229
+ }
150
230
  }
151
231
  }
152
232
  }
@@ -158,7 +238,6 @@ function getPresets(options) {
158
238
  if (enableTailwindcss) {
159
239
  presets.push(
160
240
  (0, antfu_exports.interopDefault)(
161
- // @ts-ignore
162
241
  import("eslint-plugin-tailwindcss")
163
242
  ).then((tailwind) => {
164
243
  return tailwind.configs["flat/recommended"];
@@ -211,49 +290,19 @@ function getPresets(options) {
211
290
  );
212
291
  }
213
292
  }
214
- return presets;
293
+ return [opts, ...presets];
215
294
  }
216
295
 
217
296
  // src/factory.ts
218
- function getRestConfigAndPresets(options) {
219
- const opts = defu(options, {
220
- formatters: true,
221
- typescript: {
222
- overrides: {
223
- "ts/no-unused-vars": [
224
- "error",
225
- {
226
- args: "all",
227
- argsIgnorePattern: "^_",
228
- caughtErrors: "all",
229
- caughtErrorsIgnorePattern: "^_",
230
- destructuredArrayIgnorePattern: "^_",
231
- varsIgnorePattern: "^_",
232
- ignoreRestSiblings: true
233
- }
234
- ],
235
- "ts/prefer-ts-expect-error": "off",
236
- "ts/ban-ts-comment": "off",
237
- "ts/no-use-before-define": "warn",
238
- "ts/no-unused-expressions": [
239
- "error",
240
- {
241
- allowShortCircuit: true,
242
- allowTernary: true
243
- }
244
- ]
245
- }
246
- }
247
- });
248
- const presets = getPresets(opts);
249
- return [opts, ...presets];
250
- }
251
297
  function icebreaker(options = {}, ...userConfigs) {
252
- return (0, antfu_exports.antfu)(...getRestConfigAndPresets(options), ...userConfigs);
298
+ return (0, antfu_exports.antfu)(...getPresets(options), ...userConfigs);
299
+ }
300
+ function icebreakerLegacy(options = {}, ...userConfigs) {
301
+ return (0, antfu_exports.antfu)(...getPresets(options, "legacy"), ...userConfigs);
253
302
  }
254
303
  // Annotate the CommonJS export names for ESM import in node:
255
304
  0 && (module.exports = {
256
305
  getPresets,
257
- getRestConfigAndPresets,
258
- icebreaker
306
+ icebreaker,
307
+ icebreakerLegacy
259
308
  });
package/dist/index.d.cts CHANGED
@@ -9,9 +9,9 @@ type UserDefinedOptions = OptionsConfig & TypedFlatConfigItem & {
9
9
  };
10
10
  type UserConfigItem = Awaitable<TypedFlatConfigItem | TypedFlatConfigItem[] | FlatConfigComposer<any, any> | Linter.Config[]>;
11
11
 
12
- declare function getRestConfigAndPresets(options?: UserDefinedOptions): [OptionsConfig & TypedFlatConfigItem, ...UserConfigItem[]];
13
12
  declare function icebreaker(options?: UserDefinedOptions, ...userConfigs: UserConfigItem[]): FlatConfigComposer<TypedFlatConfigItem, ConfigNames>;
13
+ declare function icebreakerLegacy(options?: UserDefinedOptions, ...userConfigs: UserConfigItem[]): FlatConfigComposer<TypedFlatConfigItem, ConfigNames>;
14
14
 
15
- declare function getPresets(options: UserDefinedOptions): UserConfigItem[];
15
+ declare function getPresets(options?: UserDefinedOptions, mode?: 'legacy'): [UserDefinedOptions, ...UserConfigItem[]];
16
16
 
17
- export { type UserConfigItem, type UserDefinedOptions, getPresets, getRestConfigAndPresets, icebreaker };
17
+ export { type UserConfigItem, type UserDefinedOptions, getPresets, icebreaker, icebreakerLegacy };
package/dist/index.d.ts CHANGED
@@ -9,9 +9,9 @@ type UserDefinedOptions = OptionsConfig & TypedFlatConfigItem & {
9
9
  };
10
10
  type UserConfigItem = Awaitable<TypedFlatConfigItem | TypedFlatConfigItem[] | FlatConfigComposer<any, any> | Linter.Config[]>;
11
11
 
12
- declare function getRestConfigAndPresets(options?: UserDefinedOptions): [OptionsConfig & TypedFlatConfigItem, ...UserConfigItem[]];
13
12
  declare function icebreaker(options?: UserDefinedOptions, ...userConfigs: UserConfigItem[]): FlatConfigComposer<TypedFlatConfigItem, ConfigNames>;
13
+ declare function icebreakerLegacy(options?: UserDefinedOptions, ...userConfigs: UserConfigItem[]): FlatConfigComposer<TypedFlatConfigItem, ConfigNames>;
14
14
 
15
- declare function getPresets(options: UserDefinedOptions): UserConfigItem[];
15
+ declare function getPresets(options?: UserDefinedOptions, mode?: 'legacy'): [UserDefinedOptions, ...UserConfigItem[]];
16
16
 
17
- export { type UserConfigItem, type UserDefinedOptions, getPresets, getRestConfigAndPresets, icebreaker };
17
+ export { type UserConfigItem, type UserDefinedOptions, getPresets, icebreaker, icebreakerLegacy };
package/dist/index.js CHANGED
@@ -12,6 +12,11 @@ var __copyProps = (to, from, except, desc) => {
12
12
  };
13
13
  var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
14
14
 
15
+ // src/antfu.ts
16
+ var antfu_exports = {};
17
+ __reExport(antfu_exports, eslint_config_star);
18
+ import * as eslint_config_star from "@antfu/eslint-config";
19
+
15
20
  // ../../node_modules/.pnpm/defu@6.1.4/node_modules/defu/dist/defu.mjs
16
21
  function isPlainObject(value) {
17
22
  if (value === null || typeof value !== "object") {
@@ -80,13 +85,93 @@ var defuArrayFn = createDefu((object, key, currentValue) => {
80
85
  }
81
86
  });
82
87
 
83
- // src/antfu.ts
84
- var antfu_exports = {};
85
- __reExport(antfu_exports, eslint_config_star);
86
- import * as eslint_config_star from "@antfu/eslint-config";
88
+ // src/defaults.ts
89
+ function getDefaultVueOptions() {
90
+ const vueOptions = {
91
+ overrides: {
92
+ "vue/attribute-hyphenation": "off",
93
+ "vue/v-on-event-hyphenation": "off",
94
+ "vue/custom-event-name-casing": "off",
95
+ "vue/no-mutating-props": "warn",
96
+ // https://eslint.vuejs.org/rules/no-useless-v-bind.html
97
+ "vue/no-useless-v-bind": [
98
+ "error",
99
+ {
100
+ // 不允许注释
101
+ ignoreIncludesComment: false,
102
+ // 允许在里面使用转义
103
+ // 比如 v-bind:foo="'bar\nbaz'"
104
+ ignoreStringEscape: true
105
+ }
106
+ ],
107
+ // https://eslint.vuejs.org/rules/no-unused-refs.html
108
+ "vue/no-unused-refs": "warn"
109
+ }
110
+ };
111
+ return vueOptions;
112
+ }
113
+ function getDefaultTypescriptOptions() {
114
+ const typescriptOptions = {
115
+ overrides: {
116
+ "ts/no-unused-vars": [
117
+ "error",
118
+ {
119
+ args: "all",
120
+ argsIgnorePattern: "^_",
121
+ caughtErrors: "all",
122
+ caughtErrorsIgnorePattern: "^_",
123
+ destructuredArrayIgnorePattern: "^_",
124
+ varsIgnorePattern: "^_",
125
+ ignoreRestSiblings: true
126
+ }
127
+ ],
128
+ "ts/prefer-ts-expect-error": "off",
129
+ "ts/ban-ts-comment": "off",
130
+ "ts/no-use-before-define": "warn",
131
+ "ts/no-unused-expressions": [
132
+ "error",
133
+ {
134
+ allowShortCircuit: true,
135
+ allowTernary: true
136
+ }
137
+ ]
138
+ }
139
+ };
140
+ return typescriptOptions;
141
+ }
142
+
143
+ // src/utils.ts
144
+ function isObject(o) {
145
+ return Object.prototype.toString.call(o) === "[object Object]";
146
+ }
87
147
 
88
148
  // src/preset.ts
89
- function getPresets(options) {
149
+ function getPresets(options, mode) {
150
+ const opts = defu(options, {
151
+ formatters: true,
152
+ javascript: {
153
+ overrides: {
154
+ "curly": ["error", "all"],
155
+ "no-console": ["warn"],
156
+ // 问题在于 auto fix 的时候,会直接 remove 整个 import ,而我们想让用户自己去 remove
157
+ // 'unused-imports/no-unused-imports': 'error',
158
+ // https://typescript-eslint.io/rules/no-unused-vars/
159
+ "no-unused-vars": "off"
160
+ }
161
+ }
162
+ });
163
+ const vueOptions = getDefaultVueOptions();
164
+ if (opts.vue === true) {
165
+ opts.vue = vueOptions;
166
+ } else if (isObject(opts.vue)) {
167
+ opts.vue = defu(opts.vue, vueOptions);
168
+ }
169
+ const typescriptOptions = getDefaultTypescriptOptions();
170
+ if (opts.typescript === void 0 || opts.typescript === true) {
171
+ opts.typescript = typescriptOptions;
172
+ } else if (isObject(opts.typescript)) {
173
+ opts.typescript = defu(opts.typescript, typescriptOptions);
174
+ }
90
175
  const {
91
176
  tailwindcss: enableTailwindcss,
92
177
  mdx: enableMDX,
@@ -94,35 +179,30 @@ function getPresets(options) {
94
179
  vue: enableVue,
95
180
  react: enableReact
96
181
  // ...opts
97
- } = options;
182
+ } = opts;
98
183
  const presetRules = {
99
- "curly": ["error", "all"],
100
- "no-console": ["warn"],
101
- // 问题在于 auto fix 的时候,会直接 remove 整个 import ,而我们想让用户自己去 remove
102
- // 'unused-imports/no-unused-imports': 'error',
103
- // https://typescript-eslint.io/rules/no-unused-vars/
104
- "no-unused-vars": "off",
105
184
  "unused-imports/no-unused-vars": "off"
106
185
  };
186
+ const isLegacy = mode === "legacy";
187
+ if (isLegacy) {
188
+ presetRules["perfectionist/sort-imports"] = "off";
189
+ }
107
190
  if (enableVue) {
108
- Object.assign(presetRules, {
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
- });
114
191
  if (typeof enableVue === "object") {
115
- if (enableVue.vueVersion === 2) {
116
- Object.assign(presetRules, {
117
- "vue/no-v-for-template-key-on-child": "off",
118
- "vue/no-v-for-template-key": "error",
119
- "vue/no-deprecated-v-bind-sync": "off"
120
- });
121
- } else {
122
- Object.assign(presetRules, {
123
- "vue/no-v-for-template-key-on-child": "error",
124
- "vue/no-v-for-template-key": "off"
125
- });
192
+ const overrides = enableVue.overrides;
193
+ if (overrides) {
194
+ if (enableVue.vueVersion === 2) {
195
+ Object.assign(overrides, {
196
+ "vue/no-v-for-template-key-on-child": "off",
197
+ "vue/no-v-for-template-key": "error",
198
+ "vue/no-deprecated-v-bind-sync": "off"
199
+ });
200
+ } else {
201
+ Object.assign(overrides, {
202
+ "vue/no-v-for-template-key-on-child": "error",
203
+ "vue/no-v-for-template-key": "off"
204
+ });
205
+ }
126
206
  }
127
207
  }
128
208
  }
@@ -134,7 +214,6 @@ function getPresets(options) {
134
214
  if (enableTailwindcss) {
135
215
  presets.push(
136
216
  (0, antfu_exports.interopDefault)(
137
- // @ts-ignore
138
217
  import("eslint-plugin-tailwindcss")
139
218
  ).then((tailwind) => {
140
219
  return tailwind.configs["flat/recommended"];
@@ -187,48 +266,18 @@ function getPresets(options) {
187
266
  );
188
267
  }
189
268
  }
190
- return presets;
269
+ return [opts, ...presets];
191
270
  }
192
271
 
193
272
  // src/factory.ts
194
- function getRestConfigAndPresets(options) {
195
- const opts = defu(options, {
196
- formatters: true,
197
- typescript: {
198
- overrides: {
199
- "ts/no-unused-vars": [
200
- "error",
201
- {
202
- args: "all",
203
- argsIgnorePattern: "^_",
204
- caughtErrors: "all",
205
- caughtErrorsIgnorePattern: "^_",
206
- destructuredArrayIgnorePattern: "^_",
207
- varsIgnorePattern: "^_",
208
- ignoreRestSiblings: true
209
- }
210
- ],
211
- "ts/prefer-ts-expect-error": "off",
212
- "ts/ban-ts-comment": "off",
213
- "ts/no-use-before-define": "warn",
214
- "ts/no-unused-expressions": [
215
- "error",
216
- {
217
- allowShortCircuit: true,
218
- allowTernary: true
219
- }
220
- ]
221
- }
222
- }
223
- });
224
- const presets = getPresets(opts);
225
- return [opts, ...presets];
226
- }
227
273
  function icebreaker(options = {}, ...userConfigs) {
228
- return (0, antfu_exports.antfu)(...getRestConfigAndPresets(options), ...userConfigs);
274
+ return (0, antfu_exports.antfu)(...getPresets(options), ...userConfigs);
275
+ }
276
+ function icebreakerLegacy(options = {}, ...userConfigs) {
277
+ return (0, antfu_exports.antfu)(...getPresets(options, "legacy"), ...userConfigs);
229
278
  }
230
279
  export {
231
280
  getPresets,
232
- getRestConfigAndPresets,
233
- icebreaker
281
+ icebreaker,
282
+ icebreakerLegacy
234
283
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@icebreakers/eslint-config",
3
3
  "type": "module",
4
- "version": "0.5.3",
4
+ "version": "0.6.0",
5
5
  "description": "icebreakers's eslint config",
6
6
  "author": "ice breaker <1324318532@qq.com>",
7
7
  "license": "MIT",
@@ -40,9 +40,9 @@
40
40
  "dist"
41
41
  ],
42
42
  "dependencies": {
43
- "@antfu/eslint-config": "3.7.2",
44
- "@eslint-react/eslint-plugin": "^1.14.2",
45
- "@unocss/eslint-plugin": "^0.62.4",
43
+ "@antfu/eslint-config": "3.7.3",
44
+ "@eslint-react/eslint-plugin": "^1.14.3",
45
+ "@unocss/eslint-plugin": "^0.63.4",
46
46
  "eslint-plugin-format": "0.1.2",
47
47
  "eslint-plugin-jsx-a11y": "^6.10.0",
48
48
  "eslint-plugin-mdx": "3.1.5",
@@ -50,7 +50,7 @@
50
50
  "eslint-plugin-react-refresh": "^0.4.12",
51
51
  "eslint-plugin-tailwindcss": "3.17.4",
52
52
  "eslint-plugin-vuejs-accessibility": "^2.4.1",
53
- "globals": "^15.9.0",
53
+ "globals": "^15.10.0",
54
54
  "local-pkg": "0.5.0"
55
55
  },
56
56
  "publishConfig": {