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

Switch import management from Typescript Hero to import-sort #16

Merged
merged 3 commits into from
Jan 3, 2019

Conversation

brendoncaulkins
Copy link
Collaborator

@brendoncaulkins brendoncaulkins commented Dec 22, 2018

TypescriptHero only applies it's changes on save, it does not apply changes when `standardize is run via the CLI because there is no way to run TypescriptHero from the command line. These two tools can also have disagreements when it comes to single imports that exceed the maximum line length (one enforces a wrap, one allows the line to exceed). This can cause extra line changes on PRs that muddy the review process and can lead to mistakes or import issues slipping through.

import-sort performs a similar function regarding managing imports but offers a CLI option as well, so it can be run before prettier on CLI functions. This way, the VSCode changes on save sync with the CLI actions during the (updated) standardize script. Settings are kept in package.json just like prettier.

NOTE: One downside to import-sort is that it does not automatically remove unused imports, so those must be managed manually. Luckily, VSCode now highlights those, and they are not difficult to identify.

I've chosen the module sort style for typescript. It groups imports by source module, and separates imports from external libraries and imports from local files with an empty line, which is a nice distinction, in my opinion. There are alternate sort styles available.

References:
https://github.com/renke/import-sort

@duluca
Copy link
Owner

duluca commented Jan 3, 2019

@brendoncaulkins thank you

@duluca duluca merged commit a108c8b into duluca:master Jan 3, 2019
@brendoncaulkins brendoncaulkins deleted the sort-imports branch January 9, 2019 01:25
This pull request was closed.
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.

2 participants