SoominHan / import-sorter

MIT License
87 stars 28 forks source link

Add ability to exclude some unused imports #59

Closed adetoola closed 4 years ago

adetoola commented 4 years ago

When working in some projects like a react based project, you might need to import react with specifically using it in that file.

import React from 'react';

const App = () => <p>I love import sorter</p>

Unfortunately, import sorter will remove that import statement causing your code to throw an error.

SanderDeWaal1992 commented 4 years ago

What user settings do you have configured? For me it doesn't do this with default settings.

adetoola commented 4 years ago

I have "importSorter.sortConfiguration.removeUnusedDefaultImports" set to true and forgot about it. Thanks for pointing that out.

However, it will be nice if you can add exemptions to this rule with regex.

SanderDeWaal1992 commented 4 years ago

True. There has already been an issue for this #41 (closed) and also a PR #42 (maintainer is not going to merge it in as it looks now). Probably can close this issue too, or you have to convince the maintainer that it has enough value. For me it has value because of #49.