dabbott / vscode-import-js

VSCode extension for ImportJS
23 stars 10 forks source link

The extension merges output of importjs and existing content incorrectly #10

Closed hibikiledo closed 6 years ago

hibikiledo commented 6 years ago

To reproduce the issue

  1. Clone https://github.com/hibikiledo/vscode-import-js-issue
  2. Install the following versions of importjs and importjs-vs-code
    • importjs version 3.0.0
    • importjs-vs-code 0.0.10
  3. Open file with-issue.js and use ImportJS: Fix Imports command

Expected Result

import I18n from './common/I18n';

function Hello () {
  return I18n.t('key')
}

Actual Result

import I18n from './common/I18n';

  return I18n.t('key')
}

I believe this is the issue with the extension.
When calling importjs directly with the command below,

importjs fix ./src/with-issue.js

importjs returns the correct value of fileContent

{"messages":["Imported I18n from './common/I18n'"],"fileContent":"import I18n from './common/I18n';\n\nfunction Hello () {\n  return I18n.t('key')\n}\n","unresolvedImports":{}}