When set to true, these options will make JSHint produce more warnings about your code.
bitwise |
This option prohibits the use of bitwise operators such as |
camelcase |
Warning This option has been deprecated and will be
removed in the next major release of JSHint.
JSHint is limiting its scope to issues of code correctness. If you would like to enforce rules relating to code style, check out the JSCS project. This option allows you to force all variable names to use either camelCase style or UPPER_CASE with underscores. |
curly |
This option requires you to always put curly braces around blocks in loops and conditionals. JavaScript allows you to omit curly braces when the block consists of only one statement, for example:
However, in some circumstances, it can lead to bugs (you'd think that
|
enforceall |
Warning This option has been deprecated and will be
removed in the next major release of JSHint.
The option cannot be maintained without automatically opting users in to new features. This can lead to unexpected warnings/errors in when upgrading between minor versions of JSHint. This option is a short hand for the most strict JSHint configuration as available in JSHint version 2.6.3. It enables all enforcing options and disables all relaxing options that were defined in that release. |
eqeqeq |
This options prohibits the use of |
es3 |
Warning This option has been deprecated and will be
removed in the next major release of JSHint.
Use This option tells JSHint that your code needs to adhere to ECMAScript 3 specification. Use this option if you need your program to be executable in older browsers—such as Internet Explorer 6/7/8/9—and other legacy JavaScript environments. |
es5 |
Warning This option has been deprecated and will be
removed in the next major release of JSHint.
Use This option enables syntax first defined in the ECMAScript 5.1 specification. This includes allowing reserved keywords as object properties. |
esversion |
This option is used to specify the ECMAScript version to which the code must adhere. It can assume one of the following values:
|
forin |
This option requires all
For more in-depth understanding of |
freeze |
This options prohibits overwriting prototypes of native objects such as
|
futurehostile |
This option enables warnings about the use of identifiers which are defined in future versions of JavaScript. Although overwriting them has no effect in contexts where they are not implemented, this practice can cause issues when migrating codebases to newer versions of the language. |
globals |
This option can be used to specify a white list of global variables that
are not formally defined in the source code. This is most useful when
combined with the Setting an entry to See also the "environment" options: a set of options to be used as short hand for enabling global variables defined in common JavaScript environments. To configure |
immed |
Warning This option has been deprecated and will be
removed in the next major release of JSHint.
JSHint is limiting its scope to issues of code correctness. If you would like to enforce rules relating to code style, check out the JSCS project. This option prohibits the use of immediate function invocations without wrapping them in parentheses. Wrapping parentheses assists readers of your code in understanding that the expression is the result of a function, and not the function itself. |
indent |
Warning This option has been deprecated and will be
removed in the next major release of JSHint.
JSHint is limiting its scope to issues of code correctness. If you would like to enforce rules relating to code style, check out the JSCS project. This option sets a specific tab width for your code. |
latedef |
This option prohibits the use of a variable before it was defined. JavaScript has function scope only and, in addition to that, all variables are always moved—or hoisted— to the top of the function. This behavior can lead to some very nasty bugs and that's why it is safer to always use variable only after they have been explicitly defined. Setting this option to "nofunc" will allow function declarations to be ignored. For more in-depth understanding of scoping and hoisting in JavaScript, read JavaScript Scoping and Hoisting by Ben Cherry. |
leanswitch |
This option prohibits unnecessary clauses within
While clauses like these are techincally valid, they do not effect program behavior and may indicate an erroneous refactoring. |
maxcomplexity |
This option lets you control cyclomatic complexity throughout your code. Cyclomatic complexity measures the number of linearly independent paths through a program's source code. Read more about cyclomatic complexity on Wikipedia. |
maxdepth |
This option lets you control how nested do you want your blocks to be:
|
maxerr |
This options allows you to set the maximum amount of errors JSHint will produce before giving up. Default is 50. |
maxlen |
Warning This option has been deprecated and will be
removed in the next major release of JSHint.
JSHint is limiting its scope to issues of code correctness. If you would like to enforce rules relating to code style, check out the JSCS project. This option lets you set the maximum length of a line. |
maxparams |
This option lets you set the max number of formal parameters allowed per function:
|
maxstatements |
This option lets you set the max number of statements allowed per function:
|
newcap |
Warning This option has been deprecated and will be
removed in the next major release of JSHint.
JSHint is limiting its scope to issues of code correctness. If you would like to enforce rules relating to code style, check out the JSCS project. This option requires you to capitalize names of constructor functions.
Capitalizing functions that are intended to be used with Not doing so won't break your code in any browsers or environments but
it will be a bit harder to figure out—by reading the code—if the
function was supposed to be used with or without new. And this is
important because when the function that was intended to be used with
|
noarg |
This option prohibits the use of |
nocomma |
This option prohibits the use of the comma operator. When misused, the comma operator can obscure the value of a statement and promote incorrect code. |
noempty |
Warning This option has been deprecated and will be
removed in the next major release of JSHint.
JSHint is limiting its scope to issues of code correctness. If you would like to enforce rules relating to code style, check out the JSCS project. This option warns when you have an empty block in your code. JSLint was originally warning for all empty blocks and we simply made it optional. There were no studies reporting that empty blocks in JavaScript break your code in any way. |
nonbsp |
This option warns about "non-breaking whitespace" characters. These characters can be entered with option-space on Mac computers and have a potential of breaking non-UTF8 web pages. |
nonew |
This option prohibits the use of constructor functions for side-effects. Some people like to call constructor functions without assigning its result to any variable:
There is no advantage in this approach over simply calling
|
noreturnawait |
Async functions resolve on their return value. In most cases, this makes
returning the result of an AwaitExpression (which is itself a Promise
instance) unnecessary. For clarity, it's often preferable to return the
result of the asynchronous operation directly. The notable exception is
within the https://jakearchibald.com/2017/await-vs-return-vs-return-await/ |
predef |
This option allows you to control which variables JSHint considers to be implicitly defined in the environment. Configure it with an array of string values. Prefixing a variable name with a hyphen (-) character will remove that name from the collection of predefined variables. JSHint will consider variables declared in this way to be read-only. This option cannot be specified in-line; it may only be used via the JavaScript API or from an external configuration file. |
quotmark |
Warning This option has been deprecated and will be
removed in the next major release of JSHint.
JSHint is limiting its scope to issues of code correctness. If you would like to enforce rules relating to code style, check out the JSCS project. This option enforces the consistency of quotation marks used throughout
your code. It accepts three values: |
regexpu |
This option enables warnings for regular expressions which do not include the "u" flag. The "u" flag extends support for Unicode and also enables more strict parsing rules. JSHint will enforce these rules even if it is executed in a JavaScript engine which does not support the "u" flag. |
shadow |
This option suppresses warnings about variable shadowing i.e. declaring a variable that had been already declared somewhere in the outer scope.
|
singleGroups |
This option prohibits the use of the grouping operator when it is not strictly required. Such usage commonly reflects a misunderstanding of unary operators, for example:
|
strict |
This option requires the code to run in ECMAScript 5's strict mode. Strict mode is a way to opt in to a restricted variant of JavaScript. Strict mode eliminates some JavaScript pitfalls that didn't cause errors by changing them to produce errors. It also fixes mistakes that made it difficult for the JavaScript engines to perform certain optimizations.
|
trailingcomma |
This option warns when a comma is not placed after the last element in an array or object literal. Due to bugs in old versions of IE, trailing commas used to be discouraged, but since ES5 their semantics were standardized. (See #11.1.4 and #11.1.5.) Now, they help to prevent the same visual ambiguities that the strict usage of semicolons helps prevent. For example, this code might have worked last Tuesday:
But if one adds an element to the array and forgets to compensate for the missing comma, no syntax error is thrown, and a linter cannot determine if this was a mistake or an intentional function invocation.
If one always appends a list item with a comma, this ambiguity cannot occur:
|
undef |
This option prohibits the use of explicitly undeclared variables. This option is very useful for spotting leaking and mistyped variables.
If your variable is defined in another file, you can use the |
unused |
This option warns when you define and never use your variables. It is very
useful for general code cleanup, especially when used in addition to
In addition to that, this option will warn you about unused global
variables declared via the When set to |
varstmt |
When set to true, the use of VariableStatements are forbidden. For example:
|
When set to true, these options will make JSHint produce fewer warnings about your code.
asi |
This option suppresses warnings about missing semicolons. There is a lot of FUD about semicolon spread by quite a few people in the community. The common myths are that semicolons are required all the time (they are not) and that they are unreliable. JavaScript has rules about semicolons which are followed by all browsers so it is up to you to decide whether you should or should not use semicolons in your code. For more information about semicolons in JavaScript read An Open Letter to JavaScript Leaders Regarding Semicolons by Isaac Schlueter and JavaScript Semicolon Insertion. |
boss |
This option suppresses warnings about the use of assignments in cases
where comparisons are expected. More often than not, code like
You can silence this error on a per-use basis by surrounding the assignment with parenthesis, such as:
|
debug |
This option suppresses warnings about the |
elision |
This option tells JSHint that your code uses ES3 array elision elements,
or empty elements (for example, |
eqnull |
This option suppresses warnings about |
esnext |
Warning This option has been deprecated and will be
removed in the next major release of JSHint.
Use This option tells JSHint that your code uses ECMAScript 6 specific syntax. Note that not all browsers implement these features. More info: |
evil |
This option suppresses warnings about the use of |
expr |
This option suppresses warnings about the use of expressions where normally you would expect to see assignments or function calls. Most of the time, such code is a typo. However, it is not forbidden by the spec and that's why this warning is optional. |
funcscope |
This option suppresses warnings about declaring variables inside
of control structures while accessing them later from the outside.
Even though identifiers declared with
|
globalstrict |
Warning This option has been deprecated and will be
removed in the next major release of JSHint.
Use This option suppresses warnings about the use of global strict mode. Global strict mode can break third-party widgets so it is not recommended. For more info about strict mode see the |
iterator |
This option suppresses warnings about the |
lastsemic |
This option suppresses warnings about missing semicolons, but only when the semicolon is omitted for the last statement in a one-line block:
This is a very niche use case that is useful only when you use automatic JavaScript code generators. |
laxbreak |
Warning This option has been deprecated and will be
removed in the next major release of JSHint.
JSHint is limiting its scope to issues of code correctness. If you would like to enforce rules relating to code style, check out the JSCS project. This option suppresses most of the warnings about possibly unsafe line
breakings in your code. It doesn't suppress warnings about comma-first
coding style. To suppress those you have to use |
laxcomma |
Warning This option has been deprecated and will be
removed in the next major release of JSHint.
JSHint is limiting its scope to issues of code correctness. If you would like to enforce rules relating to code style, check out the JSCS project. This option suppresses warnings about comma-first coding style:
|
loopfunc |
This option suppresses warnings about functions inside of loops. Defining functions inside of loops can lead to bugs such as this one:
To fix the code above you need to copy the value of
|
moz |
This options tells JSHint that your code uses Mozilla JavaScript extensions. Unless you develop specifically for the Firefox web browser you don't need this option. More info: |
multistr |
Warning This option has been deprecated and will be
removed in the next major release of JSHint.
JSHint is limiting its scope to issues of code correctness. If you would like to enforce rules relating to code style, check out the JSCS project. This option suppresses warnings about multi-line strings. Multi-line
strings can be dangerous in JavaScript because all hell breaks loose if
you accidentally put a whitespace in between the escape character ( Note that even though this option allows correct multi-line strings, it still warns about multi-line strings without escape characters or with anything in between the escape character and a whitespace.
|
notypeof |
This option suppresses warnings about invalid
Do not use this option unless you're absolutely sure you don't want these checks. |
noyield |
This option suppresses warnings about generator functions with no
|
plusplus |
This option prohibits the use of unary increment and decrement
operators. Some people think that |
proto |
This option suppresses warnings about the |
scripturl |
This option suppresses warnings about the use of script-targeted
URLs—such as |
sub |
Warning This option has been deprecated and will be
removed in the next major release of JSHint.
JSHint is limiting its scope to issues of code correctness. If you would like to enforce rules relating to code style, check out the JSCS project. This option suppresses warnings about using |
supernew |
This option suppresses warnings about "weird" constructions like
|
validthis |
This option suppresses warnings about possible strict violations when
the code is running in strict mode and you use Note: This option can be used only inside of a function scope. JSHint will fail with an error if you will try to set this option globally. |
withstmt |
This option suppresses warnings about the use of the More info: |
These options let JSHint know about some pre-defined global variables.
browser |
This option defines globals exposed by modern browsers: all the way from
good old Note: This option doesn't expose variables like |
browserify |
This option defines globals available when using the Browserify tool to build a project. |
couch |
This option defines globals exposed by CouchDB. CouchDB is a document-oriented database that can be queried and indexed in a MapReduce fashion using JavaScript. |
devel |
This option defines globals that are usually used for logging poor-man's
debugging: |
dojo |
This option defines globals exposed by the Dojo Toolkit. |
jasmine |
This option defines globals exposed by the Jasmine unit testing framework. |
jquery |
This option defines globals exposed by the jQuery JavaScript library. |
mocha |
This option defines globals exposed by the "BDD" and "TDD" UIs of the Mocha unit testing framework. |
module |
This option informs JSHint that the input code describes an ECMAScript 6 module. All module code is interpreted as strict mode code. |
mootools |
This option defines globals exposed by the MooTools JavaScript framework. |
node |
This option defines globals available when your code is running inside
of the Node runtime environment. Node.js is a
server-side JavaScript environment that uses an asynchronous
event-driven model. This option also skips some warnings that make sense
in the browser environments but don't make sense in Node such as
file-level |
nonstandard |
This option defines non-standard but widely adopted globals such as
|
phantom |
This option defines globals available when your core is running inside of the PhantomJS runtime environment. PhantomJS is a headless WebKit scriptable with a JavaScript API. It has fast and native support for various web standards: DOM handling, CSS selector, JSON, Canvas, and SVG. |
prototypejs |
This option defines globals exposed by the Prototype JavaScript framework. |
qunit |
This option defines globals exposed by the QUnit unit testing framework. |
rhino |
This option defines globals available when your code is running inside of the Rhino runtime environment. Rhino is an open-source implementation of JavaScript written entirely in Java. |
shelljs |
This option defines globals exposed by the ShellJS library. |
typed |
This option defines globals for typed array constructors. More info: |
worker |
This option defines globals available when your code is running inside of a Web Worker. Web Workers provide a simple means for web content to run scripts in background threads. |
wsh |
This option defines globals available when your code is running as a script for the Windows Script Host. |
yui |
This option defines globals exposed by the YUI JavaScript framework. |
These options enable behavior which is subject to change between major releases of JSHint. Exercise caution when enabling them in automated environments (e.g. continuous integration).
exports.unstable = { }; // These are JSHint boolean options which are shared with JSLint // where the definition in JSHint is opposite JSLint exports.inverted = { bitwise |
Unstable options allow control for parsing and linting of proposed additions to the JavaScript language. Just like the language features they describe, the presence and behavior of these options is volatile; JSHint reserves the right to remove or modify them between major version releases. |