Closed wanghaooo closed 4 years ago
Seems like this issue happens for any config greater than 100 at least
Some are not used to code blocks so short line breaks
In my case the wrap does not even work for small numbers.
If I set
"printWidth": 70
with code like
const a = function afterAll(aaaaa, sssss, ddddd, fffff, ggggg, hhhhhh, jjjjj, kkkkk) {};
it never wraps.
I see a tslintIntegration. Do you have anything in your tslint config which could cause printWidth to be smaller?
Same happening here.
I have a project .prettierrc file with just one override:
{ "overrides": [ { "files": "*.ts", "options": { "singleQuote": true } } ] }
In addition, I have a workspace setting like this:
"prettier.printWidth": 140
However, when formatting a .ts file, this workspace printWidth is not respected and uses the default one 80.
It only works if I put this configuration in the .prettierrc.
I also use tslint, but it's well configured as:
"max-line-length": [ true, 140 ],
Any clue?
@alvarodp which configuration do you put in .prettierrc to make it work (make it wraps the line after 140 char)? Thanks
To make it work I must include the "prettier.printWidth" property.
{ "overrides": [ { "files": "*.ts", "options": { "singleQuote": true, "prettier.printWidth": 140 } } ] }
But I want to set this property in the workspace, not in the .prettierrc.
If you have a prettier config file, we discard settings from VSCode. That's why you see default values for them. Explained: https://github.com/prettier/prettier-vscode#prettiers-settings.
You should set printWidth
, not prettier.printWidth
in your config file. Prefix are only for VSCode
True, without the prefix. So there's no "merge" with vscode settings and it's not planned.
Here is the content of my .prettierrc file:
{
"trailingComma": "es5",
"tabWidth": 2,
"useTabs": false,
"singleQuote": true,
"printWidth": 100,
"bracketSpacing": true,
}
My code never wraps when my line of code exceeds 100 characters.
@alvarodp Unfortunately adding your override suggestion to my .prettierrc did not work for me.
{
"trailingComma": "es5",
"tabWidth": 2,
"useTabs": false,
"singleQuote": true,
"printWidth": 100,
"bracketSpacing": true,
"overrides": [
{
"files": "*.js*",
"options": {
"prettier.printWidth": 50
}
}
]
}
Is that the format you have been using?
@alvarodp It was the case in older versions of this extension but was removed to stay consistent with prettier cli and other IDE which do not read from VSCode's settings. No settings means default ones.
@DavidHenri008 it's printWidth
not prettier.printWidth
. Check if you don't have any other extension formatting your given file and your config file is above your file (file path wise)
@CiGit Unfortunately, even with printWidth
only it still does not work. The syntax or the whole command is wrong.
Same here.
Only works if you set it in .prettierrc
@ph55 if it works for you, could you post your complete .prettierrc
file content.
@DavidHenri008 sure, very simple:
{
"singleQuote": true,
"printWidth": 100
}
i have this same issue
@CiGit I'm having the same issue as @DavidHenri008, where the formatting does not wrap at all.
The issue appears to happen for me only when the ESLint Integration option is enabled. However, all of my other ESLint rules appear to be working fine. It just does not seem to recognize any sort of printWidth at all (i.e. max-len rule).
airbnb
, so it should infer 100.package.json
: "printWidth": 100
"prettier.printWidth": 100,
Update This appears to be an ESLint bug.
The issue appears to happen for me only when the ESLint Integration option is enabled.
THANK YOU. Unchecked ESLint integration from VSCode options -> Works again.
I have been wondering why VSCode is doing one thing and prettier CLI another.. I would expect that the prettier config file (in my case, .prettierrc.yaml
) would be the end-all. Shouldn't the config override any workspace/user settings that are set?
I checked that I didn't have ESLint Integration set, but VSCode prettier was still wrapping a long line even though prettier CLI didn't. My .prettierrc.yaml
file:
singleQuote: true
semi: true
tabWidth: 2
useTabs: false
proseWrap: 'never'
printWidth: 120
bracketSpacing: true
arrowParens: 'always'
But ... I had my "prettier.printWidth": 80
in my User settings. I made it 120
to match the prettier config file and voila -- It now works.
And, I didn't have anything set (directly) for printWidth
in my tsconfig.json
file, but I am extending ["tslint:latest", "tslint-plugin-prettier", "tslint-config-prettier"]
I'm confused. I've been struggling to get this working for weeks. It seemed like vscode wasn't picking up my .prettierrc.
I just added "prettier.printWidth" to .vscode/settings.json and it finally worked correctly. Why isn't vscode picking up my .prettierrc?
here are my configs + their names and paths
@blackmad Please post a new issue about the prettierrc and include the log data and ideally a sample project that can be used to reproduce the issue.
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.
I set the prettier.printWidth property to 500, but the line is still wrapped after formatting
I want the block of code to be a little bit longer and I'm going to wrap it, but do I need to set some places besides the printwidth property?