quick-lint-js

Find bugs in JavaScript programs.

quick-lint-js can find the following warnings and errors in your code:

E0001: variable assigned before its declaration

Variables declared with let can only be reassigned by code below the declaration. The assignment will crash with a ReferenceError if you assign to the variable.

function getNumberOfChocolates() { return 3; }
let shouldEatChocolates = true;

if (shouldEatChocolates) {
  chocolates = 0;
}
let chocolates = getNumberOfChocolates();

To fix this error, move the declaration above the assignment:

function getNumberOfChocolates() { return 3; }
let shouldEatChocolates = true;

let chocolates = getNumberOfChocolates();
if (shouldEatChocolates) {
  chocolates = 0;
}

E0002: assignment to const global variable

Infinity, NaN, and undefined are global variables which cannot be changed. Assignments to these variables are silently ignored.

NaN = 0;
undefined = null;

To fix this error, pick a different variable to assign to.

E0003: assignment to const variable

You cannot reassign variables declared with const. The assignment will crash with a ReferenceError if you run the code.

const pi = 3.14;
pi = 6;

const friends = ["Alice"];
friends = ["Bob"];

To fix this error, assign to a different variable, declare a new variable with a different name, or change const to let:

let pi = 3.14;
pi = 6;

const friends = ["Alice"];
const acquaintances = ["Bob"];

E0004: assignment to const variable before its declaration

You cannot reassign variables declared with const, and you cannot reference a variable declared with const above its declaration. The assignment will crash with a ReferenceError if you run the code.

let timeElapsed = 31;

let pie = "cooking";
if (timeElapsed > 30) {
  pi = "cooked";
}
const pi = 3.14;

To fix this error, assign to a different variable or declare a new variable with a different name:

let timeElapsed = 31;

let pie = "cooking";
if (timeElapsed > 30) {
  pie = "cooked";
}
const pi = 3.14;

See also: E0001, E0003

E0005: BigInt literal contains decimal point

BigInt literals are number literals with an n suffix. These literals must represent integers and cannot contain a decimal point (.).

let gallons = 3.50n;
let pennies = 100.00n;

To fix this error, make the number literal a Number literal by removing the n suffix, or remove the fractional portion of the number:

let gallons = 3.50;
let pennies = 100n;

E0006: BigInt literal contains exponent

BigInt literals are number literals with an n suffix. These literals must represent integers and cannot contain exponents (e).

let atomDiameter = 1e-10n;
let score = 1e2n;

To fix this error, make the number literal a Number literal by removing the n suffix, or expand the exponent of the number:

let atomDiameter = 1e-10;
let score = 100n;

E0007: classes cannot be named 'let'

Classes declared with class cannot be named let.

class let {
  bark() {
    console.log("woof");
  }
}

To fix this error, name the class something other than let, or declare the class with var:

class Dog {
  bark() {
    console.log("woof");
  }
}

var let = class {
  bark() {
    console.log("woof");
  }
};

E0008: let statement cannot declare variables named 'let'

Variables declared with let cannot be named let.

function getLotNumber() { return 42; }

let let = getLotNumber();
console.log(let);

To fix this error, name the variable something other than let, or declare the variable with var:

function getLotNumber() { return 42; }

let lot = getLotNumber();
console.log(lot);

var let = getLotNumber();
console.log(let);

E0009: cannot export variable named 'let'

An exported function cannot be named let:

export function let() {
  console.log("access permitted");
}

To fix this error, name the function something other than let, or declare the function separately with a different name and use export-as:

export function allow() {
  console.log("access permitted");
}

function allowAccess() {
  console.log("access permitted");
}
export { allowAccess as let };

E0010: cannot import 'let'

An imported function or variable cannot be named let:

import { let } from "./security.mjs";

To fix this error, name the function or variable something other than let, or rename the function or variable using import-as:

import { allow } from "./security.mjs";

import { let as permit } from "./security.mjs";

E0011: character is not allowed in identifiers

/* TODO */

E0012: escaped character is not allowed in identifiers

A function or variable name includes a Unicode escape sequence, and the escape sequence refers to a character which isn't allowed in a function or variable name:

let guitar\u2604 = "\uD83C\uDFB8";
let handc\uffed = true;

To fix this error, use the code point of a Unicode character which is allowed, or remove the extraneous backslash from the name:

let guitar\u3604 = "\uD83C\uDFB8";
let handcuffed = true;

The initial character in a function or variable name can be any of the following:

Characters after the initial character in a function or variable name can be any of the following:

E0013: code point out of range

A function or variable name includes a Unicode escape sequence, and the escape sequence refers to a character which is beyond the range of valid Unicode code points (U+0000 to U+10FFFF):

class ChirpSound {}
let bird\u{360000} = new ChirpSound();

To fix this error, use the code point of a Unicode character which is in range:

class ChirpSound {}
let bird\u{3600} = new ChirpSound();

E0014: expected expression before newline

throw statements cannot have a newline between the throw keyword and the thrown expression:

throw
  new Error(
    "something terrible happened!"
  );

To fix this error, add parentheses:

throw (
  new Error(
    "something terrible happened!"
  )
);

Alternatively, start the expression on the same line as the throw keyword:

throw new Error(
  "something terrible happened!"
);

E0015: expected expression before semicolon

throw statements require an expression following the throw keyword. It is an error to rethrow an exception by writing just throw;:

try {
  goNuts();
} catch (e) {
  console.error(`couldn't handle deez nuts: ${e}`);
  throw;
}

function goNuts() {}

To rethrow an exception, name the exception variable after throw:

try {
  goNuts();
} catch (e) {
  console.error(`couldn't handle deez nuts: ${e}`);
  throw e;
}

function goNuts() {}

E0016: expected hexadecimal digits in Unicode escape sequence

In variable names and strings, a Unicode escape sequence must contain only hexadecimal digits (any of 0123456789abcdefABCDEF). It is an error if other characters appear within a Unicode escape sequence:

console.log("List of Pok\ue9mon by weight:");
console.log("Nidoran\u{2642 {male}");

For an escape sequence without { and }, add { and }:

console.log("List of Pok\u{e9}mon by weight:");

Alternatively, for an escape sequence without { and }, include 0 digits such that the escape sequence contains exactly four hexadecimal digits:

console.log("List of Pok\u00e9mon by weight:");

For an escape sequence with { and }, ensure the } appears after the hexadecimal digits:

console.log("Nidoran\u{2642} {male}");

E0017: if statement needs parentheses around condition

In JavaScript, if statements require parentheses around the condition. It is an error to omit the parentheses:

if 2 + 2 == 4 {
  console.log("Math works!");
}

To fix this error, add ( and ):

if (2 + 2 == 4) {
  console.log("Math works!");
}

E0018: if statement is missing '(' or ')' around condition

An if statement is missing either ( before the condition or ) after the condition:

if (2 + 2 == 4 {
  console.log("Math works!");
}
if 4 == 2 + 2) {
  console.log("Jedi math works!");
}

To fix this error, add the missing ( or ):

if (2 + 2 == 4) {
  console.log("Math works!");
}
if (4 == 2 + 2) {
  console.log("Jedi math works!");
}

E0019: invalid binding in let statement

/* TODO */

E0020: invalid expression left of assignment

/* TODO */

E0021: invalid lone literal in object literal

An object literal entry must either be a key: value pair, a method, or variable short-hand. It is an error to use the short-hand syntax with anything except a variable name:

// A tasty enum
const FRUITS = {
  "BANANA",
  "ORANGE",
  "STRAWBERRY",
  "KIWI",
};

// Pre-computed for speed
let smallPrimes = {2, 3, 5, 7, 11, 13, 17, 19};

To fix this error, either use the key: value pair syntax, or use [ ] to create an array literal instead of an object literal:

// A tasty enum
const FRUITS = {
  BANANA: "BANANA",
  ORANGE: "ORANGE",
  STRAWBERRY: "STRAWBERRY",
  KIWI: "KIWI",
};

// Pre-computed for speed
let smallPrimes = [2, 3, 5, 7, 11, 13, 17, 19];

E0022: invalid UTF-8 sequence

/* TODO */

E0023: keywords cannot contain escape sequences

Outside a string or template literal, Unicode escape sequences (like \u{65}) can be used in identifiers. However, Unicode escape sequences are not allowed if they would make an identifier look like a keyword when unescaped:

let \u{69}\u{66} = "if";
let which = \u{66}inally;

To fix this error, either pick a different variable name, or make a string:

let _\u{69}\u{66} = "if";
let which = "\u{66}inally";

E0024: const/let/var with no bindings

const, let, or var statements need to declare at least one variable. It is an error to declare nothing:

var
const friends = ["strager"];
for (let  of friends) {
}

To fix this error, add a variable name:

var bestFriend;
const friends = ["strager"];
for (let friend of friends) {
  bestFriend = friend;
}

E0025: missing comma between object literal entries

Object literal entries, including methods, are separated by commas. It is an error to write two entries without a comma in between:

const snuffles = {
  age: 7
  meow() {
    console.log("😾")
  }
  eat() {
    console.log("😸")
  }
}

To fix this error, include commas:

const snuffles = {
  age: 7,
  meow() {
    console.log("😾")
  },
  eat() {
    console.log("😸")
  }
}

E0026: missing operand for operator

Binary operators (such as * and >>) require an expression (e.g. a variable or number) on both sides of the operator. Unary operators require an expression before or after the operator (depending on the operator). Ternary operators require three expressions. With some exceptions, it is an error to exclude an expression:

