rule.create() — react Function Reference
Architecture documentation for the rule.create() function in ExhaustiveDeps.ts from the react codebase.
Entity Profile
Dependency Diagram
graph TD c0937ffe_5980_6959_3af6_e18a4a23114f["rule.create()"] ea02b01a_dd46_4b35_fe00_775aec496668["ExhaustiveDeps.ts"] c0937ffe_5980_6959_3af6_e18a4a23114f -->|defined in| ea02b01a_dd46_4b35_fe00_775aec496668 1a929da5_96c8_bcab_86db_7fe06b23af38["getAdditionalEffectHooksFromSettings()"] c0937ffe_5980_6959_3af6_e18a4a23114f -->|calls| 1a929da5_96c8_bcab_86db_7fe06b23af38 b0c8a050_07e4_e229_6279_281564aeb478["fastFindReferenceWithParent()"] c0937ffe_5980_6959_3af6_e18a4a23114f -->|calls| b0c8a050_07e4_e229_6279_281564aeb478 7919f546_26f3_78fb_b60f_89cc3c37610e["isUseEffectEventIdentifier()"] c0937ffe_5980_6959_3af6_e18a4a23114f -->|calls| 7919f546_26f3_78fb_b60f_89cc3c37610e d25d44a2_a814_6c2f_1f81_168e5b1e6d98["getDependency()"] c0937ffe_5980_6959_3af6_e18a4a23114f -->|calls| d25d44a2_a814_6c2f_1f81_168e5b1e6d98 bf9b6b10_9341_d44c_d960_2c1a990db056["analyzePropertyChain()"] c0937ffe_5980_6959_3af6_e18a4a23114f -->|calls| bf9b6b10_9341_d44c_d960_2c1a990db056 433729aa_5315_6737_eded_ebac4cce3d75["collectRecommendations()"] c0937ffe_5980_6959_3af6_e18a4a23114f -->|calls| 433729aa_5315_6737_eded_ebac4cce3d75 a8ca46d1_1e1d_7275_227b_3492441252b4["scanForConstructions()"] c0937ffe_5980_6959_3af6_e18a4a23114f -->|calls| a8ca46d1_1e1d_7275_227b_3492441252b4 85285807_0028_02c0_7f46_68856091c6ec["joinEnglish()"] c0937ffe_5980_6959_3af6_e18a4a23114f -->|calls| 85285807_0028_02c0_7f46_68856091c6ec 895f966f_4edb_0ba3_8a49_6adf99e31ec1["getReactiveHookCallbackIndex()"] c0937ffe_5980_6959_3af6_e18a4a23114f -->|calls| 895f966f_4edb_0ba3_8a49_6adf99e31ec1 57d4575e_cb38_7d65_a871_8e1ae5d76a1f["getNodeWithoutReactNamespace()"] c0937ffe_5980_6959_3af6_e18a4a23114f -->|calls| 57d4575e_cb38_7d65_a871_8e1ae5d76a1f 9218e6ed_699f_ad1f_3f94_b4af3bc93ec8["getUnknownDependenciesMessage()"] c0937ffe_5980_6959_3af6_e18a4a23114f -->|calls| 9218e6ed_699f_ad1f_3f94_b4af3bc93ec8 style c0937ffe_5980_6959_3af6_e18a4a23114f fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/eslint-plugin-react-hooks/src/rules/ExhaustiveDeps.ts lines 79–1531
create(context: Rule.RuleContext) {
const rawOptions = context.options && context.options[0];
const settings = context.settings || {};
// Parse the `additionalHooks` regex.
// Use rule-level additionalHooks if provided, otherwise fall back to settings
const additionalHooks =
rawOptions && rawOptions.additionalHooks
? new RegExp(rawOptions.additionalHooks)
: getAdditionalEffectHooksFromSettings(settings);
const enableDangerousAutofixThisMayCauseInfiniteLoops: boolean =
(rawOptions &&
rawOptions.enableDangerousAutofixThisMayCauseInfiniteLoops) ||
false;
const experimental_autoDependenciesHooks: ReadonlyArray<string> =
rawOptions && Array.isArray(rawOptions.experimental_autoDependenciesHooks)
? rawOptions.experimental_autoDependenciesHooks
: [];
const requireExplicitEffectDeps: boolean =
(rawOptions && rawOptions.requireExplicitEffectDeps) || false;
const options = {
additionalHooks,
experimental_autoDependenciesHooks,
enableDangerousAutofixThisMayCauseInfiniteLoops,
requireExplicitEffectDeps,
};
function reportProblem(problem: Rule.ReportDescriptor) {
if (enableDangerousAutofixThisMayCauseInfiniteLoops) {
// Used to enable legacy behavior. Dangerous.
// Keep this as an option until major IDEs upgrade (including VSCode FB ESLint extension).
if (
Array.isArray(problem.suggest) &&
problem.suggest.length > 0 &&
problem.suggest[0]
) {
problem.fix = problem.suggest[0].fix;
}
}
context.report(problem);
}
/**
* SourceCode that also works down to ESLint 3.0.0
*/
const getSourceCode =
typeof context.getSourceCode === 'function'
? () => {
return context.getSourceCode();
}
: () => {
return context.sourceCode;
};
/**
* SourceCode#getScope that also works down to ESLint 3.0.0
*/
const getScope =
typeof context.getScope === 'function'
? () => {
return context.getScope();
}
: (node: Node) => {
return context.sourceCode.getScope(node);
};
const scopeManager = getSourceCode().scopeManager;
// Should be shared between visitors.
const setStateCallSites = new WeakMap<
Expression | Super,
Pattern | null | undefined
>();
const stateVariables = new WeakSet<Identifier>();
const stableKnownValueCache = new WeakMap<Scope.Variable, boolean>();
const functionWithoutCapturedValueCache = new WeakMap<
Scope.Variable,
boolean
Domain
Subdomains
Calls
Source
Frequently Asked Questions
What does rule.create() do?
rule.create() is a function in the react codebase, defined in packages/eslint-plugin-react-hooks/src/rules/ExhaustiveDeps.ts.
Where is rule.create() defined?
rule.create() is defined in packages/eslint-plugin-react-hooks/src/rules/ExhaustiveDeps.ts at line 79.
What does rule.create() call?
rule.create() calls 11 function(s): analyzePropertyChain, collectRecommendations, fastFindReferenceWithParent, getAdditionalEffectHooksFromSettings, getDependency, getNodeWithoutReactNamespace, getReactiveHookCallbackIndex, getUnknownDependenciesMessage, and 3 more.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free