microsoft / tslint-microsoft-contrib

A set of TSLint rules used on some Microsoft projects.
MIT License
702 stars 198 forks source link

Improve prefer-array-literal rule #862

Closed IllusionMH closed 5 years ago

IllusionMH commented 5 years ago

PR checklist

Overview of change:

  1. Updated tslint test for rule
  2. It is forbidden to call Array only like Array, window.Array, global.Array, and globalThis.Array. Other namespaces are allowed.
  3. Allow calls with single number parameter

Is there anything you'd like reviewers to focus on?

I haven't included self from Web Wrokers to list of restricted parents for property access expression because of var self = this pattern. Should I include self too?

Any suggesting what should trigger error for single parameter if type checker is not available? I think that allowing everything without type checker (like ESLint does) and expect anything assignable to number if checker available will be good enough.

Code is ready for review, ~but I still need to add options description to rule meta and update README.md with new option.~

IllusionMH commented 5 years ago

Thank you for feedback and review!