Skip to content

Commit 291f88a

Browse files
committed
Fix false positive error in no-runloop validator
1 parent be09821 commit 291f88a

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

lib/rules/no-runloop.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ module.exports = {
119119
if (node.callee.type === 'Identifier') {
120120
const name = node.callee.name;
121121
const runloopFn = localToImportedNameMap[name];
122-
const isNotAllowed = runloopFn && !allowList.includes(runloopFn);
122+
const isNotAllowed = runloopFn && !allowList.includes(runloopFn) && !Object.prototype.hasOwnProperty.call(Object.prototype, name);
123123
if (isNotAllowed) {
124124
report(node, runloopFn, name);
125125
}

tests/lib/rules/no-runloop.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,28 @@ eslintTester.run('no-runloop', rule, {
6565
`,
6666
options: [{ allowList: ['later'] }],
6767
},
68+
`
69+
function hasOwnProperty() {};
70+
hasOwnProperty();
71+
72+
function isPrototypeOf() {};
73+
isPrototypeOf();
74+
75+
function propertyIsEnumerable() {};
76+
propertyIsEnumerable();
77+
78+
function toLocaleString() {};
79+
toLocaleString();
80+
81+
function toString() {};
82+
toString();
83+
84+
function valueOf() {};
85+
valueOf();
86+
87+
function constructor() {};
88+
constructor();
89+
`,
6890
],
6991
invalid: [
7092
{

0 commit comments

Comments
 (0)