Skip to content
This repository has been archived by the owner on Sep 28, 2020. It is now read-only.

.eslintignore does not work with symlinked dependencies #202

Closed
jrencz opened this issue Nov 14, 2017 · 4 comments
Closed

.eslintignore does not work with symlinked dependencies #202

jrencz opened this issue Nov 14, 2017 · 4 comments

Comments

@jrencz
Copy link

jrencz commented Nov 14, 2017

I observed strange behaviour in my setup and I'm not 100% sure if it's eslint-loader, but maybe it is.

I have my applications composed from public packages and from several in-house packages published to private NPM instance.

Those in-house dependencies are most of the time npm linked in applications which allows seamless development.

The problem is that in case I modify installed dependency (the one that is not a result of executing npm link <dependency package name>) it's not linted
I fI modify a linked dependecy is changed then it's linted

Both main project (where webpack runs) and the linked dependency have .eslintignore files:

/node_modules/*
/dist/*

Main project has loader config (webpack1):

{
      test: /\.js$/,
      loader: 'eslint-loader',
}

(I expect the loader not to have to have exclude if there is.eslintignore)

Steps to reproduce:

  1. create webpack project with at least 2 dependencies and eslint-loader. add some rules which are not violated in project code but are violated in dependency code (easiest: make sure dependencies are minified. It's going to violate virtually any rule)
  2. prepare a working copy of one of dependencies, make sure both main project and dependency working copy use the same version of node in order to be able to link.
  3. execute npm link in the working copy of one of dependencies.
  4. start webpack in the main project
  5. go to non-linked dependency in main project node_modules and modify source
  6. observe that project was rebuilt and there are no eslint errors
  7. go to linked dependency working copy and modify the source
  8. observe that project was rebuilt and there are some eslint errors
@MoOx
Copy link
Contributor

MoOx commented Nov 14, 2017

The best way to confirm a bug, and have it fixed quickly is by producing a PR with a failing test. I won't have time to try to reproduce this very specific use case.

@jrencz
Copy link
Author

jrencz commented Nov 14, 2017

I gave it a try by copying the existing eslintignore.js test and trying to symlink the ./test/fixtures/ignore.js file but the test passes.
I couldn't create link inside node_modules because tests config ignores node_modules (and I don't think undoing that would change anything in terms of that particular test)

I investigated the problem a bit more by trying to run ESLint CLI agains 2 files: one from linked dependency and one from installed: the one from installed triggered 0:0 warning File ignored because of a matching ignore pattern. Use "--no-ignore" to override warning while the one from linked did not.

It turns out ESLint resolves paths before matching against .eslintignore rules so the fact that my linked dependency is linked means nothing to ESLint: it won't match against node_modules.

In my case turning dist/* to **/dist/* did the trick.

Anyway: @MoOx thanks for a quick response and making me THINK :)

@Akryum
Copy link

Akryum commented Mar 23, 2020

**/dist/* doesn't work for me 😭

@towry
Copy link

towry commented Jun 1, 2020

Thanks for @jrencz 's solution. I have a local package named abc, and I add abc/ to .eslintignore, it works.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants