Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

prefer-array-literal: catch new Array(10) but not Array(10) #839

Closed
sangheestyle opened this issue Mar 7, 2019 · 1 comment · Fixed by #842
Closed

prefer-array-literal: catch new Array(10) but not Array(10) #839

sangheestyle opened this issue Mar 7, 2019 · 1 comment · Fixed by #842
Labels
Difficulty: Easy Someone with little to no experience in TSLint should be able to send a pull request for this issue. Status: Accepting PRs Type: Breaking Change Type: Bug
Milestone

Comments

@sangheestyle
Copy link
Contributor

sangheestyle commented Mar 7, 2019

Bug Report

  • tslint-microsoft-contrib version: 6.1.0
  • TSLint version: 5.11.0
  • TypeScript version: 3.3.3333
  • Running TSLint via: (pick one) Node.js

TypeScript code being linted

const caseA = new Array(10);
const caseB = Array(10);

with tslint.json configuration:

{
    "extends": ["tslint-microsoft-contrib/latest"]
}

Actual behavior

With tslint -c tslint.json -p tsconfig.json, Array(10) didn't detected.

ERROR: ... : Replace Array constructor with an array literal: new Array(10)

Expected behavior

With tslint -c tslint.json -p tsconfig.json, both cases should be detected.

ERROR: ... : Replace Array constructor with an array literal: new Array(10)
ERROR: ... : Replace Array function with an array literal: Array(10)
@JoshuaKGoldberg JoshuaKGoldberg added Type: Bug Status: Accepting PRs Difficulty: Easy Someone with little to no experience in TSLint should be able to send a pull request for this issue. Type: Breaking Change labels Mar 10, 2019
@JoshuaKGoldberg
Copy link

Good find! Looks like the rule checks nodes that are NewExpressions but not CallExpressions.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Difficulty: Easy Someone with little to no experience in TSLint should be able to send a pull request for this issue. Status: Accepting PRs Type: Breaking Change Type: Bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants