Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add automatic tslint fixers #2242

Merged
merged 3 commits into from
Jun 7, 2018
Merged

Add automatic tslint fixers #2242

merged 3 commits into from
Jun 7, 2018

Conversation

lukastaegert
Copy link
Member

This will add tslint to our setup and to the commit hook. However, as we already have prettier, this PR solely introduces some hand-picked semantic rules that prettier cannot cover:

  • prefer-const: This replaces let with const if possible. const is usually slightly faster in V8
  • ordered-imports: Probably the biggest diff. Imports are sorted so that similar imports are next to each other and removing and re-adding an import will put it in the same position.
  • arrow-return-shorthand: Replaces ()=>{return 1} with ()=>1.
  • no-string-literal: Replaces x['y'] with x.y which should be better optimized
  • object-literal-shorthand: Replaces {x: x} with {x}
  • no-unnecessary-type-assertion: Removes all unnecessary TS type casts!
  • interface-over-type-literal: Replaces types with interfaces (which are e.g. extensible) wherever possible

All of these rules have automatic fixers and are applied automatically on commit. I have put the application of the rules into a separate commit that can be easily undone so that we can remove/add rules.

Copy link
Contributor

@guybedford guybedford left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

Looking through, wondering if we should include no-unused-variable or prefer-object-spread as well.

@lukastaegert
Copy link
Member Author

Good idea, added!

@lukastaegert lukastaegert merged commit bac311c into master Jun 7, 2018
@lukastaegert lukastaegert deleted the linting branch June 7, 2018 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants