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

Support glob path on command line #3402

Closed
leebyron opened this issue Aug 14, 2015 · 7 comments

Comments

Projects
None yet
7 participants
@leebyron
Copy link

commented Aug 14, 2015

Similar to mocha cli's ability to determine which files to run as tests by looking at a glob, it would be great if eslint could accept a glob pattern on the command line.

This would be nice when you could very concisely describe the set of directories and files to include or exclude with a single glob.

In my case, I would love to be able to write: eslint @(src/resources)/**/*.js to run eslint across two directories in one go.

@eslintbot

This comment has been minimized.

Copy link

commented Aug 14, 2015

Thanks for the issue! We get a lot of issues, so this message is automatically posted to each one to help you check that you've included all of the information we need to help you.

Reporting a bug? Please be sure to include:

  1. The version of ESLint you are using (run eslint -v)
  2. The source code that caused the problem
  3. The configuration you're using (for the rule or your entire config file)
  4. The actual ESLint output complete with line numbers

Requesting a new rule? Please be sure to include:

  1. The use case for the rule - what is it trying to prevent or flag?
  2. Whether the rule is trying to prevent an error or is purely stylistic
  3. Why you believe this rule is generic enough to be included

Requesting a feature? Please be sure to include:

  1. The problem you want to solve (don't mention the solution)
  2. Your take on the correct solution to problem

Including this information in your issue helps us to triage it and get you a response as quickly as possible.

Thanks!

@eslintbot eslintbot added the triage label Aug 14, 2015

@IanVS

This comment has been minimized.

Copy link
Member

commented Aug 14, 2015

Hi, I'm not an expert on globs, and from a brief search I can't find a description of the @ syntax. Can you explain your use case which our current CLI does not support?

@nzakas

This comment has been minimized.

Copy link
Member

commented Aug 14, 2015

@leebyron is there a reason you don't use your shell to do that?

@alexindigo

This comment has been minimized.

Copy link

commented Aug 18, 2015

Shell is limited, especially in windows.
closest thing I could achieve using shell is via find, but it limits number of environments I can run it on.

So something simple and recursive would help bring more developers (on different platforms) on board.

Like eslint ., will find all the .js files (because --ext default is .js, and right now it reads all the files), and it will perform recursive search (with respect to .eslintignore). At the moment it processes only current level, without going into sub directories.

We're setting up package template for all our internal modules and would like to have eslint as default linter, but it doesn't work for us now.

For example is we set eslint *.js and developer puts all his js files into lib/ shell won't expand *.js and send it to eslint literally – eslint would exit with ENOENT error. If we set it to eslint **/*.js it would process only second level of folders, ignoring files in the current folder and in the third level folder.
If we set it to eslint {*,**/*}.js – windows developers would look at as with dismay, and third level will be ignored anyway.

Closest option to the desired solution we have now is find . -name '*.js' ! -path './node_modules/*' | xargs eslint. But again we didn't get courage to ask developers with windows machines to use it.

So native support for recursive search is very crucial for us to adopt eslint as default linting tool.

Thank you.

@leebyron

This comment has been minimized.

Copy link
Author

commented Aug 18, 2015

@nzakas using shell to expand globs directly isn't really ideal. @alexindigo brings up the good point that different shells support different features, which can make writing universal scripts quite hard.

Also, expanding the glob in a shell script would result in a node process running eslint for every matched file, which I would imagine would run less efficiently that allowing eslint to determine how to lint many files.

@IanVS the @ syntax allows for an "one of options" pattern and is supported in some rare shells, but most importantly is supported by node-glob. You can see descriptions for what node-glob supports here: https://github.com/isaacs/node-glob#glob-primer

Mocha uses node-glob to walk a filesystem and find files which identify as tests. It's a really nice usability detail of that tool. It would be awesome if eslint did the same.

@nzakas

This comment has been minimized.

Copy link
Member

commented Aug 18, 2015

Fair. We can look into it. I'm not sure how much work it will be, but since there's already a module to use, hopefully not much.

@nzakas nzakas added enhancement cli accepted and removed triage labels Aug 18, 2015

@sindresorhus

This comment has been minimized.

Copy link
Contributor

commented Aug 22, 2015

You can use globby if you need support for multiple patterns, which I assume you do, since ESLint supports multiple files as input.

BYK added a commit that referenced this issue Aug 23, 2015

@BYK BYK self-assigned this Aug 23, 2015

BYK added a commit that referenced this issue Aug 23, 2015

BYK added a commit that referenced this issue Aug 24, 2015

BYK added a commit that referenced this issue Aug 26, 2015

BYK added a commit that referenced this issue Aug 26, 2015

BYK added a commit that referenced this issue Aug 26, 2015

BYK added a commit that referenced this issue Aug 26, 2015

BYK added a commit that referenced this issue Aug 26, 2015

BYK added a commit that referenced this issue Aug 26, 2015

BYK added a commit that referenced this issue Aug 26, 2015

BYK added a commit that referenced this issue Aug 27, 2015

BYK added a commit that referenced this issue Aug 27, 2015

BYK added a commit that referenced this issue Aug 28, 2015

BYK added a commit that referenced this issue Aug 31, 2015

BYK added a commit that referenced this issue Aug 31, 2015

BYK added a commit that referenced this issue Aug 31, 2015

@nzakas nzakas closed this in #3496 Aug 31, 2015

@eslint eslint bot locked and limited conversation to collaborators Feb 7, 2018

@eslint eslint bot added the archived due to age label Feb 7, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.