Fork me on GitHub

JSLint Error Explanations

JSLint will hurt your feelings. It's time to make them better!


Welcome!

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.


JSHint Error Messages

Search
  • JSHint Mixed double and single quotes

    JSHint (since version r09) will throw the "Mixed double and single quotes" error when it encounters a string literal delimited by double or single quote characters, when a string literal...

  • JSHint Missing name in function declaration

    JSHint will throw the "Missing name in function declaration" error when it encounters the function keyword, where it would be parsed as a statement, followed immediately by an opening parenthesis....

  • JSLint JSHint Do not use {a} as a constructor

    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 JSHint '{a}' is not a function

    JSLint and JSHint will throw the "'{a}' is not a function" error when they encounter an attempt to invoke the Math object as a function. JSLint is designed to also...

  • JSHint '{a}' is not a statement label

    JSHint will throw the "'{a}' is not a statement label" error when it encounters a break or continue statement referencing a label that does not exist. In the following example...

  • JSHint Octal literals are not allowed in strict mode

    JSHint will throw the "Octal literals are not allowed in strict mode" error when it encounters a string literal that contains the escape character followed by a '0', followed by...

  • JSLint JSHint Unexpected parameter '{a}' in get {b} function

    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 JSHint Missing radix parameter

    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 JSHint Read only

    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...

  • JSHint Redefinition of '{a}'

    JSHint will throw the "Redefinition of '{a}'" error when it encounters an attempt to declare a variable whose identifier is the same as that of a built-in native object. In...

  • JSHint Did you mean to return a conditional instead of an assignment?

    JSHint will throw this error when a return clause contains an ambiguous assignment operator where a comparison operator could exist:function multiply(num_one, num_two) { return result = num_one * num_two;} In...

  • JSLint JSHint A regular expression literal can be confused with '/='

    JSLint and JSHint (prior to version 1.0.0) will throw the "A regular expression literal can be confused with '/='" error when they encounter a regular expression literal that begins with...

  • JSLint JSHint Stopping. ({a}% scanned)

    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...

  • JSHint Strings must use singlequote

    JSHint (since version r09) will throw the "Strings must use singlequote" error when it encounters a string literal delimited by double quote characters, but only when quotmark option is set...

  • JSLint JSHint ['{a}'] is better written in dot notation

    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...

  • JSHint This function has too many parameters

    JSHint (version 1.0.0 and above) will throw the "This function has too many parameters" error when it encounters a function signature with more named arguments than specified by the maxparams...

  • JSHint Too many parameters per function ({a})

    JSHint (below version 1.0.0) will throw the "Too many parameters per function ({a})" error when it encounters a function signature with more named arguments than specified by the maxparams option....

  • JSLint JSHint Unclosed string

    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 JSHint Unclosed comment

    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 JSHint Unclosed regular expression

    JSLint and JSHint will throw the "Unclosed regular expression" error when they encounter a regular expression literal with no closing / character. Here's an example:var r = /^unclosed$; Why do...

  • JSLint JSHint Unexpected '{a}'

    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...

  • JSHint Unnecessary semicolon

    JSHint will throw the "Unnecessary semicolon" error when it encounters a semicolon following a block statement or function declaration. In the following example we mistakenly include a semicolon after an...

  • JSLint JSHint It is not necessary to initialize '{a}' to 'undefined'

    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...

  • JSHint The array literal notation [] is preferrable

    JSHint (version 1.0.0 and above) will throw the "The array literal notation [] is preferrable" error when it encounters a call to the Array constructor preceded by the new operator....

  • JSLint JSHint Use the array literal notation []

    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 JSHint Spaces are hard to count. Use {a}

    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...

  • JSHint The object literal notation {} is preferrable

    JSHint (version 1.0.0 and above) will throw the "The object literal notation {} is preferrable" error when it encounters a call to the Object constructor preceded by the new operator....

  • JSLint JSHint Use the object literal notation {}

    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....

  • JSHint '{a}' is not defined

    JSHint will throw the "'{a}' is not defined" error when it encounters a reference to an identifier that has not been declared as part of a var or function statement,...

  • JSLint JSHint Variable {a} was not declared correctly

    JSLint and JSHint (prior to version 2.1.4) will throw the "Variable {a} was not declared correctly" error when they encounter more than one inline assignment. In this example, we attempt...

  • JSHint Don't use 'with'

    JSHint will throw the "Don't use 'with'" error when it encounters a use of the with statement in code that is not running in strict mode. Here's an example:function example()...

  • JSHint 'with' is not allowed in strict mode

    JSHint will throw the "'with' is not allowed in strict mode" error when it encounters a with statement inside code running in strict mode. In the following example we attempt...

  • JSLint JSHint Wrap an immediate function invocation in parentheses

    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...

  • JSHint You might be leaking a variable ({a}) here

    JSHint (version 2.1.4 and above) will throw the "You might be leaking a variable ({a}) here" error when it encounters more than one inline assignment. In this example, we attempt...

Sorry, but we couldn't find any JSHint 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.


Proceeds generated by this site are donated to help advance other open source projects