quick-lint-js

Find bugs in JavaScript programs.

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.

Introduced in quick-lint-js version 0.2.0.

Documentation for other errors