@dloizides/frontend-devtools 1.3.0 → 1.5.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 CHANGED
@@ -5,6 +5,28 @@ 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.5.0] - 2026-10-07
9
+
10
+ KEFI-ACT-1 "Same attendee actions everywhere" (generalized: one row-action source per entity, every portal).
11
+
12
+ ### Added
13
+
14
+ - `single-row-action-source`: reports `<RowActionGroup actions>` from `@dloizides/ui-buttons` built in the same file
15
+ (inline array, array-bound identifier, `useMemo` returning an array, local builder function, `RowActionSpec[]`
16
+ annotated local). Imported builders/sets and props pass. No options, no autofix.
17
+ - `rowActionsConfig` and `recommendedConfig` flat-config blocks (`recommendedConfig` = comments + row actions, all `error`).
18
+
19
+ ## [1.4.0] - 2026-10-07
20
+
21
+ COMMENTS-1 "No code comments; only short doc comments on public members", decision D-CMT-4 "One-line summary, no call chains".
22
+
23
+ ### Changed
24
+
25
+ - `doc-comment-max-lines`: the description (lines other than `@param` / `@returns`) is capped at ONE line
26
+ (`summaryMaxLines`, default 1), every doc line at 120 chars (`lineMaxChars`), and a line containing an arrow
27
+ (U+2192 or `->`) or starting `Flow:` is reported (`callChain`). Matches `.claude/hooks/review-violations.js` docBlock().
28
+ The 3-line total cap is unchanged. One report per block; banned tags take precedence.
29
+
8
30
  ## [1.3.0] - 2026-10-06
9
31
 
10
32
  COMMENTS-1 "No code comments; only short doc comments on public members" (decisions D-CMT-1, D-CMT-3).
