Skip to content

Commit 42c6a5b

Browse files
committed
chore: inline parent lookup in no-create-ref rule
1 parent 3026dc6 commit 42c6a5b

3 files changed

Lines changed: 247 additions & 222 deletions

File tree

.sentrux/baseline.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
2-
"timestamp": 1783707933.238873,
3-
"quality_signal": 0.5646604680801464,
4-
"coupling_score": 0.06274509803921569,
2+
"timestamp": 1784539218.608508,
3+
"quality_signal": 0.5778091345775828,
4+
"coupling_score": 0.056589147286821705,
55
"cycle_count": 0,
6-
"god_file_count": 2,
6+
"god_file_count": 3,
77
"hotspot_count": 0,
8-
"complex_fn_count": 49,
9-
"max_depth": 18,
10-
"total_import_edges": 1275,
11-
"cross_module_edges": 651
8+
"complex_fn_count": 50,
9+
"max_depth": 16,
10+
"total_import_edges": 1290,
11+
"cross_module_edges": 663
1212
}

plugins/eslint-plugin-react-x/src/rules/no-create-ref/no-create-ref.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ export function create(context: RuleContext<MessageID, []>): RuleListener {
4747
const hooks = hc.api.getAllHooks(node);
4848
const funcs = [...comps, ...hooks];
4949
for (const call of createRefCalls) {
50-
const func = Traverse.findParent(call, (n) => funcs.some((f) => f.node === n));
51-
if (func == null) continue;
50+
// Only report if the call is within a function component or Hook
51+
if (Traverse.findParent(call, (n) => funcs.some((f) => f.node === n)) == null) continue;
5252
context.report({ messageId: "default", node: call });
5353
}
5454
},

0 commit comments

Comments
 (0)