diff --git a/packages/eslint-plugin-react-hooks/src/ExhaustiveDeps.js b/packages/eslint-plugin-react-hooks/src/ExhaustiveDeps.js
index a708f78f25f7..668458903211 100644
--- a/packages/eslint-plugin-react-hooks/src/ExhaustiveDeps.js
+++ b/packages/eslint-plugin-react-hooks/src/ExhaustiveDeps.js
@@ -37,6 +37,8 @@ export default {
     ],
   },
   create(context) {
+    const sourceCode = context.sourceCode ?? context.getSourceCode();
+
     // Parse the `additionalHooks` regex.
     const additionalHooks =
       context.options &&
@@ -67,7 +69,7 @@ export default {
       context.report(problem);
     }
 
-    const scopeManager = context.getSourceCode().scopeManager;
+    const scopeManager = sourceCode.scopeManager;
 
     // Should be shared between visitors.
     const setStateCallSites = new WeakMap();
@@ -526,11 +528,11 @@ export default {
           node: writeExpr,
           message:
             `Assignments to the '${key}' variable from inside React Hook ` +
-            `${context.getSource(reactiveHook)} will be lost after each ` +
+            `${sourceCode.getText(reactiveHook)} will be lost after each ` +
             `render. To preserve the value over time, store it in a useRef ` +
             `Hook and keep the mutable value in the '.current' property. ` +
             `Otherwise, you can move this variable directly inside ` +
-            `${context.getSource(reactiveHook)}.`,
+            `${sourceCode.getText(reactiveHook)}.`,
         });
       }
 
