@dloizides/frontend-devtools 1.3.0 → 1.4.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/CHANGELOG.md +11 -0
- package/dist/eslint/index.js +35 -17
- package/dist/eslint/index.js.map +1 -1
- package/dist/eslint/index.mjs +35 -17
- package/dist/eslint/index.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,17 @@ All notable changes to `@dloizides/frontend-devtools` are documented here.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [1.4.0] - 2026-10-07
|
|
9
|
+
|
|
10
|
+
COMMENTS-1 "No code comments; only short doc comments on public members", decision D-CMT-4 "One-line summary, no call chains".
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
- `doc-comment-max-lines`: the description (lines other than `@param` / `@returns`) is capped at ONE line
|
|
15
|
+
(`summaryMaxLines`, default 1), every doc line at 120 chars (`lineMaxChars`), and a line containing an arrow
|
|
16
|
+
(U+2192 or `->`) or starting `Flow:` is reported (`callChain`). Matches `.claude/hooks/review-violations.js` docBlock().
|
|
17
|
+
The 3-line total cap is unchanged. One report per block; banned tags take precedence.
|
|
18
|
+
|
|
8
19
|
## [1.3.0] - 2026-10-06
|
|
9
20
|
|
|
10
21
|
COMMENTS-1 "No code comments; only short doc comments on public members" (decisions D-CMT-1, D-CMT-3).
|
package/dist/eslint/index.js
CHANGED
|
@@ -91,11 +91,27 @@ function removeSuggestion(sourceCode, comment) {
|
|
|
91
91
|
// src/rules/doc-comment-max-lines.js
|
|
92
92
|
var DEFAULT_MAX = 3;
|
|
93
93
|
var DEFAULT_ALLOWED_TAGS = ["param", "returns"];
|
|
94
|
+
var DEFAULT_SUMMARY_MAX_LINES = 1;
|
|
95
|
+
var DEFAULT_LINE_MAX_CHARS = 120;
|
|
96
|
+
var CALL_CHAIN = /(→|->|^Flow\s*:)/i;
|
|
97
|
+
var PARAM_LINE = /^@(param|returns?)\b/i;
|
|
98
|
+
function firstShapeProblem(lines, limits) {
|
|
99
|
+
if (lines.length > limits.max)
|
|
100
|
+
return { messageId: "tooLong", data: { actual: String(lines.length), max: String(limits.max) } };
|
|
101
|
+
if (lines.some((line) => CALL_CHAIN.test(line))) return { messageId: "callChain", data: {} };
|
|
102
|
+
const summary = lines.filter((line) => !PARAM_LINE.test(line)).length;
|
|
103
|
+
if (summary > limits.summaryMaxLines)
|
|
104
|
+
return { messageId: "summaryTooLong", data: { actual: String(summary), max: String(limits.summaryMaxLines) } };
|
|
105
|
+
const long = lines.find((line) => line.length > limits.lineMaxChars);
|
|
106
|
+
if (long !== void 0)
|
|
107
|
+
return { messageId: "lineTooLong", data: { actual: String(long.length), max: String(limits.lineMaxChars) } };
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
94
110
|
var docCommentMaxLinesRule = {
|
|
95
111
|
meta: {
|
|
96
112
|
type: "suggestion",
|
|
97
113
|
docs: {
|
|
98
|
-
description: "Cap a doc comment at a few lines and
|
|
114
|
+
description: "Cap a doc comment at a few lines, a one-line summary with no call chain, and only @param / @returns tags (RV-1, D-CMT-3, D-CMT-4)"
|
|
99
115
|
},
|
|
100
116
|
schema: [
|
|
101
117
|
{
|
|
@@ -103,20 +119,29 @@ var docCommentMaxLinesRule = {
|
|
|
103
119
|
properties: {
|
|
104
120
|
max: { type: "integer", minimum: 1 },
|
|
105
121
|
allowedTags: { type: "array", items: { type: "string" } },
|
|
106
|
-
bannedTags: { type: "array", items: { type: "string" } }
|
|
122
|
+
bannedTags: { type: "array", items: { type: "string" } },
|
|
123
|
+
summaryMaxLines: { type: "integer", minimum: 1 },
|
|
124
|
+
lineMaxChars: { type: "integer", minimum: 1 }
|
|
107
125
|
},
|
|
108
126
|
additionalProperties: false
|
|
109
127
|
}
|
|
110
128
|
],
|
|
111
129
|
messages: {
|
|
112
130
|
tooLong: "RV-1: doc comment is {{actual}} lines; the cap is {{max}}.",
|
|
113
|
-
bannedTag: "RV-1: @{{tag}} is not allowed in a doc comment (allowed: {{allowed}})."
|
|
131
|
+
bannedTag: "RV-1: @{{tag}} is not allowed in a doc comment (allowed: {{allowed}}).",
|
|
132
|
+
summaryTooLong: "RV-1: doc summary is {{actual}} lines; it must be one line saying what the member is for.",
|
|
133
|
+
callChain: "RV-1: no call chain or Flow: in a doc comment; say what the member is for, not how it runs.",
|
|
134
|
+
lineTooLong: "RV-1: doc line is {{actual}} chars; the cap is {{max}}."
|
|
114
135
|
}
|
|
115
136
|
},
|
|
116
137
|
create(context) {
|
|
117
138
|
const sourceCode = context.sourceCode ?? context.getSourceCode();
|
|
118
139
|
const options = context.options[0] ?? {};
|
|
119
|
-
const
|
|
140
|
+
const limits = {
|
|
141
|
+
max: options.max ?? DEFAULT_MAX,
|
|
142
|
+
summaryMaxLines: options.summaryMaxLines ?? DEFAULT_SUMMARY_MAX_LINES,
|
|
143
|
+
lineMaxChars: options.lineMaxChars ?? DEFAULT_LINE_MAX_CHARS
|
|
144
|
+
};
|
|
120
145
|
const allowed = new Set(options.allowedTags ?? DEFAULT_ALLOWED_TAGS);
|
|
121
146
|
for (const tag of options.bannedTags ?? []) allowed.delete(tag);
|
|
122
147
|
const allowedText = [...allowed].map((tag) => `@${tag}`).join(", ") || "none";
|
|
@@ -125,19 +150,12 @@ var docCommentMaxLinesRule = {
|
|
|
125
150
|
for (const comment of sourceCode.getAllComments()) {
|
|
126
151
|
if (!isDocBlock(comment) || isTypeAnnotationDoc(comment)) continue;
|
|
127
152
|
const lines = docBodyLines(comment);
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
for (const tag of blockTags(lines))
|
|
135
|
-
if (!allowed.has(tag))
|
|
136
|
-
context.report({
|
|
137
|
-
loc: comment.loc,
|
|
138
|
-
messageId: "bannedTag",
|
|
139
|
-
data: { tag, allowed: allowedText }
|
|
140
|
-
});
|
|
153
|
+
const banned = blockTags(lines).filter((tag) => !allowed.has(tag));
|
|
154
|
+
for (const tag of banned)
|
|
155
|
+
context.report({ loc: comment.loc, messageId: "bannedTag", data: { tag, allowed: allowedText } });
|
|
156
|
+
if (banned.length > 0) continue;
|
|
157
|
+
const problem = firstShapeProblem(lines, limits);
|
|
158
|
+
if (problem) context.report({ loc: comment.loc, ...problem });
|
|
141
159
|
}
|
|
142
160
|
}
|
|
143
161
|
};
|