support a --filename flag #1503

merged 4 commits into from Mar 21, 2014


None yet

3 participants


This flags allows sending code to jshint over STDIN and pretending it is a certain file.

Then we can do the config lookup algorithm relative to the dirname of that file as we would do with jshint somefile

This makes text editor integration easier

See SublimeLinter/SublimeLinter-jshint#22

@Raynos Raynos referenced this pull request in SublimeLinter/SublimeLinter-jshint Jan 30, 2014

Support `jshintConfig` in package.json #22


You should run the tests locally, you're missing some semicolons.


Thanks for that. Fixed to match jshint

@evocateur evocateur commented on an outdated diff Feb 7, 2014
@@ -457,7 +460,16 @@ var exports = {
if (opts.useStdin) {
cli.withStdin(function (code) {
- lint(extract(code, opts.extract), results, opts.config || {}, data);
+ var config = opts.config;
+ if (opts.filename && !config) {
+ var filename = path.join(process.cwd(), opts.filename);
evocateur Feb 7, 2014

This seems a little naïve. What if someone passes an absolute path? path.resolve is what you want.

var filename = path.resolve(opts.filename);
JSHint member

It'd be nice to have a test covering that. Also, can you explain how is this making editor integration easier? Maybe there's another way? This particular approach seems a tad too hacky to me.


@antonkovalyov See issue SublimeLinter/SublimeLinter-jshint#22

The main use case is for linting a buffer in a text editor that has not been saved to disk yet. The options are pass it in over stdin to jshint or write it to a temporary file.

The latter option will only work if its a temporary file in the same location as the real file so that the lookup path for the local .jshintrc file works.

@valueof valueof merged commit 7f55920 into jshint:2.x Mar 21, 2014

1 check passed

Details default The Travis CI build passed
@valueof valueof referenced this pull request Mar 21, 2014

PRs that need to be merged into master #1579

2 of 6 tasks complete
@harrytruong harrytruong referenced this pull request in AtomLinter/linter-jshint Jun 5, 2015

Look for config in package.json #25

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