Giter Site home page Giter Site logo

vscode-import-js's Introduction

VS Code ImportJS extension

This is the VS Code extension for ImportJS.

Installing

  1. Install import-js globally:

    npm install --global import-js
  2. Configure ImportJS for your project

  3. Open the root directory of your project (File -> Open…)

  4. Import a file!

Default keybindings

By default, vscode-import-js attempts to set up the following keybindings:

Mapping Action Description
Cmd+Shift+j Import word Import the module for the variable under the cursor.
Cmd+Shift+i Fix imports Import any missing modules and remove any modules that are not used.
Cmd+Shift+k Go to word Go to the module of the variable under the cursor.

vscode-import-js's People

Contributors

dabbott avatar feifanzhou avatar trotzig avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

vscode-import-js's Issues

Installation directly from vscode

This is more of a question than an issue. I was giving a brief talk on import-js during http://nordicjs.com/ last week. As part of the preparation, I was making animated gifs of import-js in action. In the past, I've only tried running vscode-import-js from source code, not as an installed extension. But this time I thought I'd try installing it the "proper" way through the Extensions UI. However, none of the searches I could come up made vscode-import-js show up in the results. Is there something we have to do in order to fix that?

Does not import missing modules

So, I have two files, client.js and home.js

When I press ctrl+shift+i, it says, imported { Home } from './home.js' on the status line, but all it actually does is delete all my other imports on the first line.

Import statement is removed when another variable is added

πŸ‘‹

This is a carry-over from an issue reported in the upstream import-js project:
Galooshi/import-js#467

If I have a file with an existing import statement

import { foo } from './foobar';

foo();
bar();

then if I try to import bar, which is a named export of the ./foobar.js file, I get this:

foo();
bar();

Other plugins (e.g. vim, sublime) correctly combines the two variables in one statement:

import { bar, foo } from './foobar';

foo();
bar();

The extension merges output of importjs and existing content incorrectly

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
  1. 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":{}}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.