How to tell JSLint / JSHint what global variables are already defined

global-variables, javascript, jshint, jslint

Solution

For JSHint you can create `.jshintrc` to your project directory with

{
  "globals": { "MyProject": true }
}

Problem

In my project we have some global variables that work as containers: ``` MyProject.MyFreature.someFunction = function() { ... } ``` So then I use that script across the site and JSLint / JSHint complains about that: 'MyProject' is not defined I know that I can go to every JavaScript file and add the comment `/*global MyProject*/` on top of it. But I'm looking a way to define that comment in some sort of config file so I don't have to go file by file adding this comment. Some kind on option in the `config/jshint.yml` would be nice.

Original source