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

Prettier 3.x Plugin Loading New Behavior #1798

Closed
4 tasks done
samypr100 opened this issue Sep 1, 2023 · 2 comments · Fixed by #1802
Closed
4 tasks done

Prettier 3.x Plugin Loading New Behavior #1798

samypr100 opened this issue Sep 1, 2023 · 2 comments · Fixed by #1802
Assignees
Labels

Comments

@samypr100
Copy link
Contributor

samypr100 commented Sep 1, 2023

If you are submitting a bug, please include the following:

  • summary of problem
  • gradle or maven version: Gradle
  • spotless version: 6.21.0
  • operating system and version: Ubuntu 22.04

Hello, Prettier v3.x changed the way it load plugins. Now plugins are not loaded by default anymore, instead users have to manually pass a --plugin=prettier-plugin-name, or configure it in a configuration file via plugins: ['prettier-plugin-name'].

I tried something like this to see if it would work:

spotless {
    // ...
    java {
        // ...
        prettier(['prettier': '3.0.2', 'prettier-plugin-java': '2.3.0'])
                .config(['plugins': ['prettier-plugin-java'], 'parser': 'java', 'tabWidth': 4, 'printWidth': 120, 'useTabs': false])
        // ...
    }
}

But gave me the error:

Only values of type 'String', 'JsonRawValue', 'Number' and 'Boolean' are supported. You provided: [java, [prettier-plugin-java], 120, 4, false]

Am I missing something? I saw prettier v3 support was added in #1760, but I didn't see any noticeable docs updates about the plugin loading changes.

Note, just by doing

prettier(['prettier': '3.0.2', 'prettier-plugin-java': '2.3.0'])
  .config(['parser': 'java', 'tabWidth': 4, 'printWidth': 120, 'useTabs': false])

The following error happens:

Unexpected response status code at /prettier/format [HTTP 500] -- (Error while formatting: ConfigError: Couldn't resolve parser "java".)

Which is why I tried to go the manual plugin loading route.

@nedtwigg nedtwigg added the bug label Sep 1, 2023
@simschla simschla self-assigned this Sep 1, 2023
@simschla
Copy link
Contributor

simschla commented Sep 1, 2023

Thanks for reporting. I must have missed this in the docs. Will look into it!

@nedtwigg
Copy link
Member

Shipped in plugin-gradle 6.22.0 and plugin-maven 2.40.0.

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

Successfully merging a pull request may close this issue.

3 participants