@putout/plugin-remove-useless-array-constructor

2.0.0 • Public • Published

@putout/plugin-remove-useless-array-constructor NPM version

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:

const a = new Array(2); // [undefined, undefined]
const b = new Array(2, 3); // [2, 3];

Install

npm i @putout/plugin-remove-useless-array-constructor -D

Rule

{
    "rules": {
        "remove-useless-array-constructor": "on"
    }
}

Example of incorrect code

const a = Array(1, 2, 3);

Example of correct code

const a = [1, 2, 3];

Comparison

Linter Rule Fix
🐊 Putout remove-useless-array-constructor
ESLint no-array-constructor

License

MIT

Package Sidebar

Install

npm i @putout/plugin-remove-useless-array-constructor

Weekly Downloads

16,219

Version

2.0.0

License

MIT

Unpacked Size

4.83 kB

Total Files

4

Last publish

Collaborators

  • coderaiser