@kazupon/eslint-plugin 0.6.1 → 0.6.2

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
@@ -59,7 +59,7 @@ The rules with the following star ⭐ are included in the configs.
59
59
 
60
60
  <!--RULES_TABLE_START-->
61
61
 
62
- ### @kazupon/eslint-plugin Rules
62
+ ### `@kazupon/eslint-plugin` Rules
63
63
 
64
64
  | Rule ID | Description | Category | Fixable | RECOMMENDED |
65
65
  | :--------------------------------------------------------------------------------------------------------------------------- | :------------------------------------------------------------ | :------- | :-----: | :---------: |
package/lib/index.d.ts CHANGED
@@ -23,7 +23,5 @@ declare const configs: {
23
23
  */
24
24
  comment: typeof commentConfig;
25
25
  };
26
- /** @alias */
27
-
28
26
  //#endregion
29
27
  export { configs, plugin as default, plugin };
package/lib/index.js CHANGED
@@ -21,8 +21,7 @@ function stripJSDocPrefix(line) {
21
21
  function detectTag(text, tags) {
22
22
  for (const tag of tags) {
23
23
  const tagRegex = /* @__PURE__ */ new RegExp(`^${tag}\\b`);
24
- const match = text.match(tagRegex);
25
- if (match) {
24
+ if (text.match(tagRegex)) {
26
25
  const afterTag = text.slice(tag.length);
27
26
  if (afterTag.startsWith("(")) {
28
27
  const closingParenIndex = afterTag.indexOf(")");
@@ -175,8 +174,7 @@ function parseDirectiveComment(text, directives) {
175
174
  const spaceMatch = afterDirective.match(/^\s+/);
176
175
  if (spaceMatch) {
177
176
  const description = afterDirective.trim();
178
- const directiveIndex = text.indexOf(directive);
179
- const descriptionStart = directiveIndex + directive.length + spaceMatch[0].length;
177
+ const descriptionStart = text.indexOf(directive) + directive.length + spaceMatch[0].length;
180
178
  return {
181
179
  directive,
182
180
  description,
@@ -201,7 +199,7 @@ const name = "@kazupon/eslint-plugin";
201
199
  /**
202
200
  * The plugin version.
203
201
  */
204
- const version = "0.6.1";
202
+ const version = "0.6.2";
205
203
  /**
206
204
  * The namespace for rules
207
205
  */
@@ -296,8 +294,7 @@ const rule$3 = createRule({
296
294
  else {
297
295
  const lastComment = comments.at(-1);
298
296
  const firstNode = node.body[0];
299
- const distance = Math.abs(lastComment.range[1] - firstNode.range[0]);
300
- taregetComments = distance > 1 ? comments : comments.slice(0, -1);
297
+ taregetComments = Math.abs(lastComment.range[1] - firstNode.range[0]) > 1 ? comments : comments.slice(0, -1);
301
298
  }
302
299
  },
303
300
  "Program:exit": (node) => {
@@ -416,8 +413,7 @@ const rule$2 = createRule({
416
413
  }]
417
414
  },
418
415
  create(ctx) {
419
- const options = parseArrayOptions(ctx.options[0], { tags: DEFAULT_TAGS$1 });
420
- const tags = options.tags;
416
+ const tags = parseArrayOptions(ctx.options[0], { tags: DEFAULT_TAGS$1 }).tags;
421
417
  const sourceCode = ctx.sourceCode;
422
418
  /**
423
419
  * Report a tag comment violation
@@ -452,8 +448,7 @@ const rule$2 = createRule({
452
448
  }
453
449
  const lines = value.split("\n");
454
450
  for (const [i, line] of lines.entries()) {
455
- const trimmedLine = line.trim();
456
- if (!trimmedLine) continue;
451
+ if (!line.trim()) continue;
457
452
  const contentToCheck = stripJSDocPrefix(line);
458
453
  const tagInfo = detectTag(contentToCheck, tags);
459
454
  if (tagInfo) {
@@ -567,10 +562,10 @@ const rule$1 = createRule({
567
562
  column: position.column + word.length
568
563
  }
569
564
  },
570
- fix(fixer) {
571
- const startOffset = comment.range[0] + 2 + index;
572
- const endOffset = startOffset + word.length;
573
- return fixer.replaceTextRange([startOffset, endOffset], `\`${word}\``);
565
+ *fix(fixer) {
566
+ const start = comment.range[0] + 2 + index;
567
+ const end = start + word.length;
568
+ return [yield fixer.insertTextBeforeRange([start, start], "`"), yield fixer.insertTextAfterRange([start, end], "`")];
574
569
  }
575
570
  });
576
571
  }
@@ -700,11 +695,9 @@ const rule = createRule({
700
695
  const lineTagInfo = detectTag(descLine.trim(), tags);
701
696
  if (lineTagInfo && !lineTagInfo.hasScope) {
702
697
  const descStartInComment = value.indexOf(directiveInfo.description);
703
- const linesBeforeDesc = value.slice(0, descStartInComment).split("\n").length - 1;
704
- const actualLineIndex = linesBeforeDesc + descLineIndex;
698
+ const actualLineIndex = value.slice(0, descStartInComment).split("\n").length - 1 + descLineIndex;
705
699
  if (actualLineIndex < lines.length) {
706
- const actualLine = lines[actualLineIndex];
707
- const tagIndex = actualLine.indexOf(lineTagInfo.tag);
700
+ const tagIndex = lines[actualLineIndex].indexOf(lineTagInfo.tag);
708
701
  if (tagIndex !== -1) {
709
702
  const location = {
710
703
  line: comment.loc.start.line + actualLineIndex,
@@ -720,8 +713,7 @@ const rule = createRule({
720
713
  return;
721
714
  }
722
715
  for (const [i, line] of lines.entries()) {
723
- const trimmedLine = line.trim();
724
- if (!trimmedLine) continue;
716
+ if (!line.trim()) continue;
725
717
  const contentToCheck = stripJSDocPrefix(line);
726
718
  const tagInfo = detectTag(contentToCheck, tags);
727
719
  if (tagInfo && !tagInfo.hasScope) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@kazupon/eslint-plugin",
3
3
  "description": "ESLint plugin for @kazupon",
4
- "version": "0.6.1",
4
+ "version": "0.6.2",
5
5
  "license": "MIT",
6
6
  "funding": "https://github.com/sponsors/kazupon",
7
7
  "bugs": {
@@ -47,49 +47,49 @@
47
47
  }
48
48
  },
49
49
  "dependencies": {
50
- "@es-joy/jsdoccomment": "^0.52.0",
51
- "@eslint/core": "^0.15.1"
50
+ "@es-joy/jsdoccomment": "^0.60.0",
51
+ "@eslint/core": "^0.15.2"
52
52
  },
53
53
  "peerDependencies": {
54
54
  "eslint": "^9.0.0"
55
55
  },
56
56
  "devDependencies": {
57
- "@eslint/compat": "^1.3.1",
58
- "@eslint/markdown": "^7.1.0",
59
- "@kazupon/eslint-config": "^0.34.0",
57
+ "@eslint/compat": "^1.4.0",
58
+ "@eslint/markdown": "^7.3.0",
59
+ "@kazupon/eslint-config": "^0.35.0",
60
60
  "@kazupon/prettier-config": "^0.1.1",
61
- "@shikijs/vitepress-twoslash": "^3.9.1",
62
- "@types/node": "^22.17.0",
63
- "@vitest/eslint-plugin": "^1.3.4",
64
- "bumpp": "^10.2.2",
65
- "eslint": "^9.32.0",
61
+ "@shikijs/vitepress-twoslash": "^3.13.0",
62
+ "@types/node": "^22.18.6",
63
+ "@vitest/eslint-plugin": "^1.3.12",
64
+ "bumpp": "^10.2.3",
65
+ "eslint": "^9.36.0",
66
66
  "eslint-config-prettier": "^10.1.8",
67
67
  "eslint-import-resolver-typescript": "^4.4.4",
68
68
  "eslint-plugin-import": "^2.32.0",
69
- "eslint-plugin-jsdoc": "^52.0.2",
69
+ "eslint-plugin-jsdoc": "^52.0.4",
70
70
  "eslint-plugin-jsonc": "^2.20.1",
71
- "eslint-plugin-markdown-preferences": "^0.5.0",
71
+ "eslint-plugin-markdown-preferences": "^0.10.0",
72
72
  "eslint-plugin-module-interop": "^0.3.1",
73
73
  "eslint-plugin-promise": "^7.2.1",
74
- "eslint-plugin-regexp": "^2.9.1",
74
+ "eslint-plugin-regexp": "^2.10.0",
75
75
  "eslint-plugin-unicorn": "^60.0.0",
76
- "eslint-plugin-unused-imports": "^4.1.4",
76
+ "eslint-plugin-unused-imports": "^4.2.0",
77
77
  "eslint-plugin-yml": "^1.18.0",
78
- "eslint-vitest-rule-tester": "^2.2.1",
78
+ "eslint-vitest-rule-tester": "^2.2.2",
79
79
  "gh-changelogen": "^0.2.8",
80
- "knip": "^5.62.0",
81
- "lint-staged": "^16.1.2",
82
- "pkg-pr-new": "^0.0.54",
80
+ "knip": "^5.64.0",
81
+ "lint-staged": "^16.2.0",
82
+ "pkg-pr-new": "^0.0.60",
83
83
  "prettier": "^3.6.2",
84
- "publint": "^0.3.12",
85
- "tsdown": "^0.13.2",
86
- "tsx": "^4.20.3",
87
- "twoslash-eslint": "^0.3.3",
84
+ "publint": "^0.3.13",
85
+ "tsdown": "^0.15.4",
86
+ "tsx": "^4.20.5",
87
+ "twoslash-eslint": "^0.3.4",
88
88
  "typescript": "^5.9.2",
89
- "typescript-eslint": "^8.38.0",
89
+ "typescript-eslint": "^8.44.1",
90
90
  "vite-plugin-eslint4b": "^0.6.0",
91
- "vitepress": "^1.6.3",
92
- "vitepress-plugin-group-icons": "^1.6.1",
91
+ "vitepress": "^1.6.4",
92
+ "vitepress-plugin-group-icons": "^1.6.3",
93
93
  "vitest": "^3.2.4"
94
94
  },
95
95
  "prettier": "@kazupon/prettier-config",