Skip to content

Latest commit

 

History

History
43 lines (29 loc) · 1.03 KB

no-array-constructor.md

File metadata and controls

43 lines (29 loc) · 1.03 KB

Disallow generic Array constructors (no-array-constructor)

Rule Details

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

Examples of incorrect code for this rule:

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

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

Examples of correct code for this rule:

/*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