let ripe = true;
let tasty = true;
if (ripe && ) {
  console.log("delicious!")+;
}

To fix this error, add an expression, or remove the extraneous operator:

let ripe = true;
let tasty = true;
if (ripe && tasty) {
  console.log("delicious!");
}

Note that sometimes, it appears that expressions can be omitted, but some operators are binary and unary, and some operators look like other operators conjoined. In these cases, the code might be completely valid, so quick-lint-js won't report any error:

3**5       // different than: 3 * * 5
3<<5       // different than: 3 < < 5
7 + - 8    // same as: 7 + (-8)

E0027: missing semicolon after statement

If multiple statements are on the same line, they must be separated with a semicolon (;):

console.log("hello") console.log("world")

$("#message").text("Logged in")fadeIn()

function stop() { /*...*/ }
let shouldStop = false
if (shouldStop) stop() return

To fix this error, add a semicolon, break the line, or use a dot (.) to call a method:

console.log("hello")
console.log("world")

$("#message").text("Logged in").fadeIn()

function stop() { /*...*/ }
let shouldStop = false
if (shouldStop) { stop(); return }

E0028: number literal contains consecutive underscores

Number literals can contain underscores (_) to separate digits for legibility. At most one _ can be used between a pair of digits:

let PIN_LED = 0b0__1;
const tau = 3.14159____26536 * 2;

To fix this error, remove extraneous underscores:

let PIN_LED = 0b0_1;
const tau = 3.14159_26536 * 2;

E0029: number literal contains trailing underscores

Number literals can contain underscores (_) to separate digits for legibility. Underscores can only appear between digits, not after all digits:

let PIN_UART = 0b00_01;
let PIN_LED  = 0b01_;
const tau = 3.1415926536__ * 2;

To fix this error, remove the trailing underscores, or write more digits:

let PIN_UART = 0b00_01;
let PIN_LED  = 0b01_01;
const tau = 3.1415926536 * 2;

E0030: octal literal may not have exponent

Decimal number literals can contain exponents. Octal number literals, which start with an extra 0 digit, cannot contain exponents:

const googol = 01e+100;

To fix this error, make the number literal a decimal number literal by removing the extra leading 0:

const googol = 1e+100;

E0031: octal literal may not have decimal

Decimal number literals can contain a decimal (fraction). Octal number literals, which start with an extra 0 digit, cannot contain a decimal:

const PI = 03.14;

To fix this error, make the number literal a decimal number literal by removing the extra leading 0:

const PI = 3.14;

E0032: legacy octal literal may not be BigInt

Decimal number literals can be BigInt with an n suffix. Legacy octal number literals, which start with an extra 0 digit, cannot be suffixed with n:

const ID = 012127638745381751821n;
const perms = 07750775077507750775n;

To fix this error, make the number literal a decimal number literal by removing the extra leading 0, or use the 0o to make the a modern octal literal:

const ID = 1234567890123456789n;
const perms = 0o0775_0775_0775_0775_0775n;

E0033: redeclaration of global variable

Global variables listed in quick-lint-js.config with "shadowable": false cannot be re-declared in the global scope by a JavaScript module or script:

let window = new windowlib.Window();

let $ = (selector) => document.querySelectorAll(selector);
$('#banana')[0].peel();

To fix this error, choose a different variable name, or put the variable (and code which uses the variable) into a function:

let qsa = (selector) => document.querySelectorAll(selector);
qsa('#banana')[0].peel();

function createUI() {
  let myWindow = new windowlib.Window();
}
createUI();

E0034: redeclaration of variable

In a given function or {} block, a variable can only be declared multiple times if it is declared with var or function. Other types of variables can be declared only once:

let x, y, y, w;

const friends = loadFriends();
const friends = friends.filter(friend => friend.name !== "strager");

class Orange { name = "orange" }
class Orange { name = "banana" }

function jump(player, height) {
  let height = height || player.height/2;
}

To fix this error, assign to the existing variable, choose a different variable name, or delete the extra variable:

let x, y, z, w;

let friends = loadFriends();
friends = friends.filter(friend => friend.name !== "strager");

class Orange { name = "orange" }
class Banana { name = "banana" }

function jump(player, height) {
  height = height || player.height/2;
}

E0035: RegExp literal flags cannot contain Unicode escapes

Regular expression literals can contain flags. These flags must not be escaped using a Unicode escape sequence:

const isContentLength = /content-length/\u{69}.test(headerName);

To fix this error, stop being clever; write the flag letter directly:

const isContentLength = /content-length/i.test(headerName);

E0036: stray comma in let statement

/* TODO */

E0037: unclosed block comment

/* TODO */

E0038: unclosed identifier escape sequence

/* TODO */

E0039: unclosed regexp literal

Regular expression literals start with / and end with /. The / symbol is also used for the division operator. It is a syntax error to omit the trailing / from a regular expression literal:

// The final / is escaped by \.
let LINE_CONTINUATION_RE = / +\/m;

function feetToCentimeters(feet) {
    // The / is interpreted as the start of a regular
    // expression, not the division operator.
    return / 3.28 * 100;
}

To fix this error, close the regular expression literal:

let LINE_CONTINUATION_RE = / +\\/m;

Alternatively, include an expression before / to treat the / as a division operator:

function feetToCentimeters(feet) {
    return feet / 3.28 * 100;
}

E0040: unclosed string literal

String literals start with " or ' and end with " or ', respectively. It is a syntax error to omit the trailing " or ' from a string literal. A missing terminator can happen for a number of reasons:

// The final " is escaped by \.
let temp = "c:\temp\";

// String literals cannot span multiple lines.
let poemByIanJohnson = "My code fails. I do not know why.
My code works. I do not know why.";

let unfinishedThought = "The solution to all of our problems is

To fix this error, ensure a backslash (\) is not escaping the terminator, use a template literal for multi-line strings, or just include a terminator:

let temp = "c:\\temp\\";

let poemByIanJohnson = `My code fails. I do not know why.
My code works. I do not know why.`;

let unfinishedThought = "The solution to all of our problems is";

E0041: unclosed template

/* TODO */

E0042: unexpected '@'

In JavaScript, @ is only allowed in string and template literals. It is a syntax error to write @ anywhere else:

@  // oops

// JavaScript does not support C# verbatim strings:
let notepadPath = @"C:\Windows\System32\notepad.exe";

To fix this error, remove the @:

let notepadPath = "C:\\Windows\\System32\\notepad.exe";

E0043: unexpected '\' in identifier

Identifiers (variable names, etc.) can contain Unicode escape sequences (\u{69} for example). It is an error for an identifier to have a backslash which is not part of a Unicode escape sequence:

function identity\(x) { return x; }

let bird\U3600 = new ChirpSound();

To fix this error, remove the backslash, or complete the Unicode escape sequence:

function identity(x) { return x; }

let bird\u3600 = new ChirpSound();

E0044: unexpected characters in number literal

Letters are allowed in number literals in certain situations, such as in 123n, 1e6, and 0xff. It is an error to include other letters or letters in the wrong spot:

let gazillion = 10000000000000000000000000N;
let pi = 3.14l;
let tau = 2pi;

To fix this error, use the correct letter or remove the extraneous letter:

let gazillion = 10000000000000000000000000n;
let pi = 3.14;

Alternatively, use the * operator to multiply a variable by a number:

let tau = 2*pi;

E0045: unexpected control character

JavaScript treats some Unicode control characters, such as newlines, tabs, and form feeds, as whitespace. Most other control characters are now allowed outside string literals and template literals:

 

To fix this error, delete the extra control characters, or put them inside a comment:

/*
 
*/

E0046: unexpected characters in binary literal

Binary number literals start with 0b and can only contain 0 or 1 digits (and optionally an n to signify a BigInt). It is an error to include other digits in binary number literals:

let minInt64 = 0b1000000000000000000000000000000000000000000000000000000000000000N;
let mouse = [0xf09f, 0b196];

To fix this error, fix or remove the extra digits or letters:

let minInt64 = 0b1000000000000000000000000000000000000000000000000000000000000000n;

Alternatively, convert the binary number literal into a decimal, hexadecimal, or octal number literal:

let mouse = [0xf09f, 0xb196];

E0047: unexpected characters in octal literal

Octal number literals start with 0 or 0o and can only contain digits 0 through 7 (and optionally an n to signify a BigInt). It is an error to include other digits in octal number literals:

let permissions = 0o755N;
let bcdDigits = 0o0123456789;
let million = 0o1e6;

To fix this error, fix or remove the extra digits or letters:

let permissions = 0o755n;

Alternatively, convert the octal number literal into a decimal or hexadecimal number literal:

let bcdDigits = 123456789;
let million = 1e6;

E0048: unexpected characters in hex literal

Hexadecimal (hex) number literals start with 0x and can only contain digits 0 through 9 and a through f (and optionally an n to signify a BigInt). It is an error to include other letters in hex number literals:

let hungry = 0xfeedme;

To fix this error, fix or remove the extra digits or letters:

let hungry = 0xfeedad00d;

E0049: binary number literal has no digits

Decimal number literals start with 0b and require at least one digit. It is an error to write 0b with no following digits:

let mask = 0b

To fix this error, write digits after 0b:

let mask = 0b1000;

Alternatively, remove b to create a 0 number literal.

E0050: hex number literal has no digits

