/bug-vs-code-prettier-eslint

prettier-eslint error There was trouble creating the ESLint CLIEngine.

Primary LanguageTypeScript

prettier-eslint highlights errors but doesn't fix them: There was trouble creating the ESLint CLIEngine

Describe the bug

I'm working with TSX files for a Next.js project with Yarn. I'm not having this problem with other projects, even with the same Prettier and ESLint configuration files.

The prettier and eslint commands work fine with npx and yarn run in the project's directory.

VS Code highlights the errors accordingly to my .eslintrc rules, but doesn't fix them. When trying to format a file (Shift+Alt+F), it fails with the following message:

Error: r is not a constructor

And the VS Code window's log says:

[2021-11-25 12:17:44.403] [renderer1] [error] [Extension Host] prettier-eslint [ERROR]: There was trouble creating the ESLint CLIEngine.

It only happens in this project and I don't know how to dig deeper in the extension logs, I have no information about the bug to work with. And since both Prettier and ESLint work fine from the console, the problem's source seems to be the extension.

Deleting node_modules and yarn.lock didn't fix it. Neither did restarting VS Code or my PC.

UPDATE: the command "fix all" works! VS Code is able to fix the ESLint problems with that command. Yet "Format document" with the prettier-eslint extension still doesn't work (doesn't apply neither ESLint nor Prettier rules).

To Reproduce

Steps to reproduce the behavior:

  1. Download this repository.
  2. Run yarn install
  3. Run yarn run lint
  4. Run yarn run format:check
  5. Open the project in VS Code.
  6. Open any .tsx file (like pages/index.tsx) in the editor and wait for the linting to appear.
  7. Errors should be highlighted now.
  8. Try to fix it with the Format document command in VS Code (Shift+Alt+F).
  9. The Prettier ESLint extension fails.

Expected behavior

The Prettier ESLint extension clearly highlights the errors, so it should be able to fix them without crashing.

Example Project

This repository is an example project where it happens

Screenshots

image image image

Versions:

  • Visual Studio Code: 1.62.3
  • VS Code Node: 14.16.0
  • Node installed on system: 16.9.1
  • Package Manager: npm 7.20.6, yarn 1.22.11
  • prettier-eslint: 3.0.4
  • prettier: 2.5.0
  • eslint: 8.3.0

System Specifications:

  • OS: Windows 10 Pro 21H1
  • Processor: Intel(R) Pentium(R) CPU G4560 @ 3.50GHz 3.50 GHz
  • RAM Size: 8,00 GB