errors.md
August 7, 2026 ยท View on GitHub
Errors
Comma dangle
require trailing commas in multiline object literals
:white_check_mark: Enabled (error)
// Bad
/*
var bad = {
bar: 'baz',
qux: 'quux'
};
*/
// Good
var good = {
bar: 'baz',
qux: 'quux',
};
No cond assign
disallow assignment in conditional expressions
:white_check_mark: Enabled (error)
// Bad
/*
var x;
if (x = 0) {
var b = 1;
}
*/
No console
disallow use of console
:white_check_mark: Enabled (error)
// Bad
/*
console.log('hello world');
*/
No constant condition
disallow use of constant expressions in conditions
:white_check_mark: Enabled (error)
// Bad
/*
if (false) {
doSomethingUnfinished();
}
*/
No control regex
disallow control characters in regular expressions
:white_check_mark: Enabled (error)
// Bad
/*
var pattern1 = /\x1f/;
var pattern2 = new RegExp('\x1f');
*/
// Good
var pattern1 = /\x20/;
var pattern2 = new RegExp('\x20');
No debugger
disallow use of debugger
:white_check_mark: Enabled (error)
// Bad
/*
function isTruthy(x) {
debugger;
return Boolean(x);
}
*/
No dupe args
disallow duplicate arguments in functions
:white_check_mark: Enabled (error)
// Bad
/*
function foo(a, b, a) {
console.log('value of the second a:', a);
}
*/
No dupe keys
disallow duplicate keys when creating object literals
:white_check_mark: Enabled (error)
// Bad
/*
var foo = {
bar: 'baz',
bar: 'qux'
};
*/
No duplicate case
disallow a duplicate case label.
:white_check_mark: Enabled (error)
// Bad
/*
var a = 1;
switch (a) {
case 1:
break;
case 2:
break;
case 1:
break;
default:
break;
}
*/
No empty character class
disallow the use of empty character classes in regular expressions
:white_check_mark: Enabled (error)
// Bad
/*
(/^abc[]/).test('abcdefg');
'abcdefg'.match(/^abc[]/);
*/
// Good
(/^abc/).test('abcdefg');
'abcdefg'.match(/^abc/);
No empty
disallow empty statements
:white_check_mark: Enabled (error)
// Bad
/*
var foo = true;
if (foo) {
}
*/
No ex assign
disallow assigning to the exception in a catch block
:white_check_mark: Enabled (error)
// Bad
/*
try {
// code
} catch (e) {
e = 10;
}
*/
No extra boolean cast
disallow double-negation boolean casts in a boolean context
:x: Disabled
No extra parens
disallow unnecessary parentheses
:x: Disabled
// Bad
var b = 1;
var c = 2;
var a = (b * c);
var d = (a * b) + c;
No extra semi
disallow unnecessary semicolons
:white_check_mark: Enabled (error)
// Bad
/*
var x = 5;;
*/
No func assign
disallow overwriting functions written as function declarations
:white_check_mark: Enabled (error)
// Bad
/*
function foo() {}
foo = bar;
*/
No inner declarations
disallow function or variable declarations in nested blocks
:white_check_mark: Enabled (error)
// Bad
/*
if (test) {
function doSomethingElse() { }
}
*/
// Good
function doSomething() { }
No invalid regexp
disallow invalid regular expression strings in the RegExp constructor
:white_check_mark: Enabled (error)
// Bad
/*
RegExp('[');
RegExp('.', 'z');
new RegExp('\\');
*/
No irregular whitespace
disallow irregular whitespace outside of strings and comments
:white_check_mark: Enabled (error)
No negated in lhs
disallow negation of the left operand of an in expression
:white_check_mark: Enabled (error)
// Bad
/*
if (!key in object) {
// operator precedence makes it equivalent to (!key) in object
// and type conversion makes it equivalent to (key ? "false" : "true") in object
}
*/
No obj calls
disallow the use of object properties of the global object (Math and JSON) as functions
:white_check_mark: Enabled (error)
// Bad
/*
var math = Math();
var json = JSON();
*/
No prototype builtins
disallow use of Object.prototypes builtins directly
:white_check_mark: Enabled (error)
// Bad
/*
var hasBarProperty = foo.hasOwnProperty('bar');
var isPrototypeOfBar = foo.isPrototypeOf(bar);
var barIsEnumerable = foo.propertyIsEnumerable('bar');
*/
// Good
var hasBarProperty = {}.hasOwnProperty.call(foo, 'bar');
var isPrototypeOfBar = {}.isPrototypeOf.call(foo, bar);
var barIsEnumerable = {}.propertyIsEnumerable.call(foo, 'bar');
No regex spaces
disallow multiple spaces in a regular expression literal
:white_check_mark: Enabled (error)
// Bad
/*
var re = /foo bar/;
var re = new RegExp('foo bar');
*/
// Good
var re = /foo {3}bar/;
var re = new RegExp('foo {3}bar');
No sparse arrays
disallow sparse arrays
:white_check_mark: Enabled (error)
// Bad
/*
var items = [, ];
var colors = ['red',, 'blue'];
*/
// Good
var items = [];
var items = new Array(23);
var colors = ['red', 'blue'];
No unexpected multiline
Avoid code that looks like two expressions but is actually one
:x: Disabled
// Bad
let a = function () {}
`hello`
// Good
let b = function () {};
`hello`
No unreachable
disallow unreachable statements after a return, throw, continue, or break statement
:white_check_mark: Enabled (error)
// Bad
/*
function foo() {
return true;
console.log('done');
}
*/
No unsafe finally
disallow return/throw/break/continue inside finally blocks
:white_check_mark: Enabled (error)
// Bad
/*
let foo = function () {
try {
return 1;
} catch (err) {
return 2;
} finally {
return 3;
}
};
*/
Use isnan
disallow comparisons with the value NaN
:white_check_mark: Enabled (error)
// Bad
/*
if (foo === NaN) {
// ...
}
*/
// Good
if (isNaN(foo)) {
// ...
}
Valid jsdoc
ensure JSDoc comments are valid
:white_check_mark: Enabled (error)
Valid typeof
ensure that the results of typeof are compared against a valid string
:white_check_mark: Enabled (error)
// Bad
/*
typeof foo === 'strnig';
typeof foo === 'undefimed';
typeof bar !== 'nunber';
typeof bar !== 'fucntion';
*/
// Good
typeof foo === 'string';
typeof foo === 'undefined';
typeof bar !== 'number';
typeof bar !== 'function';