@kazupon/eslint-plugin 0.6.0 → 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 +1 -1
- package/lib/index.d.ts +0 -2
- package/lib/index.js +14 -24
- package/package.json +26 -26
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
|
-
###
|
|
62
|
+
### `@kazupon/eslint-plugin` Rules
|
|
63
63
|
|
|
64
64
|
| Rule ID | Description | Category | Fixable | RECOMMENDED |
|
|
65
65
|
| :--------------------------------------------------------------------------------------------------------------------------- | :------------------------------------------------------------ | :------- | :-----: | :---------: |
|
package/lib/index.d.ts
CHANGED
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
|
-
|
|
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
|
|
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.
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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) {
|
|
@@ -532,9 +527,7 @@ const rule$1 = createRule({
|
|
|
532
527
|
type: "object",
|
|
533
528
|
properties: { words: {
|
|
534
529
|
type: "array",
|
|
535
|
-
items: { type: "string" }
|
|
536
|
-
minItems: 1,
|
|
537
|
-
uniqueItems: true
|
|
530
|
+
items: { type: "string" }
|
|
538
531
|
} },
|
|
539
532
|
required: ["words"],
|
|
540
533
|
additionalProperties: false
|
|
@@ -569,10 +562,10 @@ const rule$1 = createRule({
|
|
|
569
562
|
column: position.column + word.length
|
|
570
563
|
}
|
|
571
564
|
},
|
|
572
|
-
fix(fixer) {
|
|
573
|
-
const
|
|
574
|
-
const
|
|
575
|
-
return fixer.
|
|
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], "`")];
|
|
576
569
|
}
|
|
577
570
|
});
|
|
578
571
|
}
|
|
@@ -702,11 +695,9 @@ const rule = createRule({
|
|
|
702
695
|
const lineTagInfo = detectTag(descLine.trim(), tags);
|
|
703
696
|
if (lineTagInfo && !lineTagInfo.hasScope) {
|
|
704
697
|
const descStartInComment = value.indexOf(directiveInfo.description);
|
|
705
|
-
const
|
|
706
|
-
const actualLineIndex = linesBeforeDesc + descLineIndex;
|
|
698
|
+
const actualLineIndex = value.slice(0, descStartInComment).split("\n").length - 1 + descLineIndex;
|
|
707
699
|
if (actualLineIndex < lines.length) {
|
|
708
|
-
const
|
|
709
|
-
const tagIndex = actualLine.indexOf(lineTagInfo.tag);
|
|
700
|
+
const tagIndex = lines[actualLineIndex].indexOf(lineTagInfo.tag);
|
|
710
701
|
if (tagIndex !== -1) {
|
|
711
702
|
const location = {
|
|
712
703
|
line: comment.loc.start.line + actualLineIndex,
|
|
@@ -722,8 +713,7 @@ const rule = createRule({
|
|
|
722
713
|
return;
|
|
723
714
|
}
|
|
724
715
|
for (const [i, line] of lines.entries()) {
|
|
725
|
-
|
|
726
|
-
if (!trimmedLine) continue;
|
|
716
|
+
if (!line.trim()) continue;
|
|
727
717
|
const contentToCheck = stripJSDocPrefix(line);
|
|
728
718
|
const tagInfo = detectTag(contentToCheck, tags);
|
|
729
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.
|
|
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.
|
|
51
|
-
"@eslint/core": "^0.15.
|
|
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.
|
|
58
|
-
"@eslint/markdown": "^7.
|
|
59
|
-
"@kazupon/eslint-config": "^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.
|
|
62
|
-
"@types/node": "^22.
|
|
63
|
-
"@vitest/eslint-plugin": "^1.3.
|
|
64
|
-
"bumpp": "^10.2.
|
|
65
|
-
"eslint": "^9.
|
|
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.
|
|
69
|
+
"eslint-plugin-jsdoc": "^52.0.4",
|
|
70
70
|
"eslint-plugin-jsonc": "^2.20.1",
|
|
71
|
-
"eslint-plugin-markdown-preferences": "^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.
|
|
74
|
+
"eslint-plugin-regexp": "^2.10.0",
|
|
75
75
|
"eslint-plugin-unicorn": "^60.0.0",
|
|
76
|
-
"eslint-plugin-unused-imports": "^4.
|
|
76
|
+
"eslint-plugin-unused-imports": "^4.2.0",
|
|
77
77
|
"eslint-plugin-yml": "^1.18.0",
|
|
78
|
-
"eslint-vitest-rule-tester": "^2.2.
|
|
78
|
+
"eslint-vitest-rule-tester": "^2.2.2",
|
|
79
79
|
"gh-changelogen": "^0.2.8",
|
|
80
|
-
"knip": "^5.
|
|
81
|
-
"lint-staged": "^16.
|
|
82
|
-
"pkg-pr-new": "^0.0.
|
|
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.
|
|
85
|
-
"tsdown": "^0.
|
|
86
|
-
"tsx": "^4.20.
|
|
87
|
-
"twoslash-eslint": "^0.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.
|
|
89
|
+
"typescript-eslint": "^8.44.1",
|
|
90
90
|
"vite-plugin-eslint4b": "^0.6.0",
|
|
91
|
-
"vitepress": "^1.6.
|
|
92
|
-
"vitepress-plugin-group-icons": "^1.6.
|
|
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",
|