standard: Don't iterate over files and folders that should be ignored

In a project of mine, I have a build directory that quickly gets really large. It’s ignored via .gitignore, so standard doesn’t fail on it, but it still runs through all files in the directory. It results in a running time of 13 seconds as opposed to 1 second without the build directory.

I know this have been discussed before (#680) and it seems to be a “feature” inherited from eslint. But I’m opening this issue to hopefully start a discussion on how to work around this or how to potentially fix it (either in standard or in eslint).

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 1
  • Comments: 19 (14 by maintainers)

Most upvoted comments

I’m removing deglob for standard 16. So this issue will be fixed for free!

I took at stab at this and found that this is a combination of a few issues.

As @searls pointed out, the issue is inside deglob.

  1. Diving further, the time is spend inside the glob module: https://github.com/standard/deglob/blob/bce559a275faf286395c52912a82c601a6740f2d/index.js#L23-L27
  2. The ignore option passed to the glob module does not contain patterns found in the .gitignore file, so files only ignored here will still be processed by glob
  3. Even if the lines from the .gitignore file were passed to the ignore option, these would have to end with /** to ignore whole directories. This is inconsistent with how .gitignore works and with what’s documented in the README

Suggested solution:

  1. Document that you need to append /** to directories you wish to ignore in the package.json standard.ignore array
  2. Convert the patterns from .gitignore to patterns compatible with the glob module and add them to the list of ignored glob patterns

@feross what do you think of this?

LOL amazing issue report

@ematipico Correct. I think what @Flet was hinting at was if the solution to this might come automatically when at some point standard is upgraded to 4.x