JSLint and the popular fork of it, JSHint, seem to be proud of the fact that they will "hurt your feelings". Well that's OK, but it would be nice if it made it a bit clearer why they were hurting them.
JSLint Error Explanations is designed to help you improve your JavaScript by understanding the sometimes cryptic error messages produced by JSLint and JSHint, and teaching you how to avoid such errors.
This site is still a work in progress. Not all JSLint or JSHint error messages are documented here yet. The code is all available on GitHub if you would like to help out! Alternatively, you can request an article for a specific error message by contacting me or raising an issue on GitHub.
JSLint and JSHint will throw the "'{a}' is a statement label" error when it encounters a reference that shares an identifier with a label defined in the same scope. In...
JSLint (prior to version 2013-03-18) will throw the "ADsafe violation: '{a}'" error in a number of situations, but only when the adsafe option is set to true (it's false by...
JSLint (prior to version 2013-03-18) throws the "ADsafe autocomplete violation" error when the adsafe and fragment options are both set to true (they're false by default) and you pass it...
JSLint (prior to version 2013-03-18) throws the "ADSAFE violation: bad id" error when the adsafe and fragment options are set to true (they're false by default) and you pass it...
JSLint (prior to version 2013-03-18) throws the "ADsafe violation: Wrap the widget in a div" error when the adsafe and fragment options are set to true (they're false by default)...
JSLint (prior to version 2013-03-18) throws the "ADSAFE: Use the fragment option" error when the adsafe option is set to true (it's false by default) and you pass it a...
JSLint (prior to version 2013-03-18) throws the "ADsafe violation: Misformed ADSAFE.go" error when the adsafe and fragment options are set to true (they're false by default) and the call to...
JSLint (prior to version 2013-03-18) throws the "Currently, ADsafe does not operate on whole HTML documents. It operates on <div> fragments and .js files" error when the adsafe and fragment...
JSLint will throw the "Nested comment" error when it encounters the characters /* inside a multiline comment. Here's an example:/* This is a multiline comment./* It's valid JavaScript,/* but JSLint...
JSLint and JSHint will throw the "Do not assign to the exception parameter" error when they encounter an assignment inside a catch block to the identifer associated with that block....
JSLint and JSHint will throw the "Do not use 'new' for side effects" error when they encounter a function invocation preceded by the new operator when not part of an...
JSLint will throw the "Do not wrap function literals in parens unless they are to be immediately invoked" error when it encounters a function expression wrapped in parentheses with no...
JSLint will throw the "Combine this with the previous 'var' statement" error when it encounters multiple variable statements within a function. Here's an example in which we attempt to declare...
JSLint will throw the "A constructor name '{a}' should start with an uppercase letter" error when it encounters a function whose identifier begins with a lowercase letter and is later...
JSLint will throw the "Unexpected dangling '_' in '{a}'" error when it encounters an identifier that begins or ends with the underscore character. JSHint will throw this error in the...
JSLint will throw the "Only properties should be deleted" error when it encounters the delete operator when its operand does not appear to be an object property. In the following...
JSLint and JSHint (prior to version 1.0.0) will throw the "Empty class" error when it encounters a regular expression literal containing an empty character class. Note that it will not...
JSLint will throw the "This is an ES5 feature" error when it encounters a multiline string. In the following example we attempt to assign a multiline string to the variable...
JSLint and JSHint (prior to version 1.0.0) will throw the "eval is evil" error when they encounter an invocation of the eval function. Here's an example in which we use...
JSLint and JSHint will throw the "Expected an identifier and instead saw '{a}' (a reserved word)" error when they expect a reference to an identifier but finds a keyword that...
JSLint will throw the "Expected exactly one space between '{a}' and '{b}'" error when it encounters a number of spaces that is not equal to one in the following situations...
JSLint will throw the "The body of a for in should be wrapped in an if statement to filter unwanted properties from the prototype" error when it encounters a for-in...
JSLint will throw the "Function statements should not be placed in blocks" error when it encounters a function declaration inside a block statement. In the following example we attempt to...
JSLint and JSHint (before version 1.0.0) will throw the "The Function constructor is eval" error when they encounter a call to the Function constructor function preceded by the new operator....
JSLint and JSHint will throw the "Don't make functions within a loop" error when they encounter a function statement or expression within a for, while or do statement. In the...
JSLint will throw the "Function statements are not invocable. Wrap the whole function invocation in parens" error when it encounters a function declaration followed by a pair of invoking parentheses....
JSLint and JSHint (before version 1.0.0) will throw the "Implied eval is evil. Pass a function instead of a string" error when they encounter a call to the setTimeout or...
JSLint and JSHint will throw the "Use the isNaN function to compare with NaN" error when they encounter a comparison in which one side is NaN. In the following example...
JSLint and JSHint will throw the "A leading decimal point can be confused with a dot: '{a}'" error when they encounter a numeric literal preceded by a . character which...
JSLint will throw the "Missing 'use strict' statement" error when it encounters a function that does not contain the strict mode directive, and none of whose ancestor scopes contain the...
JSLint will throw the "Move the invocation into the parens that contain the function" error when it encounters an immediately invoked function expression in which the invoking parentheses appear outside...
JSLint will throw the "Move 'var' declarations to the top of the function" error when it encounters a variable declaration in a for loop initialiser. Here's an example in which...
JSLint will throw the "Missing name in function statement" error when it encounters the function keyword, where it would be parsed as a statement, followed immediately by an opening parenthesis....
JSLint and JSHint will throw the "Do not use {a} as a constructor" error when they encounter a call to String, Number, Boolean, Math or JSON preceded by the new...
JSLint will throw the "'{a}' is not a label" error when it encounters a break or continue statement referencing a label that does not exist. In the following example we...
JSLint will throw the "Don't use octal: '{a}'. Use '\u...' instead" error when it encounters a string literal that contains the escape character followed by a digit between 0 and...
JSLint and JSHint will throw the "Unexpected parameter '{a}' in get {b} function" error when they encounter a named argument in the signature of a property getter function. In the...
JSLint will throw the "Expected parameter (value) in set '{a}' function" error when it encounters multiple named arguments in the signature of a property setter function, none of which have...
JSLint and JSHint will throw the "Missing radix parameter" error when they encounter a call to the parseInt function that only has one argument. Here's an example:parseInt("10"); Why do I...
JSLint and JSHint will throw the "Read only" error when they encounter an attempt to assign a value to built-in native object. In the following example we attempt to overwrite...
JSLint and JSHint will throw the "A regular expression literal can be confused with '/='" error when they encounter a regular expression literal that begins with the = character. In...
JSLint will throw the "Stopping. ({a}% scanned)" error when it encounters a JavaScript syntax error and cannot continue to reliably parse the program. JSHint will throw this error in the...
JSLint and JSHint will throw the "['{a}'] is better written in dot notation" error when they encounter an attempt to access a property using a string literal and square bracket...
JSLint will throw the "Unexpected sync method: '{a}'" error when it encounters an attempt to access a property whose identifier ends with the string "Sync". In the following example we...
JSLint will throw the "Unexpected TODO comment" error when it encounters a comment in which the first word is "TODO". Here's an example:// TODO: Finish writing about JSLint errors Why...
JSLint and JSHint will throw the "Unclosed string" error when they encounter a string that is not closed at the next line break, or at the end of the program....
JSLint and JSHint will throw the "Unclosed comment" error when they encounter a multiline comment that does not end with the characters */. Here's an example:/* This is a comment...
JSLint will throw the "Unexpected '++'" error when it encounters the use of the increment operator ++. It will throw the related "Unexpected '--'" error when it encounters the use...
JSLint and JSHint will throw the "Unexpected '{a}' error in a wide range of situations, which can cover both fatal syntax errors and simple stylistic choices. Some of the common...
JSLint will throw the "Unexpected 'else' after 'return'" error when it encounters an else block following an if block that contains a return statement. Here's some example code:function example(x) {...
JSLint will throw the "Unexpected label '{a}'" error when it encounters a labelled statement whose statement is not an iteration or switch statement or a labelled statement in the global...
JSLint and JSHint will throw the "It is not necessary to initialize '{a}' to 'undefined'" error when they encounter a variable statement in which the variable is explicitly initialized to...
JSLint will throw the "Unnecessary use strict" error when it encounters an occurence of the "use strict" directive in code that is already running in strict mode. In the following...
JSLint and JSHint (before version 1.0.0) will throw the "Use the array literal notation []" error when they encounter a call to the Array constructor with the new operator. Here's...
JSLint and JSHint (before version 1.0.0) will throw the "Spaces are hard to count. Use {a}" error when they encounter a regular expression literal containing multiple consecutive space characters. In...
JSLint and JSHint (before version 1.0.0) will throw the "Use the object literal notation {}" error when they encounter a call to the Object constructor preceded by the new operator....
JSLint will throw the "'{a}' was used before it was defined" error when it encounters a reference to an identifier that has not been declared as part of a var...
JSLint will throw the "Weird assignment" error when it encounters an assignment expression in which the left hand and right hand side expressions are "similar". In the following example we...
JSLint will throw the "Weird relation" error when it encounters a comparison in which the left and right hand sides are "similar", or a comparison in which either the left...
JSLint will throw the "Wrap an immediate function invocation in parentheses" error when it encounters an immediately invoked function expression that is not wrapped in parentheses. JSHint will throw this...
Sorry, but we couldn't find any JSLint errors that match your search.
Tip: if your search contains variable or function identifiers from your own code, try removing them. All of our article titles are generic and use placeholders instead of the identifiers that JSLint will actually include in your error message.