Code Monkey home page Code Monkey logo

Comments (11)

dlindahl avatar dlindahl commented on May 21, 2024 1

I am also running into this issue. An initial poke at the source code seems to indicate that prettier-eslint-cli is honoring the .eslintignore file that is shipped with installed NPM modules. I added some console.infos inside isFilePathMatchedByEslintignore, just before the return, and here is a snippet of the output:

eslintignorePath /Users/dlindahl/Work/website/.eslintignore
eslintignoreDir /Users/dlindahl/Work/website
isIgnored? node_modules/fsevents/node_modules/punycode/punycode.js true
---
eslintignorePath /Users/dlindahl/Work/website/node_modules/fsevents/node_modules/qs/.eslintignore
eslintignoreDir /Users/dlindahl/Work/website/node_modules/fsevents/node_modules/qs
isIgnored? dist/qs.js true
---
eslintignorePath /Users/dlindahl/Work/website/node_modules/fsevents/node_modules/qs/.eslintignore
eslintignoreDir /Users/dlindahl/Work/website/node_modules/fsevents/node_modules/qs
isIgnored? lib/formats.js false

You can see when the parser is looping through punycode, it is using the project .eslintignore. But when its looping throug fsevents, it picks up the .eslintignore file contained in the fsevents module which is configured only to ignore its own dist directory.

Because fsevents isn't ignoring node_modules on its own, prettier-eslint-cli starts to process all of the dependencies of fsevents.

I want to say that the way prettier-eslint-cli treats nested .eslintignore paths seems like a bug to me. I would think that the project settings should trump anything nested within it. Is this the expected behavior?

from prettier-eslint-cli.

kentcdodds avatar kentcdodds commented on May 21, 2024

Hmmm... That's weird. Does it not work if you exclude the --ignore? As you see here so long as you're not explicitly trying to format node_modules, it will be ignored.

Could you dig a little deeper?

from prettier-eslint-cli.

DontPanic345 avatar DontPanic345 commented on May 21, 2024

Not sure how it was happening but whenever I use \"./**/*.js\" it will always include the node_modules folder.

I just explicitly included all the folders I wanted to format.

from prettier-eslint-cli.

kentcdodds avatar kentcdodds commented on May 21, 2024

Ok, feel free to dig deeper to see if there really is a bug.

from prettier-eslint-cli.

kentcdodds avatar kentcdodds commented on May 21, 2024

This is definitely not expected behavior. Due to this (specifically globOptions.ignore), those files should never be included in the array of files that are processed. If you could figure out why those are included, that would be helpful.

from prettier-eslint-cli.

dlindahl avatar dlindahl commented on May 21, 2024

I have to imagine its due to getNearestEslintignorePath(filePath)

Based on the name of the function, it would make sense that, given a path deep inside node_modules, that it would find the nearest .eslintlignore and use it. I would imagine that the intention of getNearestEslintignorePath is to find an .eslintignore file in the root of the project or above (not below).

At first thought, a good place to start would be to restrict this method from going down into project sub-paths. However, in something like a lerna repo, I supposed it would be possible to have many .eslintignore files in a single project. So on second thought, getNearestEslintignorePath should itself be prevented from ever looking into node_modules... maybe?

from prettier-eslint-cli.

kentcdodds avatar kentcdodds commented on May 21, 2024

Thanks for chipping in @dlindahl. The fact is that due to the code I linked to before, those file paths should never even reach getNearestEslintignorePath. They shouldn't be included in the map called on rxGlob because they should be ignored via globOptions. So what we need to figure out is why those files are being matched by the glob. A good place to start would be to add a console.log({fileGlob, globOptions}) above this line

from prettier-eslint-cli.

dlindahl avatar dlindahl commented on May 21, 2024

The output of getFilesFromGlob is:

{ fileGlob: './**/*.js',
  globOptions: { ignore: [ '**/node_modules/**' ] } }

from prettier-eslint-cli.

kentcdodds avatar kentcdodds commented on May 21, 2024

Ok, so based on that we shouldn't be seeing anything from node_modules included. Can anyone investigate why we are?

from prettier-eslint-cli.

denis-sokolov avatar denis-sokolov commented on May 21, 2024

@kentcdodds, perhaps you want to reopen this issue?

from prettier-eslint-cli.

kentcdodds avatar kentcdodds commented on May 21, 2024

It's unclear this is an issue with the package. Feel free to investigate further.

from prettier-eslint-cli.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.