Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: aliased internal modules that look like core modules #1297

Open
wants to merge 4 commits into
base: master
from

Conversation

Projects
None yet
3 participants
@echenley
Copy link

echenley commented Mar 6, 2019

What

Posting this PR a little prematurely to get feedback. Added a couple commented-out tests to show the issue. I think this could be merged as-is, but I'd prefer to sort out the resolver behavior first for consistency.

Update isBuiltIn to return false if a path is returned from a resolver.
Previously an alias like 'constants/foo' would be classified as a builtin rather than internal since 'constants' is a core module of node. Fixes one of the issues mentioned in #1034.

Example

project
└── src
    └── constants
        └── index.js
{
  "settings": {
    "import/resolver": {
      "node": {
        "paths": ["/project/src"]
      }
    }
  }
}

Result:

// BEFORE
import { FOO } from 'constants/index'
import { isObject } from 'lodash'

// AFTER
import { isObject } from 'lodash'
import { FOO } from 'constants/index'
Show resolved Hide resolved tests/src/core/importType.js Outdated
Show resolved Hide resolved tests/src/core/importType.js Outdated
@coveralls

This comment has been minimized.

Copy link

coveralls commented Mar 6, 2019

Coverage Status

Coverage increased (+0.002%) to 97.319% when pulling 9eed55b on echenley:ech/fix-isBuiltIn-local-aliases into 651829d on benmosher:master.

Show resolved Hide resolved src/core/importType.js Outdated
Show resolved Hide resolved tests/src/core/importType.js Outdated
Show resolved Hide resolved tests/src/core/importType.js Outdated
@ljharb

ljharb approved these changes Mar 16, 2019

@ljharb ljharb requested a review from benmosher Mar 16, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.