no-object-constructor
eslint
Suggestion
eslint.config.js
export default [
{
rules: {
"no-object-constructor": "error",
},
},
];Disallow calls to the Object constructor without an argument
Object();
new Object();Object("foo");
const obj = { a: 1, b: 2 };
const isObject = value => value === Object(value);
const createObject = Object => new Object();Examples from the ESLint documentation.
no-object-constructor
eslint
export default [
{
rules: {
"no-object-constructor": "error",
},
},
];no-object-constructor
eslint plugin · pedantic
{
"rules": {
"no-object-constructor": "error"
}
}nursery/noObjectConstructor
nursery · since 2.6.0
{
"linter": {
"rules": {
"nursery": {
"noObjectConstructor": "error"
}
}
}
}Enforce a maximum depth that callbacks can be nested
Enforce a maximum cyclomatic complexity allowed in a program
Disallow equal signs explicitly at the beginning of regular expressions
Enforce the use of u or v flag on regular expressions
Disallow use of Object.prototype.hasOwnProperty.call() and prefer use of Object.hasOwn()
Disallow declarations in the global scope