Skip to main content

no-array-constructor

Disallow generic Array constructors.

🔧

Some problems reported by this rule are automatically fixable by the --fix ESLint command line option.

Examples

This rule extends the base eslint/no-array-constructor rule. It adds support for the generically typed Array constructor (new Array<Foo>()).

/*eslint no-array-constructor: "error"*/

Array(0, 1, 2);
new Array(0, 1, 2);

How to Use

.eslintrc.cjs
module.exports = {
"rules": {
// Note: you must disable the base rule as it can report incorrect errors
"no-array-constructor": "off",
"@typescript-eslint/no-array-constructor": "error"
}
};

Options

See eslint/no-array-constructor options.

Taken with ❤️ from ESLint core

Resources