import-js

A tool to simplify importing JS modules

MIT License

Downloads
1.2K
Stars
525
Committers
31

Bot releases are hidden (Show)

import-js - 0.6.0

Published by trotzig over 8 years ago

Two new configuration options added in this release:

  • group_imports - set to false to disable the default behavior of grouping imports
  • environments - set to ["node"] to get access to core modules for Node.js

Apart from that, the Sublime plugin should now be easier to get up and running thanks to work by @lencioni.

import-js - 0.5.1

Published by trotzig over 8 years ago

Changes:

  • Fix issue with parsing imports where the assignment was not an alphanumerical string (bd696a0da66af65dd9f05365eaf8297db17ba61d)
  • Fix unused variables sharing names of imports (9f552ed6950b53f0cc2136c82637d4e97da7f3b0)
import-js - 0.5.0

Published by trotzig over 8 years ago

Changes:

  • Imports are now grouped (see separate section at the bottom).
  • tab and max_line_length has been moved to configuration (was previously controlled by the editor)
  • goto is now no longer experimental (after a few important improvements was made)
  • The import-js CLI tool is now able to overwrite a file (--overwrite flag), as well as rewriting all imports for a file (--rewrite flag).

Grouping

Starting with version 0.5.0, imports are now split into groups. Package
dependencies come first, followed by one or more groups containing "internal"
imports. It will look something like this:

import React from 'react';
import { debounce } from 'underscore';

import Button from 'components/Button'
import Icon from 'components/Icon';

To prepare your codebase for the change in one sweep, you can run the following
command:

find ./app -name "**.js" -exec import-js {} --overwrite --rewrite \;

You will need to adapt it to fit your project. And please note that this command
is destructive
- it will overwrite all files matched by the find pattern.

Thanks to @lencioni for making the grouping feature happen!

import-js - 0.4.1

Published by trotzig over 8 years ago

Changes:

  • let is no longer supported as a declaration_keyword.
  • goto is now even better
    • works for aliases pointing to package dependencies
    • you no longer have to select a package when that package is already imported in the file
    • works for package dependencies without a main file specified, and with main pointing to a directory

Thanks to @lencioni for making this release happen.

import-js - 0.4.0

Published by trotzig over 8 years ago

Changes

  • In order to support different importing needs within a project, import-js now supports using local configuration.
  • Added minimum_version configuration option that you can use to warn people using old versions of import-js.
  • Many improvements to the eslint integration (support for local eslint config, better parsing of error messages)
  • React is now automatically imported if you are using jsx and have the react-in-scope plugin installed and enabled.
  • A few improvements to goto to make it work in more situations.
  • Split out destructure from aliases into a new, named_exports, configuration option.
  • Better message when importing destructured props/named imports.
  • Comments at the top of the file will now be preserved when importing.
  • You can now import devDependencies, by enabling the import_dev_dependencies option.
  • Improvements to relative imports.
  • Improvements to using the default lookup_paths value (['.']).

Upgrade guide

If you are using aliases with nested destructure arrays, turn them into named_exports instead. Here's how it was previously done:

"aliases": {
  "_": {
    "path": "underscore",
    "destructure": [
      "omit",
      "debounce"
    ]
  }
}

This is how it should look now:

"aliases": {
  "_": "underscore"
},
"named_exports": {
  "underscore": [
      "omit",
      "debounce"
    ]
}

Credits

Thanks to @lencioni for making sure that this release is as exciting as possible!

import-js - 0.3.1

Published by trotzig almost 9 years ago

Changes:

  • Bug fixes for relative imports
  • Bug fixes for when lookup_path starts with or is a dot (.)
  • Added ignore_package_prefixes so that you can use a variable named e.g. foo to import a package named brigade-foo.
  • Support for matching plural folder names, so that e.g. mockComponent matches foo/bar/mocks/component.js.

Thanks to @lencioni for filing a bunch of issues leading up to these enhancements.

import-js - 0.3.0

Published by trotzig almost 9 years ago

Changes:

  • The default declaration_keyword keyword has changed from var to import. If you were using var before, and would like to keep it, you need to add this to your .importjs.json file:
