Logo

dev-resources.site

for different kinds of informations.

How to Fix Common ESLint Errors: Troubleshooting Unknown or Strange Issues

Published at
11/7/2024
Categories
eslint
webdev
npm
Author
jenchen
Categories
3 categories in total
eslint
open
webdev
open
npm
open
Author
7 person written this
jenchen
open
How to Fix Common ESLint Errors: Troubleshooting Unknown or Strange Issues

When get the error by running

npm run lint -w myFolder
Enter fullscreen mode Exit fullscreen mode

Error messages

Oops! Something went wrong! :(

ESLint: 9.12.0

TypeError: ObjectSchema is not a constructor
    at new Config (/node_modules/eslint/lib/config/config.js:175:24)
    at [finalizeConfig] (/node_modules/eslint/lib/config/flat-config-array.js:216:16)
    at FlatConfigArray.getConfigWithStatus (/node_modules/@eslint/config-array/dist/cjs/index.cjs:1102:55)
    at FlatConfigArray.getConfig

    ...
Enter fullscreen mode Exit fullscreen mode

Root cause

The version specified in package.json is 9.9.0, but the error log shows that the command is running ESLint version 9.12.0:

Image description

The issue arises because I use Bun to manage the packages in my project, but when running npm run lint -w myFolder, it uses npm (the Node.js package manager) instead of Bun. This causes a version mismatch, as npm installs or uses a different version of ESLint than the one managed by Bun.

Solution

Install the same version of ESLint as specified in package.json in Node.js using npm by running the following command:

npm i [email protected] -D
Enter fullscreen mode Exit fullscreen mode

Check the installed version

npm ls eslint
Enter fullscreen mode Exit fullscreen mode

Check the output to see if the version is correct

Image description

Run the command below again to see the correct results

npm run lint -w myFolder
Enter fullscreen mode Exit fullscreen mode
eslint Article's
30 articles in total
Favicon
Just use this Next.js Eslint Configuration
Favicon
3. How to setup Jest in a Next 15 project (+ eslint for testing)
Favicon
Do me lint! 🙋‍♂️ An easy way to setup ESLint in any project.
Favicon
Restricting some syntax with ESLint
Favicon
Beyond Spellcheck: How Static Analysis Tools Enhance Collaboration in Coding
Favicon
ESlint 9
Favicon
How to Fix Common ESLint Errors: Troubleshooting Unknown or Strange Issues
Favicon
Incrementally fixing lots of ESlint errors in a clean way with ESlint Nibble
Favicon
Setup Eslint Prettier in a TypeScript project with mongoose ODM
Favicon
Vue3 + ESLint 9.13.0 + Prettier +TypeScript and VSCode Autoformat on Save
Favicon
Configurando un proyecto de React para producción
Favicon
Configurando Prettier, ESLint y Husky en Angular
Favicon
Eslint Code Insights from Bitbucket pipelines
Favicon
How to get ESLint 9.11.1 to run in Vue 3
Favicon
Cómo hacer que ESLint 9.11.1 funcione en Vue 3
Favicon
Performing Maintenance Task For A Large Codebase
Favicon
Setup Prettier Pada Nextjs Tailwind Project
Favicon
“Eslint-Summary” — Hack your Eslint Config
Favicon
Regras customizáveis para Prettier + Eslint em React
Favicon
Useful VS Code Extensions for JS
Favicon
ESLint 9 Flat config tutorial
Favicon
ESLint x Prettier: The Right Way To Start A JavaScript Project
Favicon
How to Set Up ESLint and Prettier in a TypeScript Project
Favicon
Customizable rules for Prettier + Eslint in React
Favicon
How to set up Eslint and prettier
Favicon
Configure Eslint, Prettier and show eslint warning into running console vite react typescript project
Favicon
Building Vue3 Component Library from Scratch #11 ESlint + Prettier + Stylelint
Favicon
Setup Eslint + Prettier for code standardization in React
Favicon
Setup Eslint + Prettier para padronização de código em React
Favicon
ESLint Plugin. What was missed in the doc?

Featured ones: