@kazupon/eslint-plugin 0.2.0 → 0.2.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.
Files changed (3) hide show
  1. package/README.md +1 -0
  2. package/lib/index.js +30 -10
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -47,6 +47,7 @@ export default defineConfig(
47
47
  {
48
48
  // ...
49
49
  }
50
+
50
51
  // ... something other configurations
51
52
  )
52
53
  ```
package/lib/index.js CHANGED
@@ -2,12 +2,12 @@ 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.0";
5
+ const version = "0.2.2";
6
6
  const namespace = "@kazupon";
7
7
 
8
8
  //#endregion
9
9
  //#region src/utils/rule.ts
10
- const BLOB_URL = "https://github.com/kazupon/eslint-plugin/tree/main/src/rules";
10
+ const BLOB_URL = "https://eslint-plugin.kazupon.dev/rules";
11
11
  function RuleCreator(urlCreator, namespace$1 = "") {
12
12
  return function createNamedRule({ meta, name: name$1,...rule$1 }) {
13
13
  const ruleId = namespace$1 ? `${namespace$1}/${name$1}` : name$1;
@@ -26,7 +26,7 @@ function RuleCreator(urlCreator, namespace$1 = "") {
26
26
  };
27
27
  }
28
28
  const createRule = RuleCreator((ruleName) => {
29
- return `${BLOB_URL}/${ruleName}.ts`;
29
+ return `${BLOB_URL}/${ruleName}`;
30
30
  }, namespace);
31
31
 
32
32
  //#endregion
@@ -134,15 +134,35 @@ const rule = createRule({
134
134
  comment,
135
135
  ast: parseComment(comment)
136
136
  }));
137
- let reported = false;
138
- for (const { comment, ast } of commentWithAstNodes) {
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)) break;
145
- reported = reportTagDiagnosis(comment, ENFORCED_TAGS, tagDiagnosis);
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.0",
4
+ "version": "0.2.2",
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.27.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",