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

.eslintignore patterns are not excluded from globbing, so performance can be very slow #6710

Closed
rocketmonkeys opened this issue Jul 19, 2016 · 12 comments
Assignees
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion core Relates to ESLint's core APIs and features enhancement This change enhances an existing feature of ESLint needs bikeshedding Minor details about this change need to be discussed

Comments

@rocketmonkeys
Copy link

What version of ESLint are you using?
v3.1.1

What parser (default, Babel-ESLint, etc.) are you using?
Default (espree?)

Please show your full configuration:

In .eslintignore:

/some/folder/with/lots/of/files/**

What did you do? Please include the actual source code causing the issue.
run eslint .

What did you expect to happen?
eslint should be quick, since I've excluded folders via .eslintignore.

What actually happened? Please include the actual, raw output from ESLint.
eslint takes a long time, since it still globs all folders even if they're in .eslintignore.

This is a follow-on from #5679. The fix for that one excluded "DEFAULT_IGNORE_DIRS" from globbing, which was a good start.

However, if your project has large folders outside of the default ones, globbing will still take a long time even if you specify them in .eslintignore.

Including all patterns from .eslintignore speeds things up a lot. The goal is to exclude the patterns in .eslintignore from globbing, just like we do with DEFAULT_IGNORE_DIRS already.

@eslintbot eslintbot added the triage An ESLint team member will look at this issue soon label Jul 19, 2016
@platinumazure platinumazure added enhancement This change enhances an existing feature of ESLint core Relates to ESLint's core APIs and features evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion and removed triage An ESLint team member will look at this issue soon labels Jul 19, 2016
@platinumazure
Copy link
Member

I think the dust has mostly settled from our last attempt to fix globbing of ignored directories (in the default ignore directories), so I'd love to see us take another crack at this. But we'll see what the team thinks.

@alberto
Copy link
Member

alberto commented Jul 19, 2016

Thanks for opening the issue. I think I have an idea of how to do this, so I'll take a stab at this.

@nzakas nzakas added accepted There is consensus among the team that this change meets the criteria for inclusion and removed evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion labels Jul 20, 2016
@nzakas
Copy link
Member

nzakas commented Jul 20, 2016

We did say we would do this, so marking as accepted.

@rocketmonkeys
Copy link
Author

My PR (rocketmonkeys#1) has a really naive attempt at fixing this. It's probably all sorts of wrong, but it does work for at least my case, and speeds things up a ton.

@ilyavolodin
Copy link
Member

@rocketmonkeys Unfortunately, it wouldn't work for all cases. .eslintignore is using gitignore style, but traversal is done using globs. While those two patterns intersect and have common syntax, they are not the same, and in a lot of cases, glob will not understand gitignore patterns. That's the reason we couldn't fix it correctly the first time around.

@nzakas
Copy link
Member

nzakas commented Jul 20, 2016

@rocketmonkeys you should read through the whole thread on #6215 where we discuss some of the gotchas.

@alberto
Copy link
Member

alberto commented Jul 23, 2016

My intention was to do glob ignoring only when we have an ignored folder in a glob compatible syntax (no wildcards or any special syntax? absolute path?) an we can ensure it's not unignored later (no unignore at all?).

@kaelzhang
Copy link

kaelzhang commented Jul 23, 2016

Maybe we could inherit glob.GlobSync(glob.sync.GlobSync) class, override prototype._process method, and use our own childrenIgnored method?

Our custom childrenIgnored could support both minimatch patterns and gitignore patterns.

But there is still maintainence issue, that we will have to upgrade our sub-class if GlobSync changes.

node-glob is not that easy to be monkeypatched.

@alberto alberto added the needs bikeshedding Minor details about this change need to be discussed label Jul 27, 2016
@alberto
Copy link
Member

alberto commented Jul 27, 2016

@eslint/eslint-team any opinions on how do we want to approach this? @kaelzhang also submitted #6730 that addresses this by forking glob

@mysticatea
Copy link
Member

mysticatea commented Jul 27, 2016

Though I don't understand this issue.
If we use monkeypatching, Glob.prototype._readdir might be proper.

My image is:

const IGNORE = Symbol("ignore");

class OurGlob extends glob.GlobSync {
    constructor(pattern, options, ignore) {
        super(pattern, options);
        this[IGNORE] = ignore; // use symbol to avoid to conflict with base class's property.
    }

    _readdir(abs, inGlobStar) {
        if (this[IGNORE].match(abs)) {
            return null;
        }
        return super._readdir(abs, inGlobStar);
    }
}

@nzakas
Copy link
Member

nzakas commented Jul 27, 2016

I don't think we want to fork glob to solve this problem. Inheritance seems like a better option.

@kaelzhang
Copy link

@nzakas Ok,I'm working on this.

@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Feb 6, 2018
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Feb 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion core Relates to ESLint's core APIs and features enhancement This change enhances an existing feature of ESLint needs bikeshedding Minor details about this change need to be discussed
Projects
None yet
Development

No branches or pull requests

8 participants