prettier / prettier-eslint-cli

CLI for prettier-eslint
https://npm.im/prettier-eslint-cli
MIT License
539 stars 85 forks source link

Error after updating eslint to 8.1.0 #427

Closed 1v3n closed 2 years ago

1v3n commented 2 years ago

Hey,

once I update eslint from 7.32.0 to 8.1.0. I see an error on my command line when I run prettier-eslint:

Scripts:

"prettier:watch": "onchange \"**/*.+(js|jsx|json|scss|css)\" -- prettier-eslint --write $PWD/{{changed}}",
"prettier:format": "prettier-eslint --write \"src/**/*.+(js|jsx|json|scss|css)\"",

My config:

prettier-eslint shows error:

prettier-eslint [ERROR]: There was trouble creating the ESLint CLIEngine.
prettier-eslint-cli [ERROR]: There was an error formatting "/Users/me/workspace/company/app/frontend/package.json":
TypeError: CLIEngine is not a constructor
at getESLintCLIEngine (/Users/me/workspace/company/app/frontend/node_modules/prettier-eslint/dist/utils.js:403:12)
at getESLintConfig (/Users/me/workspace/company/app/frontend/node_modules/prettier-eslint/dist/index.js:210:51)
at format (/Users/me/workspace/company/app/frontend/node_modules/prettier-eslint/dist/index.js:75:71)
at MapSubscriber.project (/Users/me/workspace/company/app/frontend/node_modules/prettier-eslint-cli/dist/format-files.js:268:54)
at MapSubscriber._next (/Users/me/workspace/company/app/frontend/node_modules/rxjs/internal/operators/map.js:49:35)
at MapSubscriber.Subscriber.next (/Users/me/workspace/company/app/frontend/node_modules/rxjs/internal/Subscriber.js:66:18)
at AsyncSubject.Subject.next (/Users/me/workspace/company/app/frontend/node_modules/rxjs/internal/Subject.js:60:25)
at AsyncSubject.complete (/Users/me/workspace/company/app/frontend/node_modules/rxjs/internal/AsyncSubject.js:53:35)
at handler (/Users/me/workspace/company/app/frontend/node_modules/rxjs/internal/observable/bindNodeCallback.js:53:33)
at FSReqCallback.readFileAfterClose [as oncomplete] (node:internal/fs/read_file_context:69:3)
failure formatting 1 file with prettier-eslint
chrisbobbe commented 2 years ago

Supporting prettier-eslint, prettier, and eslint later than v9.0.2, v1.19.1, and v5.16.0, respectively, is #304. 😕

YuliyaNovik commented 2 years ago

https://eslint.org/docs/8.0.0/user-guide/migrating-to-8.0.0#remove-cliengine seems to be useful

YuliyaNovik commented 2 years ago

any updates?

haase1020 commented 2 years ago

I am running into this issue as well when updating to eslint v8.13.0. Any updates or should I wait on updating eslint?

idahogurl commented 2 years ago

@haase1020 Support for ESLint 8 is coming (see https://github.com/prettier/prettier-eslint/pull/696). However there was an issue with the publishing process and it didn't push out a new version. In short, do not update to ESLint 8 just yet.

georgecrawford commented 2 years ago

@idahogurl Thanks for your work on this. I'm running the following (all the latest versions, AFAICT):

"eslint": "8.13.0",
"prettier": "2.6.2",
"prettier-eslint": "14.0.0",
"prettier-eslint-cli": "5.0.1",

... and yet I'm still seeing:

$ ./node_modules/.bin/prettier-eslint file.js
prettier-eslint [ERROR]: There was trouble creating the ESLint CLIEngine.
prettier-eslint-cli [ERROR]: There was an error formatting "file.js":
    TypeError: CLIEngine is not a constructor
        at getESLintCLIEngine (./node_modules/prettier-eslint-cli/node_modules/prettier-eslint/dist/utils.js:403:12)
        at getESLintConfig (./node_modules/prettier-eslint-cli/node_modules/prettier-eslint/dist/index.js:210:51)
        at format (./node_modules/prettier-eslint-cli/node_modules/prettier-eslint/dist/index.js:75:71)
        at MapSubscriber.project (./node_modules/prettier-eslint-cli/dist/format-files.js:268:54)
        at MapSubscriber._next (./node_modules/rxjs/internal/operators/map.js:49:35)
        at MapSubscriber.Subscriber.next (./node_modules/rxjs/internal/Subscriber.js:66:18)
        at AsyncSubject.Subject.next (./node_modules/rxjs/internal/Subject.js:60:25)
        at AsyncSubject.complete (./node_modules/rxjs/internal/AsyncSubject.js:53:35)
        at handler (./node_modules/rxjs/internal/observable/bindNodeCallback.js:53:33)
        at FSReqCallback.readFileAfterClose [as oncomplete] (node:internal/fs/read_file_context:68:3)
failure formatting 1 file with prettier-eslint
georgecrawford commented 2 years ago

Since https://github.com/prettier/prettier-eslint/pull/696 is merged and prettier-eslint supports ESLint v8, what are the chances of this project upgrading eslint and prettier-eslint?

smartdev322 commented 2 years ago

hey @georgecrawford same here

    "@nuxtjs/style-resources": "^1.2.1",
    "eslint": "^8.14.0",
    "eslint-config-prettier": "^8.3.0",
    "eslint-plugin-prettier": "^4.0.0",
    "eslint-plugin-vue": "^8.7.1",
    "prettier": "^2.4.1",
    "prettier-eslint-cli": "^5.0.1",