Giter VIP home page Giter VIP logo

js-import's People

Contributors

arnebab avatar jakoblind avatar renatofdds 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  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

js-import's Issues

Sometimes the import is placed inside a method instead of at the top of the file

Have a file bar.js:

export const here = 1;

And foo.js:

here;

export class SomeClass {

  _logfail (error) {
    logger.error('Failed to import uploaded files', error);
  }
  _cancel () {
    this._setImportingState(false);
    clearUploaded(this._mapId)
      .then(() => logger.debug(` for `))
      .catch(error => logger.error('failed', error));
    this._somethingElse();
  }
}

Place the cursor on here; and call C-u M-x js-import. Select bar.js.

The import lands before this._somethingElse() instead of at the top of the file;

Breaks without "dependencies" key on package.json

If there's not a "dependencies" key on "package.json" json-import breaks because it expects it to create a hash table. It should support projects without it.
It would be great to add support for "devDependencies" with a custom variable too.

Does not handle trailing commas

When there are imports as follows:

import {
  IonButton,
  IonContent,
} from '@ionic/react'

Importing IonGrid for example produces the following result.

import {
  IonButton,
  IonContent,, IonGrid 
} from '@ionic/react'

This causes an error. It would be useful if a trailing comma will be detected and no extra comma is added before the newly added import.

imports from project root (non-relative)

Currently if I have a filesystem layout like

src/foobar/
  bar/bar.js
  foo/foo.js

and I am in foo/foo.js, js-import adds imports relative to the current file, similar to this:

`import { foo } from '../bar/bar';

However we use:

`import { foo } from 'foobar/bar/bar';

I always fix that manually, but that’s annoying.

It would be great if I could define a project root (here src/) — or even better if it could detect the root from a jsconfig.json or similar — and then have automatic imports from project-root.

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.