JSLint and the popular alternatives JSHint and ESLint are brilliant tools that make your code more consistent. But sometimes it's hard to understand exactly what they're asking you to change. JSLint goes so far as to be proud of the fact that it will "hurt your feelings".
JSLint Error Explanations is designed to help you improve your JavaScript by understanding the sometimes cryptic error messages produced by JSLint, JSHint and ESLint, and teaching you how to avoid such errors.
This warning has existed in two forms across JSLint and JSHint. It was introduced in the original version of JSLint and has remained in both tools ever since. In JSLint releases prior to May 2015 and all version…
Also known as
The "Avoid arguments.{a}" error is thrown when JSLint, JSHint or ESLint encounters a reference to the callee or caller property of an arguments object. The text of this warning can the…
Also known as
The "Bad constructor" error is thrown when JSLint or JSHint encounters the new operator followed by a literal value. In the following example we are attempting to apply the new operato…
Also known as
This warning has existed in several forms across the three main linters. It was introduced in the original version of JSLint and has remained in all three tools ever since. In JSLint and JSHint prior to version…
Also known as
This warning has existed in a few forms in both JSLint and JSHint. It was introduced in the original version of JSLint and has remained in both tools ever since. In JSHint prior to version 1.0.0 the warning give…
Also known as
The "Unexpected dangling '_' in '{a}'" error is thrown when JSLint, JSHint or ESLint encounters an identifier that begins or ends with the underscore character. JSHint…
Also known as
The "['{a}'] is better written in dot notation" error is thrown when JSLint, JSHint or ESLint encounters an attempt to access a property using a string literal within a pair of…
Also known as
The "Empty class" error is thrown when JSLint, JSHint (only versions before 1.0.0) or ESLint encounters a regular expression literal containing an empty character class. The following…
This warning has existed in various forms across the three main linters. It was introduced in the original version of JSHint and has remained (in a way) in all three tools from some point since. In JSLint the wa…
Also known as
The "Do not assign to the exception parameter" error is thrown when JSLint, JSHint or ESLint encounters an assignment inside a catch block to the identifer associated with that block.…
Also known as
The "Expected a string and instead saw '{a}'" error is thrown when JSLint encounters a comparison operator in which one of the operands is a typeof expression and the other ope…
This warning has existed in various forms across the three main linters. It was introduced in the original version of JSLint and has remained in all three tools ever since. In JSLint the warning given is the gen…
Also known as
This warning has existed in two forms in JSLint, JSHint and ESLint. It was introduced in the original version of JSLint and has remained in all three linters ever since. In JSLint and JSHint prior to version 1.0…
Also known as
The "Don't make functions within a loop" error is thrown when JSLint, JSHint and ESLint encounter a function expression in a for, while or do statement body. In the following examp…
Also known as
This warning has existed in two forms across JSLint and JSHint. It was introduced in May 2011 version of JSLint and remained in both tools for a period of time. In JSLint between May 2011 and August 2013 the mes…
Also known as
The "It is not necessary to initialize '{a}' to 'undefined'" error is thrown when JSLint, JSHint or ESLint encounters a variable statement in which the variable is expl…
Also known as
This warning has existed in two forms across the three main linters. It was introduced in the original version of JSLint and has remained in all three tools ever since. In JSLint versions dated before May 2013 t…
Also known as
This warning has existed in two forms across the three main linters. It was introduced in the original version of JSLint and has remained in all three tools ever since. In JSLint the warning given is the generic…
Also known as
The "Missing 'use strict' statement" error is thrown when JSLint, JSHint and ESLint encounter a function that does not contain the strict mode directive, and none of whose ance…
Also known as
The "Move 'var' declarations to the top of the function" error is thrown when JSLint encounters a variable declaration in a for or for-in statement initialiser. Here's an e…
The "Do not use 'new' for side effects" error is thrown when JSLint, JSHint or ESLint encounters a function invocation preceded by the new operator when not part of an assignme…
Also known as
This warning has existed in three forms across the three main linters. It was introduced in the original version of JSLint and has remained (in a way) in all three tools ever since. In JSLint the warning given i…
Also known as
This warning has existed in various forms across the three main linters. It was introduced in the original version of JSLint and has remained in all three tools ever since. In JSLint versions dated May 2013 onwa…
Also known as
This warning has existed in two forms across the three main linters. It was introduced in the original version of JSLint and has remained in all three tools ever since. In all versions of JSLint and JSHint the w…
Also known as
This warning was introduced in the original version of JSLint and existed in the same form in JSHint until version 1.0.0 when it was removed. ESLint has always issued the same warning. T…
Also known as
The "Expected an identifier and instead saw '{a}' (a reserved word)" error is thrown when JSLint or JSHint encounters a reference to what should be an identifier but is actuall…
Also known as
The "Stopping. ({a}% scanned)" error is thrown when JSLint or JSHint encounters a JavaScript syntax error and cannot continue to reliably parse the program. JSHint will only raise this…
Also known as
The "Unexpected TODO comment" error is thrown when JSLint encounters an attempt to a comment in which the first word is TODO. The regular expression used by JSLint to determine whether…
The "Type confusion: {a} and {b}" error is thrown when JSLint (versions dated between June 2011 and July 2011) encounters an attempt to change the type of data assigned to a variable.…
The "Unclosed mega literal" error is thrown when JSLint encounters an unclosed template string literal. JSHint raises the "Unclosed template literal" error in the same situat…
Also known as
The "Unclosed string" error is thrown when JSLint or JSHint encounters a a string that is not closed before the next line break or the end of the program. There are numerous situations…
Also known as
The "Unexpected comment" error is thrown when JSLint encounters a single-line or multi-line comment in a JSON string. It will only generate this error when in JSON mode (it enters JSON…
This warning has existed in two forms in JSLint and ESLint. It was introduced in the original version of JSLint and has remained in both tools since. It is not present in JSHint. In JSLint the warning given is &…
Also known as
This warning has existed in two forms in JSLint, JSHint and ESLint. It was introduced in the original version of JSLint and has remained in all three linters ever since. In JSLint versions dated July 2013 and la…
Also known as
This warning has existed in two forms in JSLint and ESLint. It was introduced in the original version of JSLint and has remained in both tools ever since. It is not present in JSHint. In JSLint versions dated la…
Also known as
This warning has existed in two forms across the three main linters. It was introduced in a very early version of JSLint and has remained in all three tools ever since. In JSLint and JSHint prior to version 1.0.…
Also known as
This warning has existed in a number of forms in both JSLint and JSHint. It was introduced in the original version of both and has remained ever since. In JSLint versions dated before May 2015 the warning given…
Also known as
This warning has existed in two forms in JSLint, JSHint and ESLint. It was introduced in the original version of JSLint and has remained in all three linters ever since. In JSLint the warning given is "Unus…
Also known as
The "Use the isNaN function to compare with NaN" error is thrown when JSLint, JSHint and ESLint encounter a comparison in which one side is NaN. In the following example we attempt to…
Also known as
The "Use the || operator" error is thrown when JSLint encounters a conditional operator in which the logical expression and first assignment expression are identical. In the following…
The "Weird assignment" error is thrown when JSLint encounters an assignment expression in which the left hand side and right hand side expressions are the same. In the following exampl…
The "Wrap an immediate function invocation in parentheses" error is thrown when JSLint, JSHint and ESLint encounter an immediately invoked function expression that is not wrapped in pa…
Also known as
This warning has existed in two forms across the three main linters. It was introduced in the original version of JSLint and has remained in all three tools ever since. In JSLint and JSHint prior to version 1.0.…
Also known as
This warning has existed in two forms across the three main linters. It was introduced in the original version of JSLint and has remained in all three tools ever since. In JSLint and JSHint the warning given has…
Also known as
This warning has existed in two forms across the three main linters. It was introduced in the original version of JSLint and has remained in all three tools ever since. In JSLint and JSHint prior to version 2.1.…
Also known as
This warning has existed in two forms in JSLint and JSHint. It was introduced in JSLint in June 2011 and has remained in both tools ever since. In JSLint the warning given is "Combine this with the previous…
Also known as
This warning has existed in a few forms in both JSLint and JSHint. It was introduced in the original version of JSLint and has remained in both tools ever since. In JSHint prior to version 1.0.0 the warning give…
Also known as
This warning has existed in various forms in JSLint, JSHint and ESLint. It was introduced in the original version of JSLint and has remained in all three linters ever since. In JSLint the warning given is "…
Also known as
This warning has existed in three forms in JSLint, JSHint and ESLint. It was introduced in the original version of JSLint and has remained in all three linters ever since. In JSLint the warning given is the gene…
Also known as
This is one of many generic error messages uses by JSLint in a number of situations. Most of these cases are covered in detail by dedicated articles. Following is a list of situations that will…
This warning has existed in two forms in JSLint, JSHint and ESLint. It was introduced in the original version of JSLint and has remained in all three tools ever since. In JSLint the warning given is "eval i…
Also known as
The "Expected exactly one space between '{a}' and '{b}'" error is thrown when JSLint encounters a number of spaces that is not equal to one in the following situations…
The "Expected parameter (value) in set '{a}' function" error is thrown when JSLint encounters property setter function in which the first parameter is not named value. In the f…
The "The body of a for in should be wrapped in an if statement to filter unwanted properties from the prototype" error is thrown when JSLint encounters a for-in statement in which the…
Also known as
The "Function statements should not be placed in blocks" error (and the alternative "Function declarations should not be placed in blocks" error) is thrown when JSLint or JSH…
Also known as
The "Use the function form of 'use strict'" error is thrown when JSLint, JSHint or ESLint encounters a strict mode directive in the outermost scope of the code. In the followin…
Also known as
This warning has existed in two forms across the three main linters. It was introduced in the original version of JSLint and has remained in all three tools ever since. In JSLint and JSHint prior to version 1.0.…
Also known as
The "Function statements are not invocable. Wrap the whole function invocation in parens" error (and the alternative "Function declarations are not invocable" error) is throw…
Also known as
The "Do not use {a} as a constructor" error is thrown when JSLint, JSHint or ESLint encounters a call to String, Number, Boolean, Math or JSON preceded by the new operator. In the foll…
Also known as
The "Missing radix parameter" error is thrown when JSLint, JSHint or ESLint encounters a call to the parseInt function that only has one argument. As of JSHint 2.3.0 the warning will o…
Also known as
The "Move the invocation into the parens that contain the function" error is thrown when JSLint and ESLint encounter an immediately invoked function expression in which the invoking pa…
The "Nested comment" error is thrown when JSLint encounters the character sequence /* inside a multiline comment. Here's an example: /* This is a multiline comment. /* It's…
The "'{a}' is not a function" error is thrown when JSLint, JSHint or ESLint encounters an attempt to invoke the Math object as a function. JSLint and ESLint (but not JSHint) wi…
Also known as
This warning has existed in two forms across the three main linters. It was introduced in the original version of JSLint and has remained in all three tools ever since. In JSLint the warning given is "'…
Also known as
This warning has existed in three forms across the three main linters. It was introduced in the original version of JSLint and has remained (in a way) in all three tools ever since. In JSLint the warning given i…
Also known as
This warning has existed in two forms across the three main linters. It was introduced in the original version of JSLint and has remained (in a way) in all three tools ever since. In JSLint and JSHint the warnin…
Also known as
The "Spaces are hard to count. Use {a}" error is thrown when JSLint, ESLint or JSHint (prior to version 1.0.0) encounters a regular expression literal containing two or more consecutiv…
This warning has existed in two forms across the three main linters. It was introduced in the original version of JSLint and has remained in all three tools ever since. In all versions of JSLint and JSHint the w…
Also known as
The "The '&&' subexpressions should be wrapped in parens" error is thrown when JSLint encounters an expression containing both logical 'or' and logical 'and…
This warning has existed in two forms across the three main linters. It was introduced in the original version of JSLint and has remained in all three tools ever since. In JSLint versions dated before May 2013 t…
Also known as
The "Unclosed comment" error is thrown when JSLint or JSHint encounters a multiline comment that does not end with the character sequence */. Here's an example: /* This is a commen…
Also known as
The "Unclosed regular expression" error is thrown when JSLint or JSHint encounters a regular expression literal with no closing / character. Here's an example: var regex = /^unclos…
Also known as
This warning has existed in two forms across the three main linters. It was introduced in the original version of JSLint and has remained in all three tools ever since. In JSLint, up until July 2013, the warning…
Also known as
This warning has existed in two forms across the three main linters. It was introduced in the original version of JSLint and has remained (in a way) in all three tools ever since. In JSLint and JSHint the warnin…
Also known as
The "Unexpected sync method: '{a}'" error is thrown when JSLint (versions from March 2012 onwards) encounters an attempt to access a property whose identifier ends with the cha…
This warning has existed in three forms across the three main linters. It was introduced in the original version of JSLint and has remained (in a way) in all three tools ever since. In JSLint the warning given i…
Also known as
This warning has existed in two forms in JSLint. It was introduced in the original version and has remained ever since. It is not present in JSHint or ESLint. In JSLint versions dated December 2010 and earlier t…
Also known as
The "Unnecessary 'use strict'" error (and the alternative "Unnecessary directive '{a}'" error) is thrown when JSLint, JSHint or ESLint encounters a "use…
Also known as
The "Expected an assignment or function call and instead saw an expression" error is thrown when JSLint, JSHint or ESLint encounters an expression with no effect. In the following exam…
Also known as
The "A constructor name should start with an uppercase letter" error is thrown when JSLint, JSHint or ESLint encounters an identifier, preceded by the new operator, whose first charact…
Also known as
The "Use a named parameter" error is thrown when JSLint encounters a access a property of the arguments object by numerical index. The following example adds two numbers. Since the fun…
This warning has existed in two forms in JSLint, JSHint and ESLint. It was introduced in the original version of JSLint and has remained in all three tools ever since. In JSLint the warning given is "Only p…
Also known as
This warning has existed in two forms in JSLint and ESLint. It was introduced in the original version of JSLint and has remained in both tools since. It is not present in JSHint. In JSLint the warning given is &…
Also known as