Skip to content

Add support for prettier 3.x #1751

Closed
@DavidGregory084

Description

@DavidGregory084

I'm trying to update the version of prettier used in a VS Code plugin.

Currently I'm using the default version of prettier that's installed by spotless - this seems to be version 2.8.1.

If I update my spotless configuration to use version 3.0.0 and use the workaround mentioned in #1750 to get spotless installed, then Spotless replaces my TypeScript code with an empty JS object.

Gradle version: 8.2.1
Spotless version: 6.19.0

Spotless configuration:

spotless {
    ratchetFrom("origin/main")

    typescript {
        target("src/**/*.ts")
        prettier("3.0.0")
    }

    json {
        target("syntaxes/**/*.json")
        prettier("3.0.0")
    }
}

build command output:

* What went wrong:
Execution failed for task ':vscode-plugin:spotlessTypescriptCheck'.
> The following files had format violations:
      src/extension.ts
          @@ -1,273 +1 @@
          -import·*·as·child_process·from·"child_process";
          -import·*·as·os·from·"os";
          -import·*·as·path·from·"path";
          -import·*·as·util·from·"util";
          -
          -import·{
          -··ExtensionContext,
          -··OutputChannel,
          -··ProgressLocation,
          -··Uri,
          -··window,
          -··workspace,
          -}·from·"vscode";
          -
          -import·{
          -··LanguageClient,
          -··LanguageClientOptions,
          -··ServerOptions,
          -··TransportKind,
          -}·from·"vscode-languageclient/node";
          -
          -import·{·getApi,·FileDownloader·}·from·"@microsoft/vscode-file-downloader-api";
          -import·{·findRuntimes·}·from·"jdk-utils";
          -
          -const·COURSIER_DOWNLOAD_TIMEOUT_MS·=·120000;
          -const·COURSIER_LAUNCHER_URI·=·Uri.parse(
          -··"https://github.com/coursier/launchers/raw/master/coursier.jar",
          -);
          -
          -let·client:·LanguageClient;
          -
          -async·function·downloadCoursierJar(
          -··context:·ExtensionContext,
          -··fileDownloader:·FileDownloader,
          -):·Promise<Uri>·{
          -··return·await·window.withProgress(
          -····{
          -······location:·ProgressLocation.Window,
          -····},
          -····(progress,·cancellationToken)·=>·{
          -······return·fileDownloader.downloadFile(
          -········COURSIER_LAUNCHER_URI,
          -········"coursier.jar",
          -········context,
          -········cancellationToken,
          -········(_downloadedBytes,·_totalBytes)·=>
          -··········progress.report({·message:·"Downloading·coursier·JAR"·}),
          -········{·timeoutInMs:·COURSIER_DOWNLOAD_TIMEOUT_MS·},
      ... (226 more lines that didn't fit)
  Run './gradlew :vscode-plugin:spotlessApply' to fix these violations.

If I run ./gradlew :vscode-plugin:spotlessApply as suggested it applies this diff to the file.

If I run npx prettier --write src from within the vscode-plugin folder to use prettier directly, I don't get the same result, so I don't think it's an issue in prettier itself.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions