Skip to content

Prettier 3.x Plugin Loading New Behavior #1798

Description

@samypr100

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.

Activity

  1. self-assigned this
    on Sep 1, 2023
  2. simschla commented on Sep 1, 2023

    @simschla
    Contributor

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

  3. added a commit that references this issue on Sep 9, 2023
    7631fb0
  4. nedtwigg commented on Sep 29, 2023

    @nedtwigg
    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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions