Skip to content

Prettier 3.x Plugin Loading New Behavior #1798

@samypr100

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.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions