🐊Putout plugin adds ability to remove useless Array constructor
npm install @putout/plugin-remove-useless-array-constructor[NPMIMGURL]: https://img.shields.io/npm/v/@putout/plugin-remove-useless-array-constructor.svg?style=flat&longCache=true
[NPMURL]: https://npmjs.org/package/@putout/plugin-remove-useless-array-constructor "npm"
> TypeScript code must not use the Array() constructor, with or without new. It has confusing and contradictory usage.
>
> (c) Google TypeScript Style Guide
🐊Putout plugin removes useless Array constructor.
It has a different meaning for one, and couple arguments:
``js`
const a = new Array(2); // [undefined, undefined]
const b = new Array(2, 3); // [2, 3];
``
npm i @putout/plugin-remove-useless-array-constructor -D
`json`
{
"rules": {
"remove-useless-array-constructor": "on"
}
}
`js`
const a = Array(1, 2, 3);
`js`
const a = [1, 2, 3];
Linter | Rule | Fix
--------|-------|------------|
🐊 Putout| remove-useless-array-constructor| ✅
⏣ ESLint | no-array-constructor` | ❌
MIT