@putout/plugin-remove-useless-array-constructor
🐊Putout plugin adds ability to remove useless Array constructor
Last updated 3 years ago by coderaiser .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install @putout/plugin-remove-useless-array-constructor 
SYNC missed versions from official npm registry.

@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

Current Tags

  • 3.0.0                                ...           latest (2 years ago)

4 Versions

  • 3.0.0                                ...           2 years ago
  • 2.0.0                                ...           3 years ago
  • 1.1.0                                ...           6 years ago
  • 1.0.0                                ...           6 years ago
Maintainers (1)
Downloads
Total 6
Today 0
This Week 0
This Month 6
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (6)
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE