@sxzz/eslint-config 3.3.2 → 3.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/index.cjs CHANGED
@@ -5,6 +5,9 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __commonJS = (cb, mod) => function __require() {
9
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
10
+ };
8
11
  var __export = (target, all2) => {
9
12
  for (var name in all2)
10
13
  __defProp(target, name, { get: all2[name], enumerable: true });
@@ -27,6 +30,337 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
27
30
  ));
28
31
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
32
 
33
+ // node_modules/.pnpm/eslint-plugin-unused-imports@3.0.0_@typescript-eslint+eslint-plugin@6.4.1_eslint@8.48.0/node_modules/eslint-plugin-unused-imports/lib/rules/predicates.js
34
+ var require_predicates = __commonJS({
35
+ "node_modules/.pnpm/eslint-plugin-unused-imports@3.0.0_@typescript-eslint+eslint-plugin@6.4.1_eslint@8.48.0/node_modules/eslint-plugin-unused-imports/lib/rules/predicates.js"(exports) {
36
+ "use strict";
37
+ exports.unusedVarsPredicate = (problem, context) => {
38
+ const { node } = problem;
39
+ const { parent } = node;
40
+ if (parent == null) {
41
+ return problem;
42
+ }
43
+ switch (parent.type) {
44
+ case "ImportSpecifier":
45
+ case "ImportDefaultSpecifier":
46
+ case "ImportNamespaceSpecifier":
47
+ return false;
48
+ default:
49
+ return problem;
50
+ }
51
+ };
52
+ var commaFilter = { filter: (token) => token.value === "," };
53
+ var includeCommentsFilter = { includeComments: true };
54
+ exports.unusedImportsPredicate = (problem, context) => {
55
+ const { sourceCode } = context;
56
+ const { node } = problem;
57
+ const { parent } = node;
58
+ if (parent == null) {
59
+ return problem;
60
+ }
61
+ switch (parent.type) {
62
+ case "ImportSpecifier":
63
+ case "ImportDefaultSpecifier":
64
+ case "ImportNamespaceSpecifier":
65
+ break;
66
+ default:
67
+ return false;
68
+ }
69
+ problem.fix = (fixer) => {
70
+ if (!parent) {
71
+ return null;
72
+ }
73
+ const grandParent = parent.parent;
74
+ if (!grandParent) {
75
+ return null;
76
+ }
77
+ if (grandParent.specifiers.length === 1) {
78
+ const nextToken = sourceCode.getTokenAfter(grandParent, includeCommentsFilter);
79
+ const newLinesBetween = nextToken ? nextToken.loc.start.line - grandParent.loc.start.line : 0;
80
+ const endOfReplaceRange = nextToken ? nextToken.range[0] : grandParent.range[1];
81
+ const count = Math.max(0, newLinesBetween - 1);
82
+ return [
83
+ fixer.remove(grandParent),
84
+ fixer.replaceTextRange([grandParent.range[1], endOfReplaceRange], "\n".repeat(count))
85
+ ];
86
+ }
87
+ if (parent !== grandParent.specifiers[grandParent.specifiers.length - 1]) {
88
+ const comma = sourceCode.getTokenAfter(parent, commaFilter);
89
+ const prevNode = sourceCode.getTokenBefore(parent);
90
+ return [
91
+ fixer.removeRange([prevNode.range[1], parent.range[0]]),
92
+ fixer.remove(parent),
93
+ fixer.remove(comma)
94
+ ];
95
+ }
96
+ if (grandParent.specifiers.filter((specifier) => specifier.type === "ImportSpecifier").length === 1) {
97
+ const start = sourceCode.getTokenBefore(parent, commaFilter);
98
+ const end = sourceCode.getTokenAfter(parent, { filter: (token) => token.value === "}" });
99
+ return fixer.removeRange([start.range[0], end.range[1]]);
100
+ }
101
+ return fixer.removeRange([
102
+ sourceCode.getTokenBefore(parent, commaFilter).range[0],
103
+ parent.range[1]
104
+ ]);
105
+ };
106
+ return problem;
107
+ };
108
+ }
109
+ });
110
+
111
+ // node_modules/.pnpm/eslint-rule-composer@0.3.0/node_modules/eslint-rule-composer/lib/rule-composer.js
112
+ var require_rule_composer = __commonJS({
113
+ "node_modules/.pnpm/eslint-rule-composer@0.3.0/node_modules/eslint-rule-composer/lib/rule-composer.js"(exports, module2) {
114
+ "use strict";
115
+ function normalizeMultiArgReportCall() {
116
+ if (arguments.length === 1) {
117
+ return arguments[0];
118
+ }
119
+ if (typeof arguments[1] === "string") {
120
+ return {
121
+ node: arguments[0],
122
+ message: arguments[1],
123
+ data: arguments[2],
124
+ fix: arguments[3]
125
+ };
126
+ }
127
+ return {
128
+ node: arguments[0],
129
+ loc: arguments[1],
130
+ message: arguments[2],
131
+ data: arguments[3],
132
+ fix: arguments[4]
133
+ };
134
+ }
135
+ function normalizeReportLoc(descriptor) {
136
+ if (descriptor.loc) {
137
+ if (descriptor.loc.start) {
138
+ return descriptor.loc;
139
+ }
140
+ return { start: descriptor.loc, end: null };
141
+ }
142
+ return descriptor.node.loc;
143
+ }
144
+ function normalizeMessagePlaceholders(descriptor, messageIds) {
145
+ const message = typeof descriptor.messageId === "string" ? messageIds[descriptor.messageId] : descriptor.message;
146
+ if (!descriptor.data) {
147
+ return {
148
+ message,
149
+ data: typeof descriptor.messageId === "string" ? {} : null
150
+ };
151
+ }
152
+ const normalizedData = /* @__PURE__ */ Object.create(null);
153
+ const interpolatedMessage = message.replace(/\{\{\s*([^{}]+?)\s*\}\}/g, (fullMatch, term) => {
154
+ if (term in descriptor.data) {
155
+ normalizedData[term] = descriptor.data[term];
156
+ return descriptor.data[term];
157
+ }
158
+ return fullMatch;
159
+ });
160
+ return {
161
+ message: interpolatedMessage,
162
+ data: Object.freeze(normalizedData)
163
+ };
164
+ }
165
+ function getRuleMeta(rule) {
166
+ return typeof rule === "object" && rule.meta && typeof rule.meta === "object" ? rule.meta : {};
167
+ }
168
+ function getMessageIds(rule) {
169
+ const meta = getRuleMeta(rule);
170
+ return meta.messages && typeof rule.meta.messages === "object" ? meta.messages : {};
171
+ }
172
+ function getReportNormalizer(rule) {
173
+ const messageIds = getMessageIds(rule);
174
+ return function normalizeReport() {
175
+ const descriptor = normalizeMultiArgReportCall.apply(null, arguments);
176
+ const interpolatedMessageAndData = normalizeMessagePlaceholders(descriptor, messageIds);
177
+ return {
178
+ node: descriptor.node,
179
+ message: interpolatedMessageAndData.message,
180
+ messageId: typeof descriptor.messageId === "string" ? descriptor.messageId : null,
181
+ data: typeof descriptor.messageId === "string" ? interpolatedMessageAndData.data : null,
182
+ loc: normalizeReportLoc(descriptor),
183
+ fix: descriptor.fix
184
+ };
185
+ };
186
+ }
187
+ function getRuleCreateFunc(rule) {
188
+ return typeof rule === "function" ? rule : rule.create;
189
+ }
190
+ function removeMessageIfMessageIdPresent(reportDescriptor) {
191
+ const newDescriptor = Object.assign({}, reportDescriptor);
192
+ if (typeof reportDescriptor.messageId === "string" && typeof reportDescriptor.message === "string") {
193
+ delete newDescriptor.message;
194
+ }
195
+ return newDescriptor;
196
+ }
197
+ module2.exports = Object.freeze({
198
+ filterReports(rule, predicate) {
199
+ return Object.freeze({
200
+ create(context) {
201
+ const filename = context.getFilename();
202
+ const sourceCode = context.getSourceCode();
203
+ const settings = context.settings;
204
+ const options = context.options;
205
+ return getRuleCreateFunc(rule)(
206
+ Object.freeze(
207
+ Object.create(
208
+ context,
209
+ {
210
+ report: {
211
+ enumerable: true,
212
+ value() {
213
+ const reportDescriptor = getReportNormalizer(rule).apply(null, arguments);
214
+ if (predicate(reportDescriptor, {
215
+ sourceCode,
216
+ settings,
217
+ options,
218
+ filename
219
+ })) {
220
+ context.report(removeMessageIfMessageIdPresent(reportDescriptor));
221
+ }
222
+ }
223
+ }
224
+ }
225
+ )
226
+ )
227
+ );
228
+ },
229
+ schema: rule.schema,
230
+ meta: getRuleMeta(rule)
231
+ });
232
+ },
233
+ mapReports(rule, iteratee) {
234
+ return Object.freeze({
235
+ create(context) {
236
+ const filename = context.getFilename();
237
+ const sourceCode = context.getSourceCode();
238
+ const settings = context.settings;
239
+ const options = context.options;
240
+ return getRuleCreateFunc(rule)(
241
+ Object.freeze(
242
+ Object.create(
243
+ context,
244
+ {
245
+ report: {
246
+ enumerable: true,
247
+ value() {
248
+ context.report(
249
+ removeMessageIfMessageIdPresent(
250
+ iteratee(
251
+ getReportNormalizer(rule).apply(null, arguments),
252
+ {
253
+ sourceCode,
254
+ settings,
255
+ options,
256
+ filename
257
+ }
258
+ )
259
+ )
260
+ );
261
+ }
262
+ }
263
+ }
264
+ )
265
+ )
266
+ );
267
+ },
268
+ schema: rule.schema,
269
+ meta: getRuleMeta(rule)
270
+ });
271
+ },
272
+ joinReports(rules) {
273
+ return Object.freeze({
274
+ create(context) {
275
+ return rules.map((rule) => getRuleCreateFunc(rule)(context)).reduce(
276
+ (allListeners, ruleListeners) => Object.keys(ruleListeners).reduce(
277
+ (combinedListeners, key) => {
278
+ const currentListener = combinedListeners[key];
279
+ const ruleListener = ruleListeners[key];
280
+ if (currentListener) {
281
+ return Object.assign({}, combinedListeners, {
282
+ [key]() {
283
+ currentListener.apply(null, arguments);
284
+ ruleListener.apply(null, arguments);
285
+ }
286
+ });
287
+ }
288
+ return Object.assign({}, combinedListeners, { [key]: ruleListener });
289
+ },
290
+ allListeners
291
+ ),
292
+ /* @__PURE__ */ Object.create(null)
293
+ );
294
+ },
295
+ meta: Object.freeze({
296
+ messages: Object.assign.apply(
297
+ null,
298
+ [/* @__PURE__ */ Object.create(null)].concat(rules.map(getMessageIds))
299
+ ),
300
+ fixable: "code"
301
+ })
302
+ });
303
+ }
304
+ });
305
+ }
306
+ });
307
+
308
+ // node_modules/.pnpm/eslint-plugin-unused-imports@3.0.0_@typescript-eslint+eslint-plugin@6.4.1_eslint@8.48.0/node_modules/eslint-plugin-unused-imports/lib/rules/no-unused-vars.js
309
+ var require_no_unused_vars = __commonJS({
310
+ "node_modules/.pnpm/eslint-plugin-unused-imports@3.0.0_@typescript-eslint+eslint-plugin@6.4.1_eslint@8.48.0/node_modules/eslint-plugin-unused-imports/lib/rules/no-unused-vars.js"(exports, module2) {
311
+ "use strict";
312
+ var { unusedVarsPredicate } = require_predicates();
313
+ var ruleComposer = require_rule_composer();
314
+ var rule;
315
+ try {
316
+ const tslint = require("@typescript-eslint/eslint-plugin");
317
+ rule = tslint.rules["no-unused-vars"];
318
+ } catch (_) {
319
+ const eslint = require("eslint");
320
+ rule = new eslint.Linter().getRules().get("no-unused-vars");
321
+ }
322
+ rule.meta.fixable = "code";
323
+ rule.meta.docs.url = "https://github.com/sweepline/eslint-plugin-unused-imports/blob/master/docs/rules/no-unused-vars.md";
324
+ module2.exports = ruleComposer.filterReports(rule, unusedVarsPredicate);
325
+ }
326
+ });
327
+
328
+ // node_modules/.pnpm/eslint-plugin-unused-imports@3.0.0_@typescript-eslint+eslint-plugin@6.4.1_eslint@8.48.0/node_modules/eslint-plugin-unused-imports/lib/rules/no-unused-imports.js
329
+ var require_no_unused_imports = __commonJS({
330
+ "node_modules/.pnpm/eslint-plugin-unused-imports@3.0.0_@typescript-eslint+eslint-plugin@6.4.1_eslint@8.48.0/node_modules/eslint-plugin-unused-imports/lib/rules/no-unused-imports.js"(exports, module2) {
331
+ "use strict";
332
+ var { unusedImportsPredicate } = require_predicates();
333
+ var ruleComposer = require_rule_composer();
334
+ var rule;
335
+ try {
336
+ const tslint = require("@typescript-eslint/eslint-plugin");
337
+ rule = tslint.rules["no-unused-vars"];
338
+ } catch (_) {
339
+ const eslint = require("eslint");
340
+ rule = new eslint.Linter().getRules().get("no-unused-vars");
341
+ }
342
+ rule.meta.fixable = "code";
343
+ rule.meta.docs.url = "https://github.com/sweepline/eslint-plugin-unused-imports/blob/master/docs/rules/no-unused-imports.md";
344
+ rule.meta.docs.extendsBaseRule = false;
345
+ module2.exports = ruleComposer.filterReports(rule, unusedImportsPredicate);
346
+ }
347
+ });
348
+
349
+ // node_modules/.pnpm/eslint-plugin-unused-imports@3.0.0_@typescript-eslint+eslint-plugin@6.4.1_eslint@8.48.0/node_modules/eslint-plugin-unused-imports/lib/index.js
350
+ var require_lib = __commonJS({
351
+ "node_modules/.pnpm/eslint-plugin-unused-imports@3.0.0_@typescript-eslint+eslint-plugin@6.4.1_eslint@8.48.0/node_modules/eslint-plugin-unused-imports/lib/index.js"(exports, module2) {
352
+ "use strict";
353
+ var noUnusedVars = require_no_unused_vars();
354
+ var noUnusedImports = require_no_unused_imports();
355
+ module2.exports.rules = {
356
+ "no-unused-vars": noUnusedVars,
357
+ "no-unused-imports": noUnusedImports,
358
+ "no-unused-vars-ts": noUnusedVars,
359
+ "no-unused-imports-ts": noUnusedImports
360
+ };
361
+ }
362
+ });
363
+
30
364
  // index.js
