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;
}
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;
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 };
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:
ID_Start
$
_
Characters after the initial character in a function or variable name can be
any of the following:
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();
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:
const, let, and var can only declare variables directly or by
destructuring an array or an object. Number literals and keywords are not
allowed where a variable name is expected:
let wordCounts = {for: 4, if: 5, while: 0};
let {for, if} = wordCounts;
let queue = ["first", "second", "third"];
let {first: 0} = queue;
To fix this error when destructuring an object with keyword keys, pick a
variable name which is not a keyword:
let wordCounts = {for: 4, if: 5, while: 0};
let {for: forWordCount, if: ifWordCount} = wordCounts;
When destructuring an object, it's common to confuse the variable name with the
key. Make sure the variable name comes after the ::
let queue = ["first", "second", "third"];
let {0: first} = queue;
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"));
quick-lint-js configuration files (named quick-lint-js.config or
.quick-lint-js.config or package.json) contain valid JSON (according to
RFC8259). quick-lint-js cannot read a configuration file with malformed
JSON:
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:
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:
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:
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:
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:
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: