@so1ve/eslint-plugin 3.20.1 → 3.21.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.d.ts CHANGED
@@ -1,27 +1,62 @@
1
- import * as _typescript_eslint_utils_ts_eslint0 from "@typescript-eslint/utils/ts-eslint";
1
+ import { ESLintUtils } from "@typescript-eslint/utils";
2
2
 
3
3
  //#region src/rules/function-style.d.ts
4
- type MessageIds = "arrow" | "declaration";
4
+ type MessageIds$9 = "arrow" | "declaration";
5
+ declare const rule: ESLintUtils.RuleModule<MessageIds$9>;
6
+ //#endregion
7
+ //#region src/rules/import-dedupe.d.ts
8
+ type MessageIds$8 = "importDedupe";
9
+ declare const rule$1: ESLintUtils.RuleModule<MessageIds$8>;
10
+ //#endregion
11
+ //#region src/rules/no-import-promises-as.d.ts
12
+ type MessageIds$7 = "noImportPromisesAs";
13
+ declare const rule$2: ESLintUtils.RuleModule<MessageIds$7>;
14
+ //#endregion
15
+ //#region src/rules/no-inline-type-import.d.ts
16
+ type MessageIds$6 = "noInlineTypeImport";
17
+ declare const rule$3: ESLintUtils.RuleModule<MessageIds$6>;
18
+ //#endregion
19
+ //#region src/rules/no-negated-comparison.d.ts
20
+ type MessageIds$5 = "noNegatedComparison";
21
+ declare const rule$4: ESLintUtils.RuleModule<MessageIds$5>;
22
+ //#endregion
23
+ //#region src/rules/no-useless-template-string.d.ts
24
+ type MessageIds$4 = "noUselessTemplateString";
25
+ declare const rule$5: ESLintUtils.RuleModule<MessageIds$4>;
26
+ //#endregion
27
+ //#region src/rules/pad-after-last-import.d.ts
28
+ type MessageIds$3 = "padAfterLastImport";
29
+ declare const rule$6: ESLintUtils.RuleModule<MessageIds$3>;
30
+ //#endregion
31
+ //#region src/rules/prefer-ts-expect-error.d.ts
32
+ type MessageIds$2 = "preferExpectErrorComment";
33
+ declare const rule$7: ESLintUtils.RuleModule<MessageIds$2>;
34
+ //#endregion
35
+ //#region src/rules/require-async-with-await.d.ts
36
+ type MessageIds$1 = "requireAsyncWithAwait";
37
+ declare const rule$8: ESLintUtils.RuleModule<MessageIds$1>;
5
38
  //#endregion
6
39
  //#region src/rules/vue-root-element-sort-attributes.d.ts
40
+ type MessageIds = "wrongOrder";
7
41
  type Options = [{
8
42
  script?: string[];
9
43
  [otherElement: string]: string[] | undefined;
10
44
  }];
45
+ declare const rule$9: ESLintUtils.RuleModule<MessageIds, Options>;
11
46
  //#endregion
12
47
  //#region src/index.d.ts
