Skip to content

Releases: Galooshi/import-js

0.6.0

05 Mar 21:47
Compare
Choose a tag to compare

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.

0.5.1

03 Mar 15:44
Compare
Choose a tag to compare

Changes:

  • Fix issue with parsing imports where the assignment was not an alphanumerical string (bd696a0)
  • Fix unused variables sharing names of imports (9f552ed)

0.5.0

01 Mar 14:48
Compare
Choose a tag to compare

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!

0.4.1

31 Jan 19:58
Compare
Choose a tag to compare

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.

0.4.0

27 Jan 15:38
Compare
Choose a tag to compare

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!

0.3.1

17 Jan 12:47
Compare
Choose a tag to compare

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.

0.3.0

11 Jan 20:37
Compare
Choose a tag to compare

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

0.2.5

08 Jan 21:31
Compare
Choose a tag to compare

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.

0.2.4

07 Jan 19:49
Compare
Choose a tag to compare

This version fixes a few minor issues introduced in 0.2.3.

0.2.3

07 Jan 18:59
Compare
Choose a tag to compare

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

From the commit message in a307e0a (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