"declaration_keyword": "var"
  • Added eslint_executable so that you can use e.g. a locally installed eslint (by @lencioni)
  • Better failure messages when running eslint
import-js - 0.2.5

Published by trotzig almost 9 years ago

Changes:

  • Removed support for Ruby 1.9.3 (we weren't really supporting it since the addition of the slop gem, but now it's official)
  • Better line-breaking of destructured imports

Thanks to @lencioni once again for spearheading recent feature work.

import-js - 0.2.4

Published by trotzig almost 9 years ago

This version fixes a few minor issues introduced in 0.2.3.

import-js - 0.2.3

Published by trotzig almost 9 years ago

This version improves import statements that use both a default variable and a list of destructured properties.

From the commit message in a307e0a5 (slightly altered here):

Improve importing defaults and destructured from the same modules

Currently, with aliases configuration like the following:

"React": {
  "path": "react",
  "destructure": [
    "PropTypes"
  ]
}

importing both React and PropTypes will result in:

import React from 'react';
import { PropTypes } from 'react';

but it would be better if it instead resulted in:

import React, { PropTypes } from 'react';

This commit makes this happen. Unfortunately, there doesn't seem to be
any equivalent syntax for CommonJS imports, so I made it simply add a
following statement that does the destructuring:

const React = require('react');
const { PropTypes } = require('react');

Thanks to @lencioni for the contribution

import-js - 0.2.2

Published by trotzig almost 9 years ago

Changes:

  • Fixed a few issues related to selecting from lists in Sublime. Thanks to @vini175pa for the contribution!
import-js - 0.2.1

Published by trotzig almost 9 years ago

Changes:

  • Fixed "ImportJS: fix all imports" in Sublime (error was something like try_process': unknown option--fix' (Slop::UnknownOption)`)
  • Improved documentation for Sublime

Breaking change: The default Sublime setting for executable has changed to just import-js, from previously being ~/.rbenv/shims/import-js. If you were relying on the rbenv path, you need to override the executable setting with a full path to the import-js executable. Create or edit <path-to-sublime>/Packages/User/ImportJS.sublime-settings with something that looks like this:

{
  "executable": "/Users/henrictrotzig/.rbenv/shims/import-js"
}

Please note that you can't use ~ to refer to the home directory, you need to specify the full path.

import-js - 0.2.0

Published by trotzig almost 9 years ago

Changes:

  • Removed support for import_all. We instead rely on fix_imports.
import-js - 0.1.5

Published by trotzig almost 9 years ago

Adds "fix imports" command to Sublime.

import-js - 0.1.4

Published by trotzig almost 9 years ago

Fixes a bug with importing all / fix imports when using jsx.

I accidentally pushed 0.1.3 prematurely to rubygems, so that's why this is 0.1.4 instead of 0.1.3.

import-js - 0.1.2

Published by trotzig almost 9 years ago

This version contains some checks to make sure that the import-js gem is installed and available. It also adds some messaging to when the plugin is installed via Package Control.

import-js - 0.1.1

Published by trotzig almost 9 years ago

Changes:

  • moved sublime files to the root of the project, to prepare for submitting to Package Control (which has been done).
  • added goto option for Sublime
  • added {filename} in aliases support for Emacs and Sublime
import-js - v0.1.0

Published by trotzig almost 9 years ago

This version improves the support for Sublime. The command line interface (import-js) has been enhanced to support more use cases:

  • Asking for selection when a variable can be mapped to multiple potential modules
  • Displaying status messages

With these changes, the Sublime plugin can now do the following:

  • Import the word under the cursor
  • Import all (this already existed before)
  • Prompt the user for a selection
  • Display status messages
import-js - v0.0.3

Published by trotzig almost 9 years ago

First gem release with proper support for Emacs.

Thanks to @lencioni, @kevinkehl and @syohex for your contributions.

Package Rankings
Top 4.84% on Npmjs.org
Top 6.68% on Proxy.golang.org
Badges
Extracted from project README
npm Version License Build Status Test Coverage