NOTE: this package isn't actively maintained anymore. I have since switched to VSCode. I'll still review and merge Pull Requests if there are any, and I'm also open to adding contributors to the repo if there's interest.
Contributions and Pull Requests are welcome.
apm install jump-to-import
NOTE: please do the following before submitting an Issue
Enable Debug
)[jump-to-import] Debug Report: Object
down arrow
next to Object
to expand it, then copy and paste the log into a GitHub IssuePrivacy Note: please be aware that this will submit the following information to me:
Quickly jump to an ES6 module file from its import path or variable. Also supports jumping to Ember.Service
definitions (with alias support), as well as Ember.Component
template files from an HTMLBars
file.
Support for project-specific settings/aliases via .jump-to-import
, additional aliases via .babelrc
and/or webpack.config.js
package.json
required at root of project
jump-to-import:go-to-module
(default keybind: CTRL+ALT+E)jump-to-import:create-project-config
jump-to-import:debug-log
import
and require
syntaxnpm:foo
syntax for Browserify
)import
statementsEmber.Service
files, with or without pod structure
Ember.Service
name aliasingEmber.Component
template files, with or without pod structure
.hbs
file, component names can jump to their template filehyperclick
support:
hyperclick
is a requirement if you plan to use this functionalityhyperclick
to use an appropriate hotkeybabel-plugin-module-resolver
support:
.babelrc
resolve.alias
section of the webpack.config.js
webpack.config.js
requires reloading Atom for now.jump-to-import
fileEmber.Service
name aliasing.babelrc
overrides, hyperclick
supportjs
and jsx
)hyperclick
Press CTRL+ALT+E with the cursor either on:
import
/require
pathEmber.Service
dependency injection (i.e foo: Ember.inject.service()
)to open that file and jump to the relevant method, if applicable.
hyperclick
Hold your hyperclick
toggle key and click on any applicable string to jump to that module.
The package looks for configuration options and path aliases in two places:
.jump-to-import
files (project settings).babelrc
files (babel aliases)These are simply accessed in Atom's Settings > Packages > Jump To Import
. These are basically global settings that will apply to any project.
You can define your own path aliases in Settings.
Default aliases are:
$PROJECT:app
$PROJECT/config:config
With the above default settings (for Ember projects) we would get the following behavior:
PROJECT_NAME/components/foo
-> app/components/foo.js
PROJECT_NAME/config/environment
-> config/environment.js
PROJECT_NAME
in the path needs to match the project name defined in your package.json
file in the root directory.
The package will look for a package.json
file in every root directory of the project to determine project names.
You can also define a list of file extensions to look for.
You can define Ember.Service
name aliases, in case the injected variable name and registered service name differ.
.jump-to-import
Optionally, you can add a .jump-to-import
file in any root folder of your project which will take precedence over the package settings. These allow for project-specific settings and aliases.
You can trigger the jump-to-import:create-project-config
through the Command Palette
to generate a default config.
NOTE: Project settings only apply to the root directory they belong to.
Here's a sample config, using default settings:
{
"usePendingPane": true,
"openInSeparatePane": true,
"panePosition": "right",
"useEmberPods": true,
"fileExtensions": [
"js",
"jsx"
],
"pathOverrides": [
"$PROJECT:app",
"$PROJECT/config:config",
"$PROJECT/tests:tests"
],
"serviceOverrides": [
"fastboot:boot"
],
"disablePathOverrides": false,
"disableBabelRc": false,
"disableHyperclickSupport": false
}
Optionally, you can use path aliases defined in .babelrc
. A sample file looks like:
{
"plugins": [
["module-resolver", {
"root": ["./src"],
"alias": {
"utils": "./utils"
}
}]
]
}
With the above .babelrc
file, a path of utils/test
will resolve to ./src/utils/test.js
Project settings and aliases defined in .jump-to-import
will always take priority. Next, .babelrc
aliases take precedence over aliases defined in Package Settings.
Remember, .jump-to-import
> .babelrc
> Package Settings
With the following import
line:
// assuming the project's name is defined as `my-project` in `package.json`
// with cursor on, or selecting, `FooMixin` or the path, will open project-root/app/mixins/foo.js
import FooMixin from 'my-project/mixins/foo'
// with cursor on, or selecting, bar, will open project-root/app/mixins/foo.js and jump to the bar() method
FooMixin.bar();