版本号:
vue/cli:4.5.12
eslint: 6.7.2
问题
ESLint升级后如下错误:
Do not access Object.prototype method ‘hasOwnProperty’ from target object no-prototype-bui
// 错误代码
for (let Key in OPTIONS) {
if (OPTIONS.hasOwnProperty(Key) === true) {
...
}
}
解决方案
for (let Key in OPTIONS) {
if (Object.prototype.hasOwnProperty.call(OPTIONS, Key) === true) {
...
}
}
参考博客:
Do not access Object.prototype method ‘hasOwnProperty’ from target object no-prototype-builtins