preprocess() — react Function Reference
Architecture documentation for the preprocess() function in code-path-analyzer.js from the react codebase.
Entity Profile
Dependency Diagram
graph TD 6f68084b_bea2_71c3_ca2d_d9fa72214a6a["preprocess()"] 09a1c78a_21af_9be8_1cc6_22cf0ceb9f8f["code-path-analyzer.js"] 6f68084b_bea2_71c3_ca2d_d9fa72214a6a -->|defined in| 09a1c78a_21af_9be8_1cc6_22cf0ceb9f8f d082f1e7_4eef_c1db_f99e_4cfec174190f["enterNode()"] d082f1e7_4eef_c1db_f99e_4cfec174190f -->|calls| 6f68084b_bea2_71c3_ca2d_d9fa72214a6a 8f9baede_3c74_c103_bf16_8ed6896c980e["isHandledLogicalOperator()"] 6f68084b_bea2_71c3_ca2d_d9fa72214a6a -->|calls| 8f9baede_3c74_c103_bf16_8ed6896c980e 1b797861_fe3d_e47c_ac86_c6dca04010f2["isLogicalAssignmentOperator()"] 6f68084b_bea2_71c3_ca2d_d9fa72214a6a -->|calls| 1b797861_fe3d_e47c_ac86_c6dca04010f2 348cb342_f9d3_f608_ead4_1ee28d79cbc2["getBooleanValueIfSimpleConstant()"] 6f68084b_bea2_71c3_ca2d_d9fa72214a6a -->|calls| 348cb342_f9d3_f608_ead4_1ee28d79cbc2 style 6f68084b_bea2_71c3_ca2d_d9fa72214a6a fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/eslint-plugin-react-hooks/src/code-path-analysis/code-path-analyzer.js lines 251–372
function preprocess(analyzer, node) {
const codePath = analyzer.codePath;
const state = CodePath.getState(codePath);
const parent = node.parent;
switch (parent.type) {
// The `arguments.length == 0` case is in `postprocess` function.
case 'CallExpression':
if (
parent.optional === true &&
parent.arguments.length >= 1 &&
parent.arguments[0] === node
) {
state.makeOptionalRight();
}
break;
case 'MemberExpression':
if (parent.optional === true && parent.property === node) {
state.makeOptionalRight();
}
break;
case 'LogicalExpression':
if (parent.right === node && isHandledLogicalOperator(parent.operator)) {
state.makeLogicalRight();
}
break;
case 'AssignmentExpression':
if (
parent.right === node &&
isLogicalAssignmentOperator(parent.operator)
) {
state.makeLogicalRight();
}
break;
case 'ConditionalExpression':
case 'IfStatement':
/*
* Fork if this node is at `consequent`/`alternate`.
* `popForkContext()` exists at `IfStatement:exit` and
* `ConditionalExpression:exit`.
*/
if (parent.consequent === node) {
state.makeIfConsequent();
} else if (parent.alternate === node) {
state.makeIfAlternate();
}
break;
case 'SwitchCase':
if (parent.consequent[0] === node) {
state.makeSwitchCaseBody(false, !parent.test);
}
break;
case 'TryStatement':
if (parent.handler === node) {
state.makeCatchBlock();
} else if (parent.finalizer === node) {
state.makeFinallyBlock();
}
break;
case 'WhileStatement':
if (parent.test === node) {
state.makeWhileTest(getBooleanValueIfSimpleConstant(node));
} else {
assert(parent.body === node);
state.makeWhileBody();
}
break;
case 'DoWhileStatement':
if (parent.body === node) {
state.makeDoWhileBody();
} else {
assert(parent.test === node);
state.makeDoWhileTest(getBooleanValueIfSimpleConstant(node));
}
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does preprocess() do?
preprocess() is a function in the react codebase, defined in packages/eslint-plugin-react-hooks/src/code-path-analysis/code-path-analyzer.js.
Where is preprocess() defined?
preprocess() is defined in packages/eslint-plugin-react-hooks/src/code-path-analysis/code-path-analyzer.js at line 251.
What does preprocess() call?
preprocess() calls 3 function(s): getBooleanValueIfSimpleConstant, isHandledLogicalOperator, isLogicalAssignmentOperator.
What calls preprocess()?
preprocess() is called by 1 function(s): enterNode.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free