Use-Array-Literal
Documentation Index
Fetch the complete documentation index at: https://docs.sourcery.ai/llms.txt
Use this file to discover all available pages before exploring further.
Sourcery rule id: use-array-literal
Section titled “Sourcery rule id: use-array-literal”Description
Section titled “Description”Use literal syntax for array creation.
Before
Section titled “Before”const items = new Array();const items = [];Explanation
Section titled “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