Skip to content

esbenp.prettier-vscode formats more than needed by normal prettier #3631

Closed as not planned
@sebbi08

Description

@sebbi08

Summary

esbenp.prettier-vscode reformats code that when running npx prettier --write filename

it will format this :

export class Test {
    private test(params: any) {
        console.log();
    }
    private test2() {
        this.test({
            parameter1: 1,
            parameter2: 2,
            parameter3: 3,
            parameter4: 4
        });
    }
}

to this

export class Test {
    private test(params: any) {
        console.log();
    }
    private test2() {
        this.test({ parameter1: 1, parameter2: 2, parameter3: 3, parameter4: 4 });
    }
}

we are using the following .prettierrc

{
    "endOfLine": "lf",
    "printWidth": 180,
    "tabWidth": 4,
    "trailingComma": "none",
    "semi": true,
    "arrowParens": "always",
    "overrides": [
        {
            "files": ["*.yaml", "*.yml"],
            "options": {
                "tabWidth": 2
            }
        }
    ]
}

Additional information

Here you can see that both are valid and VS Code save should not change anything

prettier.io-multiline

prettier.io-singleline

VS Code Version:

Version: 1.97.2 (system setup)
Commit: e54c774e0add60467559eb0d1e229c6452cf8447
Date: 2025-02-12T23:20:35.343Z
Electron: 32.2.7
ElectronBuildId: 10982180
Chromium: 128.0.6613.186
Node.js: 20.18.1
V8: 12.8.374.38-electron.0
OS: Windows_NT x64 10.0.26100

Prettier Extension Version: 11.0.0

OS and version: WSL: Ubuntu-22.04

Prettier Log Output

["INFO" - 1:09:09 PM] Formatting file://projectfolder/test.ts
["INFO" - 1:09:09 PM] Using config file at projectfolder/.prettierrc
["INFO" - 1:09:09 PM] PrettierInstance:
{
  "modulePath": "projectfolder/node_modules/prettier/index.cjs",
  "messageResolvers": {},
  "version": "3.4.2"
}
["INFO" - 1:09:09 PM] Using ignore file (if present) at projectfolder/.prettierignore
["INFO" - 1:09:09 PM] File Info:
{
  "ignored": false,
  "inferredParser": "typescript"
}
["INFO" - 1:09:09 PM] Detected local configuration (i.e. .prettierrc or .editorconfig), VS Code configuration will not be used
["INFO" - 1:09:09 PM] Prettier Options:
{
  "filepath": "projectfolder/test.ts",
  "parser": "typescript",
  "endOfLine": "lf",
  "printWidth": 180,
  "tabWidth": 4,
  "trailingComma": "none",
  "semi": true,
  "arrowParens": "always"
}
["INFO" - 1:09:09 PM] Formatting completed in 10ms.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions