@dloizides/frontend-devtools 1.4.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 +11 -0
- package/README.md +12 -1
- package/dist/eslint/index.d.mts +6 -1
- package/dist/eslint/index.d.ts +6 -1
- package/dist/eslint/index.js +180 -0
- package/dist/eslint/index.js.map +1 -1
- package/dist/eslint/index.mjs +178 -1
- 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.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
|
+
|
|
8
19
|
## [1.4.0] - 2026-10-07
|
|
9
20
|
|
|
10
21
|
COMMENTS-1 "No code comments; only short doc comments on public members", decision D-CMT-4 "One-line summary, no call chains".
|
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`, `
|
|
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).
|
package/dist/eslint/index.d.mts
CHANGED
|
@@ -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 };
|
package/dist/eslint/index.d.ts
CHANGED
|
@@ -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 };
|
package/dist/eslint/index.js
CHANGED
|
@@ -2146,6 +2146,171 @@ var require_stable_hook_args_default = {
|
|
|
2146
2146
|
}
|
|
2147
2147
|
};
|
|
2148
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
|
+
|
|
2149
2314
|
// src/rules/smart-max-lines.js
|
|
2150
2315
|
var COMPONENT_MAX_DEFAULT = 200;
|
|
2151
2316
|
var FUNCTION_MAX_DEFAULT = 50;
|
|
@@ -2417,6 +2582,7 @@ var ruleModules = [
|
|
|
2417
2582
|
no_raw_color_literal_default,
|
|
2418
2583
|
prefer_const_enum_default,
|
|
2419
2584
|
require_stable_hook_args_default,
|
|
2585
|
+
single_row_action_source_default,
|
|
2420
2586
|
smart_max_lines_default
|
|
2421
2587
|
];
|
|
2422
2588
|
function mergeRules(modules) {
|
|
@@ -2469,11 +2635,25 @@ var commentsConfig = {
|
|
|
2469
2635
|
"@dloizides/doc-comment-max-lines": ["error", { max: DOC_COMMENT_MAX_LINES }]
|
|
2470
2636
|
}
|
|
2471
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
|
+
};
|
|
2472
2649
|
|
|
2473
2650
|
exports.COMMENT_RULE_NAMES = COMMENT_RULE_NAMES;
|
|
2651
|
+
exports.ROW_ACTION_RULE_NAMES = ROW_ACTION_RULE_NAMES;
|
|
2474
2652
|
exports.commentsConfig = commentsConfig;
|
|
2475
2653
|
exports.legacyPlugins = legacyPlugins;
|
|
2476
2654
|
exports.plugin = plugin;
|
|
2655
|
+
exports.recommendedConfig = recommendedConfig;
|
|
2656
|
+
exports.rowActionsConfig = rowActionsConfig;
|
|
2477
2657
|
exports.ruleNames = ruleNames;
|
|
2478
2658
|
exports.rules = rules;
|
|
2479
2659
|
//# sourceMappingURL=index.js.map
|