Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I pass global config to jshint?

How do I pass global config to jshint? I didn't find the answer in the documentation.

My config file:

>type tests\jshint_options.js
/*jshint globalstrict:true */

This is what I've tried so far:

>jshint myfile.js --config=tests\jshint_options.js
myfile.js: line 1, col 1, Use the function form of "use strict".
myfile.js: line 4, col 24, Unescaped '['.
myfile.js: line 4, col 49, Unescaped '['.

3 errors

>jshint myfile.js --config tests\jshint_options.js

node.js:201
        throw e; // process.nextTick error, or 'error' event on first tick
              ^
SyntaxError: Unexpected end of input
    at Object.parse (native)
    at _loadAndParseConfig (C:\Users\RONG\AppData\Roaming\npm\node_modules\jshint\lib\cli.js:28:18)
    at Object.interpret (C:\Users\RONG\AppData\Roaming\npm\node_modules\jshint\lib\cli.js:114:22)
    at Object.<anonymous> (C:\Users\RONG\AppData\Roaming\npm\node_modules\jshint\bin\hint:2:25)
    at Module._compile (module.js:441:26)
    at Object..js (module.js:459:10)
    at Module.load (module.js:348:31)
    at Function._load (module.js:308:12)
    at Array.0 (module.js:479:10)
    at EventEmitter._tickCallback (node.js:192:40)

>
like image 817
ripper234 Avatar asked Mar 19 '12 13:03

ripper234


People also ask

How do I configure JSHint?

Place your file into the project root directory and, as long as you run JSHint from anywhere within your project directory tree, the same configuration file will be used. Configuration file is a simple JSON file that specifies which JSHint options to turn on or off.

Where do you put Jshintrc?

Normally, you would put the “. jshintrc” in the source code root for the project. This way it's easily discoverable by others. Then each project applies it's own set of rules.

How do I ignore JSHint warning?

Yes, there is a way. Two in fact. In October 2013 jshint added a way to ignore blocks of code like this: // Code here will be linted with JSHint. /* jshint ignore:start */ // Code here will be ignored by JSHint. /* jshint ignore:end */ // Code here will be linted with JSHint.

Is JSHint a Linter?

Called a “linter,” these are programs that examine your code and warn developers when parts of it don't conform to the team's rules. The two foremost linting options for JavaScript codebases are ESLint and JSHint.


1 Answers

After much digging, I found this helpful blog post that reveled ...

that the config file is in JSON format, not javascript comments!

{
    "supernew": true
}

P.S.

This is actually documented in nodejs-jshint documentations! Not sure why I haven't found that before.

like image 99
ripper234 Avatar answered Oct 06 '22 08:10

ripper234