prefer-object-has-own
eslint
Safe autofix
eslint.config.js
export default [
{
rules: {
"prefer-object-has-own": "error",
},
},
];Disallow use of Object.prototype.hasOwnProperty.call() and prefer use of Object.hasOwn()
Object.prototype.hasOwnProperty.call(obj, "a");
Object.hasOwnProperty.call(obj, "a");
({}).hasOwnProperty.call(obj, "a");
const hasProperty = Object.prototype.hasOwnProperty.call(object, property);Object.hasOwn(obj, "a");
const hasProperty = Object.hasOwn(object, property);Examples from the ESLint documentation.
prefer-object-has-own
eslint
export default [
{
rules: {
"prefer-object-has-own": "error",
},
},
];prefer-object-has-own
eslint plugin · style
{
"rules": {
"prefer-object-has-own": "error"
}
}suspicious/noPrototypeBuiltins
suspicious · since 1.1.0
{
"linter": {
"rules": {
"suspicious": {
"noPrototypeBuiltins": "error"
}
}
}
}Enforce the use of u or v flag on regular expressions
Enforce a maximum cyclomatic complexity allowed in a program
Enforce a maximum depth that callbacks can be nested
Disallow declarations in the global scope
Disallow calls to the Object constructor without an argument
Disallow null comparisons without type-checking operators