31
365
  var eslint_config_exports = {};
32
366
  __export(eslint_config_exports, {
@@ -50,6 +384,7 @@ __export(eslint_config_exports, {
50
384
  typescript: () => typescript,
51
385
  unicorn: () => unicorn,
52
386
  unicornPlugin: () => import_eslint_plugin_unicorn.default,
387
+ unocss: () => unocss,
53
388
  vue: () => vue,
54
389
  vueParser: () => import_vue_eslint_parser.default,
55
390
  vuePlugin: () => import_eslint_plugin_vue.default,
@@ -80,6 +415,7 @@ var import_js = __toESM(require("@eslint/js"), 1);
80
415
  var import_eslint_plugin_import = __toESM(require("eslint-plugin-import"), 1);
81
416
  var import_eslint_plugin_unicorn = __toESM(require("eslint-plugin-unicorn"), 1);
82
417
  var import_eslint_plugin_antfu = __toESM(require("eslint-plugin-antfu"), 1);
418
+ var import_eslint_plugin_unused_imports = __toESM(require_lib(), 1);
83
419
 
84
420
  // src/shared.js
85
421
  var GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
@@ -135,6 +471,7 @@ var GLOB_EXCLUDE = (
135
471
  );
136
472
 
137
473
  // src/js.js
474
+ var isInEditor = (process.env.VSCODE_PID || process.env.JETBRAINS_IDE) && !process.env.CI;
138
475
  var js = [
139
476
  import_js.default.configs.recommended,
140
477
  {
@@ -146,8 +483,11 @@ var js = [
146
483
  },
147
484
  sourceType: "module"
148
485
  },
486
+ plugins: {
487
+ "unused-imports": import_eslint_plugin_unused_imports.default
488
+ },
149
489
  rules: {
150
- "no-unused-vars": ["error", { args: "none", ignoreRestSiblings: true }],
490
+ "no-unused-vars": "off",
151
491
  "no-constant-condition": "warn",
152
492
  "no-debugger": "warn",
153
493
  "no-console": ["warn", { allow: ["warn", "error"] }],
@@ -207,7 +547,12 @@ var js = [
207
547
  }
208
548
  ],
209
549
  "no-lonely-if": "error",
210
- "prefer-exponentiation-operator": "error"
550
+ "prefer-exponentiation-operator": "error",
551
+ "unused-imports/no-unused-imports": isInEditor ? "off" : "error",
552
+ [isInEditor ? "no-unused-vars" : "unused-imports/no-unused-vars"]: [
553
+ "error",
554
+ { args: "after-used", ignoreRestSiblings: true }
555
+ ]
211
556
  }
212
557
  },
213
558
  {
@@ -486,7 +831,8 @@ var markdown = [
486
831
  "no-restricted-imports": "off",
487
832
  "no-undef": "off",
488
833
  "no-unused-expressions": "off",
489
- "no-unused-vars": "off"
834
+ "no-unused-vars": "off",
835
+ "unused-imports/no-unused-vars": "off"
490
836
  }
491
837
  }
492
838
  ];
@@ -559,11 +905,24 @@ var typescript = [
559
905
  }
560
906
  ];
561
907
 
908
+ // src/unocss.js
909
+ var import_eslint_plugin3 = __toESM(require("@unocss/eslint-plugin"), 1);
910
+ var unocss = [
911
+ {
912
+ plugins: {
913
+ "@unocss": import_eslint_plugin3.default
914
+ },
915
+ rules: {
916
+ ...import_eslint_plugin3.default.configs.recommended.rules
917
+ }
918
+ }
919
+ ];
920
+
562
921
  // src/vue.js
563
922
  var import_local_pkg = require("local-pkg");
564
923
  var import_vue_eslint_parser = __toESM(require("vue-eslint-parser"), 1);
565
924
  var import_eslint_plugin_vue = __toESM(require("eslint-plugin-vue"), 1);
566
- var import_eslint_plugin3 = __toESM(require("@typescript-eslint/eslint-plugin"), 1);
925
+ var import_eslint_plugin4 = __toESM(require("@typescript-eslint/eslint-plugin"), 1);
567
926
  function getVueVersion() {
568
927
  const pkg = (0, import_local_pkg.getPackageInfoSync)("vue", { paths: [process.cwd()] });
569
928
  if (pkg && typeof pkg.version === "string" && !Number.isNaN(+pkg.version[0])) {
@@ -589,7 +948,7 @@ var reactivityTransform = [
589
948
  vue: import_eslint_plugin_vue.default
590
949
  },
591
950
  rules: {
592
- "vue/no-setup-props-destructure": "off"
951
+ "vue/no-setup-props-reactivity-loss": "off"
593
952
  }
594
953
  }
595
954
  ];
@@ -611,10 +970,7 @@ var vueCustomRules = {
611
970
  math: "always"
612
971
  }
613
972
  ],
