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 Error Messages

Search
  • JSLint Move 'var' declarations to the top of the function

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

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

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

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

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

  • 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 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 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 'else' after 'return'

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

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

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

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

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

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.