diff --git a/lib/rules/no-runloop.js b/lib/rules/no-runloop.js index f0fd1ef7b7..b889bf390d 100644 --- a/lib/rules/no-runloop.js +++ b/lib/rules/no-runloop.js @@ -75,7 +75,7 @@ module.exports = { // List of allowed runloop functions const allowList = context.options[0]?.allowList ?? []; // Maps local names to imported names of imports - const localToImportedNameMap = {}; + const localToImportedNameMap = new Map(); /** * Reports a node with usage of a disallowed runloop function @@ -107,7 +107,7 @@ module.exports = { if (spec.type === 'ImportSpecifier') { const importedName = spec.imported.name; if (EMBER_RUNLOOP_FUNCTIONS.includes(importedName)) { - localToImportedNameMap[spec.local.name] = importedName; + localToImportedNameMap.set(spec.local.name, importedName); } } } @@ -118,9 +118,8 @@ module.exports = { // Examples: run(...), later(...) if (node.callee.type === 'Identifier') { const name = node.callee.name; - const runloopFn = localToImportedNameMap[name]; - const isNotAllowed = - runloopFn && !allowList.includes(runloopFn) && !Object.prototype.hasOwnProperty(name); + const runloopFn = localToImportedNameMap.get(name); + const isNotAllowed = runloopFn && !allowList.includes(runloopFn); if (isNotAllowed) { report(node, runloopFn, name); } @@ -130,7 +129,7 @@ module.exports = { // Examples: run.later(...), run.schedule(...) if (node.callee.type === 'MemberExpression' && node.callee.object?.type === 'Identifier') { const objectName = node.callee.object.name; - const objectRunloopFn = localToImportedNameMap[objectName]; + const objectRunloopFn = localToImportedNameMap.get(objectName); if (objectRunloopFn === 'run' && node.callee.property?.type === 'Identifier') { const runloopFn = node.callee.property.name;