node-jslint
node-jslint copied to clipboard
Excluding files when linting from command line
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' }
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
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.
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
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
Tricky.. I don't mostly run on Windows. What shell are you using? Cmd or powershell or..?
+1 Adding the support to jslint would make such npm script portable (i.e. runnable from any shell).
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.
@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?