no-array-constructor
Disallows generic Array
constructors.
Attributes
- Included in configs
- ✅ Recommended
- 🔒 Strict
- Fixable
- 🔧 Automated Fixer
- 🛠 Suggestion Fixer
- 💭 Requires type information
Rule Details
This rule extends the base eslint/no-array-constructor
rule.
It adds support for the generically typed Array
constructor (new Array<Foo>()
).
- ❌ Incorrect
- ✅ Correct
/*eslint no-array-constructor: "error"*/
Array(0, 1, 2);
new Array(0, 1, 2);
/*eslint no-array-constructor: "error"*/
Array<number>(0, 1, 2);
new Array<Foo>(x, y, z);
Array(500);
new Array(someOtherArray.length);
How to Use
{
// 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