Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue upgrading to Prettier 3 #562

Closed
broksonic21 opened this issue Jul 5, 2023 · 42 comments · Fixed by #569
Closed

Issue upgrading to Prettier 3 #562

broksonic21 opened this issue Jul 5, 2023 · 42 comments · Fixed by #569

Comments

@broksonic21
Copy link

What version of eslint are you using?
8.44.0

What version of prettier are you using?
3.0.0

What version of eslint-plugin-prettier are you using?
4.2.1

Please paste any applicable config files that you're using (e.g. .prettierrc or .eslintrc files)

/* eslint-env node */

module.exports = {
  plugins: ["@typescript-eslint", "prettier"],

  extends: [
    "eslint:recommended",
    "plugin:@typescript-eslint/eslint-recommended",
    "plugin:@typescript-eslint/recommended",
  ],
  rules: {
    "prettier/prettier": "error",
  },
  settings: {
    "import/resolver": {
      typescript: {
        alwaysTryTypes: true,
      },
    },
  },
};

What source code are you linting?
private source code

What did you expect to happen?
Can run with prettier 3 like with prettier 2

What actually happened?

✖ eslint --quiet --fix:

Oops! Something went wrong! :(

ESLint: 8.44.0

TypeError: prettier.resolveConfig.sync is not a function
Occurred while linting REDACTED
Rule: "prettier/prettier"
    at Program (/Users/REDACTED/REDACTED/REDACTED/node_modules/eslint-plugin-prettier/eslint-plugin-prettier.js:138:40)
    at ruleErrorHandler (/Users/REDACTED/REDACTED/REDACTED/node_modules/eslint/lib/linter/linter.js:1050:28)
    at /Users/REDACTED/REDACTED/REDACTED/node_modules/eslint/lib/linter/safe-emitter.js:45:58
    at Array.forEach (<anonymous>)
    at Object.emit (/Users/REDACTED/REDACTED/REDACTED/node_modules/eslint/lib/linter/safe-emitter.js:45:38)
    at NodeEventGenerator.applySelector (/Users/REDACTED/REDACTED/REDACTED/node_modules/eslint/lib/linter/node-event-generator.js:297:26)
    at NodeEventGenerator.applySelectors (/Users/REDACTED/REDACTED/REDACTED/node_modules/eslint/lib/linter/node-event-generator.js:326:22)
    at NodeEventGenerator.enterNode (/Users/REDACTED/REDACTED/REDACTED/node_modules/eslint/lib/linter/node-event-generator.js:340:14)
    at CodePathAnalyzer.enterNode (/Users/REDACTED/REDACTED/REDACTED/node_modules/eslint/lib/linter/code-path-analysis/code-path-analyzer.js:795:23)
    at /Users/REDACTED/REDACTED/REDACTED/node_modules/eslint/lib/linter/linter.js:1085:32
@shogo82148
Copy link

@sandrooco
Copy link

V5 pre-release actually adds support for this. I'm shocked this has been in September last year... @JounQin can you provide information about the future of this package? Thanks for your work!

@isimmons
Copy link

isimmons commented Jul 5, 2023

Same issue both for running eslint in a package.json script and vscode eslint output from the extension. Fixed by downgrading prettier to version 2.8.8

@ali4heydari
Copy link

ali4heydari commented Jul 5, 2023

prettier.resolveConfigFile.sync is removed from version 3 of prettier.

@sandrooco I tried version ^5.0.0-alpha.1 and I got this error:

Cannot read properties of undefined (reading 'parsers')
Occurred while linting path/to/file:1
Rule: "prettier/prettier"

Dependencies:

    "@typescript-eslint/eslint-plugin": "^5.61.0",
    "@typescript-eslint/parser": "^5.61.0",
    "eslint": "8.44.0",
    "eslint-config-next": "^13.4.8",
    "eslint-config-prettier": "^8.8.0",
    "eslint-plugin-cypress": "^2.13.3",
    "eslint-plugin-jest": "^27.2.2",
    "eslint-plugin-no-relative-import-paths": "^1.5.2",
    "eslint-plugin-prettier": "^5.0.0-alpha.1",
    "prettier": "^3.0.0",
    "prettier-plugin-tailwindcss": "^0.3.0",
     "typescript": "^5.1.6",

@ali4heydari
Copy link

prettier.resolveConfigFile.sync is removed from version 3 of prettier.

@sandrooco I tried version ^5.0.0-alpha.1 and I got this error:

Cannot read properties of undefined (reading 'parsers')
Occurred while linting path/to/file:1
Rule: "prettier/prettier"

Dependencies:

    "@typescript-eslint/eslint-plugin": "^5.61.0",
    "@typescript-eslint/parser": "^5.61.0",
    "eslint": "8.44.0",
    "eslint-config-next": "^13.4.8",
    "eslint-config-prettier": "^8.8.0",
    "eslint-plugin-cypress": "^2.13.3",
    "eslint-plugin-jest": "^27.2.2",
    "eslint-plugin-no-relative-import-paths": "^1.5.2",
    "eslint-plugin-prettier": "^5.0.0-alpha.1",
    "prettier": "^3.0.0",
    "prettier-plugin-tailwindcss": "^0.3.0",
     "typescript": "^5.1.6",

I realized that my problem is related to the prettier-plugin-tailwindcss package, read more.

@skratchdot
Copy link

V5 pre-release actually adds support for this. I'm shocked this has been in September last year... @JounQin can you provide information about the future of this package? Thanks for your work!

as mentioned by @sandrooco, the v5 pre-release fixed things for me. changing:

"eslint-plugin-prettier": "^4.2.1",

to:

"eslint-plugin-prettier": "^5.0.0-alpha.1",

in my package.json and re-running npm install fixed things for me.

@JounQin
Copy link
Member

JounQin commented Jul 6, 2023

Please use the alpha version for now, I think we need some feedback before we release the final major version.

npm i -D eslint-plugin-prettier@alpha

@xiaoqiang1999

This comment was marked as resolved.

@JounQin
Copy link
Member

JounQin commented Jul 6, 2023

@sandrooco
Copy link

Thanks for your feedback @JounQin. I was able to successfully run prettier 3.0.0 with the alpha release.

@simPod

This comment was marked as resolved.

@JounQin
Copy link
Member

JounQin commented Jul 6, 2023

@simPod You need v5.0.0-alpha.2, see #564

@simPod
Copy link

simPod commented Jul 6, 2023

Smooth, thanks

adnene-guessoum added a commit to adnene-guessoum/Bugtrax that referenced this issue Jul 31, 2023
- cf. prettier/eslint-plugin-prettier#562
- Solution: eslint-plugin-prettier upgrade to v5
mhofman pushed a commit to Agoric/agoric-sdk that referenced this issue Aug 7, 2023
anilhelvaci pushed a commit to anilhelvaci/agoric-sdk that referenced this issue Aug 16, 2023
jspn-creative added a commit to jspn-creative/linkedin that referenced this issue Aug 24, 2023
Can't build without either downgrading or upgrading. See [this issue for details](prettier/eslint-plugin-prettier#562).
icazevedo pushed a commit to vtex/faststore that referenced this issue Oct 9, 2023
## What's the purpose of this pull request?

This PR fixes
[this](https://github.com/vtex/faststore/actions/runs/6458890810/job/17533535581)
issue that happened while publishing packages due to incompatible
`eslint-plugin-prettier` versions with prettier 3.x.

## How it works?

In #2050 I upgraded the prettier version to 3.x. That caused the issue
because `tsdx` has a dependency on an old `eslint-plugin-prettier`
version, which is incompatible with `prettier@3`. I'm rolling back the
upgrade and fixing the prettier version on the major `2` which makes it
difficult for others to make the same mistake as me.

In the future, we remove all uses of `tsdx` as it is no longer supported
and has gone 3 years without updates.

## How to test it?

By merging this!

## References

prettier/eslint-plugin-prettier#562
Thanks @hellofanny for noticing the error and investigating it!
@ivantrave
Copy link

ivantrave commented Oct 16, 2023

I tried using alpha version and still got this error:

<path_to_npm>/.npm/_npx/15f9efe159c89f49/node_modules/pretty-quick/dist/isSupportedExtension.js:12
  ..._prettier.resolveConfig.sync(file, {
                             ^
TypeError: _prettier.resolveConfig.sync is not a function
    at <path_to_npm>/.npm/_npx/15f9efe159c89f49/node_modules/pretty-quick/dist/isSupportedExtension.js:12:30
    at Array.filter (<anonymous>)
    at _default (<path_to_npm>/.npm/_npx/15f9efe159c89f49/node_modules/pretty-quick/dist/index.js:53:157)
    at Object.<anonymous> (<path_to_npm>/.npm/_npx/15f9efe159c89f49/node_modules/pretty-quick/bin/pretty-quick.js:17:27)
    at Module._compile (node:internal/modules/cjs/loader:1198:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1252:10)
    at Module.load (node:internal/modules/cjs/loader:1076:32)
    at Function.Module._load (node:internal/modules/cjs/loader:911:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:22:47

in the package json I have:

"eslint-config-prettier": "^8.8.0",
"eslint-plugin-prettier": "^5.0.0-alpha.1",
"prettier": "^3.0.0",

Node version: v16.20.2

Tried with version "eslint-plugin-prettier": "^5.0.1", and "prettier": "^3.0.3" with no luck.

Any suggestion? What may I be missing here?

@lehni
Copy link

lehni commented Oct 16, 2023

@ivantrave it looks like pretty-quick would need to be updated in order to work with prettier 3. The last release was 2 years ago. You can track the issue here:

prettier/pretty-quick#164

@ivantrave
Copy link

Thanks for your comment @lehni !

For now, I downgraded to the following versions and it worked:

"eslint-plugin-prettier": "^4.2.1",
"prettier": "^2.8.8",
"pretty-quick": "^3.1.3",

Thanks

@konradbjk
Copy link

Why this issue is closed, if the error is still not resolved?

For me next.js, prettier 3.0.3 and plugin 5.0.1 do not work either

@JounQin
Copy link
Member

JounQin commented Oct 31, 2023

@konradbjk Then please post another issue with runnable reproduction.

eddybrando added a commit to Qiskit/qiskit.org that referenced this issue Jan 2, 2024
eddybrando added a commit to Qiskit/qiskit.org that referenced this issue Jan 2, 2024
* chore(deps-dev): bump prettier from 2.8.8 to 3.1.1

Bumps [prettier](https://github.com/prettier/prettier) from 2.8.8 to 3.1.1.
- [Release notes](https://github.com/prettier/prettier/releases)
- [Changelog](https://github.com/prettier/prettier/blob/main/CHANGELOG.md)
- [Commits](prettier/prettier@2.8.8...3.1.1)

---
updated-dependencies:
- dependency-name: prettier
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* chore(deps-dev): update eslint-config-prettier and eslint-plugin-prettier

Necessary updates to support Prettier update: prettier/eslint-plugin-prettier#562

* style: Prettier fixes

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Eddybrando Vásquez <eddybrando.vasquez@gmail.com>
anilhelvaci pushed a commit to Jorge-Lopes/agoric-sdk that referenced this issue Feb 16, 2024
@CyxouD
Copy link

CyxouD commented May 25, 2024

Fixed after updating ESLint

 "eslint": "8.57.0",
 "prettier": "3.2.5",
  "eslint-plugin-prettier": "^5.1.3",

@IonelLupu
Copy link

Fixed after updating ESLint

 "eslint": "8.57.0",
 "prettier": "3.2.5",
  "eslint-plugin-prettier": "^5.1.3",

I can confirm this works for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.