Search code examples
jshinteslint

jshint - ignore node_modules directory


I am simply running:

$> jshint .

which looks through my project's directory for .js files, but it is also looking into the node_modules directory which has a shit-ton of .js files that I don't really want to know about.

I might mention that eslint works out of the box to ignore the node_modules directory.

is there a way to run .jshint with a flag to ignore the node_modules directory?

for example

$> jshint . --ignore ./node_modules

?


Solution

  • To ignore the node_modules folder using JSHint, this seems to work best

    in your package.json file at the root of your project:

    {
      "scripts": {
        "jshint": "jshint --exclude 'node_modules/**/*' ."
      }
    }
    

    now you can run this at the command line

    npm run jshint
    

    and you won't forget the syntax because you have documented it for yourself

    You can also use .jshintignore:

    node_modules/**/*