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

core-modules does not resolve files inside declared modules #886

Closed
mplewis opened this issue Jul 5, 2017 · 2 comments
Closed

core-modules does not resolve files inside declared modules #886

mplewis opened this issue Jul 5, 2017 · 2 comments
Labels

Comments

@mplewis
Copy link
Contributor

mplewis commented Jul 5, 2017

tl;dr I want to tell eslint-plugin-import that I have a package named assets and it shouldn't worry about resolving this package in my project dependencies.

I am using Rails 5.1 with Webpacker. The default app config allows Webpack to import assets from the Rails asset pipeline transparently as follows:

import myLogo from 'assets/images/my_logo.svg';

...where my_logo.svg lives in /app/assets/images/my_logo.svg.

I searched and found #433, which is similar to my issue. I added the following to my .eslintrc.json:

"settings": {
  "import/core-modules": ["assets"]
},

However, I'm running into another problem. In importType.js, when isBuiltIn() evaluates my imports based on the import/core-modules setting, it's called with the following arguments and returns false:

{
  name: 'assets/images/my_logo.svg',
  settings: {
    'import/ignore': ['node_modules', '\\.(coffee|scss|css|less|hbs|svg|json)$'],
    ... 
  },
  extras: ['assets']
}

The error message reads as follows:

'assets' should be listed in the project's dependencies. Run 'npm i -S assets to add it (import/no-extraneous-dependencies)

I believe I have marked assets as a package that is present. No errors are thrown if I write something such as import foo from 'assets'.

But the import is being evaluated as assets/images/my_logo.svg and the plugin believes the package is not present.

How can I tell the plugin that assets and everything under it are present?

@benmosher
Copy link
Member

sounds like a bug. I would also expect it to behave as you've described 👍🏻

@benmosher benmosher added the bug label Jul 6, 2017
@mplewis
Copy link
Contributor Author

mplewis commented Jul 9, 2017

I'll take a crack at solving this one today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants