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
  • JSLint JSHint Use the isNaN function to compare with NaN

    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 JSHint A leading decimal point can be confused with a dot: '{a}'

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

  • JSHint Missing '()' invoking a constructor

    JSHint will throw the "Missing '()' invoking a constructor" error when it encounters a new expression that is not immediately followed by a pair of parentheses. In the following example...

  • JSLint JSHint Missing 'use strict' statement

    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 Move the invocation into the parens that contain the function

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

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

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

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

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

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

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

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.