Skip to content

Commit 9cadef9

Browse files
perf(no-unstable-default-props): skip identifier extraction when safeDefaultProps is empty
1 parent 969eccb commit 9cadef9

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

packages/plugins/eslint-plugin-react-x/src/rules/no-unstable-default-props.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,11 @@ export function create(context: RuleContext<MessageID, Options>, [options]: Opti
124124
if (isReactHookCall(construction.node)) {
125125
continue;
126126
}
127-
const identifier = extractIdentifier(right);
128-
if (identifier != null && safePatterns.some((pattern) => pattern.test(identifier))) {
129-
continue;
127+
if (safePatterns.length > 0) {
128+
const identifier = extractIdentifier(right);
129+
if (identifier != null && safePatterns.some((pattern) => pattern.test(identifier))) {
130+
continue;
131+
}
130132
}
131133
const forbiddenType = AST.toDelimiterFormat(right);
132134
context.report({

0 commit comments

Comments
 (0)