@blumintinc/eslint-plugin-blumint 1.20.121 → 1.20.122
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/lib/index.js
CHANGED
|
@@ -103,11 +103,17 @@ const EVENT_SUPPRESSION_METHODS = new Set([
|
|
|
103
103
|
* arguments. Such a wrapper is not redundant, so the receiver is deliberately
|
|
104
104
|
* unconstrained — deleting `x.preventDefault()` changes behaviour whether `x`
|
|
105
105
|
* is a parameter, a captured value or a nested member.
|
|
106
|
+
*
|
|
107
|
+
* The question is asked of the call itself rather than of a statement, because
|
|
108
|
+
* the behaviour that makes the wrapper load-bearing is identical whether the
|
|
109
|
+
* author spelled it as a concise arrow body, a `return` or an expression
|
|
110
|
+
* statement — and a predicate that recognizes only one of those spellings
|
|
111
|
+
* reports the other two while prescribing a remedy that does not exist.
|
|
106
112
|
*/
|
|
107
|
-
function isEventSuppressionCall(
|
|
108
|
-
if (
|
|
113
|
+
function isEventSuppressionCall(expression) {
|
|
114
|
+
if (!expression)
|
|
109
115
|
return false;
|
|
110
|
-
const expr = unwrapChainExpression(
|
|
116
|
+
const expr = unwrapChainExpression(expression);
|
|
111
117
|
if (!expr || expr.type !== utils_1.AST_NODE_TYPES.CallExpression)
|
|
112
118
|
return false;
|
|
113
119
|
const callee = unwrapChainExpression(expr.callee);
|
|
@@ -124,6 +130,19 @@ function isEventSuppressionCall(stmt) {
|
|
|
124
130
|
}
|
|
125
131
|
return false;
|
|
126
132
|
}
|
|
133
|
+
/**
|
|
134
|
+
* The statement carrying a wrapper's effective call, so the suppression test
|
|
135
|
+
* reads the same expression from either statement kind.
|
|
136
|
+
*/
|
|
137
|
+
function isEventSuppressionStatement(stmt) {
|
|
138
|
+
if (stmt.type === utils_1.AST_NODE_TYPES.ExpressionStatement) {
|
|
139
|
+
return isEventSuppressionCall(stmt.expression);
|
|
140
|
+
}
|
|
141
|
+
if (stmt.type === utils_1.AST_NODE_TYPES.ReturnStatement) {
|
|
142
|
+
return isEventSuppressionCall(stmt.argument);
|
|
143
|
+
}
|
|
144
|
+
return false;
|
|
145
|
+
}
|
|
127
146
|
function isIdentifierOrMemberOn(obj, nameSet) {
|
|
128
147
|
if (obj.type === utils_1.AST_NODE_TYPES.Identifier) {
|
|
129
148
|
return nameSet.has(obj.name);
|
|
@@ -379,6 +398,11 @@ exports.noRedundantUseCallbackWrapper = (0, createRule_1.createRule)({
|
|
|
379
398
|
// Handle implicit return: () => memoizedFn()
|
|
380
399
|
if (fn.type === utils_1.AST_NODE_TYPES.ArrowFunctionExpression &&
|
|
381
400
|
fn.body.type !== utils_1.AST_NODE_TYPES.BlockStatement) {
|
|
401
|
+
// An event-suppression call disqualifies the wrapper outright: no
|
|
402
|
+
// spelling of "pass the callback directly" keeps it, so reporting
|
|
403
|
+
// here would prescribe a remedy that does not exist.
|
|
404
|
+
if (isEventSuppressionCall(fn.body))
|
|
405
|
+
return;
|
|
382
406
|
const bodyExpr = unwrapChainExpression(fn.body);
|
|
383
407
|
if (bodyExpr && bodyExpr.type === utils_1.AST_NODE_TYPES.CallExpression) {
|
|
384
408
|
const callee = unwrapChainExpression(bodyExpr.callee);
|
|
@@ -426,8 +450,10 @@ exports.noRedundantUseCallbackWrapper = (0, createRule_1.createRule)({
|
|
|
426
450
|
const stmts = fn.body.body.filter(Boolean);
|
|
427
451
|
// An event-suppression call disqualifies the wrapper outright: no
|
|
428
452
|
// spelling of "pass the callback directly" keeps it, so reporting
|
|
429
|
-
// here would prescribe a remedy that does not exist.
|
|
430
|
-
|
|
453
|
+
// here would prescribe a remedy that does not exist. Any statement
|
|
454
|
+
// carrying one is enough — the call is load-bearing wherever in
|
|
455
|
+
// the body it sits.
|
|
456
|
+
if (stmts.some(isEventSuppressionStatement))
|
|
431
457
|
return;
|
|
432
458
|
// Exactly one statement. A wrapper that sequences a second call is
|
|
433
459
|
// doing work the delegate alone does not, so collapsing it would
|
package/package.json
CHANGED
package/release-manifest.json
CHANGED
|
@@ -1,4 +1,18 @@
|
|
|
1
1
|
[
|
|
2
|
+
{
|
|
3
|
+
"version": "1.20.122",
|
|
4
|
+
"date": "2026-08-06T11:06:53.595Z",
|
|
5
|
+
"rules": [
|
|
6
|
+
{
|
|
7
|
+
"name": "no-redundant-usecallback-wrapper",
|
|
8
|
+
"changeType": "fix",
|
|
9
|
+
"issues": [
|
|
10
|
+
1796
|
|
11
|
+
],
|
|
12
|
+
"summary": "exempt a suppression wrapper in every body spelling (closes #1796)"
|
|
13
|
+
}
|
|
14
|
+
]
|
|
15
|
+
},
|
|
2
16
|
{
|
|
3
17
|
"version": "1.20.121",
|
|
4
18
|
"date": "2026-08-06T10:37:08.150Z",
|