no-array-constructor
eslint
Safe autofix
eslint.config.js
export default [
{
rules: {
"no-array-constructor": "error",
},
},
];Array();
Array(0, 1, 2);
new Array(0, 1, 2);
Array(...args);new Array();
new Array(0, 1, 2);
Array?.(x, y);
Array?.(0, 1, 2);Array(500);
new Array(someOtherArray.length);
[0, 1, 2];
const createArray = Array => new Array();new Array<number>(1, 2, 3);
new Array<Foo>();
Array<number>(1, 2, 3);
Array<Foo>();
Array?.foo();Examples from the ESLint documentation.
no-array-constructor
eslint
export default [
{
rules: {
"no-array-constructor": "error",
},
},
];no-array-constructor
eslint plugin · pedantic
{
"rules": {
"no-array-constructor": "error"
}
}style/useArrayLiterals
style · since 1.7.2
{
"linter": {
"rules": {
"style": {
"useArrayLiterals": "error"
}
}
}
}Disallow generic Array constructors
Enforce default clauses in switch statements to be last
Require constructor names to begin with a capital letter
Disallow use of the RegExp constructor in favor of regular expression literals
Disallow labels that share a name with a variable