Hexadecimal (hex) number literals start with 0x and require at least one digit. It is an error to write 0x with no following digits:

let mask = 0x

To fix this error, write digits after 0x:

let mask = 0xff00;

Alternatively, remove x to create a 0 number literal.

E0051: octal number literal has no digits

Octal number literals start with 0o and require at least one digit. It is an error to write 0o with no following digits:

let mask = 0o

To fix this error, write digits after 0o:

let mask = 0o700;

Alternatively, remove o to create a 0 number literal.

E0052: unexpected '#'

In JavaScript, # is used for shebangs at the beginning of a file (e.g. #!/usr/bin/env node) and private properties. (# does not start a comment.) It is an error to use # anywhere else:

class Auth {
  #password;

  authenticate() {
    # synchronous (blocking)
    sendMessage(encrypt(this.# password));
  }
}

To fix this error, write the property's name after #, and use // for line comments:

class Auth {
  #password;

  authenticate() {
    // synchronous (blocking)
    sendMessage(encrypt(this.#password));
  }
}

E0053: missing property name between '.' and '.'

The . operator accesses an object's property. It is a syntax error to write two . in a row without a property name in between:

console.log(`My best friend is ${me..name}`);

let favoriteLanguage = 'Lua';
console.log('I love ' .. favoriteLanguage .. '!');

To fix this error, write the property name between the two .s:

console.log(`My best friend is ${me.bestFriend.name}`);

Alternatively, concatenate strings using + instead of ..:

let favoriteLanguage = 'Lua';
console.log('I love ' + favoriteLanguage + '!');

E0054: unexpected token

If you get error E0054, quick-lint-js does not understand your code for some reasons. The authors of quick-lint-js have not written a helpful message.

If you encounter this error, please submit a bug report.

Typically, this error occurs if code contains an operator which doesn't belong:

let person = "Sam";:

To fix this error, write correct JavaScript syntax:

let person = "Sam";

E0055: unmatched indexing bracket

It is an error to write the indexing operator [ without its matching ]:

for (let i = 0; i < friends.length; ++i) {
  let friend = friends[i;
  console.log[(`Hello, ${friend}!`);
}

To fix this error, write the closing ], or remove the extraneous [:

for (let i = 0; i < friends.length; ++i) {
  let friend = friends[i];
  console.log(`Hello, ${friend}!`);
}

E0056: unmatched parenthesis

It is an error to write the ( without its matching ):

function fma(a, b, c) {
  return (a * b + c;
}
let five = (fma(2, 2, 1);

To fix this error, write the closing ), or remove the extraneous (:

function fma(a, b, c) {
  return (a * b) + c;
}
let five = fma(2, 2, 1);

E0057: use of undeclared variable

It is an error to use a function or variable without declaring it:

consol.write("Hello, world!");
const one = Math.sin(pi/2);

function encrypt() {
  return data ^ 0x13371337;
}

if (isHappy) {
  let emotion = "happy";
} else {
  let emotion = "sad";
}
console.log("I am " + emotion);

function MyComponent({}) {
  let [pressed, setPressed] = useState(false);
}

google.charts.load('current', {'packages':['corechart']});

To fix this error, fix the name of the function or variable:

console.write("Hello, world!");
const one = Math.sin(Math.pi/2);

Alternatively, declare the function or variable:

function encrypt(data) {
  return data ^ 0x13371337;
}

Alternatively, move the declaration of the variable into an outer scope:

let emotion;
if (isHappy) {
  emotion = "happy";
} else {
  emotion = "sad";
}
console.log("I am " + emotion);

Alternatively, import the function or variable:

import { useState } from "react";
function MyComponent({}) {
  let [pressed, setPressed] = useState(false);
}

Alternatively, if the function or variable is global in your environment, write a quick-lint-js.config file.

E0058: variable used before declaration

Variables can be declared in many ways. For variables declared with class, const, or let, it is an error to use the variable before/above its declaration:

let firstName = person.firstName;
if (firstName === "") {
  firstName = lastName;
}
let lastName = person.lastName;

function printAdjacentPairs(items) {
  let first = true;
  for (let current of items) {
    if (!first) {
      console.log(previous, current);
    }
    let previous = current;
    first = false;
  }
}

To fix this error, move the variable's declaration up above its use:

let firstName = person.firstName;
let lastName = person.lastName;
if (firstName === "") {
  firstName = lastName;
}

Alternatively, declare the variable in an outer scope:

function printAdjacentPairs(items) {
  let first = true;
  let previous;
  for (let current of items) {
    if (!first) {
      console.log(previous, current);
    }
    previous = current;
    first = false;
  }
}

E0059: assignment to undeclared variable

It is an error to assign to a variable without declaring it:

tau = Math.pi * 2;

let emotion;
if (isHappy) {
  emotion = "happy";
} else {
  emotio = "sad";
}
console.log("I am " + emotion);

To fix this error, declare the variable using const or let:

let emotion;
if (isHappy) {
  emotion = "happy";
} else {
  emotion = "sad";
}
console.log("I am " + emotion);

Alternatively, if the variable is global in your environment, write a quick-lint-js.config file.

E0060: invalid hex escape sequence

String literals and template literals can contain escape sequences, including \x followed by two hexadecimal digits. It is an error for \x to be followed by anything except two hexadecimal digits:

let gameTitle = isBlue ? 'Pok\xmon Blue' : 'Pok\xe9mon Red';

let path = 'c:\xampp\bin\apache.exe';

To fix this error, complete the sequence by writing two hexadecimal digits:

let gameTitle = isBlue ? 'Pok\xe9mon Blue' : 'Pok\xe9mon Red';

Alternatively, escape \ with an extra \:

let path = 'c:\\xampp\\bin\\apache.exe';

E0061: missing name in function statement

If a statement begins with the function keyword, the declared function must have a name. It is an error to start a statement with function but not give a name to the function:

function (number) {
  return number % 2 === 0;
}

To fix this error, write the name of the function after the function keyword:

function isEven(number) {
  return number % 2 === 0;
}

E0062: missing name or parentheses for function

If a statement begins with the function keyword, the declared function must have a name. It is an error to start a statement with function but not give a name to the function:

function() {  // IIFE for our module
  class PublicClass {}
  class PrivateClass {}
  window.PublicClass = PublicClass;
}()

function (number) {
  return number % 2 === 0;
}
[1, 2, 3, 4].filter(isEven).forEach(number => console.log(number));

To fix this error, wrap the IIFE (Immediately Invoked Function Expression) in parentheses:

(function() {  // IIFE for our module
  class PublicClass {}
  class PrivateClass {}
  window.PublicClass = PublicClass;
}())

Alternatively, write the name of the function after the function keyword:

function isEven(number) {
  return number % 2 === 0;
}
[1, 2, 3, 4].filter(isEven).forEach(number => console.log(number));

E0063: missing operator between expression and arrow function

The left-hand side of => must be a list of parameters. It is a syntax error if the left-hand side looks like a function call:

let fs = require("fs");
let path = process.argv[2];
fs.readFile(path (err, data) => {
  console.log(data);
});

To fix this error, make the left-hand side of => valid by adding an operator (usually ,) before the parameter list:

let fs = require("fs");
let path = process.argv[2];
fs.readFile(path, (err, data) => {
  console.log(data);
});

E0064: missing body for 'if' statement

if statements require a body, which must be a statement or { } surrounding a list of statements. It is a syntax error to omit the body of an if statement:

function assert(condition) {
  if (!condition)
}

if (rose.color === 'red' && violet.color === 'blue')

To fix this error, write the body of the if statement:

function assert(condition) {
  if (!condition)
    throw new AssertionError();
}

if (rose.color === 'red' && violet.color === 'blue') {
  sugar.flavor = 'sweet';
}

E0065: 'else' has no corresponding 'if'

if-else statements require an if clause. It is a syntax error to have an else without a matching if immediately preceeding:

if (testPassed)
  console.log("passed!");
  console.log("tests took ${endTime - startTime} seconds");
else {
  console.log("TEST FAILED:");
  console.log(failingTestDescription);
}

Note: In the above example, the second console.log call is not part of the if statement. Only the first console.log call is part of the if statement.

To fix this error, make sure your else is properly attached to an if:

if (testPassed) {
  console.log("passed!");
  console.log("tests took ${endTime - startTime} seconds");
} else {
  console.log("TEST FAILED:");
  console.log(failingTestDescription);
}

E0066: exporting requires '{' and '}'

When exporting a class, function, or variable, you must either export while declaring or export separately from declaring. When exporting separately, it is a syntax error to write export followed by the name of the thing you want to export:

class Person {}

export Person;

To fix this error, add { and } around the exported names:

class Person {}

export {Person};

Alternatively, write the default keyword after export:

class Person {}

export default Person;

E0067: exporting requires 'default'

It is a syntax error to export an expression without using the default keyword:

function loadConfig() {}

export loadConfig();

To fix this error, add the default keyword to export the result of the expression as the module's default export:

function loadConfig() {}

export default loadConfig();

E0068: extra ',' is not allowed between function call arguments

In a function call, an extra , can be added to the end of the argument list. However, it is a syntax error to include an extra , in between arguments:

let name = prompt();
console.log("Hello",, name);

To fix this error, remove the extra ,:

let name = prompt();
console.log("Hello", name);

Alternatively, write an argument between the two ,s:

let honorific = prompt();
let name = prompt();
console.log("Hello", honorific, name);

E0069: cannot declare 'await' inside async function

In non-strict mode, a variable can be named await. In strict mode and inside async functions, it is a syntax error to use await as a variable name:

async function main() {
  const
  await fs.promises.writeFile(pidFile, process.pid);
}

async function getCookedPizza(await) {
  visitOven();
  openOven();
  if (await) {
    await waitForPizza();
  }
  let pizza = takePizza();
  closeOven();
  return pizza;
}

To fix this error, complete the variable declaration preceeding await:

async function main() {
  const pidFile = "./myapp.pid";
  await fs.promises.writeFile(pidFile, process.pid);
}

Alternatively, rename the variable to something other than await:

async function getCookedPizza(wait) {
  visitOven();
  openOven();
  if (wait) {
    await waitForPizza();
  }
  let pizza = takePizza();
  closeOven();
  return pizza;
}

E0070: commas are not allowed after spread parameter

In a function declaration, an extra , can be added to the end of the parameter list. However, it is a syntax error to include an extra , after a spread parameter:

function sum(
  ...numbers,
) {
  return numbers.reduce((x, y) => x+y, 0);
}

To fix this error, remove the extra ,:

function sum(
  ...numbers
) {
  return numbers.reduce((x, y) => x+y, 0);
}

E0071: cannot declare 'yield' inside generator function

In non-strict mode, a variable can be named yield. In strict mode and inside generator functions, it is a syntax error to use yield as a variable name:

function *mapRange(end, f) {
  for (let i = 0; i < end; ++i) {
    const
    yield item;
  }
}

To fix this error, complete the variable declaration preceeding yield:

function *mapRange(f, end) {
  for (let i = 0; i < end; ++i) {
    const item = f(i);
    yield item;
  }
}

E0072: methods should not use the 'function' keyword

Classes and object literals can contain methods. It is an error to use the function keyword in a class or object literal when defining a method:

class Doge {
  function speak() {
    console.log('many woofie');
  }
}

To fix this error, remove the function keyword:

class Doge {
  speak() {
    console.log('many woofie');
  }
}

E0073: missing function parameter list

Functions declared with function can have zero or more parameters. It is a syntax error to omit the parameter list, including ( and ), even if the function has no parameters:

class Doge {
  speak {
    console.log('many woofie');
  }
}

function visitDogPark {
  new Doge().speak();
}

setInterval(
  function {
    visitDogPark();
  },
  1000,
);

To fix this error, add a pair of parentheses before { in the function:

class Doge {
  speak() {
    console.log('many woofie');
  }
}

function visitDogPark() {
  new Doge().speak();
}

setInterval(
  function() {
    visitDogPark();
  },
  1000,
);

E0074: '.' operator needs a key name; use + to concatenate strings; use [] to access with a dynamic key

The right-hand side of the . operator must be a property name or a private property name. It is an error for . to be followed by a literal:

const ages = {
  "strager": 29,
  "Elon Musk": 50,
};
console.log("the Musker is", ages."Elon Musk", "years old");

const $favoriteLanguage = 'PHP';
console.log('I love ' . $favoriteLanguage . '!');

To fix this error, access properties using [ ] instead of .:

const ages = {
  "strager": 29,
  "Elon Musk": 50,
};
console.log("the Musker is", ages["Elon Musk"], "years old");

Alternatively, concatenate strings using + instead of .:

const $favoriteLanguage = 'PHP';
console.log('I love ' + $favoriteLanguage);

E0075: indexing requires an expression

The syntax for indexing is expr1[expr2]. It is an error to omit the expression between [ and ]:

let colorToHexCode = {
  red:   '#ff0000',
  green: '#00ff00',
  blue:  '#0000ff',
};
let colorName = prompt();
document.body.style.color = colorToHexCode[];

let newFriends = friends[];
newFriends.push("Alice");
console.log("before:", friends, "after:", newFriends);

To fix this error, write an expression between [ and ]:

let colorToHexCode = {
  red:   '#ff0000',
  green: '#00ff00',
  blue:  '#0000ff',
};
let colorName = prompt();
document.body.style.color = colorToHexCode[colorName];

Alternatively, to copy an array, create a new array and spread the old array into the new array:

let newFriends = [...friends];
newFriends.push("Alice");
console.log("before:", friends, "after:", newFriends);

E0076: cannot declare and export variable with 'export default'

In modules, you can declare and export a variable at the same time. However, it is a syntax error to declare and export a variable by default:

export default let cache = {};

To fix this error, export by name, not by default:

// Import using: import {cache} from "./cache.mjs";
export let cache = {};

Alternatively, to export by default, declare the variable then export it in a separate statement. Note that this means importers of the variable cannot assign to the variable (but the object can still be modified):

// Import using: import cache from "./cache.mjs";
let cache = {};
export default cache;

E0077: function call before declaration in blocked scope

A function can't be called before its declaration in block scope in Safari.

f();
{
    function f() {}
}

To fix this error, move the function call below the block scope in which it is declared:

{
    function f() {}
}
f();

Another way to fix this error, move the function out of the block scope in which it is declared.

f();
function f() {}
{
}

OR

f();
{
}
function f() {}

E0078: missing expression between parentheses

Parentheses (( and )) serve three purposes in JavaScript:

It is a syntax error to write ( immediately followed by ) (with nothing between) when grouping in expressions:

function fma(a, b, c) {
  return () + c;
}

const config = ();

takeCookiesFromCookieJar()
  .then(cookies => eatCookies()
    .then(()));

To fix this error, write an expression between the parentheses:

function fma(a, b, c) {
  return (a*b) + c;
}

Alternatively, put the name of a function before the parentheses to call a function with no arguments:

const config = loadConfig();

Alternatively, write the rest of your arrow function:

takeCookiesFromCookieJar()
  .then(cookies => eatCookies()
    .then(() => putAwayCookieJar()));

E0079: missing name of exported function

In modules, functions can be exported by name or by default. It is an error to export an unnamed function by name:

export function({props}) {
  return React.createElement("h1", null, `Hello, ${props.name}!`);
}

To fix this error, export the function by default:

// Import using: import MyComponent from "./MyComponent.mjs";
export default function({props}) {
  return React.createElement("h1", null, `Hello, ${props.name}!`);
}

Alternatively, give a name to the function:

// Import using: import {MyComponent} from "./MyComponent.mjs";
export function MyComponent({props}) {
  return React.createElement("h1", null, `Hello, ${props.name}!`);
}

E0080: missing name of class

If a statement begins with the class keyword, the declared class must have a name. It is a syntax error to start a statement with class but not give a name to the class:

class {
  speak() {
    console.log('woof!');
  }
}

To fix this error, write the name of the class after the class keyword:

class Doggie {
  speak() {
    console.log('woof!');
  }
}

Alternatively, declare a variable and initialize it with the class:

const Doggie = class {
  speak() {
    console.log('woof!');
  }
};

E0081: missing name of exported class

In modules, classes can be exported by name or by default. It is an error to export an unnamed class by name:

export class {
  render() {
    return React.createElement("h1", null, `Hello, ${this.props.name}!`);
  }
}

To fix this error, export the class by default:

// Import using: import MyComponent from "./MyComponent.mjs";
export default class {
  render() {
    return React.createElement("h1", null, `Hello, ${this.props.name}!`);
  }
}

Alternatively, give a name to the class:

// Import using: import {MyComponent} from "./MyComponent.mjs";
export class MyComponent {
  render() {
    return React.createElement("h1", null, `Hello, ${this.props.name}!`);
  }
}

E0082: assigning to 'async' in a for-of loop requires parentheses

If a variable is named async, it is a syntax error to assign to that variable in a for-of loop:

async function awaitSequentially(asyncs) {
  let results = [];
  let async;
  for (async of asyncs) {
    results.push(await async);
  }
  return results;
}

To fix this error, declare the variable inside the for-of loop:

async function awaitSequentially(asyncs) {
  let results = [];
  for (let async of asyncs) {
    results.push(await async);
  }
  return results;
}

Alternatively, rename the variable to something other than async:

async function awaitSequentially(promises) {
  let results = [];
  let promise;
  for (promise of promises) {
    results.push(await promise);
  }
  return results;
}

E0083: missing value for object property

Object literals support a short-hand syntax which allows you to omit the value of a property. It is a syntax error to omit the value if the key is computed or is a keyword:

let class_ = classes.join(" ");
React.createElement('div', { class }, children);

To fix this error, explicitly write a value for the property:

let class_ = classes.join(" ");
React.createElement('div', { class: class_ }, children);

E0084: do-while loop needs parentheses around condition

do-while loops have a condition after the while keyword. It is a syntax error to write a condition without ( and ):

let name;
do {
  name = prompt('What is your name?');
} while name === '';

To fix this error, write ( before the condition and ) after the condition:

let name;
do {
  name = prompt('What is your name?');
} while (name === '');

E0085: do-while loop is missing '(' or ')' around condition

do-while loops have a condition after the while keyword. It is a syntax error to write a condition without either ( or ):

let name;
do {
  name = prompt('What is your name?');
} while (name === '';

To fix this error, write ( before the condition or ) after the condition:

let name;
do {
  name = prompt('What is your name?');
} while (name === '');

E0086: redundant delete statement on variable

The following delete statement is redundant on variable:

let x = 3;
delete x;
console.log(x);

To fix this warning, remove the delete statement:

let x = 3;
console.log(x);

E0087: while loop needs parentheses around condition

while loops have a condition after the while keyword. It is a syntax error to write a condition without ( and ):

let name = '';
while name === '' {
  name = prompt('What is your name?');
}

To fix this error, write ( before the condition and ) after the condition:

let name = '';
while (name === '') {
  name = prompt('What is your name?');
}

E0088: while loop is missing '(' or ')' around condition

while loops have a condition after the while keyword. It is a syntax error to write a condition without either ( or ):

let name = '';
while (name === '' {
  name = prompt('What is your name?');
}

To fix this error, write ( before the condition or ) after the condition:

let name = '';
while (name === '') {
  name = prompt('What is your name?');
}

E0089: with statement needs parentheses around expression

with statements have an expression after the with keyword. It is a syntax error to write an expression without ( and ):

with person {
  console.log(`Hello, ${firstName} ${lastName}!`);
}

To fix this error, write ( before the expression and ) after the expression:

with (person) {
  console.log(`Hello, ${firstName} ${lastName}!`);
}

E0090: with statement is missing '(' or ')' around expression

with statements have an expression after the with keyword. It is a syntax error to write an expression without either ( or ):

with (person {
  console.log(`Hello, ${firstName} ${lastName}!`);
}

To fix this error, write ( before the expression or ) after the expression:

with (person) {
  console.log(`Hello, ${firstName} ${lastName}!`);
}

E0091: switch statement needs parentheses around condition

switch statements have a condition after the switch keyword. It is a syntax error to write a condition without ( and ):

function colorToHexCode(color) {
  switch color {
    case 'red':   return '#ff0000';
    case 'green': return '#00ff00';
    case 'blue':  return '#0000ff';
  }
}

To fix this error, write ( before the condition and ) after the condition:

function colorToHexCode(color) {
  switch (color) {
    case 'red':   return '#ff0000';
    case 'green': return '#00ff00';
    case 'blue':  return '#0000ff';
  }
}

E0092: switch statement is missing '(' or ')' around condition

switch statements have a condition after the switch keyword. It is a syntax error to write a condition without either ( or ):

function colorToHexCode(color) {
  switch (color {
    case 'red':   return '#ff0000';
    case 'green': return '#00ff00';
    case 'blue':  return '#0000ff';
  }
}

To fix this error, write ( before the condition or ) after the condition:

function colorToHexCode(color) {
  switch (color) {
    case 'red':   return '#ff0000';
    case 'green': return '#00ff00';
    case 'blue':  return '#0000ff';
  }
}

E0093: C-style for loop is missing its third component

C-style for loops have three components, each separated by ;: an initializer, a condition expression, and an update expression. It is a syntax error to write only two of these three components:

for (let i = 0; i < 100) {
  console.log(i % 15 ? i : "FizzBuzz");
}

To fix this error, write the missing component:

for (let i = 0; i < 100; ++i) {
  console.log(i % 15 ? i : "FizzBuzz");
}

E0094: missing body for 'for' loop

C-style for loops, for-in loops, and for-of loops require a body, which must be a statement or { } surrounding a list of statements. It is a syntax error to omit the body of a for loop:

function skipNumber(parser) {
  for (; isDigit(parser.peek()); parser.next())
}

To fix this error, write the body of the for loop:

function skipNumber(parser) {
  for (; isDigit(parser.peek()); parser.next()) {}
}

E0095: Unicode byte order mark (BOM) cannot appear before #! at beginning of script

A script cannot have Unicode byte order mark (BOM) before #!

#!/usr/bin/env node
let x = 3;
console.log(x);

To fix this error, remove the Unicode BOM before #!

#!/usr/bin/env node
let x = 3;
console.log(x);

E0096: missing for loop header

It is a syntax error to have nothing between the ( and ) in a for loop:

for () {
  runBenchmark(benchmark);
}

To fix this error, continue writing the for loop:

for (const benchmark of collectBenchmarks()) {
  runBenchmark(benchmark);
}

E0097: for loop needs an iterable, or condition and update clauses

There are three kinds of for loops: C-style for loops (;), for-in loops, and for-of loops. It is a syntax error to write a for loop without ;, in, or of:

for (queue.length > 0) {
  process(queue.pop());
}

To fix this error, use a while loop instead of a for loop:

while (queue.length > 0) {
  process(queue.pop());
}

E0098: for loop needs an iterable, or condition and update clauses

There are three kinds of for loops: C-style for loops (;), for-in loops, and for-of loops. It is a syntax error to write a for loop without ;, in, or of:

for (const enemy) {
  enemy.health -= damage;
}

for (let i) {
  console.log(i % 15 ? i : "FizzBuzz");
}

To fix this error, write in or of followed by an iterable (such as an array):

for (const enemy of collidedEntities) {
  enemy.health -= damage;
}

Alternatively, write the remainder of the C-style for loop:

for (let i = 0; i < 100; ++i) {
  console.log(i % 15 ? i : "FizzBuzz");
}

E0099: missing semicolon between init and condition parts of for loop

C-style for loops require two semicolons: one ; between the init and the condition, and one ; between the condition and the update expression. It is a syntax error to omit the ; between the init and the condition:

let i;
for (i = 0 i < 100; ++i) {
  console.log(i % 15 ? i : "FizzBuzz");
}

To fix this error, insert a semicolon (;) before the condition:

let i;
for (i = 0; i < 100; ++i) {
  console.log(i % 15 ? i : "FizzBuzz");
}

E0100: missing semicolon between condition and update parts of for loop

C-style for loops require two semicolons: one ; between the init and the condition, and one ; between the condition and the update expression. It is a syntax error to omit the ; between the condition and the update expression:

for (let i = 0; i < 100 ++i) {
  console.log(i % 15 ? i : "FizzBuzz");
}

To fix this error, insert a semicolon (;) after the condition:

for (let i = 0; i < 100; ++i) {
  console.log(i % 15 ? i : "FizzBuzz");
}

E0101: missing body for do-while loop

do-while loops require a body, which must be a statement or { } surrounding a list of statements. It is a syntax error to omit the body of a do-while loop:

function skipNumber(parser) {
  do
  while (isDigit(parser.peek()));
}

do while (queue.length > 0) {
  queue.pop().run();
}

To fix this error, write the body of the do-while loop:

function skipNumber(parser) {
  do parser.next();
  while (isDigit(parser.peek()));
}

Alternatively, remove the extraneous do keyword:

while (queue.length > 0) {
  queue.pop().run();
}

E0102: C-style for loops have only three semicolon-separated components

C-style for loops have three components, each separated by ;: an initializer, a condition expression, and an update expression. It is a syntax error to write more than three components:

for (let x = 0, y = 0; x < width && y < height; ++x; ++y) {
  draw(x, y, pixelAt(x, y));
}

To fix this error, use , instead of ; to separate expressions in the update clause:

for (let x = 0, y = 0; x < width && y < height; ++x, ++y) {
  draw(x, y, pixelAt(x, y));
}

E0103: missing 'while (condition)' for do-while statement

A do-while loop has three parts: the do keyword, a body (a statement, or a list of statements surrounded by { and }), and the while part including the condition. It is a syntax error to write the do keyword without the while part:

let name;
do {
  name = prompt('What is your name?');
};
while (name === '');

To fix this error, make sure there is nothing between the loop's body and the while keyword:

let name;
do {
  name = prompt('What is your name?');
}
while (name === '');

E0104: missing body for while loop

while loops require a body, which must be a statement or { } surrounding a list of statements. It is a syntax error to omit the body of a while loop:

function bogoSort(array) {
  while (!isSorted(array))
}

function skipNumber(parser) {
  {
    parser.next();
  } while (isDigit(parser.peek()))
}

To fix this error, write the body of the while loop:

function bogoSort(array) {
  while (!isSorted(array))
    shuffle(array);
}

Alternatively, make the while loop a do-while loop:

function skipNumber(parser) {
  do {
    parser.next();
  } while (isDigit(parser.peek()))
}

E0105: missing parameters for arrow function

Arrow functions need a parameter list. It is a syntax error to omit the parameter list before =>, even if the arrow function takes no parameters:

setInterval(=> {
  console.log("it is now", new Date());
}, 1000);

To fix this error, write an empty parameter list before =>:

setInterval(() => {
  console.log("it is now", new Date());
}, 1000);

E0106: missing body for 'switch' statement

switch statements require a body, which must be a list of statements surrounded by { and }. It is a syntax error to omit the body of an switch statement:

function colorToHexCode(color) {
  switch (color)
}

To fix this error, write the body of the switch statement:

function colorToHexCode(color) {
  switch (color) {
    case 'red':   return '#ff0000';
    case 'green': return '#00ff00';
    case 'blue':  return '#0000ff';
  }
}

E0107: expected '{'

A switch statement has a list of cases. It is a syntax error to omit { after the condition of a switch statement:

function colorToHexCode(color) {
  switch (color)
    case 'red':   return '#ff0000';
    case 'green': return '#00ff00';
    case 'blue':  return '#0000ff';
  }
}

To fix this error insert a { after the condition:

function colorToHexCode(color) {
  switch (color) {
    case 'red':   return '#ff0000';
    case 'green': return '#00ff00';
    case 'blue':  return '#0000ff';
  }
}

E0108: 'in' disallowed in C-style for loop initializer

C-style for loops can have a expression the first ;-separated part. It is an error for the expression to use the in operator without parentheses:

for (let i = 'startAtOne' in options ? 1 : 0; i < options.count; ++i) {
  if (!processItem(data[i])) {
    break;
  }
}

To fix this error, surround the in expression with parentheses:

for (let i = ('startAtOne' in options) ? 1 : 0; i < options.count; ++i) {
  if (!processItem(data[i])) {
    break;
  }
}

E0109: for-of loop expression cannot have semicolons

There are three kinds of for loops: C-style for loops (;), for-in loops, and for-of loops. It is a syntax error to write a for-of loop with a ;:

for (let i of 0; i < 100; ++i) {
  console.log(i % 15 ? i : "FizzBuzz");
}

for (const benchmark of collectBenchmarks();) {
  runBenchmark(benchmark);
}

To fix this error, remove the of keyword in the C-style for loop:

for (let i = 0; i < 100; ++i) {
  console.log(i % 15 ? i : "FizzBuzz");
}

Alternatively, remove the extra ;:

for (const benchmark of collectBenchmarks()) {
  runBenchmark(benchmark);
}

E0110: for-in loop expression cannot have semicolons

There are three kinds of for loops: C-style for loops (;), for-in loops, and for-of loops. It is a syntax error to write a for-in loop with a ;:

for (let i in 0; i < 100; ++i) {
  console.log(i % 15 ? i : "FizzBuzz");
}

let benchmarks = collectBenchmarks();
for (const benchmarkName in benchmarks;) {
  runBenchmark(benchmarkName, benchmarks[benchmarkName]);
}

To fix this error, remove the in keyword in the C-style for loop:

for (let i = 0; i < 100; ++i) {
  console.log(i % 15 ? i : "FizzBuzz");
}

Alternatively, remove the extra ;:

for (const benchmark of collectBenchmarks()) {
  runBenchmark(benchmark);
}

E0111: missing body for class

Classes require a body, which must be a list of properties and methods surrounded by { and }. It is a syntax error to omit the body of a class:

class Animal {}
class Doge extends Animal
class Kitty extends Animal

To fix this error, write the body of the class, including { and }:

class Animal {}
class Doge extends Animal {}
class Kitty extends Animal {}

E0112: unexpected token in export; expected 'export default ...' or 'export {name}' or 'export * from ...' or 'export class' or 'export function' or 'export let'

It is a syntax error to write the export keyword without anything following:

class SmallBenchmark extends Benchmark {}
export {SmallBenchmark};
class BigBenchmark extends Benchmark {}
export

for (let benchmark of [new SmallBenchmark(), new BigBenchmark()]) {
  registerBenchmark(benchmark);
}

To fix this error, complete the export statement:

class SmallBenchmark extends Benchmark {}
export {SmallBenchmark};
class BigBenchmark extends Benchmark {}
export {BigBenchmark};

for (let benchmark of [new SmallBenchmark(), new BigBenchmark()]) {
  registerBenchmark(benchmark);
}

E0113: incomplete export; expected 'export default ...' or 'export {name}' or 'export * from ...' or 'export class' or 'export function' or 'export let'

It is a syntax error to write the export keyword without anything following:

class SmallBenchmark extends Benchmark {}
export {SmallBenchmark};
class BigBenchmark extends Benchmark {}
export

To fix this error, complete the export statement:

class SmallBenchmark extends Benchmark {}
export {SmallBenchmark};
class BigBenchmark extends Benchmark {}
export {BigBenchmark};

E0114: unexpected token in variable declaration; expected variable name

Variables can be declared using a keyword such as const, let, or var. It is a syntax error write anything except a variable name or a destructuring pattern in a const, let, or var declaration:

let sawFizzBuzz,
100..toRange().forEach(i => {
  if (i % 15) {
    console.log(i);
  } else {
    console.log("FizzBuzz");
    sawFizzBuzz = true;
  }
});

let while (!done) {
  doMoreWork();
}

To fix this error, replace , with ;:

let sawFizzBuzz;
100..toRange().forEach(i => {
  if (i % 15) {
    console.log(i);
  } else {
    console.log("FizzBuzz");
    sawFizzBuzz = true;
  }
});

Alternatively, remove the extra const, let, or var keyword:

while (!done) {
  doMoreWork();
}

E0115: unexpected 'case' outside switch statement

switch statements can contain case labels. It is a syntax error to write a case label outside a switch statement:

function colorToHexCode(color) {
  switch (color) {
  }
    case 'red':   return '#ff0000';
    case 'green': return '#00ff00';
    case 'blue':  return '#0000ff';
}

To fix this error, move the case label into a switch statement:

function colorToHexCode(color) {
  switch (color) {
    case 'red':   return '#ff0000';
    case 'green': return '#00ff00';
    case 'blue':  return '#0000ff';
  }
}

E0116: unexpected 'default' outside switch statement

switch statements can contain a default label. It is a syntax error to write a default label outside a switch statement:

function colorToHexCode(color) {
  switch (color) {
    case 'red':   return '#ff0000';
    case 'green': return '#00ff00';
    case 'blue':  return '#0000ff';
  }
    default:
      throw new Error(`unknown color ${color}`);
}

To fix this error, move the default label into a switch statement:

function colorToHexCode(color) {
  switch (color) {
    case 'red':   return '#ff0000';
    case 'green': return '#00ff00';
    case 'blue':  return '#0000ff';
    default:
      throw new Error(`unknown color ${color}`);
  }
}

E0117: unexpected 'catch' without 'try'

try statements can have a catch clause. It is a syntax error to have a catch clause with no corresponding try statement:

async function readConfig(configFilePath) {
  try {
    let data = await fs.promises.readFile(configFilePath, "utf-8");
    return parseConfig(data);
  };
  catch (error) {
    if (error.code === 'ENOENT') {
      return {};
    } else {
      throw error;
    }
  }
}

To fix this error, make sure the catch keyword immediately follows the } for a try block:

async function readConfig(configFilePath) {
  try {
    let data = await fs.promises.readFile(configFilePath, "utf-8");
    return parseConfig(data);
  }
  catch (error) {
    if (error.code === 'ENOENT') {
      return {};
    } else {
      throw error;
    }
  }
}

E0118: unexpected 'finally' without 'try'

try statements can have a finally clause. It is a syntax error to have a finally clause with no corresponding try statement:

let recursionDepth = 0;
function recursionExample() {
  if (recursionDepth > 100) {
    throw new Error("too much recursion!");
  }
  recursionDepth += 1;
  try {
    recursionExample();
  };
  finally {
    recursionDepth -= 1;
  }
}

To fix this error, make sure the finally keyword immediately follows the } for a try block or a catch block:

let recursionDepth = 0;
function recursionExample() {
  if (recursionDepth > 100) {
    throw new Error("too much recursion!");
  }
  recursionDepth += 1;
  try {
    recursionExample();
  }
  finally {
    recursionDepth -= 1;
  }
}

E0119: missing body for catch clause

catch clauses in try statements require a body, which must be a list of statements surrounded by { and }. It is a syntax error to omit the body of a catch clause:

const fs = require("fs");

async function readConfig(configFilePath) {
  try {
    let data = await fs.promises.readFile(configFilePath, "utf-8");
    return parseConfig(data);
  } catch (error)
}

To fix this error, write the body of the catch statement, including { and }:

const fs = require("fs");

async function readConfig(configFilePath) {
  try {
    let data = await fs.promises.readFile(configFilePath, "utf-8");
    return parseConfig(data);
  } catch (error) {
    if (error.code === 'ENOENT') {
      return {};
    } else {
      throw error;
    }
  }
}

E0120: missing body for try statement

try statements require a body, which must be a list of statements surrounded by { and }. It is a syntax error to omit the body of a try statement:

let recursionDepth = 0;
function recursionExample() {
  if (recursionDepth > 100) {
    throw new Error("too much recursion!");
  }
  recursionDepth += 1;
  try
  finally {
    recursionDepth -= 1;
  }
}

To fix this error, write the body of the try statement:

let recursionDepth = 0;
function recursionExample() {
  if (recursionDepth > 100) {
    throw new Error("too much recursion!");
  }
  recursionDepth += 1;
  try {
    recursionExample();
  } finally {
    recursionDepth -= 1;
  }
}

E0121: missing body for finally clause

finally clauses in try statements require a body, which must be a list of statements surrounded by { and }. It is a syntax error to omit the body of a finally clause:

let recursionDepth = 0;
function recursionExample() {
  if (recursionDepth > 100) {
    throw new Error("too much recursion!");
  }
  recursionDepth += 1;
  try {
    recursionExample();
  } finally
}

To fix this error, write the body of the finally statement, including { and }:

let recursionDepth = 0;
function recursionExample() {
  if (recursionDepth > 100) {
    throw new Error("too much recursion!");
  }
  recursionDepth += 1;
  try {
    recursionExample();
  } finally {
    recursionDepth -= 1;
  }
}

E0122: missing catch or finally clause for try statement

A try statement has a list of statements followed by an optional catch block followed by an optional finally block. It is a syntax error to omit both the catch block and the finally block:

async function readConfig(configFilePath) {
  try {
    let data = await fs.promises.readFile(configFilePath, "utf-8");
    return parseConfig(data);
  }
}

let recursionDepth = 0;
function recursionExample() {
  if (recursionDepth > 100) {
    throw new Error("too much recursion!");
  }
  recursionDepth += 1;
  try {
    recursionExample();
  }
}

To fix this error, remove the try keyword:

async function readConfig(configFilePath) {
  let data = await fs.promises.readFile(configFilePath, "utf-8");
  return parseConfig(data);
}

Alternatively, add a catch block after the try block:

async function readConfig(configFilePath) {
  try {
    let data = await fs.promises.readFile(configFilePath, "utf-8");
    return parseConfig(data);
  } catch (error) {
    if (error.code === 'ENOENT') {
      return {};
    } else {
      throw error;
    }
  }
}

Alternatively, add a finally block after the try block:

let recursionDepth = 0;
function recursionExample() {
  if (recursionDepth > 100) {
    throw new Error("too much recursion!");
  }
  recursionDepth += 1;
  try {
    recursionExample();
  } finally {
    recursionDepth -= 1;
  }
}

E0123: missing variable name

You can declare a variable with const, let, or var. It is a syntax error to use const, let (in some cases), or var without mentioning a variable name:

const = getBananas();
console.log(bananas[0].peel());

for (let i,= 1; i < 100; ++i) {
  console.log(i % 15 ? i : "FizzBuzz");
}

To fix this error, write a variable name:

const banans = getBananas();
console.log(bananas[0].peel());

Alternatively, remove the extra ,:

for (let i = 1; i < 100; ++i) {
  console.log(i % 15 ? i : "FizzBuzz");
}

E0124: cannot declare variable named keyword

It is a syntax error to declare a variable named certain keywords like debugger or while:

function parseVar(s) {
  let var = s.split()[0];
  let value = s.split()[1];
  return {var, value};
}

To fix this error, pick a different variable name:

function parseVar(s) {
  let varName = s.split()[0];
  let value = s.split()[1];
  return {varName, value};
}

E0125: missing header and body for 'for' loop

It is a syntax error to write a for loop without a header (in parentheses) or a body:

for let i = 1; i < 100; ++i
{
  console.log(i % 15 ? i : "FizzBuzz");
}

To fix this error, put parentheses around the for loop's header:

for (let i = 1; i < 100; ++i)
{
  console.log(i % 15 ? i : "FizzBuzz");
}

E0126: expected 'as' between '*' and variable

You can import all of a module's exports using import *. It is a syntax error to omit the as keyword between the * and the new object's name:

import * d3 from 'd3';

To fix this error, write as after *:

import * as d3 from 'd3';

E0127: TypeScript's 'enum' feature is not yet implemented by quick-lint-js

JavaScript does not support TypeScript-style enums. It is a syntax error to declare an enum:

enum Color {
  BLUE,
  GREEN,
  RED,
}

const favoriteColor = Color.BLUE;

To fix this error, write an object instead:

const Color = {
  BLUE: 0,
  GREEN: 1,
  RED: 2,
};

const favoriteColor = Color.BLUE;

Alternatively, declare separate variables:

const Color_BLUE = 0;
const Color_GREEN = 1;
const Color_RED = 2;

const favoriteColor = Color_BLUE;

E0128: expected 'from' before module specifier

import statements load things from other files. It is a syntax error to omit the from keyword before the module name:

import React, {createElement} 'react';

To fix this error, write the from keyword before the module name:

import React, {createElement} from 'react';

E0129: expected 'from "name_of_module.mjs"'

import statements load things from other files. It is a syntax error to omit the name of the module being imported:

import React, {createElement};

To fix this error, write the from keyword followed by the module name:

import React, {createElement} from 'react';

E0130: missing catch variable name between parentheses

A try statement can have a catch clause. The catch clause can define a variable for the caught exception. It is a syntax error to omit the variable name between a catch clause's parentheses:

async function downloadURLWithRetries(url) {
  for (;;) {
    try {
      return await downloadURL(url);
    } catch () {
      // Loop and try again.
    }
  }
}

To fix this error, remove the parentheses:

async function downloadURLWithRetries(url) {
  for (;;) {
    try {
      return await downloadURL(url);
    } catch {
      // Loop and try again.
    }
  }
}

Alternatively, write a variable name between the parentheses:

async function downloadURLWithRetries(url) {
  for (;;) {
    try {
      return await downloadURL(url);
    } catch (e) {
      console.log(`download failed; retrying: ${e}`);
    }
  }
}

E0131: expected ',' between object literal entries

In an object literal, entries are separated with a ,. It is a syntax error to separate entries with ; instead:

let response = await axios.get(url.toString(), {
  adapter: cachingAdapter;
  validateStatus(_status) {
    return true;
  };
  responseType: "stream"
});

To fix this error, replace ; with ,:

let response = await axios.get(url.toString(), {
  adapter: cachingAdapter,
  validateStatus(_status) {
    return true;
  },
  responseType: "stream"
});

E0132: missing ',' between variable declarations

A const, let, and var statement can declare multiple variables. It is a syntax error to omit a , between declared variables:

const x=p.x y=p.y;

let tau = 2 pi;

Fix this this error, write a , before the second variable's name:

const x=p.x, y=p.y;

Alternatively, use the * operator to multiply a variable by a number:

let tau = 2*pi;

E0133: error generator function star belongs before name

The following code has misplaced '*'.

*function f(x) { yield x; }

To fix this error, move the '*' before function name.

function *f(x) { yield x; }

E0134: unclosed code block; expected '}' by end of file

Every { introducing a code block must have a matching } ending a code block. It is a syntax error to omit the }:

function doAllWork() {
  while (work.length) {
    doWork(work.pop());
}

To fix this error, write a matching }:

function doAllWork() {
  while (work.length) {
    doWork(work.pop());
  }
}

Alternatively, remove an unnecessary {:

function doAllWork() {
  while (work.length)
    doWork(work.pop());
}

E0135: expected variable name for 'catch'

A try statement can have a catch clause. The catch clause can define a variable for the caught exception. It is a syntax error to write a string literal instead of a variable name between a catch clause's parentheses:

async function downloadURLWithRetries(url) {
  for (;;) {
    try {
      return await downloadURL(url);
    } catch ('ETIMEOUT') {
      // Loop and try again.
    }
  }
}

To fix this error, replace the string literal with a variable name:

async function downloadURLWithRetries(url) {
  for (;;) {
    try {
      return await downloadURL(url);
    } catch (e) {
      if (e.code === 'ETIMEOUT') {
        // Loop and try again.
      } else {
        throw e;
      }
    }
  }
}

E0136: cannot update variable with '+=' while declaring it

When declaring a variable with const, let, or var, you can set the variable's initial value using =. It is a syntax error to use a compound assignment operator instead of =:

let i = 0;
while (i < 100) {
  let i += 1;
  console.log(i % 15 ? i : "FizzBuzz");
}

const length *= Math.sqrt(x*x + y*y + z*z);

To fix this error, remove the let keyword:

let i = 0;
while (i < 100) {
  i += 1;
  console.log(i % 15 ? i : "FizzBuzz");
}

Alternatively, replace the compound assignment operator with =:

const length = Math.sqrt(x*x + y*y + z*z);

E0137: missing condition for switch statement

A switch statement has a condition which determines which case or default label to execute. It is an error to omit a switch's condition:

function colorToHexCode(color) {
  switch {
    case 'red':   return '#ff0000';
    case 'green': return '#00ff00';
    case 'blue':  return '#0000ff';
  }
}

To fix this error, write the condition with parentheses after the switch keyword:

function colorToHexCode(color) {
  switch (color) {
    case 'red':   return '#ff0000';
    case 'green': return '#00ff00';
    case 'blue':  return '#0000ff';
  }
}

E0138: missing condition for if statement

An if statement has a condition which determines whether the body will execute or not. It is an error to omit an if statement's condition:

let firstName = person.firstName;
let lastName = person.lastName;
if {
  firstName = lastName;
}

To fix this error, write the condition with parentheses after the if keyword:

let firstName = person.firstName;
let lastName = person.lastName;
if (firstName === "") {
  firstName = lastName;
}

E0139: missing condition for while statement

A while statement has a condition which determines whether the body will execute or not. It is an error to omit a while statement's condition:

let name = '';
while {
  name = prompt('What is your name?');
}

async function downloadURLWithRetries(url) {
  while {
    try {
      return await downloadURL(url);
    } catch {
      // Loop and try again.
    }
  }
}

To fix this error, write the condition with parentheses after the if keyword:

let name = '';
while (name === '') {
  name = prompt('What is your name?');
}

Alternatively, to write an infinite loop, write for (;;) instead of while:

async function downloadURLWithRetries(url) {
  for (;;) {
    try {
      return await downloadURL(url);
    } catch {
      // Loop and try again.
    }
  }
}

E0140: expected expression after 'case'

A switch statement has a list of cases, each beginning with either the case keyword or the default keyword. It is a syntax error to omit an expression after the case keyword:

function textContent(node) {
  switch (node.nodeType) {
    case document.TEXT_NODE:
      return node.nodeValue;
    case: {
      let result = "";
      for (let child of node.childNodes) {
        result += textContent(child, document);
      }
      return result;
    }
    default:
      throw new Error(`Unsupported DOM node type: ${node.nodeType}`);
  }
}

function colorToHexCode(color) {
  switch (color) {
    case 'red':   return '#ff0000';
    case 'green': return '#00ff00';
    case 'blue':  return '#0000ff';
    case:
      throw new Error(`unknown color ${color}`);
  }
}

To fix this error, write an expression (usually a constant) after the case keyword:

function textContent(node) {
  switch (node.nodeType) {
    case document.TEXT_NODE:
      return node.nodeValue;
    case document.ELEMENT_NODE: {
      let result = "";
      for (let child of node.childNodes) {
        result += textContent(child, document);
      }
      return result;
    }
    default:
      throw new Error(`Unsupported DOM node type: ${node.nodeType}`);
  }
}

Alternatively, replace the case keyword with default if the code should execute if no other case would:

function colorToHexCode(color) {
  switch (color) {
    case 'red':   return '#ff0000';
    case 'green': return '#00ff00';
    case 'blue':  return '#0000ff';
    default:
      throw new Error(`unknown color ${color}`);
  }
}

E0141: expected ')' to close function call

A function call requires a list of arguments surrounded by ( and ). It is a syntax error to omit the final ) in a function call:

for (let i = 0; i < iterationCount; ++i) {
  console.log("starting iteration", i, "...";
  runBenchmarkIteration();
  console.log("finished iteration", i);
}

To fix this error, write the closing ):

for (let i = 0; i < iterationCount; ++i) {
  console.log("starting iteration", i, "...");
  runBenchmarkIteration();
  console.log("finished iteration", i);
}

E0142: missing property name after '.' operator

The . operator accesses an object's property. It is a syntax error to omit a property name after the . operator:

try {
  goNuts();
} catch {
  console.("couldn't handle deez nuts");
}

To fix this error, write the property name after the .:

try {
  goNuts();
} catch {
  console.error("couldn't handle deez nuts");
}

E0143: unmatched '}'

/* TODO */

E0144: cannot export variable named keyword '{0}'

/* TODO */

E0145: cannot import variable named keyword '{0}'

/* TODO */

E0146: missing ':' in conditional expression

/* TODO */

E0147: unexpected identifier in expression; missing operator before

It is an error to write two variable names without an operator in between:

const quatro = (dos dos);
const four = add(two two);

To fix this error, remove one of the variables, or add an operator:

const quatro = (dos + dos);
const four = add(two, two);

E0148: missing body for {1:headlinese}

/* TODO */

E0149: missing body for {1:headlinese}

/* TODO */

E0150: missing body for {1:headlinese}

/* TODO */

E0151: invalid function parameter

/* TODO */

E0152: legacy octal literals may not contain underscores

/* TODO */

E0153: forwarding exports are only allowed in export-from

/* TODO */

E0154: unexpected expression; missing key for object entry

/* TODO */

E0155: cannot reference private variables without object; use 'this.'

/* TODO */

E0156: private properties are not allowed in object literals

/* TODO */

E0157: missing end of array; expected ']'

/* TODO */

E0158: unexpected '{0}'

/* TODO */

E0159: unexpected literal in parameter list; expected parameter name

/* TODO */

E0160: unexpected '=>'; expected parameter for arrow function, but got an expression instead

The left-hand side of => must be a list of parameters. It is a syntax error if the left-hand side is instead an expression (such as a property access or a function call):

if (this.mapSize => this.capacity) {
  throw new Error("too many items");
}

let fs = require("fs");
let path = process.argv[2];
fs.mkdir(path () => console.log("done"));

To fix this error, replace => with the intended operator, such as >=:

if (this.mapSize >= this.capacity) {
  throw new Error("too many items");
}

Alternatively, make the left-hand side of => valid by adding an operator (usually ,) before the parameter list:

let fs = require("fs");
let path = process.argv[2];
fs.mkdir(path, () => console.log("done"));

E0161: unclosed object literal; expected '}'

/* TODO */

E0162: 'await' is only allowed in async functions

/* TODO */

E0163: newline is not allowed between 'async' and arrow function parameter list

/* TODO */

E0164: JSON syntax error

quick-lint-js configuration files (named quick-lint-js.config) contain valid JSON (according to RFC8259). quick-lint-js cannot read a configuration file with malformed JSON:

{
    "globals": {
        // Google Analytics
        "ga": true,
        "google": true,
    }
}

Common mistakes in JSON are trailing commas (disallowed) and comments (disallowed).

To fix this error, correct mistakes in the JSON syntax for your configuration file:

{
    "globals": {
        " // Google Analytics": false,
        "ga": true,
        "google": true
    }
}

E0165: TypeScript style const field

const fields are only allowed in TypeScript, not JavaScript

class C {
  const f = null;
} 

To fix this error, remove the const declarator from the field

class C {
  f = null;
} 

E0166: "globals" descriptor "shadowable" property must be a boolean

In a quick-lint-js configuration file, a entry in "globals" can have a descriptor object. A descriptor's "shadowable" property must be either true, false, or omitted.

{
    "globals": {
        "gsap": {
          "shadowable": 0
        }
    }
}

To fix this error, make the "shadowable" property true or false:

{
    "globals": {
        "gsap": {
          "shadowable": false
        }
    }
}

E0167: "globals" descriptor "writable" property must be a boolean

In a quick-lint-js configuration file, a entry in "globals" can have a descriptor object. A descriptor's "writable" property must be either true, false, or omitted.

{
    "globals": {
        "gsap": {
          "writable": 0
        }
    }
}

To fix this error, make the "writable" property true or false:

{
    "globals": {
        "gsap": {
          "writable": false
        }
    }
}

E0168: "globals" must be an object

In a quick-lint-js configuration file, "globals" must be an object or omitted. It is an error if "globals" is an array, a boolean, a number, a string, or null:

{
    "globals": [
        "ga",
        "google",
        "$"
    ]
}

To fix this error, make "globals" an object:

{
    "globals": {
        "ga": true,
        "google": true,
        "$": true
    }
}

E0169: "global-groups" must be a boolean or an array

In a quick-lint-js configuration file, "global-groups" must be an array of strings, a boolean, or omitted. It is an error if "global-groups" is a boolean, a number, an object, a string, or null:

{
    "global-groups": {
        "ecmascript": true,
        "browser": true
    }
}

To fix this error, make "global-groups" an array:

{
    "global-groups": [
        "ecmascript",
        "browser"
    ]
}

E0170: "global-groups" entries must be strings

In a quick-lint-js configuration file, items in the "global-groups" array must be strings. It is an error if an item is an array, a boolean, a number, an object, or null:

{
    "global-groups": [
        "ecmascript",
        2020,
        "browser"
    ]
}

To fix this error, remove non-string items in "global-groups":

{
    "global-groups": [
        "ecmascript",
        "browser"
    ]
}

E0171: "globals" descriptor must be a boolean or an object

In a quick-lint-js configuration file, each entry in "globals" must be a boolean or a descriptor object. It is an error if a "globals" item is an array, a number, a string, or null:

{
    "globals": {
        "gsap": "true"
    }
}

To fix this error, make the "globals" entry true or false:

{
    "globals": {
        "gsap": true
    }
}

E0172: missing body for function

/* TODO */

E0173: cannot assign to loop variable in for of/in loop

/* TODO */

E0174: functions/methods should not have '=>'

/* TODO */

E0175: expected variable name for 'import'-'as'

/* TODO */

E0176: missing arrow operator for arrow function

/* TODO */

E0177: React/JSX is not yet implemented

quick-lint-js does not yet support JSX syntax (used in React code):

ReactDOM.render(
  <h1>Hello, world!</h1>,
  document.getElementById('root')
);

To fix this issue, stop using quick-lint-js for your code. Alternative, use React.createElement instead of JSX:

ReactDOM.render(
  React.createElement('h1', null, 'Hello, world!'),
  document.getElementById('root')
);

E0178: 'await' cannot be followed by an arrow function; use 'async' instead

/* TODO */

E0200: break can only be used inside of a loop or switch

/* TODO */

E0201: continue can only be used inside of a loop

/* TODO */

E0202: missing '=' after variable

The following code has a missing equal '=' after variable name.

let x new Array();

To fix this error, add '=' after variable x.

let x = new Array();

E0203: depth limit exceeded

/* TODO */

E0204: error generator function star belongs after keyword function

The following code has misplaced '*'.

let x = *function(y) { yield y; };

To fix this error, move the '*' after the keyword function.

let x = function*(y) { yield y; };

E0205: error missing initializer in const declaration

The following code is missing initialization for const variable declaration.

const x;

To fix this error, initialize the variable x with some value.

const x = 10;

Another way to fix this error, change const to let.

let x;

E0206: label named 'await' not allowed in async function

The following code is using label named 'await' in an async function.

async function f() {
  await:
}

To fix this error, rename label await to something else.

async function f() {
  label:
}

Another way to fix this error, make 'f' a normal function rather than an async function.

function f() {
  await:
}

E0207: code point in Unicode escape sequence must not be greater than U+10FFFF

The following code has escaped code point in Unicode out of range.

let x = "hello\u{abcdef}";

To fix this error, make sure that the escaped code point is between U+0000 and U+10FFFF inclusive.

let x = "hello\u{abcde}";

E0208: cannot access private identifier outside class

The following code is accessing a private identifier outside the class.

class C {
  #x = 10;
}

function f(c) {
  c.#x = 20;
}

To fix this error, move function f as a static member of class C .

class C {
  #x = 10;
  static f(c) {
    c.#x = 20;
  }
}

Another way to fix this error, remove # before variable x.

class C {
  x = 10;
}

function f(c) {
  c.x = 20;
}

E0209: commas are not allowed between class methods

/* TODO */

E0210: unopened block comment

/* TODO */

E0269: 'async static' is not allowed; write 'static async' instead

/* TODO */