oxlint-plugin-react-doctor 0.7.9-dev.44d3ad8 → 0.7.9-dev.51ecd7b
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/dist/index.js +6 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -19021,10 +19021,14 @@ const hookUseState = defineRule({
|
|
|
19021
19021
|
create: (context) => {
|
|
19022
19022
|
const { allowDestructuredState } = resolveSettings$40(context.settings);
|
|
19023
19023
|
return { CallExpression(node) {
|
|
19024
|
-
|
|
19024
|
+
const callExpressionNode = node;
|
|
19025
|
+
if (!isReactFunctionCall(callExpressionNode, "useState")) return;
|
|
19026
|
+
const expressionRoot = findTransparentExpressionRoot(callExpressionNode);
|
|
19027
|
+
const expressionParent = expressionRoot.parent;
|
|
19028
|
+
if (isNodeOfType(expressionParent, "ReturnStatement")) return;
|
|
19029
|
+
if (isNodeOfType(expressionParent, "ArrowFunctionExpression") && expressionParent.body === expressionRoot) return;
|
|
19025
19030
|
const parent = node.parent;
|
|
19026
19031
|
if (!parent) return;
|
|
19027
|
-
if (isNodeOfType(parent, "ReturnStatement")) return;
|
|
19028
19032
|
if (!isNodeOfType(parent, "VariableDeclarator")) {
|
|
19029
19033
|
context.report({
|
|
19030
19034
|
node,
|