jump-to-import

Jump to ES6 import/require/bower/npm modules, including Ember.Service and Ember.Component template files. With hyperclick support and project-specific configs.

alexheyd

6,910

4

3.6.5

MIT

GitHub

This package provides the following services:

jump-to-import package

Contributions and Pull Requests are welcome.

Installation

apm install jump-to-import

Bugs

NOTE: please do the following before submitting an Issue

Privacy Note: please be aware that this will submit the following information to me:

Description

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

Requirements

Features

Usage

Without hyperclick

Press CTRL+ALT+E with the cursor either on:

to open that file and jump to the relevant method, if applicable.

With hyperclick

Hold your hyperclick toggle key and click on any applicable string to jump to that module.

Setup

The package looks for configuration options and path aliases in two places:

Package Settings

These are simply accessed in Atom's Settings > Packages > Jump To Import. These are basically global settings that will apply to any project.

Aliases

You can define your own path aliases in Settings.

Default aliases are:

With the above default settings (for Ember projects) we would get the following behavior:

PROJECT_NAME in the path needs to match the project name defined in your package.json file in the root directory.

Project Name

The package will look for a package.json file in every root directory of the project to determine project names.

File Extensions

You can also define a list of file extensions to look for.

Ember.Service Aliases

You can define Ember.Service name aliases, in case the injected variable name and registered service name differ.

Project-specific settings via .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
}

.babelrc

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

Settings & Aliases Priority

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

Example

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();