Use-Array-Literal¶
Sourcery rule id: use-array-literal
¶
Description¶
Use literal syntax for array creation.
Before¶
const items = new Array();
After¶
const items = [];
Explanation¶
Use of the Array constructor to construct a new array is generally discouraged in favor of array literal notation because of the single-argument pitfall and because the Array global may be redefined. The exception is when the Array constructor is used to intentionally create sparse arrays of a specified size by giving the constructor a single numeric argument.
From ESLint From the Airbnb JavaScript Style Guide