question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Prettier indentation not working/overrides.

See original GitHub issue

Hello, I use the John Papa Angular essentials package. I like my editor to have indentations of 4 spaces. My editor was set at 4 spaces, and when I downloaded angular essentials (I believe) Prettier overrides that.

My settings:

{
    "editor.fontSize": 14,
    "editor.insertSpaces": true,
    "window.zoomLevel": 1,
    "editor.detectIndentation": false,
    "workbench.iconTheme": "material-icon-theme",
    "editor.tabSize": 4
}

I tried adding the prettier settings to keep up with the tabSize:

{
    "editor.fontSize": 14,
    "editor.insertSpaces": true,
    "window.zoomLevel": 1,
    "editor.detectIndentation": false,
    "workbench.iconTheme": "material-icon-theme",
    "editor.tabSize": 4,
    "prettier.tabWidth": 4,
    "prettier.singleQuote": true,
}

After this, my editor still specifies a tab size of 2 capture

and when I click the spaces icon, it says configured tab size is 4. If configured is 4, why is 2 selected everywhere? I can manually click 4, on each file, but if I quit/reload the editor everything is back at 2. How can I fix my formatting?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:14 (3 by maintainers)

github_iconTop GitHub Comments

86reactions
jmlscommented, Jan 25, 2018

oh, ok … I seem to have fixed it …

I created a .prettierrc file in the root of my project with the following content

{
	"singleQuote": true,
	"printWidth": 80,
	"editor.formatOnSave": true,
	"proseWrap": "always",
	"tabWidth": 4,
	"requireConfig": false,
	"useTabs": false,
	"trailingComma": "none",
	"bracketSpacing": true,
	"jsxBracketSameLine": false,
	"semi": true
}

and now I get 4 spaces for indentation

12reactions
CiGitcommented, Jan 25, 2018

The right setting to have prettier indent with 4 spaces is prettier.tabWidth: 4

@CHBaker We do not read from editor.tabSize. It may be written 2 due to editor.detectIndentation

@jmls editor.formatOnSave is useless in a .prettierrc file. (you may also have a warning about that)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Prettier is not indenting as specified - Stack Overflow
1. At the bottom of your Editor window, check for the 'Spaces: 2' (in case your code is getting indented with 2 spaces)....
Read more >
Options - Prettier
Prettier's printWidth option does not work the same way. ... in an .editorconfig file will configure Prettier's print width, unless overridden.
Read more >
Prettier | WebStorm Documentation - JetBrains
Set Prettier as default formatter · Open the Settings/Preferences dialog ( Ctrl+Alt+S ), go to Languages & Frameworks | JavaScript | Prettier, ...
Read more >
How to configure Prettier and VSCode - Gleb Bahmutov
You can configure JavaScript code auto-formatting with Prettier to work per-project. This allows you to get a consistent formatting without ...
Read more >
How to use Prettier in VS Code - Robin Wieruch
If not agreed upon with your team mates, this may cause trouble. Therefore I recommend the installation of Prettier Formatting Toggle which ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found