13
48
  declare const _default: {
14
49
  rules: {
15
- "function-style": _typescript_eslint_utils_ts_eslint0.RuleModule<MessageIds, [], unknown, _typescript_eslint_utils_ts_eslint0.RuleListener>;
16
- "import-dedupe": _typescript_eslint_utils_ts_eslint0.RuleModule<"importDedupe", [], unknown, _typescript_eslint_utils_ts_eslint0.RuleListener>;
17
- "no-import-promises-as": _typescript_eslint_utils_ts_eslint0.RuleModule<"noImportPromisesAs", [], unknown, _typescript_eslint_utils_ts_eslint0.RuleListener>;
18
- "no-inline-type-import": _typescript_eslint_utils_ts_eslint0.RuleModule<"noInlineTypeImport", [], unknown, _typescript_eslint_utils_ts_eslint0.RuleListener>;
19
- "no-negated-comparison": _typescript_eslint_utils_ts_eslint0.RuleModule<"noNegatedComparison", [], unknown, _typescript_eslint_utils_ts_eslint0.RuleListener>;
20
- "no-useless-template-string": _typescript_eslint_utils_ts_eslint0.RuleModule<"noUselessTemplateString", [], unknown, _typescript_eslint_utils_ts_eslint0.RuleListener>;
21
- "pad-after-last-import": _typescript_eslint_utils_ts_eslint0.RuleModule<"padAfterLastImport", [], unknown, _typescript_eslint_utils_ts_eslint0.RuleListener>;
22
- "prefer-ts-expect-error": _typescript_eslint_utils_ts_eslint0.RuleModule<"preferExpectErrorComment", [], unknown, _typescript_eslint_utils_ts_eslint0.RuleListener>;
23
- "require-async-with-await": _typescript_eslint_utils_ts_eslint0.RuleModule<"requireAsyncWithAwait", [], unknown, _typescript_eslint_utils_ts_eslint0.RuleListener>;
24
- "vue-root-element-sort-attributes": _typescript_eslint_utils_ts_eslint0.RuleModule<"wrongOrder", Options, unknown, _typescript_eslint_utils_ts_eslint0.RuleListener>;
50
+ "function-style": typeof rule;
51
+ "import-dedupe": typeof rule$1;
52
+ "no-import-promises-as": typeof rule$2;
53
+ "no-inline-type-import": typeof rule$3;
54
+ "no-negated-comparison": typeof rule$4;
55
+ "no-useless-template-string": typeof rule$5;
56
+ "pad-after-last-import": typeof rule$6;
57
+ "prefer-ts-expect-error": typeof rule$7;
58
+ "require-async-with-await": typeof rule$8;
59
+ "vue-root-element-sort-attributes": typeof rule$9;
25
60
  };
26
61
  };
27
62
  //#endregion
