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

Excluding files when linting from command line #130

Open
joetm opened this issue Jun 14, 2015 · 8 comments
Open

Excluding files when linting from command line #130

joetm opened this issue Jun 14, 2015 · 8 comments

Comments

@joetm
Copy link

joetm commented Jun 14, 2015

How can I exclude files when I lint from the command line?
Ideally, I would like to add an exclusion pattern to the config file, e.g.
{
'./js/.js',
'!./js/
.min.js'
}

@smikes
Copy link
Collaborator

smikes commented Jun 14, 2015

I am not sure about the config file, but I believe you can select the files to lint by running with that command line , because we use the "glob" package to resolve the file list

@joetm
Copy link
Author

joetm commented Jun 15, 2015

I could use a glob pattern like this:
./js/*/.js
But that would also include the minified files (which should not be linted).
It would be beneficial if files could be excluded.

@smikes
Copy link
Collaborator

smikes commented Jun 15, 2015

Thanks - I looked into it, and I was mistaken about what the glob package can do. I thought it could handle something like **/*.js !**/*.min.js but apparently that is something that I remember from grunt-jslint, and is provided by grunt and not glob.

Are you running jslint directly from the command line, or are you using a task runner such as make, grunt, or gulp ? For the node-jslint project, I use Make like this:

SOURCES=$(shell find bin lib -name '*.js' ! -name 'jslint*.js' -print)

lint:   $(SOURCES)
    node ./bin/jslint.js --edition=es6 --this --terse $(SOURCES); echo

@joetm
Copy link
Author

joetm commented Jun 15, 2015

I use gulp as task runner. I am using Windows, so make is not an option.
But I just wanted to add an npm task to my project's package. I would then run it manually with
npm run jslint

@smikes
Copy link
Collaborator

smikes commented Jun 15, 2015

Tricky.. I don't mostly run on Windows. What shell are you using? Cmd or powershell or..?

@ghost
Copy link

ghost commented Nov 11, 2015

+1
Adding the support to jslint would make such npm script portable (i.e. runnable from any shell).

@ghost
Copy link

ghost commented Jan 3, 2016

BTW, you can use modules like globby, glob-all, globule or simple-glob. They support the **/*.js !**/*.min.js case, IIUIC.

With just the glob module, you usually can use something like **/!(*.min).js. I am not sure why it does not work with jslint. Maybe because it depends on an older version of glob. Either way if jslint supported **/*.js !**/*.min.js it would be much more convenient.

@smikes
Copy link
Collaborator

smikes commented Aug 3, 2016

@radek-holy

node-jslint has been updated to ask for a newer version of glob. Can you see if the workaround you propose now works?

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

No branches or pull requests

2 participants