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

(from benmosher/eslint-plugin-import) packageDir should be relative to eslint config file not cwd #1546

Closed
timhwang21 opened this issue Apr 30, 2018 · 4 comments

Comments

@timhwang21
Copy link

I ran into the issue described here, was wondering if you'd consider this a wontfix or not. I ran into this due to set autochdir which I'm aware is known to cause breakage. Thanks!

Information

VIM version

VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Apr 25 2018 22:19:32)
macOS version

Operating System: macOS

:ALEInfo

What went wrong

As per the original issue: packageDir is resolved relative to cwd instead of wherever the eslint config is.

Reproducing the bug

  1. In a project using ES6 imports and the eslint-plugin-import plugin, open some file in a different dir than .eslintrc or wherever the config is; see that imports are resolved correctly
  2. Change dir to that of the open file (set autochdir, etc.)
  3. See that you now get missing import error
@w0rp
Copy link
Member

w0rp commented Apr 30, 2018

It sounds like what should be done is that plugin should be modified so you can set an option for making the director relative to where the configuration file is, or give it an absolute path. I'll leave a comment on that issue.

@w0rp w0rp added the triage label May 6, 2018
@alex-shamshurin
Copy link

I can confirm the issue, but we can specify config in .eslintrc.js and it helps with imports:

  settings: {
    'import/resolver': {
      webpack: {
        config: { // this works, but if specify webpack config file here - it doesn't work
          resolve: { 
            extensions: ['.js', '.jsx'],
            modules: [paths.appSrc, 'node_modules'],
          },
        },
      },
    },
  },

@w0rp
Copy link
Member

w0rp commented May 25, 2018

Maybe we should prefix the eslint commands with cd .... We'd just have to make sure doing that wouldn't somehow break anything. I wouldn't be surprised if it does.

@w0rp
Copy link
Member

w0rp commented Jul 30, 2019

I'll close this, as the way to get the eslint-plugin-import plugin to work is to create .js configuration files with packageDir set with __dirname. That way, you always get a directory relative to where the configuration file is. It's mentioned in the documentation for this option: https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-extraneous-dependencies.md

@w0rp w0rp closed this as completed Jul 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants