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.


JSLint & JSHint Error Messages

Search
  • 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 Missing name in function statement

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

  • JSLint '{a}' is not a label

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

  • 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 Don't use octal: '{a}'. Use '\u...' instead

    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 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 Expected parameter (value) in set '{a}' function

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

  • JSLint Unexpected sync method: '{a}'

    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 Unexpected TODO comment

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

  • 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 Type confusion: {a} and {b}

    JSLint (for versions dated between June and July 2011) will throw the "Type confusion: {a} and {b}" error when it encounters an attempt to change the type of data assigned...

  • 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 Unexpected 'with'

    JSLint (since July 2013) will throw the "Unexpected 'with'" error when it encounters a use of the with statement. Prior to July 2013, the message was "Expected an identifier and...

  • JSLint Unexpected '++'

    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 Unexpected assignment expression

    JSLint (since July 2013) will throw this error when a clause exists in a while, for, or if that contains an ambiguous assignment operator where a comparison operator could exist....

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

  • JSLint Unexpected comment

    JSLint will throw the "Unexpected comment" error when it encounters a single or multiline comment in a JSON file. It will only generate this error when in JSON mode (it...

  • JSLint Unexpected 'else' after 'return'

    JSLint (prior to July 2013) 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...

  • JSLint Unexpected label '{a}'

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

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

  • JSLint Unnecessary 'else' after disruption

    This is a new and improved version of the old JSLint "Unexpected 'else' after 'return'" warning. More details may be found on the page for that message. JSLint (since July...

  • JSLint Unnecessary use strict

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

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

  • JSLint Use the || operator

    JSLint will throw the "Use the || operator" error when it encounters a conditional operator in which the logical expression and first assignment expression are identical. In the following example...

  • JSLint Use a named parameter

    JSLint will throw the "Use a named parameter" error when it encounters an attempt to access a property of the arguments object by numerical index. In the following example we...

  • 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 '{a}' was used before it was defined

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

  • JSLint Weird assignment

    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 Weird relation

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

  • 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 JSLint or 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