614
- "vue/component-tags-order": [
615
- "error",
616
- { order: ["script", "template", "style"] }
617
- ],
973
+ "vue/block-order": ["error", { order: ["script", "template", "style"] }],
618
974
  "vue/custom-event-name-casing": ["error", "camelCase"],
619
975
  "vue/no-useless-v-bind": "error",
620
976
  "vue/no-unused-refs": "error",
@@ -650,7 +1006,7 @@ var vue = [
650
1006
  files: [GLOB_VUE],
651
1007
  plugins: {
652
1008
  vue: import_eslint_plugin_vue.default,
653
- "@typescript-eslint": import_eslint_plugin3.default
1009
+ "@typescript-eslint": import_eslint_plugin4.default
654
1010
  },
655
1011
  languageOptions: {
656
1012
  parser: import_vue_eslint_parser.default,
@@ -714,21 +1070,25 @@ var basic = [
714
1070
  ...yml,
715
1071
  ...eslintComments
716
1072
  ];
717
- var all = [...vue, ...basic, ...prettier];
1073
+ var all = [...basic, ...vue, ...unocss, ...prettier];
718
1074
  function sxzz(config = [], {
719
1075
  vue: enableVue = true,
720
1076
  prettier: enablePrettier = true,
721
- markdown: enableMarkdown = true
1077
+ markdown: enableMarkdown = true,
1078
+ unocss: enableUnocss = false
722
1079
  } = {}) {
723
1080
  const configs3 = [];
724
1081
  configs3.push(...basic);
725
- if (enableVue !== false) {
1082
+ if (enableVue) {
726
1083
  configs3.push(...vue);
727
1084
  }
728
- if (enableMarkdown !== false) {
1085
+ if (enableMarkdown) {
729
1086
  configs3.push(...markdown);
730
1087
  }
731
- if (enablePrettier !== false) {
1088
+ if (enableUnocss) {
1089
+ configs3.push(...unocss);
1090
+ }
1091
+ if (enablePrettier) {
732
1092
  configs3.push(...prettier);
733
1093
  }
734
1094
  if (Object.keys(config).length > 0) {
@@ -758,6 +1118,7 @@ function sxzz(config = [], {
758
1118
  typescript,
759
1119
  unicorn,
760
1120
  unicornPlugin,
1121
+ unocss,
761
1122
  vue,
762
1123
  vueParser,
763
1124
  vuePlugin,
package/index.js CHANGED
@@ -5,5 +5,6 @@ export * from './src/markdown.js'
5
5
  export * from './src/presets.js'
6
6
  export * from './src/prettier.js'
7
7
  export * from './src/typescript.js'
8
+ export * from './src/unocss.js'
8
9
  export * from './src/vue.js'
9
10
  export * from './src/yml.js'
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sxzz/eslint-config",
3
- "version": "3.3.2",
4
- "packageManager": "pnpm@8.6.11",
3
+ "version": "3.5.0",
4
+ "packageManager": "pnpm@8.7.0",
5
5
  "description": "ESLint config for @sxzz.",
6
6
  "type": "module",
7
7
  "license": "MIT",
@@ -31,34 +31,36 @@
31
31
  "eslint": "^8.0.0"
32
32
  },
33
33
  "dependencies": {
34
- "@eslint/js": "^8.46.0",
35
- "@typescript-eslint/eslint-plugin": "^6.2.0",
36
- "@typescript-eslint/parser": "^6.2.0",
37
- "eslint-config-prettier": "^8.9.0",
38
- "eslint-define-config": "^1.22.0",
39
- "eslint-plugin-antfu": "^0.39.8",
34
+ "@eslint/js": "^8.48.0",
35
+ "@typescript-eslint/eslint-plugin": "^6.4.1",
36
+ "@typescript-eslint/parser": "^6.4.1",
37
+ "@unocss/eslint-plugin": "^0.55.3",
38
+ "eslint-config-prettier": "^9.0.0",
39
+ "eslint-define-config": "^1.23.0",
40
+ "eslint-plugin-antfu": "^0.41.0",
40
41
  "eslint-plugin-eslint-comments": "^3.2.0",
41
- "eslint-plugin-import": "^2.28.0",
42
+ "eslint-plugin-import": "^2.28.1",
42
43
  "eslint-plugin-jsonc": "^2.9.0",
43
44
  "eslint-plugin-markdown": "^3.0.1",
44
45
  "eslint-plugin-prettier": "^5.0.0",
45
46
  "eslint-plugin-unicorn": "^48.0.1",
46
- "eslint-plugin-vue": "^9.16.1",
47
+ "eslint-plugin-vue": "^9.17.0",
47
48
  "eslint-plugin-yml": "^1.8.0",
48
- "globals": "^13.20.0",
49
+ "globals": "^13.21.0",
49
50
  "jsonc-eslint-parser": "^2.3.0",
50
51
  "local-pkg": "^0.4.3",
51
- "prettier": "^3.0.0",
52
+ "prettier": "^3.0.2",
52
53
  "vue-eslint-parser": "^9.3.1",
53
54
  "yaml-eslint-parser": "^1.2.2"
54
55
  },
55
56
  "devDependencies": {
56
57
  "@sxzz/prettier-config": "^1.0.4",
57
- "@types/node": "^20.4.5",
58
- "bumpp": "^9.1.1",
59
- "eslint": "^8.46.0",
60
- "tsup": "^7.1.0",
61
- "typescript": "^5.1.6"
58
+ "@types/node": "^20.5.7",
59
+ "bumpp": "^9.2.0",
60
+ "eslint": "^8.48.0",
61
+ "eslint-plugin-unused-imports": "^3.0.0",
62
+ "tsup": "^7.2.0",
63
+ "typescript": "^5.2.2"
62
64
  },
63
65
  "engines": {
64
66
  "node": ">=16.14.0"
package/src/js.js CHANGED
@@ -3,8 +3,12 @@ import jsConfig from '@eslint/js'
3
3
  import importPlugin from 'eslint-plugin-import'
4
4
  import unicornPlugin from 'eslint-plugin-unicorn'
5
5
  import antfuPlugin from 'eslint-plugin-antfu'
6
+ import unusedImportsPlugin from 'eslint-plugin-unused-imports'
6
7
  import { GLOB_MARKDOWN, GLOB_SRC, GLOB_SRC_EXT } from './shared.js'
7
8
 
9
+ const isInEditor =
10
+ (process.env.VSCODE_PID || process.env.JETBRAINS_IDE) && !process.env.CI
11
+
8
12
  export { importPlugin, unicornPlugin, antfuPlugin }
9
13
 
10
14
  /** @type {import('eslint-define-config').FlatESLintConfigItem[]} */
@@ -19,8 +23,11 @@ export const js = [
19
23
  },
20
24
  sourceType: 'module',
21
25
  },
26
+ plugins: {
27
+ 'unused-imports': unusedImportsPlugin,
28
+ },
22
29
  rules: {
23
- 'no-unused-vars': ['error', { args: 'none', ignoreRestSiblings: true }],
30
+ 'no-unused-vars': 'off',
24
31
  'no-constant-condition': 'warn',
25
32
  'no-debugger': 'warn',
26
33
  'no-console': ['warn', { allow: ['warn', 'error'] }],
@@ -84,6 +91,12 @@ export const js = [
84
91
  ],
85
92
  'no-lonely-if': 'error',
86
93
  'prefer-exponentiation-operator': 'error',
94
+
95
+ 'unused-imports/no-unused-imports': isInEditor ? 'off' : 'error',
96
+ [isInEditor ? 'no-unused-vars' : 'unused-imports/no-unused-vars']: [
97
+ 'error',
98
+ { args: 'after-used', ignoreRestSiblings: true },
99
+ ],
87
100
  },
88
101
  },
89
102
  {
package/src/markdown.js CHANGED
@@ -37,6 +37,7 @@ export const markdown = [
37
37
  'no-undef': 'off',
38
38
  'no-unused-expressions': 'off',
39
39
  'no-unused-vars': 'off',
40
+ 'unused-imports/no-unused-vars': 'off',
40
41
  },
41
42
  },
42
43
  ]
package/src/presets.js CHANGED
@@ -7,6 +7,7 @@ import { markdown } from './markdown.js'
7
7
  import { prettier } from './prettier.js'
8
8
  import { GLOB_EXCLUDE } from './shared.js'
9
9
  import { typescript } from './typescript.js'
10
+ import { unocss } from './unocss.js'
10
11
  import { vue } from './vue.js'
11
12
  import { yml } from './yml.js'
12
13
 
@@ -30,12 +31,13 @@ export const basic = [
30
31
  ]
31
32
 
32
33
  /** @type { FlatESLintConfigItem[] } */
33
- export const all = [...vue, ...basic, ...prettier]
34
+ export const all = [...basic, ...vue, ...unocss, ...prettier]
34
35
 
35
36
  /** @type {(config?: FlatESLintConfigItem | FlatESLintConfigItem[], enables?: Partial<{
36
37
  * vue: boolean
37
38
  * prettier: boolean
38
39
  * markdown: boolean
40
+ * unocss: boolean
39
41
  * }>) => FlatESLintConfigItem[]} */
40
42
  export function sxzz(
41
43
  config = [],
@@ -43,17 +45,21 @@ export function sxzz(
43
45
  vue: enableVue = true,
44
46
  prettier: enablePrettier = true,
45
47
  markdown: enableMarkdown = true,
48
+ unocss: enableUnocss = false,
46
49
  } = {}
47
50
  ) {
48
51
  const configs = []
49
52
  configs.push(...basic)
50
- if (enableVue !== false) {
53
+ if (enableVue) {
51
54
  configs.push(...vue)
52
55
  }
53
- if (enableMarkdown !== false) {
56
+ if (enableMarkdown) {
54
57
  configs.push(...markdown)
55
58
  }
56
- if (enablePrettier !== false) {
59
+ if (enableUnocss) {
60
+ configs.push(...unocss)
61
+ }
62
+ if (enablePrettier) {
57
63
  configs.push(...prettier)
58
64
  }
59
65
  if (Object.keys(config).length > 0) {
package/src/unocss.js ADDED
@@ -0,0 +1,13 @@
1
+ import unocssPlugin from '@unocss/eslint-plugin'
2
+
3
+ /** @type {import('eslint-define-config').FlatESLintConfigItem[]} */
4
+ export const unocss = [
5
+ {
6
+ plugins: {
7
+ '@unocss': unocssPlugin,
8
+ },
9
+ rules: {
10
+ ...unocssPlugin.configs.recommended.rules,
11
+ },
12
+ },
13
+ ]
package/src/vue.js CHANGED
@@ -38,7 +38,7 @@ export const reactivityTransform = [
38
38
  vue: vuePlugin,
39
39
  },
40
40
  rules: {
41
- 'vue/no-setup-props-destructure': 'off',
41
+ 'vue/no-setup-props-reactivity-loss': 'off',
42
42
  },
43
43
  },
44
44
  ]
@@ -63,10 +63,7 @@ const vueCustomRules = {
63
63
  math: 'always',
64
64
  },
65
65
  ],
66
- 'vue/component-tags-order': [
67
- 'error',
68
- { order: ['script', 'template', 'style'] },
69
- ],
66
+ 'vue/block-order': ['error', { order: ['script', 'template', 'style'] }],
70
67
  'vue/custom-event-name-casing': ['error', 'camelCase'],
71
68
  'vue/no-useless-v-bind': 'error',
72
69
  'vue/no-unused-refs': 'error',