Galooshi / import-js

A tool to simplify importing JS modules
MIT License
525 stars 55 forks source link

Invalid import of module url is added processing Flow type #495

Closed verkholantsev closed 9 months ago

verkholantsev commented 6 years ago

Hey there, thank you for import-js! Looks like I've found an issue, please read the description.

Prerequisites

Step one. Create example.js with this content

// example.js
type T = url => null;

Step two. Run importjs.

$ importjs fix example.js
{"messages":["Imported url from 'url'"],"fileContent":"import url from 'url';\n\ntype T = url => null;\n","unresolvedImports":{}}

Expected behaviour

No imports is added.

Actual behaviour

Import of module url is added to fileContent

Config

// .importjs.js
module.exports = {
    environments: ['node'],
    declarationKeyword: 'import',
};

Version

$ importjs --version
2.10.1

Please let me know if you need more details.

trotzig commented 6 years ago

Thanks for the report! That does indeed look like a bug. I'd be happy to review a PR fixing things if anyone has the bandwidth to take it on.

mikabytes commented 9 months ago

You'll need to add the --overwrite flag to importjs for the import to be written back to file. Like this:

importjs fix --overwrite example.js

It adds the import url from 'url' as expected.

Closing this, but if you need more guidance feel free to reopen. Thanks.