Static analysis tool for JavaScript that detects errors and potential problems in code
—
Pending
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Pending
The risk profile of this skill
Comprehensive configuration system with enforcing, relaxing, and environment options for customizing JSHint's linting behavior. JSHint provides fine-grained control over which warnings and errors to report.
JSHint configuration is organized into three main categories of boolean options plus value-based options.
// JSHint Configuration Options Object
{
// Enforcing options (stricter checking)
bitwise: boolean, // Prohibit bitwise operators
camelcase: boolean, // Force camelCase (deprecated)
curly: boolean, // Require curly braces
eqeqeq: boolean, // Prohibit == and !=
es3: boolean, // ES3 compliance (deprecated)
es5: boolean, // ES5 compliance (deprecated)
forin: boolean, // Require hasOwnProperty in for-in loops
freeze: boolean, // Prohibit native object extension
futurehostile: boolean, // Warn about future reserved words
immed: boolean, // Require immediate function invocation wrapping
latedef: boolean, // Prohibit use before definition
newcap: boolean, // Require constructor names capitalization
noarg: boolean, // Prohibit arguments.caller/callee
noempty: boolean, // Prohibit empty blocks
nonew: boolean, // Prohibit constructor usage for side effects
plusplus: boolean, // Prohibit ++ and --
quotmark: boolean, // Enforce quote marks
undef: boolean, // Require variable declarations
unused: boolean, // Warn about unused variables
strict: boolean, // Require strict mode
varstmt: boolean, // Disallow var statements
regexpu: boolean, // Enable RegExp u flag support
// Relaxing options (more permissive)
asi?: boolean;
boss?: boolean;
debug?: boolean;
eqnull?: boolean;
elision?: boolean;
esnext?: boolean;
evil?: boolean;
expr?: boolean;
funcscope?: boolean;
globalstrict?: boolean;
iterator?: boolean;
lastsemic?: boolean;
laxbreak?: boolean;
laxcomma?: boolean;
loopfunc?: boolean;
multistr?: boolean;
moz?: boolean;
notypeof?: boolean;
noyield?: boolean;
plusplus?: boolean;
proto?: boolean;
scripturl?: boolean;
sub?: boolean;
supernew?: boolean;
validthis?: boolean;
withstmt?: boolean;
// Environment options
browser?: boolean;
couch?: boolean;
devel?: boolean;
dojo?: boolean;
jasmine?: boolean;
jquery?: boolean;
mocha?: boolean;
module?: boolean;
mootools?: boolean;
node?: boolean;
nonstandard?: boolean;
phantom?: boolean;
prototypejs?: boolean;
qunit?: boolean;
rhino?: boolean;
shelljs?: boolean;
typed?: boolean;
worker?: boolean;
wsh?: boolean;
yui?: boolean;
// Value-based options
esversion?: number;
maxlen?: number;
maxerr?: number;
maxdepth?: number;
maxstatements?: number;
maxcomplexity?: number;
maxparams?: number;
indent?: number;
quotmark?: boolean | 'single' | 'double';
shadow?: boolean | 'inner' | 'outer';
strict?: boolean | 'global' | 'implied';
unused?: boolean | 'vars' | 'strict';
latedef?: boolean | 'nofunc';
ignore?: string;
ignoreDelimiters?: string;
predef?: string[] | {[key: string]: boolean};
globals?: {[key: string]: boolean};
scope?: string;
}Stricter checking options that enable additional warnings and enforce best practices.
interface EnforcingOptions {
/**
* Prohibits bitwise operators (&, |, ^, etc.)
* Prevents common typos like & instead of &&
*/
bitwise: boolean;
/**
* Enforces camelCase naming convention for variables
*/
camelcase: boolean;
/**
* Requires curly braces around blocks in if/for/while statements
*/
curly: boolean;
/**
* Requires === and !== instead of == and !=
*/
eqeqeq: boolean;
/**
* Enforces ECMAScript 3 compatibility
*/
es3: boolean;
/**
* Enforces ECMAScript 5.1 compatibility
*/
es5: boolean;
/**
* Requires hasOwnProperty checks in for-in loops
*/
forin: boolean;
/**
* Prohibits overwriting native objects like Array, Date
*/
freeze: boolean;
/**
* Warns about identifiers defined in future ECMAScript versions
*/
futurehostile: boolean;
/**
* Requires immediate function invocations to be wrapped in parentheses
*/
immed: boolean;
/**
* Warns about switch statements without default case
*/
leanswitch: boolean;
/**
* Requires constructor names to be capitalized
*/
newcap: boolean;
/**
* Prohibits use of arguments.caller and arguments.callee
*/
noarg: boolean;
/**
* Prohibits comma operator except in control statements
*/
nocomma: boolean;
/**
* Prohibits empty blocks
*/
noempty: boolean;
/**
* Warns about non-breaking space characters
*/
nonbsp: boolean;
/**
* Prohibits use of constructor functions for side effects
*/
nonew: boolean;
/**
* Prohibits return statements in async functions without await
*/
noreturnawait: boolean;
/**
* Enables warnings for regular expressions
*/
regexpu: boolean;
/**
* Prohibits grouping operators when not necessary
*/
singleGroups: boolean;
/**
* Requires trailing commas in multiline literals
*/
trailingcomma: boolean;
/**
* Requires variables to be declared before use
*/
undef: boolean;
/**
* Prohibits var statement, requires let/const
*/
varstmt: boolean;
/**
* Enables all enforcing options at once
*/
enforceall: boolean;
}Usage Examples:
// Basic enforcing options
const strictOptions = {
curly: true, // require braces
eqeqeq: true, // require ===
undef: true, // require variable declarations
unused: true // warn about unused variables
};
// ES6+ enforcing
const modernOptions = {
esversion: 6, // ES6 syntax support
varstmt: false, // allow var statements
futurehostile: true // warn about future reserved words
};More permissive options that disable specific warnings and allow certain patterns.
interface RelaxingOptions {
/**
* Allows automatic semicolon insertion
*/
asi: boolean;
/**
* Allows assignments in conditions (if (a = b))
*/
boss: boolean;
/**
* Allows debugger statements
*/
debug: boolean;
/**
* Allows == null comparisons
*/
eqnull: boolean;
/**
* Allows elision in arrays ([1, , 3])
*/
elision: boolean;
/**
* Allows ES.next syntax (deprecated, use esversion)
*/
esnext: boolean;
/**
* Allows eval usage
*/
evil: boolean;
/**
* Allows expressions as statements
*/
expr: boolean;
/**
* Allows variables from outer scope to be redeclared
*/
funcscope: boolean;
/**
* Allows global strict mode
*/
globalstrict: boolean;
/**
* Allows __iterator__ property
*/
iterator: boolean;
/**
* Allows semicolon omission for last statement
*/
lastsemic: boolean;
/**
* Allows line breaks before operators
*/
laxbreak: boolean;
/**
* Allows comma-first style
*/
laxcomma: boolean;
/**
* Allows function definitions inside loops
*/
loopfunc: boolean;
/**
* Allows multiline strings with backslash
*/
multistr: boolean;
/**
* Allows Mozilla-specific syntax
*/
moz: boolean;
/**
* Allows missing typeof in comparisons
*/
notypeof: boolean;
/**
* Allows generators without yield
*/
noyield: boolean;
/**
* Allows ++ and -- operators
*/
plusplus: boolean;
/**
* Allows __proto__ property
*/
proto: boolean;
/**
* Allows javascript: URLs
*/
scripturl: boolean;
/**
* Allows [] notation when dot notation would work
*/
sub: boolean;
/**
* Allows weird constructor invocations
*/
supernew: boolean;
/**
* Allows this usage in non-constructor functions
*/
validthis: boolean;
/**
* Allows with statements
*/
withstmt: boolean;
}Usage Examples:
// Legacy code support
const legacyOptions = {
asi: true, // allow missing semicolons
boss: true, // allow assignments in conditions
expr: true, // allow expression statements
loopfunc: true // allow functions in loops
};
// Modern relaxed settings
const relaxedModern = {
esversion: 8,
esnext: false, // use specific esversion instead
validthis: true, // allow this in arrow functions context
laxcomma: true // allow comma-first style
};Environment-specific global variable definitions for different JavaScript runtime environments.
interface EnvironmentOptions {
/**
* Browser environment globals (window, document, etc.)
*/
browser: boolean;
/**
* Node.js environment globals (global, process, Buffer, etc.)
*/
node: boolean;
/**
* Development/debugging globals (console, alert, etc.)
*/
devel: boolean;
/**
* jQuery library globals ($, jQuery)
*/
jquery: boolean;
/**
* MooTools library globals
*/
mootools: boolean;
/**
* Prototype.js library globals
*/
prototypejs: boolean;
/**
* Dojo Toolkit globals
*/
dojo: boolean;
/**
* YUI library globals
*/
yui: boolean;
/**
* Mocha testing framework globals (describe, it, etc.)
*/
mocha: boolean;
/**
* Jasmine testing framework globals
*/
jasmine: boolean;
/**
* QUnit testing framework globals
*/
qunit: boolean;
/**
* Web Worker environment globals
*/
worker: boolean;
/**
* Rhino JavaScript engine globals
*/
rhino: boolean;
/**
* Windows Script Host globals
*/
wsh: boolean;
/**
* PhantomJS globals
*/
phantom: boolean;
/**
* CouchDB globals
*/
couch: boolean;
/**
* ShellJS globals
*/
shelljs: boolean;
/**
* ES6 modules environment
*/
module: boolean;
/**
* Non-standard but widely supported globals
*/
nonstandard: boolean;
/**
* Typed array globals
*/
typed: boolean;
}Usage Examples:
// Browser + jQuery environment
const browserConfig = {
browser: true,
jquery: true,
devel: true // for console.log
};
// Node.js environment
const nodeConfig = {
node: true,
esversion: 8
};
// Testing environment
const testConfig = {
node: true,
mocha: true,
esversion: 6
};Options that accept specific values rather than just boolean true/false.
interface ValueOptions {
/**
* ECMAScript version: 3, 5, 6, 7, 8, 9, 10, 11, etc.
*/
esversion: number;
/**
* Maximum line length
*/
maxlen: number;
/**
* Maximum number of errors before stopping
*/
maxerr: number;
/**
* Maximum nesting depth for blocks
*/
maxdepth: number;
/**
* Maximum number of statements per function
*/
maxstatements: number;
/**
* Maximum cyclomatic complexity
*/
maxcomplexity: number;
/**
* Maximum number of parameters per function
*/
maxparams: number;
/**
* Expected indentation (number of spaces or tabs)
*/
indent: number;
/**
* Quote style: true (consistent), 'single', 'double', false (any)
*/
quotmark: boolean | 'single' | 'double';
/**
* Variable shadowing: true (allow), false (prohibit), 'inner', 'outer'
*/
shadow: boolean | 'inner' | 'outer';
/**
* Strict mode: true (require), false (ignore), 'global', 'implied'
*/
strict: boolean | 'global' | 'implied';
/**
* Unused variables: true (warn), false (ignore), 'vars', 'strict'
*/
unused: boolean | 'vars' | 'strict';
/**
* Late definition: true (prohibit), false (allow), 'nofunc'
*/
latedef: boolean | 'nofunc';
/**
* Ignore specific warnings by code (e.g., 'W004,W008')
*/
ignore: string;
/**
* Custom ignore delimiters for inline ignoring
*/
ignoreDelimiters: string;
/**
* Predefined globals as array or object
*/
predef: string[] | {[key: string]: boolean};
/**
* Additional global variables
*/
globals: {[key: string]: boolean};
/**
* Scope identifier for internal use
*/
scope: string;
}Usage Examples:
// Comprehensive configuration
const fullConfig = {
// ECMAScript version
esversion: 8,
// Code quality limits
maxlen: 120,
maxdepth: 4,
maxstatements: 25,
maxcomplexity: 10,
maxparams: 5,
// Code style
indent: 2,
quotmark: 'single',
// Variable handling
unused: 'vars',
latedef: 'nofunc',
shadow: 'outer',
// Strict mode
strict: 'global',
// Custom globals
predef: ['myGlobal', 'anotherGlobal'],
// Environment
node: true,
// Ignore specific warnings
ignore: 'W004,W008'
};JSHint follows a specific order when loading configuration:
--config).jshintrc files (current directory walking up)package.json jshintConfig property~/.jshintrc (user home directory)// Strict modern JavaScript
const strict = {
esversion: 8,
strict: 'global',
undef: true,
unused: true,
curly: true,
eqeqeq: true,
freeze: true,
futurehostile: true
};
// Legacy browser code
const legacy = {
browser: true,
devel: true,
jquery: true,
asi: true,
boss: true,
expr: true,
loopfunc: true
};
// Node.js server code
const server = {
node: true,
esversion: 8,
strict: 'global',
undef: true,
unused: 'vars'
};
// Test files
const testing = {
node: true,
mocha: true,
esversion: 6,
expr: true, // allow expect().to.be.ok
unused: false // test helpers might not be used
};