no-new-wrappers
eslint
No autofix
eslint.config.js
export default [
{
rules: {
"no-new-wrappers": "error",
},
},
];Disallow new operators with the String, Number, and Boolean objects
const stringObject = new String("Hello world");
const numberObject = new Number(33);
const booleanObject = new Boolean(false);
const stringObject2 = new String;
const numberObject2 = new Number;
const booleanObject2 = new Boolean;const text = String(someValue);
const num = Number(someValue);
const object = new MyString();Examples from the ESLint documentation.
no-new-wrappers
eslint
export default [
{
rules: {
"no-new-wrappers": "error",
},
},
];no-new-wrappers
eslint plugin · pedantic
{
"rules": {
"no-new-wrappers": "error"
}
}style/useConsistentBuiltinInstantiation
style · since 1.7.2
{
"linter": {
"rules": {
"style": {
"useConsistentBuiltinInstantiation": "error"
}
}
}
}Disallow unnecessary calls to .bind()
Disallow new operators with the Function object
Disallow throwing literals as exceptions
Disallow unnecessary computed property keys in objects and classes