This question isn’t a duplicate. I have read through this question: ERROR: ‘console is not defined. [no-undef] – Brackets and most of the answers are for ESLint 8 and below. Some have talked about the flat config file, which I have attempted to no avail:
// filename: eslint.config.js
import globals from "globals";
import pluginJs from "@eslint/js";
import jest from "eslint-plugin-jest";
export default [
pluginJs.configs.recommended,
{
files: ["**/*.js"],
languageOptions: {
globals: { ...globals.node },
},
...jest.configs["flat/recommended"],
plugins: {
jest,
},
rules: {},
},
];
I have tried many modifications, such as globals: { ...globals.browser, ...globals.node }
and using the 'no-console': 'off'
rule, but every time I run npm run lint
, I still get:
6:3 error 'console' is not defined no-undef
Here is my index.js
file:
import app from "./src/app.js";
const PORT = 3000;
app.listen(PORT, () => {
console.log(`Server running at http://localhost:${PORT}`);
});
I am really out of options.`
Edit: Most answers on the question I linked are not applicable because they are using the .eslintrc
file, which has been deprecated in ESLint 9, as well as properties like env
.
When I run npm run lint
, it runs the following:
"lint": "eslint '**/*.js' --ignore-pattern node_modules/",
4