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

files from node_modules getting resloved despite being in .eslintignore #606

Closed
olessavluk opened this issue May 7, 2021 · 6 comments · Fixed by #613
Closed

files from node_modules getting resloved despite being in .eslintignore #606

olessavluk opened this issue May 7, 2021 · 6 comments · Fixed by #613

Comments

@olessavluk
Copy link

olessavluk commented May 7, 2021

Hi 👋

After updating to 6.2.6 which includes #602 I've got this error eslint/eslint#14533. My config is:

eslint: {
    files: ['**/*.{js,jsx,ts,tsx}'],
},

But I also have node_modules ignored and when running from CLI yarn eslint --fix '**/*.{js,jsx,ts,tsx}' it works just fine.

Do you think it can be fixed? Or maybe I can specify this blob differently to not include node_modules in the first place?

@olessavluk olessavluk added the bug label May 7, 2021
@olessavluk olessavluk changed the title node_modules getting resloved despite being in .eslintignore file files from node_modules getting resloved despite being in .eslintignore May 7, 2021
@ratherblue
Copy link
Contributor

Having this issue as well. Just tried upgrading @nuxt/typescript-build from ^2.0.3 to ^2.1.0 and our build is broken with this same error after fork-ts-checker-webpack-plugin changed from 5.1.0 to 6.1.1. We have node_modules ignored everywhere but it still tries to check the folder.

@ratherblue
Copy link
Contributor

ratherblue commented May 11, 2021

Alright, narrowed it down. Calling engine.isPathIgnored(path) calls this code in ESLint:

isPathIgnored(filePath) {
    const {
        configArrayFactory,
        defaultIgnores,
        options: { cwd, ignore }
    } = internalSlotsMap.get(this);
    const absolutePath = path.resolve(cwd, filePath);

    if (ignore) {
        const config = configArrayFactory
            .getConfigArrayForFile(absolutePath)
            .extractConfig(absolutePath);
        const ignores = config.ignores || defaultIgnores;
        return ignores(absolutePath);
    }
    return defaultIgnores(absolutePath);
}

This calls ESLint's configArrayFactory which tries to load configuration for that file. If you try to run isPathIgnored on a file in node_modules containing an ESLint config you don't have installed locally the check will fail. So for example in my project when it tries to check if /app/node_modules/@babel/preset-modules/lib/index.js is ignored (which it is), it still loads the config for that project from the package.json file which contains this:

"eslintConfig": {
  "extends": "developit",
  "rules": {
    "no-console": 0,
    "new-cap": 0
  }
},

I don't have the developit configuration, so now my build fails.

In #602 the check for !engine.isPathIgnored(path) was moved from only checking changed files to all files that fall under the files glob match. This typically includes files inside node_modules unless your files glob is specific enough to not include any node_modules folders.

Until this bug is fixed it you have to either:

A) Downgrade to a version that doesn't include the changes from #602

or

B) Change your files glob to be very specific to avoid the node_modules directory entirely. Ignoring node_modules does not fix this issue.

@piotr-oles
Copy link
Collaborator

@ratherblue thanks for debugging it. Feel free to create a PR. If you don't have time, I will do it when I find a moment :)

@ratherblue
Copy link
Contributor

ratherblue commented May 11, 2021 via email

ratherblue added a commit to ratherblue/fork-ts-checker-webpack-plugin that referenced this issue May 11, 2021
piotr-oles pushed a commit that referenced this issue May 11, 2021
@piotr-oles
Copy link
Collaborator

🎉 This issue has been resolved in version 6.2.7 🎉

The release is available on:

Your semantic-release bot 📦🚀

@piotr-oles
Copy link
Collaborator

🎉 This issue has been resolved in version 7.0.0-alpha.15 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging a pull request may close this issue.

3 participants