prettier-vscode
prettier-vscode copied to clipboard
`printWidth` is not enforced in TypeScript file
Summary
Prettier is set up with "printWidth": 100, and VS Code is configured with "editor.formatOnSave": true, but when saving (and formatting) a TypeScript file, Prettier doesn't break up an import statement (containing more than 100 characters) into more than one line.
This issue follows up on #595 with a sample project that can be used to reproduce the issue.
Github Repository to Reproduce Issue
https://github.com/PierreFritsch/vscode-prettier-typescript-printWidth
Steps To Reproduce:
-
Clone the repo:
git clone https://github.com/PierreFritsch/vscode-prettier-typescript-printWidth code vscode-prettier-typescript-printWidth -
Open the file
index.ts -
Edit anything and save.
Expected result
The project is set to Format on Save, and the printWidth is set to 100, so I would expect the line containing the import statement to be split into more than one line, so that each line has less than 100 characters.
Actual result
The import line has a length of 146 characters.
import { MyClassHasAVeryLongNameSoThatTheImportWillExceedThePrintWidth } from "./the/import/is/located/behind/some/path/MyClassHasAVeryLongName";
Additional information
VS Code Version:
Version: 1.66.2
Commit: dfd34e8260c270da74b5c2d86d61aee4b6d56977
Date: 2022-04-11T07:49:20.994Z (3 wks ago)
Electron: 17.2.0
Chromium: 98.0.4758.109
Node.js: 16.13.0
V8: 9.8.177.11-electron.0
OS: Darwin x64 21.4.0
Prettier Extension Version: esbenp.prettier-vscode 9.5.0
OS and version: macOS Monterey Version 12.3.1
Prettier Log Output
["INFO" - 2:53:21 PM] Extension Name: esbenp.prettier-vscode.
["INFO" - 2:53:21 PM] Extension Version: 9.5.0.
["INFO" - 2:55:52 PM] Formatting file:///.../vscode-prettier-typescript-printWidth/index.ts
["INFO" - 2:55:52 PM] Using config file at '/.../vscode-prettier-typescript-printWidth/.prettierrc'
["INFO" - 2:55:52 PM] Using ignore file (if present) at /.../vscode-prettier-typescript-printWidth/.prettierignore
["INFO" - 2:55:52 PM] File Info:
{
"ignored": false,
"inferredParser": "typescript"
}
["INFO" - 2:55:52 PM] Detected local configuration (i.e. .prettierrc or .editorconfig), VS Code configuration will not be used
["INFO" - 2:55:52 PM] Prettier Options:
{
"filepath": "/.../vscode-prettier-typescript-printWidth/index.ts",
"parser": "typescript",
"tabWidth": 5,
"printWidth": 100
}
["INFO" - 2:55:53 PM] Formatting completed in 0.267ms.
I have the same issue.
This is an issue or feature request for the Prettier library itself rather than the VS Code extension for prettier. Please open an issue at https://github.com/prettier/prettier.
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.