@kazupon/eslint-plugin 0.2.0 → 0.2.1
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 -0
- package/lib/index.js +28 -8
- package/package.json +2 -2
package/README.md
CHANGED
package/lib/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import { parseComment } from "@es-joy/jsdoccomment";
|
|
|
2
2
|
|
|
3
3
|
//#region src/utils/constants.ts
|
|
4
4
|
const name = "@kazupon/eslint-plugin";
|
|
5
|
-
const version = "0.2.
|
|
5
|
+
const version = "0.2.1";
|
|
6
6
|
const namespace = "@kazupon";
|
|
7
7
|
|
|
8
8
|
//#endregion
|
|
@@ -134,15 +134,35 @@ const rule = createRule({
|
|
|
134
134
|
comment,
|
|
135
135
|
ast: parseComment(comment)
|
|
136
136
|
}));
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
if (reported) break;
|
|
140
|
-
const found = ast.tags.some((tag) => ENFORCED_TAGS.includes(tag.tag));
|
|
141
|
-
if (ast.tags.length > 0 && !found) continue;
|
|
137
|
+
const headerCommentWithAstNodes = commentWithAstNodes.find(({ ast }) => ast.tags.some((tag) => ENFORCED_TAGS.includes(tag.tag)));
|
|
138
|
+
if (headerCommentWithAstNodes) {
|
|
142
139
|
const tagDiagnosis = initializeTagDiagnosis(ENFORCED_TAGS);
|
|
140
|
+
const { comment, ast } = headerCommentWithAstNodes;
|
|
143
141
|
for (const tag of ast.tags) if (tagDiagnosis[tag.tag]) tagDiagnosis[tag.tag] = tag.description ? "ok" : "enforce";
|
|
144
|
-
if (validTagDiagnosis(tagDiagnosis))
|
|
145
|
-
|
|
142
|
+
if (!validTagDiagnosis(tagDiagnosis)) reportTagDiagnosis(comment, ENFORCED_TAGS, tagDiagnosis);
|
|
143
|
+
} else {
|
|
144
|
+
const firstComment = commentWithAstNodes[0].comment;
|
|
145
|
+
const lastComment = commentWithAstNodes.at(-1).comment;
|
|
146
|
+
const topLoc = {
|
|
147
|
+
start: {
|
|
148
|
+
line: firstComment.loc.start.line,
|
|
149
|
+
column: firstComment.loc.start.column
|
|
150
|
+
},
|
|
151
|
+
end: {
|
|
152
|
+
line: lastComment.loc.end.line,
|
|
153
|
+
column: lastComment.loc.end.column
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
ctx.report({
|
|
157
|
+
loc: topLoc,
|
|
158
|
+
messageId: "headerCommentNeedTag",
|
|
159
|
+
data: { tag: "author" }
|
|
160
|
+
});
|
|
161
|
+
ctx.report({
|
|
162
|
+
loc: topLoc,
|
|
163
|
+
messageId: "headerCommentNeedTag",
|
|
164
|
+
data: { tag: "license" }
|
|
165
|
+
});
|
|
146
166
|
}
|
|
147
167
|
}
|
|
148
168
|
};
|
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.2.
|
|
4
|
+
"version": "0.2.1",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"funding": "https://github.com/sponsors/kazupon",
|
|
7
7
|
"bugs": {
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@eslint/markdown": "^6.3.0",
|
|
58
|
-
"@kazupon/eslint-config": "^0.
|
|
58
|
+
"@kazupon/eslint-config": "^0.28.0",
|
|
59
59
|
"@kazupon/prettier-config": "^0.1.1",
|
|
60
60
|
"@shikijs/vitepress-twoslash": "^3.2.2",
|
|
61
61
|
"@types/node": "^22.14.1",
|