@@ -630,7 +632,7 @@ export default {
         reportProblem({
           node: declaredDependenciesNode,
           message:
-            `React Hook ${context.getSource(reactiveHook)} was passed a ` +
+            `React Hook ${sourceCode.getText(reactiveHook)} was passed a ` +
             'dependency list that is not an array literal. This means we ' +
             "can't statically verify whether you've passed the correct " +
             'dependencies.',
@@ -650,7 +652,7 @@ export default {
             reportProblem({
               node: declaredDependencyNode,
               message:
-                `React Hook ${context.getSource(reactiveHook)} has a spread ` +
+                `React Hook ${sourceCode.getText(reactiveHook)} has a spread ` +
                 "element in its dependency array. This means we can't " +
                 "statically verify whether you've passed the " +
                 'correct dependencies.',
@@ -662,12 +664,12 @@ export default {
               node: declaredDependencyNode,
               message:
                 'Functions returned from `useEffectEvent` must not be included in the dependency array. ' +
-                `Remove \`${context.getSource(
+                `Remove \`${sourceCode.getText(
                   declaredDependencyNode,
                 )}\` from the list.`,
               suggest: [
                 {
-                  desc: `Remove the dependency \`${context.getSource(
+                  desc: `Remove the dependency \`${sourceCode.getText(
                     declaredDependencyNode,
                   )}\``,
                   fix(fixer) {
@@ -708,7 +710,7 @@ export default {
                 reportProblem({
                   node: declaredDependencyNode,
                   message:
-                    `React Hook ${context.getSource(reactiveHook)} has a ` +
+                    `React Hook ${sourceCode.getText(reactiveHook)} has a ` +
                     `complex expression in the dependency array. ` +
                     'Extract it to a separate variable so it can be statically checked.',
                 });
@@ -978,7 +980,7 @@ export default {
             ` However, 'props' will change when *any* prop changes, so the ` +
             `preferred fix is to destructure the 'props' object outside of ` +
             `the ${reactiveHookName} call and refer to those specific props ` +
-            `inside ${context.getSource(reactiveHook)}.`;
+            `inside ${sourceCode.getText(reactiveHook)}.`;
         }
       }
 
@@ -1128,7 +1130,7 @@ export default {
       reportProblem({
         node: declaredDependenciesNode,
         message:
-          `React Hook ${context.getSource(reactiveHook)} has ` +
+          `React Hook ${sourceCode.getText(reactiveHook)} has ` +
           // To avoid a long message, show the next actionable item.
           (getWarningMessage(missingDependencies, 'a', 'missing', 'include') ||
             getWarningMessage(
@@ -1250,7 +1252,10 @@ export default {
             return; // Handled
           }
           // We'll do our best effort to find it, complain otherwise.
-          const variable = context.getScope().set.get(callback.name);
+          const scope = sourceCode.getScope
+            ? sourceCode.getScope(node)
+            : context.getScope();
+          const variable = scope.set.get(callback.name);
           if (variable == null || variable.defs == null) {
             // If it's not in scope, we don't care.
             return; // Handled
diff --git a/packages/eslint-plugin-react-hooks/src/RulesOfHooks.js b/packages/eslint-plugin-react-hooks/src/RulesOfHooks.js
index bdc23f9f885c..e4decfdccc66 100644
--- a/packages/eslint-plugin-react-hooks/src/RulesOfHooks.js
+++ b/packages/eslint-plugin-react-hooks/src/RulesOfHooks.js
@@ -125,6 +125,13 @@ export default {
     const codePathReactHooksMapStack = [];
     const codePathSegmentStack = [];
     const useEffectEventFunctions = new WeakSet();
+    const sourceCode = context.sourceCode ?? context.getSourceCode();
+
+    function getScope(node) {
+      return sourceCode.getScope
+        ? sourceCode.getScope(node)
+        : context.getScope();
+    }
 
     // For a given scope, iterate through the references and add all useEffectEvent definitions. We can
     // do this in non-Program nodes because we can rely on the assumption that useEffectEvent functions
@@ -466,7 +473,7 @@ export default {
               context.report({
                 node: hook,
                 message:
-                  `React Hook "${context.getSource(hook)}" may be executed ` +
+                  `React Hook "${sourceCode.getText(hook)}" may be executed ` +
                   'more than once. Possibly because it is called in a loop. ' +
                   'React Hooks must be called in the exact same order in ' +
                   'every component render.',
@@ -485,7 +492,7 @@ export default {
                 context.report({
                   node: hook,
                   message:
-                    `React Hook "${context.getSource(hook)}" cannot be ` +
+                    `React Hook "${sourceCode.getText(hook)}" cannot be ` +
                     'called in an async function.',
                 });
               }
@@ -500,7 +507,7 @@ export default {
                 !isUseIdentifier(hook) // `use(...)` can be called conditionally.
               ) {
                 const message =
-                  `React Hook "${context.getSource(hook)}" is called ` +
+                  `React Hook "${sourceCode.getText(hook)}" is called ` +
                   'conditionally. React Hooks must be called in the exact ' +
                   'same order in every component render.' +
                   (possiblyHasEarlyReturn
@@ -517,15 +524,15 @@ export default {
             ) {
               // Custom message for hooks inside a class
               const message =
-                `React Hook "${context.getSource(hook)}" cannot be called ` +
+                `React Hook "${sourceCode.getText(hook)}" cannot be called ` +
                 'in a class component. React Hooks must be called in a ' +
                 'React function component or a custom React Hook function.';
               context.report({node: hook, message});
             } else if (codePathFunctionName) {
               // Custom message if we found an invalid function name.
               const message =
-                `React Hook "${context.getSource(hook)}" is called in ` +
-                `function "${context.getSource(codePathFunctionName)}" ` +
+                `React Hook "${sourceCode.getText(hook)}" is called in ` +
+                `function "${sourceCode.getText(codePathFunctionName)}" ` +
                 'that is neither a React function component nor a custom ' +
                 'React Hook function.' +
                 ' React component names must start with an uppercase letter.' +
@@ -534,7 +541,7 @@ export default {
             } else if (codePathNode.type === 'Program') {
               // These are dangerous if you have inline requires enabled.
               const message =
-                `React Hook "${context.getSource(hook)}" cannot be called ` +
+                `React Hook "${sourceCode.getText(hook)}" cannot be called ` +
                 'at the top level. React Hooks must be called in a ' +
                 'React function component or a custom React Hook function.';
               context.report({node: hook, message});
@@ -547,7 +554,7 @@ export default {
               // `use(...)` can be called in callbacks.
               if (isSomewhereInsideComponentOrHook && !isUseIdentifier(hook)) {
                 const message =
-                  `React Hook "${context.getSource(hook)}" cannot be called ` +
+                  `React Hook "${sourceCode.getText(hook)}" cannot be called ` +
                   'inside a callback. React Hooks must be called in a ' +
                   'React function component or a custom React Hook function.';
                 context.report({node: hook, message});
@@ -600,7 +607,7 @@ export default {
           context.report({
             node,
             message:
-              `\`${context.getSource(
+              `\`${sourceCode.getText(
                 node,
               )}\` is a function created with React Hook "useEffectEvent", and can only be called from ` +
               'the same component. They cannot be assigned to variables or passed down.',
@@ -617,14 +624,14 @@ export default {
       FunctionDeclaration(node) {
         // function MyComponent() { const onClick = useEffectEvent(...) }
         if (isInsideComponentOrHook(node)) {
-          recordAllUseEffectEventFunctions(context.getScope());
+          recordAllUseEffectEventFunctions(getScope(node));
         }
       },
 
       ArrowFunctionExpression(node) {
         // const MyComponent = () => { const onClick = useEffectEvent(...) }
         if (isInsideComponentOrHook(node)) {
-          recordAllUseEffectEventFunctions(context.getScope());
+          recordAllUseEffectEventFunctions(getScope(node));
         }
       },
     };
