]> git.proxmox.com Git - pve-eslint.git/blobdiff - eslint/lib/rules/radix.js
import 8.41.0 source
[pve-eslint.git] / eslint / lib / rules / radix.js
index 0618d9844ad295aa78c4b1748780c9a236a2efc9..7df97d986025298935c12f60d407c9ea4f23e0cd 100644 (file)
@@ -82,7 +82,7 @@ module.exports = {
         docs: {
             description: "Enforce the consistent use of the radix argument when using `parseInt()`",
             recommended: false,
-            url: "https://eslint.org/docs/rules/radix"
+            url: "https://eslint.org/docs/latest/rules/radix"
         },
 
         hasSuggestions: true,
@@ -104,6 +104,7 @@ module.exports = {
 
     create(context) {
         const mode = context.options[0] || MODE_ALWAYS;
+        const sourceCode = context.sourceCode;
 
         /**
          * Checks the arguments of a given CallExpression node and reports it if it
@@ -131,7 +132,6 @@ module.exports = {
                                 {
                                     messageId: "addRadixParameter10",
                                     fix(fixer) {
-                                        const sourceCode = context.getSourceCode();
                                         const tokens = sourceCode.getTokens(node);
                                         const lastToken = tokens[tokens.length - 1]; // Parenthesis.
                                         const secondToLastToken = tokens[tokens.length - 2]; // May or may not be a comma.
@@ -162,18 +162,18 @@ module.exports = {
         }
 
         return {
-            "Program:exit"() {
-                const scope = context.getScope();
+            "Program:exit"(node) {
+                const scope = sourceCode.getScope(node);
                 let variable;
 
                 // Check `parseInt()`
                 variable = astUtils.getVariableByName(scope, "parseInt");
                 if (variable && !isShadowed(variable)) {
                     variable.references.forEach(reference => {
-                        const node = reference.identifier;
+                        const idNode = reference.identifier;
 
-                        if (astUtils.isCallee(node)) {
-                            checkArguments(node.parent);
+                        if (astUtils.isCallee(idNode)) {
+                            checkArguments(idNode.parent);
                         }
                     });
                 }
@@ -182,12 +182,12 @@ module.exports = {
                 variable = astUtils.getVariableByName(scope, "Number");
                 if (variable && !isShadowed(variable)) {
                     variable.references.forEach(reference => {
-                        const node = reference.identifier.parent;
-                        const maybeCallee = node.parent.type === "ChainExpression"
-                            ? node.parent
-                            : node;
+                        const parentNode = reference.identifier.parent;
+                        const maybeCallee = parentNode.parent.type === "ChainExpression"
+                            ? parentNode.parent
+                            : parentNode;
 
-                        if (isParseIntMethod(node) && astUtils.isCallee(maybeCallee)) {
+                        if (isParseIntMethod(parentNode) && astUtils.isCallee(maybeCallee)) {
                             checkArguments(maybeCallee.parent);
                         }
                     });