package/README.md CHANGED
@@ -120,7 +120,18 @@ export default [
120
120
  `i18n-param-names`, `no-barrel-companion-file`, `no-duplicate-nav-prefix`,
121
121
  `no-duplicate-shared-patterns`, `no-generated-models-barrel-value-import`,
122
122
  `no-null-check`, `no-optional-undefined`, `no-product-imports-in-shared`,
123
- `prefer-const-enum`, `require-stable-hook-args`, `smart-max-lines`.
123
+ `prefer-const-enum`, `require-stable-hook-args`, `single-row-action-source`,
124
+ `smart-max-lines`.
125
+
126
+ #### `single-row-action-source`
127
+
128
+ Reports `<RowActionGroup actions={...}>` (imported from `@dloizides/ui-buttons`) when
129
+ `actions` is an inline array literal, or an identifier / `useMemo` / local function in
130
+ the same file that builds the array (`RowActionSpec[]`). Allowed: a call to a builder or
131
+ set imported from another module (`buildXRowActions(row)`, `xRowActions.build(row)`), or
132
+ a prop passed in. Fix: build row actions once per entity with `defineRowActions` in a
133
+ `*RowActions` module; a table may only omit an action with a reason. Enabled at `error`
134
+ by `recommendedConfig` and `rowActionsConfig`.
124
135
 
125
136
  `ruleNames` exports the sorted list for migration assertions (prove no rule was
126
137
  dropped).
@@ -77,5 +77,10 @@ declare const legacyPlugins: Record<string, FlatConfigPlugin>;
77
77
  declare const COMMENT_RULE_NAMES: readonly string[];
78
78
  /** Flat-config block for COMMENTS-1: no code comments, short doc comments on public members only. */
79
79
  declare const commentsConfig: FlatConfig;
80
+ declare const ROW_ACTION_RULE_NAMES: readonly string[];
81
+ /** Flat-config block for row actions: RowActionGroup actions come from one shared defineRowActions set. */
82
+ declare const rowActionsConfig: FlatConfig;
83
+ /** The recommended flat-config block: every rule the pack enables by default, at error. */
84
+ declare const recommendedConfig: FlatConfig;
80
85
 
81
- export { COMMENT_RULE_NAMES, type CustomRule, type FlatConfig, type FlatConfigPlugin, type SingleRulePlugin, commentsConfig, legacyPlugins, plugin, ruleNames, rules };
86
+ export { COMMENT_RULE_NAMES, type CustomRule, type FlatConfig, type FlatConfigPlugin, ROW_ACTION_RULE_NAMES, type SingleRulePlugin, commentsConfig, legacyPlugins, plugin, recommendedConfig, rowActionsConfig, ruleNames, rules };
@@ -77,5 +77,10 @@ declare const legacyPlugins: Record<string, FlatConfigPlugin>;
77
77
  declare const COMMENT_RULE_NAMES: readonly string[];
78
78
  /** Flat-config block for COMMENTS-1: no code comments, short doc comments on public members only. */
79
79
  declare const commentsConfig: FlatConfig;
80
+ declare const ROW_ACTION_RULE_NAMES: readonly string[];
81
+ /** Flat-config block for row actions: RowActionGroup actions come from one shared defineRowActions set. */
82
+ declare const rowActionsConfig: FlatConfig;
83
+ /** The recommended flat-config block: every rule the pack enables by default, at error. */
84
+ declare const recommendedConfig: FlatConfig;
80
85
 
81
- export { COMMENT_RULE_NAMES, type CustomRule, type FlatConfig, type FlatConfigPlugin, type SingleRulePlugin, commentsConfig, legacyPlugins, plugin, ruleNames, rules };
86
+ export { COMMENT_RULE_NAMES, type CustomRule, type FlatConfig, type FlatConfigPlugin, ROW_ACTION_RULE_NAMES, type SingleRulePlugin, commentsConfig, legacyPlugins, plugin, recommendedConfig, rowActionsConfig, ruleNames, rules };
@@ -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 allow only @param / @returns block tags (RV-1, D-CMT-3)"
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 max = options.max ?? DEFAULT_MAX;
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
- if (lines.length > max)
129
- context.report({
130
- loc: comment.loc,
131
- messageId: "tooLong",
132
- data: { actual: String(lines.length), max: String(max) }
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
  };
@@ -2128,6 +2146,171 @@ var require_stable_hook_args_default = {
2128
2146
  }
2129
2147
  };
2130
2148
 
2149
+ // src/rules/single-row-action-source.js
2150
+ var UI_BUTTONS_MODULE = "@dloizides/ui-buttons";
2151
+ var GROUP_NAME = "RowActionGroup";
2152
+ var ACTIONS_PROP = "actions";
2153
+ var SPEC_TYPE = "RowActionSpec";
2154
+ var MEMO_HOOKS = /* @__PURE__ */ new Set(["useMemo", "useCallback"]);
2155
+ var MAX_DEPTH = 8;
2156
+ var Source = Object.freeze({ LOCAL: "local", EXTERNAL: "external" });
2157
+ function getScopeFor(context, node) {
2158
+ const sourceCode = context.sourceCode ?? context.getSourceCode();
2159
+ if (typeof sourceCode.getScope === "function") return sourceCode.getScope(node);
2160
+ return context.getScope();
2161
+ }
2162
+ function findVariable(scope, name) {
2163
+ let current = scope;
2164
+ while (current) {
2165
+ const found = current.set.get(name);
2166
+ if (found) return found;
2167
+ current = current.upper;
2168
+ }
2169
+ return void 0;
2170
+ }
2171
+ function rootIdentifier(node) {
2172
+ let current = node;
2173
+ while (current && current.type === "MemberExpression") current = current.object;
2174
+ return current && current.type === "Identifier" ? current : void 0;
2175
+ }
2176
+ function calleeName(callee) {
2177
+ if (callee.type === "Identifier") return callee.name;
2178
+ if (callee.type === "MemberExpression" && callee.property.type === "Identifier") return callee.property.name;
2179
+ return void 0;
2180
+ }
2181
+ function isSpecArrayType(annotation) {
2182
+ const type = annotation && annotation.typeAnnotation;
2183
+ if (!type) return false;
2184
+ const isSpecRef = (ref) => ref && ref.type === "TSTypeReference" && ref.typeName.name === SPEC_TYPE;
2185
+ if (type.type === "TSArrayType") return isSpecRef(type.elementType);
2186
+ if (type.type === "TSTypeOperator") return type.typeAnnotation.type === "TSArrayType" && isSpecRef(type.typeAnnotation.elementType);
2187
+ const params = type.typeParameters && type.typeParameters.params;
2188
+ return type.type === "TSTypeReference" && params !== void 0 && params.some(isSpecRef);
2189
+ }
2190
+ function returnedExpressions(fn) {
2191
+ if (fn.body.type !== "BlockStatement") return [fn.body];
2192
+ const found = [];
2193
+ const visit = (node) => {
2194
+ if (!node || typeof node.type !== "string") return;
2195
+ if (node.type === "ReturnStatement") {
2196
+ if (node.argument) found.push(node.argument);
2197
+ return;
2198
+ }
2199
+ if (node.type.includes("Function")) return;
2200
+ for (const key of Object.keys(node)) {
2201
+ if (key === "parent") continue;
2202
+ const child = node[key];
2203
+ if (Array.isArray(child)) child.forEach(visit);
2204
+ else if (child && typeof child.type === "string") visit(child);
2205
+ }
2206
+ };
2207
+ fn.body.body.forEach(visit);
2208
+ return found;
2209
+ }
2210
+ function isFunctionNode(node) {
2211
+ return node && (node.type === "ArrowFunctionExpression" || node.type === "FunctionExpression" || node.type === "FunctionDeclaration");
2212
+ }
2213
+ function createClassifier(context) {
2214
+ const anyLocal = (nodes, depth, seen) => nodes.some((n) => classify(n, depth, seen) === Source.LOCAL);
2215
+ function classifyVariable(variable, depth, seen) {
2216
+ if (seen.has(variable)) return Source.EXTERNAL;
2217
+ seen.add(variable);
2218
+ const def = variable.defs[0];
2219
+ if (!def) return Source.EXTERNAL;
2220
+ if (def.type === "ImportBinding" || def.type === "Parameter") return Source.EXTERNAL;
2221
+ if (def.type === "FunctionName") return Source.LOCAL;
2222
+ if (def.type !== "Variable" || def.node.id.type !== "Identifier") return Source.EXTERNAL;
2223
+ const writes = variable.references.filter((ref) => ref.isWrite() && ref.writeExpr).map((ref) => ref.writeExpr);
2224
+ if (writes.length === 0) return isSpecArrayType(def.node.id.typeAnnotation) ? Source.LOCAL : Source.EXTERNAL;
2225
+ return anyLocal(writes, depth + 1, seen) ? Source.LOCAL : Source.EXTERNAL;
2226
+ }
2227
+ function classifyCall(node, depth, seen) {
2228
+ const name = calleeName(node.callee);
2229
+ if (MEMO_HOOKS.has(name) && isFunctionNode(node.arguments[0])) {
2230
+ return anyLocal(returnedExpressions(node.arguments[0]), depth + 1, seen) ? Source.LOCAL : Source.EXTERNAL;
2231
+ }
2232
+ const root = rootIdentifier(node.callee);
2233
+ if (!root) return Source.EXTERNAL;
2234
+ const variable = findVariable(getScopeFor(context, node), root.name);
2235
+ if (!variable || variable.defs.length === 0) return Source.EXTERNAL;
2236
+ const def = variable.defs[0];
2237
+ if (def.type === "ImportBinding" || def.type === "Parameter") return Source.EXTERNAL;
2238
+ if (def.type === "FunctionName") return Source.LOCAL;
2239
+ const init = def.node.init;
2240
+ if (isFunctionNode(init)) return Source.LOCAL;
2241
+ return classifyVariable(variable, depth, seen);
2242
+ }
2243
+ function classify(node, depth, seen) {
2244
+ if (!node || depth > MAX_DEPTH) return Source.EXTERNAL;
2245
+ switch (node.type) {
2246
+ case "ArrayExpression":
2247
+ return Source.LOCAL;
2248
+ case "TSAsExpression":
2249
+ case "TSSatisfiesExpression":
2250
+ case "TSNonNullExpression":
2251
+ return classify(node.expression, depth + 1, seen);
2252
+ case "ConditionalExpression":
2253
+ return anyLocal([node.consequent, node.alternate], depth + 1, seen) ? Source.LOCAL : Source.EXTERNAL;
2254
+ case "LogicalExpression":
2255
+ return anyLocal([node.left, node.right], depth + 1, seen) ? Source.LOCAL : Source.EXTERNAL;
2256
+ case "CallExpression":
2257
+ return classifyCall(node, depth, seen);
2258
+ case "Identifier": {
2259
+ const variable = findVariable(getScopeFor(context, node), node.name);
2260
+ return variable ? classifyVariable(variable, depth, seen) : Source.EXTERNAL;
2261
+ }
2262
+ default:
2263
+ return Source.EXTERNAL;
2264
+ }
2265
+ }
2266
+ return (node) => classify(node, 0, /* @__PURE__ */ new Set());
2267
+ }
2268
+ function groupNameMatcher(imports) {
2269
+ return (nameNode) => {
2270
+ if (nameNode.type === "JSXIdentifier") return imports.named.has(nameNode.name);
2271
+ const isNamespaceMember = nameNode.type === "JSXMemberExpression" && nameNode.object.type === "JSXIdentifier" && imports.namespaces.has(nameNode.object.name);
2272
+ return isNamespaceMember && nameNode.property.name === GROUP_NAME;
2273
+ };
2274
+ }
2275
+ var singleRowActionSourceRule = {
2276
+ meta: {
2277
+ type: "problem",
2278
+ docs: {
2279
+ description: "RowActionGroup actions must come from a shared defineRowActions set, never a locally built array",
2280
+ recommended: true
2281
+ },
2282
+ schema: [],
2283
+ messages: {
2284
+ localRowActions: "Build row actions once per entity with defineRowActions in a *RowActions module; tables may only omit with a reason."
2285
+ }
2286
+ },
2287
+ create(context) {
2288
+ const imports = { named: /* @__PURE__ */ new Set(), namespaces: /* @__PURE__ */ new Set() };
2289
+ const isGroup = groupNameMatcher(imports);
2290
+ const classify = createClassifier(context);
2291
+ return {
2292
+ ImportDeclaration(node) {
2293
+ if (node.source.value !== UI_BUTTONS_MODULE) return;
2294
+ for (const spec of node.specifiers) {
2295
+ if (spec.type === "ImportNamespaceSpecifier") imports.namespaces.add(spec.local.name);
2296
+ else if (spec.type === "ImportSpecifier" && spec.imported.name === GROUP_NAME) imports.named.add(spec.local.name);
2297
+ }
2298
+ },
2299
+ JSXOpeningElement(node) {
2300
+ if (!isGroup(node.name)) return;
2301
+ const attr = node.attributes.find((a) => a.type === "JSXAttribute" && a.name.name === ACTIONS_PROP);
2302
+ if (!attr || !attr.value || attr.value.type !== "JSXExpressionContainer") return;
2303
+ if (classify(attr.value.expression) === Source.LOCAL) context.report({ node: attr, messageId: "localRowActions" });
2304
+ }
2305
+ };
2306
+ }
2307
+ };
2308
+ var single_row_action_source_default = {
2309
+ rules: {
2310
+ "single-row-action-source": singleRowActionSourceRule
2311
+ }
2312
+ };
2313
+
2131
2314
  // src/rules/smart-max-lines.js
2132
2315
  var COMPONENT_MAX_DEFAULT = 200;
2133
2316
  var FUNCTION_MAX_DEFAULT = 50;
@@ -2399,6 +2582,7 @@ var ruleModules = [
2399
2582
  no_raw_color_literal_default,
2400
2583
  prefer_const_enum_default,
2401
2584
  require_stable_hook_args_default,
2585
+ single_row_action_source_default,
2402
2586
  smart_max_lines_default
2403
2587
  ];
2404
2588
  function mergeRules(modules) {
@@ -2451,11 +2635,25 @@ var commentsConfig = {
2451
2635
  "@dloizides/doc-comment-max-lines": ["error", { max: DOC_COMMENT_MAX_LINES }]
2452
2636
  }
2453
2637
  };
2638
+ var ROW_ACTION_RULE_NAMES = ["single-row-action-source"];
2639
+ var rowActionsConfig = {
2640
+ plugins: commentsConfig.plugins,
2641
+ rules: {
2642
+ "@dloizides/single-row-action-source": "error"
2643
+ }
2644
+ };
2645
+ var recommendedConfig = {
2646
+ plugins: commentsConfig.plugins,
2647
+ rules: { ...commentsConfig.rules, ...rowActionsConfig.rules }
2648
+ };
2454
2649
 
2455
2650
  exports.COMMENT_RULE_NAMES = COMMENT_RULE_NAMES;
2651
+ exports.ROW_ACTION_RULE_NAMES = ROW_ACTION_RULE_NAMES;
2456
2652
  exports.commentsConfig = commentsConfig;
2457
2653
  exports.legacyPlugins = legacyPlugins;
2458
2654
  exports.plugin = plugin;
2655
+ exports.recommendedConfig = recommendedConfig;
2656
+ exports.rowActionsConfig = rowActionsConfig;
2459
2657
  exports.ruleNames = ruleNames;
2460
2658
  exports.rules = rules;
2461
2659
  //# sourceMappingURL=index.js.map