Releases: Galooshi/import-js
0.6.0
Two new configuration options added in this release:
group_imports
- set to false to disable the default behavior of grouping importsenvironments
- 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
0.5.0
Changes:
- Imports are now grouped (see separate section at the bottom).
tab
andmax_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
Changes:
let
is no longer supported as adeclaration_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 withmain
pointing to a directory
Thanks to @lencioni for making this release happen.
0.4.0
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 ofimport-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 thereact-in-scope
plugin installed and enabled.- A few improvements to
goto
to make it work in more situations. - Split out
destructure
fromaliases
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 theimport_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
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 namedbrigade-foo
. - Support for matching plural folder names, so that e.g.
mockComponent
matchesfoo/bar/mocks/component.js
.
Thanks to @lencioni for filing a bunch of issues leading up to these enhancements.
0.3.0
Changes:
- The default
declaration_keyword
keyword has changed fromvar
toimport
. If you were usingvar
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
0.2.4
0.2.3
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