Skip to main content
The 2024 Developer Survey results are live! See the results

Questions tagged [prettier]

Prettier is an opinionated code formatter for JavaScript, CSS, HTML, Markdown, and other languages. If possible, please use Prettier's Playground to illustrate your question (use the "Copy link" and "Copy markdown" buttons at the bottom right corner of the Playground).

737 questions with no upvoted or accepted answers
23 votes
4 answers
5k views

vsCode issue with husky

I have configured husky in my project. It is running the pre-commit hook with "lint-staged" to use "prettier" to format the code before each commit. The configuration works fine ...
dnaveen's user avatar
  • 271
20 votes
1 answer
9k views

how to support inline comments when using eslint-prettier/prettier?

i want to turn off the rule in prettier where it newlines an inline comment. my ESLint rule no-inline-comments is set to off or warn, so that is taken care of and works. turns out Prettier still wants ...
kinghat's user avatar
  • 579
12 votes
0 answers
1k views

Prettier: Remove additional spaces before self-closing tag />

We want to enforce removal of any additional spaces /> before self-closing tags in our HTML using prettier. Judging by the options, we can't find any relevant options to disable this behaviour. ...
user1429980's user avatar
  • 7,040
12 votes
3 answers
5k views

Apply dotnet-format on save in Visual Studio?

I just discovered dotnet-format, but as far as I understand it's a command line tool that has to be called manually. How can I apply dotnet-format on saving a file in Visual Studio 2019? (not Visual ...
me.at.coding's user avatar
  • 16.7k
11 votes
0 answers
2k views

Prettier arrow parentheses around single line function body

I am using Prettier with AngularJs. I am having this small function: this.resetForm = () => this.formData.email = this.user.email; When saving, Prettier add parentheses around the function body: ...
Andra's user avatar
  • 119
10 votes
0 answers
3k views

Is it possible to format only modified lines in pre-commit hooks

Using Prettier when we commit changes it formats all the code inside the file in Husky pre-commit. Is there any better method to change only modified lines of code in the file?.
Anand mishra's user avatar
9 votes
0 answers
3k views

How do I format zsh code (something like prettier / shfmt)?

For bash and sh, there is shfmt. How do I format zsh code? I'd like to be able to set some options like in shfmt, ie: -i uint indent: 0 for tabs (default), >0 for number of spaces -bn ...
Tom Hale's user avatar
  • 45.2k
9 votes
1 answer
8k views

Prettier is Indenting by 2 spaces instead of 4 on "Shift + Alt + F"

I am using Vue 3 and VS Code with Prettier as my code formatter, and I want the indentation to be 4 spaces instead of 2, and I've configured 4 spaces on the bottom right side of my VS Code. But still ...
Saud Zubedi's user avatar
8 votes
0 answers
1k views

options.editorconfig from prettier-cli

Is there a way to pass that options.editorconfig true flag using the cli without a configuration file. I can't get prettier to respect the .editorconfig file. I don't way this isn't the default. An ....
kresdjan's user avatar
  • 183
8 votes
1 answer
4k views

Visual Studio Code Prettier extension intermittently throws an error on formatting

I need to restart Visual Studio Code several times a day because the Prettier formatter extension (esbenp.prettier-vscode) throws errors. It is as if the extension gets confused after numerous ...
Clarice Bouwer's user avatar
8 votes
0 answers
1k views

Is there a way of running Prettier faster?

I'm using the latest versions of these packages: ESLint: 8.11.0 Prettier: 2.6.0 eslint-plugin-prettier: 4.0.0 eslint-config-prettier: 8.5.0 Rule Time (ms) Relative prettier/prettier 156074.280 98.4%...
Oswaldo's user avatar
  • 3,376
8 votes
0 answers
554 views

Is prettier redundant when using eslint + airbnb

This is a continuation of Is Prettier really needed when using Eslint? My understanding is that historically eslint was primarily used for code quality issues and design patterns, things that impact ...
BobtheMagicMoose's user avatar
8 votes
1 answer
2k views

VS Code Prettier - How to disable auto new lines in function arguments?

I'm using Prettier v6.4.0 and I found it annoying when it automatically add new lines to my function arguments. For example, this is the format that I desire: const Header1 = styled.h1` ${maxWidth(...
AnsonH's user avatar
  • 2,958
8 votes
0 answers
1k views

Prettier replacing comma to semicolon

I'm declaring a class in typescript with an object type. metadataList: { name: string[], metadata: Object; }; My actual problem is that prettier is replacing comma with semicolon when I save. so ...
infodev's user avatar
  • 5,145
7 votes
0 answers
3k views

Prettier settings to format object-destructuring until end of the line, instead of new line for every property

instead of this do this It could take only 2 lines not making my file longer than needed.
Rastislav Uhrin's user avatar

15 30 50 per page
1
2 3 4 5
50