Skip to content

Commit 0efc746

Browse files
committed
use map instead of object
1 parent bf4637b commit 0efc746

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

lib/rules/no-runloop.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ module.exports = {
7575
// List of allowed runloop functions
7676
const allowList = context.options[0]?.allowList ?? [];
7777
// Maps local names to imported names of imports
78-
const localToImportedNameMap = {};
78+
const localToImportedNameMap = new Map();
7979

8080
/**
8181
* Reports a node with usage of a disallowed runloop function
@@ -107,7 +107,7 @@ module.exports = {
107107
if (spec.type === 'ImportSpecifier') {
108108
const importedName = spec.imported.name;
109109
if (EMBER_RUNLOOP_FUNCTIONS.includes(importedName)) {
110-
localToImportedNameMap[spec.local.name] = importedName;
110+
localToImportedNameMap.set(spec.local.name, importedName);
111111
}
112112
}
113113
}
@@ -118,9 +118,8 @@ module.exports = {
118118
// Examples: run(...), later(...)
119119
if (node.callee.type === 'Identifier') {
120120
const name = node.callee.name;
121-
const runloopFn = localToImportedNameMap[name];
122-
const isNotAllowed =
123-
runloopFn && !allowList.includes(runloopFn) && !Object.prototype.hasOwnProperty(name);
121+
const runloopFn = localToImportedNameMap.get(name);
122+
const isNotAllowed = runloopFn && !allowList.includes(runloopFn);
124123
if (isNotAllowed) {
125124
report(node, runloopFn, name);
126125
}
@@ -130,7 +129,7 @@ module.exports = {
130129
// Examples: run.later(...), run.schedule(...)
131130
if (node.callee.type === 'MemberExpression' && node.callee.object?.type === 'Identifier') {
132131
const objectName = node.callee.object.name;
133-
const objectRunloopFn = localToImportedNameMap[objectName];
132+
const objectRunloopFn = localToImportedNameMap.get(objectName);
134133

135134
if (objectRunloopFn === 'run' && node.callee.property?.type === 'Identifier') {
136135
const runloopFn = node.callee.property.name;

0 commit comments

Comments
 (0)