package/dist/index.js CHANGED
@@ -17,7 +17,7 @@ function getPreviousNode(node) {
17
17
  //#endregion
18
18
  //#region src/rules/function-style.ts
19
19
  const RULE_NAME$8 = "function-style";
20
- var function_style_default = createEslintRule({
20
+ const rule$9 = createEslintRule({
21
21
  name: RULE_NAME$8,
22
22
  meta: {
23
23
  type: "problem",
@@ -153,11 +153,12 @@ var function_style_default = createEslintRule({
153
153
  };
154
154
  }
155
155
  });
156
+ var function_style_default = rule$9;
156
157
 
157
158
  //#endregion
158
159
  //#region src/rules/import-dedupe.ts
159
160
  const RULE_NAME$7 = "import-dedupe";
160
- var import_dedupe_default = createEslintRule({
161
+ const rule$8 = createEslintRule({
161
162
  name: RULE_NAME$7,
162
163
  meta: {
163
164
  type: "problem",
@@ -191,6 +192,7 @@ var import_dedupe_default = createEslintRule({
191
192
  }
192
193
  } })
193
194
  });
195
+ var import_dedupe_default = rule$8;
194
196
 
195
197
  //#endregion
196
198
  //#region src/rules/no-import-promises-as.ts
@@ -201,7 +203,7 @@ const POSSIBLE_IMPORT_SOURCES = [
201
203
  "readline",
202
204
  "stream"
203
205
  ].flatMap((s) => [s, `node:${s}`]);
204
- var no_import_promises_as_default = createEslintRule({
206
+ const rule$7 = createEslintRule({
205
207
  name: RULE_NAME$6,
206
208
  meta: {
207
209
  type: "problem",
@@ -232,11 +234,38 @@ var no_import_promises_as_default = createEslintRule({
232
234
  } };
233
235
  }
234
236
  });
237
+ var no_import_promises_as_default = rule$7;
235
238
 
236
239
  //#endregion
237
240
  //#region src/rules/no-inline-type-import.ts
238
241
  const RULE_NAME$5 = "no-inline-type-import";
239
- var no_inline_type_import_default = createEslintRule({
242
+ function generateImportsText(specifiers) {
243
+ let text = "{ ";
244
+ const texts = [];
245
+ for (const s of specifiers) {
246
+ const importedName = s.imported.type === AST_NODE_TYPES.Identifier ? s.imported.name : s.imported.raw;
247
+ texts.push(importedName === s.local.name ? s.local.name : `${importedName} as ${s.local.name}`);
248
+ }
249
+ text += texts.join(", ");
250
+ text += " }";
251
+ return text;
252
+ }
253
+ function generateTypeImportText(typeSpecifiers) {
254
+ let text = "type ";
255
+ text += generateImportsText(typeSpecifiers);
256
+ return text;
257
+ }
258
+ function generateValueImportText(defaultImportSpecifier, valueSpecifiers) {
259
+ const hasValueImport = valueSpecifiers.length > 0;
260
+ let text = "";
261
+ if (defaultImportSpecifier) {
262
+ text += defaultImportSpecifier.local.name;
263
+ if (hasValueImport) text += ", ";
264
+ }
265
+ if (hasValueImport) text += generateImportsText(valueSpecifiers);
266
+ return text;
267
+ }
268
+ const rule$6 = createEslintRule({
240
269
  name: RULE_NAME$5,
241
270
  meta: {
242
271
  type: "layout",
@@ -251,28 +280,24 @@ var no_inline_type_import_default = createEslintRule({
251
280
  const typeSpecifiers = specifiers.filter((s) => s.type === AST_NODE_TYPES.ImportSpecifier && s.importKind === "type");
252
281
  const valueSpecifiers = specifiers.filter((s) => s.type === AST_NODE_TYPES.ImportSpecifier && s.importKind === "value");
253
282
  const defaultImportSpecifier = specifiers.find((s) => s.type === AST_NODE_TYPES.ImportDefaultSpecifier);
254
- if (typeSpecifiers.length > 0) if (valueSpecifiers.length > 0) context.report({
255
- node,
256
- messageId: "noInlineTypeImport",
257
- fix(fixer) {
258
- const typeSpecifiersText = typeSpecifiers.map((s) => s.local.name).join(", ");
259
- const valueSpecifiersText = valueSpecifiers.map((s) => s.local.name).join(", ");
260
- const defaultImportSpecifierText = defaultImportSpecifier?.local.name;
261
- const defaultAndValueSpecifiersText = defaultImportSpecifier ? `import ${defaultImportSpecifierText}, { ${valueSpecifiersText} } from "${node.source.value}";` : `import { ${valueSpecifiersText} } from "${node.source.value}";`;
262
- const texts = [`import type { ${typeSpecifiersText} } from "${node.source.value}";`, defaultAndValueSpecifiersText];
263
- return fixer.replaceText(node, texts.join("\n"));
264
- }
265
- });
266
- else context.report({
283
+ const hasDefaultImport = !!defaultImportSpecifier;
284
+ const hasTypeImport = typeSpecifiers.length > 0;
285
+ const hasValueImport = valueSpecifiers.length > 0;
286
+ if (!hasTypeImport) return;
287
+ const texts = [];
288
+ texts.push(generateTypeImportText(typeSpecifiers));
289
+ if (hasDefaultImport || hasValueImport) texts.push(generateValueImportText(defaultImportSpecifier, valueSpecifiers));
290
+ const textToReport = texts.map((text) => `import ${text} from "${node.source.value}";`).join("\n");
291
+ context.report({
267
292
  node,
268
293
  messageId: "noInlineTypeImport",
269
294
  fix(fixer) {
270
- const typeSpecifiersText = typeSpecifiers.map((s) => s.local.name).join(", ");
271
- return fixer.replaceText(node, `import type { ${typeSpecifiersText} } from "${node.source.value}";`);
295
+ return fixer.replaceText(node, textToReport);
272
296
  }
273
297
  });
274
298
  } })
275
299
  });
300
+ var no_inline_type_import_default = rule$6;
276
301
 
277
302
  //#endregion
278
303
  //#region src/rules/no-negated-comparison.ts
@@ -288,7 +313,7 @@ const negatedToPositive = {
288
313
  ">=": "<"
289
314
  };
290
315
  const negatives = Object.keys(negatedToPositive);
291
- var no_negated_comparison_default = createEslintRule({
316
+ const rule$5 = createEslintRule({
292
317
  name: RULE_NAME$4,
293
318
  meta: {
294
319
  type: "problem",
@@ -313,11 +338,12 @@ var no_negated_comparison_default = createEslintRule({
313
338
  });
314
339
  } })
315
340
  });
341
+ var no_negated_comparison_default = rule$5;
316
342
 
317
343
  //#endregion
318
344
  //#region src/rules/no-useless-template-string.ts
319
345
  const RULE_NAME$3 = "no-useless-template-string";
320
- var no_useless_template_string_default = createEslintRule({
346
+ const rule$4 = createEslintRule({
321
347
  name: RULE_NAME$3,
322
348
  meta: {
323
349
  type: "problem",
@@ -339,11 +365,12 @@ var no_useless_template_string_default = createEslintRule({
339
365
  });
340
366
  } })
341
367
  });
368
+ var no_useless_template_string_default = rule$4;
342
369
 
343
370
  //#endregion
344
371
  //#region src/rules/pad-after-last-import.ts
345
372
  const RULE_NAME$2 = "pad-after-last-import";
346
- var pad_after_last_import_default = createEslintRule({
373
+ const rule$3 = createEslintRule({
347
374
  name: RULE_NAME$2,
348
375
  meta: {
349
376
  type: "problem",
@@ -376,10 +403,11 @@ var pad_after_last_import_default = createEslintRule({
376
403
  };
377
404
  }
378
405
  });
406
+ var pad_after_last_import_default = rule$3;
379
407
 
380
408
  //#endregion
381
409
  //#region src/rules/prefer-ts-expect-error.ts
382
- var prefer_ts_expect_error_default = createEslintRule({
410
+ const rule$2 = createEslintRule({
383
411
  name: "prefer-ts-expect-error",
384
412
  meta: {
385
413
  type: "problem",
@@ -417,11 +445,12 @@ var prefer_ts_expect_error_default = createEslintRule({
417
445
  } };
418
446
  }
419
447
  });
448
+ var prefer_ts_expect_error_default = rule$2;
420
449
 
421
450
  //#endregion
422
451
  //#region src/rules/require-async-with-await.ts
423
452
  const RULE_NAME$1 = "require-async-with-await";
424
- var require_async_with_await_default = createEslintRule({
453
+ const rule$1 = createEslintRule({
425
454
  name: RULE_NAME$1,
426
455
  meta: {
427
456
  type: "problem",
@@ -463,12 +492,13 @@ var require_async_with_await_default = createEslintRule({
463
492
  };
464
493
  }
465
494
  });
495
+ var require_async_with_await_default = rule$1;
466
496
 
467
497
  //#endregion
468
498
  //#region src/rules/vue-root-element-sort-attributes.ts
469
499
  const RULE_NAME = "vue-root-element-sort-attributes";
470
500
  const defaultOptions = { script: ["setup", "lang"] };
471
- var vue_root_element_sort_attributes_default = createEslintRule({
501
+ const rule = createEslintRule({
472
502
  name: RULE_NAME,
473
503
  meta: {
474
504
  type: "layout",
@@ -525,6 +555,7 @@ var vue_root_element_sort_attributes_default = createEslintRule({
525
555
  } };
526
556
  }
527
557
  });
558
+ var vue_root_element_sort_attributes_default = rule;
528
559
 
529
560
  //#endregion
530
561
  //#region src/index.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@so1ve/eslint-plugin",
3
- "version": "3.20.1",
3
+ "version": "3.21.0",
4
4
  "author": "Ray <i@mk1.io> (https://github.com/so1ve/)",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -38,10 +38,5 @@
38
38
  },
39
39
  "devDependencies": {
40
40
  "vue-eslint-parser": "^10.2.0"
41
- },
42
- "scripts": {
43
- "build": "tsdown",
44
- "test": "vitest",
45
- "watch": "tsdown --watch"
46
41
  }
47
42
  }