Rule | Description | KPI | URL |
---|---|---|---|
unexpectedParameterInGetterFunction | The “Unexpected parameter in getter function” error, and the alternative “Unexpected identifier”, is thrown when JSLint, JSHint or ESLint encounters a named parameter in the signature of a property getter function. In the provided example we create an object x with a getter and setter. | Maintainability | http://linterrors.com/js/unexpected-parameter-a-in-get-b-function |
avoidArguments | 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 therefore be either “Avoid arguments.callee” or “Avoid arguments.caller”. JSHint will only raise this warning if the noarg option is set to true. | Maintainability | http://linterrors.com/js/avoid-arguments |
badForInVariable | The “Bad for-in variable ‘{a}'” error (and the alternative “Creating global ‘for’ variable” and “Invalid left-hand side in for-in” errors) are thrown when JSLint, JSHint or ESLint encounters a for-in statement in which the initializer contains a literal value. JSLint and JSHint also raise this warning when it encounters a for-in statement in which the initializer contains an undefined variable reference. | Maintainability | http://linterrors.com/js/bad-for-in-variable |
ConstHasAlreadyBeenDeclared | The “const ‘{a}’ has already been declared” error is thrown when JSHint encounters a constant declaration with an identifier that has already been used in a previous constant declaration. | Maintainability | http://linterrors.com/js/const-a-has-already-been-declared |
doNotAssignToTheExceptionParameter | 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. In the example provided we attempt to assign a new value to the exception parameter e | Maintainability | http://linterrors.com/js/do-not-assign-to-the-exception-parameter |
doNotMakeFunctionsWithinALoop | 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 provided example we attempt to add a click event listener to each element with a given class name. The event handler is intended to overwrite the contents of the clicked element with the value of i at a specific iteration of the loop | Maintainability | http://linterrors.com/js/dont-make-functions-within-a-loop |
duplicateKey | The “Duplicate key ‘{a}'” error, and the alternatives “Duplicate member ‘{a}'” and “Duplicate ‘{a}'”, is thrown when JSLint, JSHint or ESLint encounters an an object literal that contains more than one property with the same identifier. In the provided example we attempt to assign an object containing two properties with the identifier y to a variable x. | Maintainability | http://linterrors.com/js/duplicate-key-a |
expectedAnIdentifier | 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 actually a keyword that is reserved by the language. In the provided example we attempt to declare a variable with the identifier default which is a reserved word. | Maintainability | http://linterrors.com/js/expected-an-identifier-and-instead-saw-a-a-reserved-word |
functionHasTooManyParameters | The “Too many parameters per function. ({a})” error, and the alternative “This function has too many parameters ({a})”, is thrown when JSHint or ESLint encounters an attempt to a function signature with more named parameters than specified by the configuration. In JSHint the configuration is controlled by the maxparams option. In ESLint it’s max-params. Here’s an example in which we attempt to declare a function that takes 3 arguments. | Maintainability | http://linterrors.com/js/this-function-has-too-many-parameters |
missingParenthesesInvokingAConstructor | The “Missing ‘()’ invoking a constructor” error is thrown when JSLint, JSHint and ESLint encounter a new expression that is not immediately followed by a pair of parentheses. In the provided example we create an instance of the built-in Date constructor. | Maintainability | http://linterrors.com/js/missing-invoking-a-constructor |
notDeclaredCorrectly | The “Variable {a} was not declared correctly error (and the alternative “You might be leaking a variable ({a}) here” error) is thrown when JSLint and JSHint encounter more than one inline assignment. In this example, we attempt to assign a string literal to the variables x, y and z. | Understandability | http://linterrors.com/js/variable-a-was-not-declared-correctly |
optionValidThis | The “Option ‘validthis’ can’t be used in a global scope” error is thrown when JSHint encounters the validthis option in a global scope. Here’s a silly example in which we declare a function that is intended to be invoked in the context of an object. | Maintainability | http://linterrors.com/js/option-validthis-cant-be-used-in-a-global-scope |
redefinition | The “Redefinition of ‘{a}'” error is thrown when JSHint or ESLint encounters a variable declaration with an identifier that is the same as that of a built-in native object. In the provided example we attempt to declare a variable with the identifier String. | Stability | http://linterrors.com/js/redefinition-of-a |
stopping | 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 error if the passfail option is set to true. In the provided example we have half a variable statement which is invalid and cannot be parsed as a complete JavaScript program. | Maintainability | http://linterrors.com/js/stopping |
trailingDecimalPointCanBeConfused | The “A trailing decimal point can be confused with a dot” error is thrown when JSLint, JSHint and ESLint encounter a numeric literal followed by a . token which itself is not followed by a decimal integer literal. Here’s an example in which we attempt to assign the value 5.0 to the variable x. | Understandability | http://linterrors.com/js/a-trailing-decimal-point-can-be-confused-with-a-dot-a |
unexpectedAssignmentExpression | The “Unexpected assignment expression” error (and the alternative “Expected a conditional expression and instead saw an assignment” error) are thrown when JSLint, JSHint or ESLint encounters an assignment expression in an if, for or while statement initializer. In the provided example we have an if statement with an assignment expression where you would normally expect a conditional. | Accuracy | http://linterrors.com/js/unexpected-assignment-expression |
usedBeforeItWasDefined | The “‘{a}’ was used before it was defined” error (and the alternative “‘{a}’ is not defined” error) is thrown when JSLint, JSHint and ESLint encounter an identifier that has not been previously declared in a var statement or function declaration. Some very common examples of this error are those that refer to native environment objects:
1. “‘document’ was used before it was defined” In the provided example we attempt to set the value of the undeclared variable x and then attempt to use some native browser environment objects: |
Maintainability | http://linterrors.com/js/a-was-used-before-it-was-defined |
withNotAllowedInStrictMode | The “‘with’ is not allowed in strict mode” error, and the alternative “Strict mode code may not include a with statement”, is thrown when JSHint or ESLint encounters the with statement in code that is running in strict mode. | Maintainability | http://linterrors.com/js/with-is-not-allowed-in-strict-mode |
wrapAnImmediateFunctionInvocation | 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 parentheses. JSHint will only raise this warning if the immed option is set to true. In the provided example we assign the return value of the anonymous function the variable x. | Maintainability | http://linterrors.com/js/wrap-an-immediate-function-invocation-in-parentheses |
undefinedInitialize | const ‘{a}’ is initialized to ‘undefined’. | Maintainability | |
expectedvariableAMatchVariableB | “Expected ‘{a}’ to match ‘{b}’ from line {c} and instead saw ‘{d}’ : Error is thrown when JSHint encounters a fatal syntax error at a particular line. This is basically a parsing error and your code will not run unless you fix this error. The exact cause will depend on your program, but other errors are usually raised along side this one that should guide you to the problem with your code. Consider the following example : switch(oldPlugin.id) {} case ‘1’: In this example , JSHint we throw syntax error for ‘:’ saying Expected ‘}’ to match ‘{‘ from line 1 and instead saw ‘:'” | Maintainability | |
expectedOtherVariable | “The “”Expected ‘{a}’ and instead saw ‘{b}’.”” error is thrown when JSLint or JSHint encounters unexpected behaviour in the code. In the provided example we attempt to write a switch block with case statement: switch(value) { case ‘1’ console.log(‘never reach here’); break; } In this case JSHint will give the error saying “”Expected ‘:’ and instead saw ‘if’ “” Why do I get this error? This error is raised to highlight a fatal JavaScript syntax error. Your code will not run if you do not fix this error. “ | Maintainability | |
lineBreakingError | “Line breaking error ‘{a}’. JSLint does more than syntax checking: It enforces certain coding conventions. As a further defense against the semicolon insertion mechanism, JSLint expects long statements to be broken only after one of these punctuation characters or operators: , . ; : { } ( [ = < > ? ! + – * / % ~ ^ | & == != <= >= += -= *= /= %= ^= |= &= << >> || && === !== <<= >>= >>> >>>= JSLint does not expect to see a long statement broken after an identifier, a string, a number, closer, or a suffix operator: ) ] ++ — JSLint allows you to turn on the Tolerate sloppy line breaking (laxbreak) option. Semicolon insertion can mask copy/paste errors. If you always break lines after operators, then JSLint can do better at finding them. “ | Accuracy | |
missingVariable | “Missing ‘{a}’. JSHint encounters this error when a keyword or token or operator is missing from the given statement. Consider the following example : var obj = {} In this example ‘;’ is missing in statement. JSHint will give warning saying ‘Missing semicolon’.” | Maintainability | |
unexpectedVariale | “Unexpected ‘{a}’ error is thrown when JSHint encounters a fatal syntax error at a particular line. This is basically a parsing error and your code will not run unless you fix this error. The exact cause will depend on your program, but other errors are usually raised along side this one that should guide you to the problem with your code. Consider the following example : switch(oldPlugin.id) {} case ‘1’: In this example , JSHint we throw syntax error saying Parsing error : Unexpected token case” | Maintainability | |
illegalComma | “Illegal comma. When do I get this error? The “”Extra comma. (it breaks older versions of IE)”” error (and the alternative “”Trailing comma”” and “”Unexpected ‘,’ errors””) are thrown when JSLint, JSHint and ESLint encounter a comma following the final element of an array literal or a comma following the final value in an object literal. Since version 2.0.0 JSHint will only raise this warning if the es3 option is set to true. Here’s an example: var x = { prop1: 10, prop2: 20, }; Why do I get this error? This error is raised to highlight a potential fatal syntax error.” | Understandability | |
expectedIntergerOrFalse | Expected a small integer or ‘false’ and instead saw ‘{a}’. | Maintainability | |
yieldExpressions | Yield expressions may only occur within generator functions. | Maintainability | |
declarationNotWithinBlock | {a} declaration not directly within block. | Maintainability | |
declarationAllowedTopLevel | {a} declarations are only allowed at the top level of module scope. | Maintainability | |
invalidMetaProperty | Invalid meta property: ‘{a}.{b}’. | Maintainability | |
nonCallableValues | Non-callable values cannot be used as the second operand to instanceof. | Maintainability | |
invalidPosition | Yield expressions are only used with generator functions and should be called inside a function. | Maintainability | |
restParameterDoesNotSupportDefault | We cannot have rest parameters and default value together. | Accuracy | |
superPropertyWithinMethodOnly | Super property should be used inside a constructor before this. | Maintainability | |
superCallWithinClassMethodOnly | Super property should be used inside a constructor before this. | Maintainability | |
usedBeforeDefined | The “‘{a}’ was used before it was defined” error (and the alternative “‘{a}’ is not defined” error) is thrown when JSLint, JSHint and ESLint encounter an identifier that has not been previously declared in a var statement or function declaration. Some very common examples of this error are those that refer to native environment objects:
1. ‘document’ was used before it was defined” In the provided example we attempt to set the value of the undeclared variable x and then attempt to use some native browser environment objects. |
Maintainability | http://linterrors.com/js/a-was-used-before-it-was-defined |
badOperand | Bad operand is not allowed. | Maintainability | |
reassignmentOfA | Reassignment of ‘{a}’, which is a {b}. Use ‘var’ or ‘let’ to declare bindings that may change. | Maintainability | |
badNumberA | It can be a range error or type error | Maintainability | |
badInvocation | when you try to invoke something which is not a function ex string. | Maintainability | |
expectedSingleParameter | Expected a single parameter in set {a} function. | Maintainability | |
expectedBreakStatement | The switch statement in JavaScript is one of the more error-prone constructs of the language thanks in part to the ability to “fall through” from one case to the next. | Maintainability | |
functionShouldContainOneYield | This rule generates warnings for generator functions that do not have the yield keyword. | Maintainability |