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.

tabWidth ignored in VS Code and .prettierrc

See original GitHub issue

My full setting overwrites are

{
    "sublimeTextKeymap.promptV3Features": true,
    "prettier.trailingComma": "es5",
    "prettier.tabWidth": 2,
    "editor.tabSize": 2,
    "editor.detectIndentation": false,
    "[javascript]": {
      "editor.formatOnSave": true
  }
}

But formatting still gives me a tab width of 4.

The only extensions I currently have installed are vscode-styled-components, Sublime Text Keymap, and Prettier - Code formatter.

I have tried running prettier on a .js file in an otherwise empty directory and it behaves as it should, indenting with 2 spaces, but the problem persists in multiple projects.

In an attempt to override whatever is causing this I have added a .prettierrc file at the top level of a project with the contents

{
    "tabWidth": 2
}

But that hasn’t worked either.

Issue Analytics

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

github_iconTop GitHub Comments

3reactions
tonyonodicommented, Dec 13, 2017

Wow, I had a .editorconfig in the directory above my project. I’m not sure why that would override .prettierrc and I’ve no idea where it came from, but I’ve edited it now and Prettier is indenting as expected.

Thanks for your help, that was driving me mad.

0reactions
github-actions[bot]commented, Apr 13, 2020

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to set tab width to 4 in prettier - Stack Overflow
First, remove any .prettierrc from the working directory. Because it overrides user settings and uses the default values.
Read more >
Options - Prettier
Setting indent_size or tab_width in an .editorconfig file will configure Prettier's tab width, unless overridden. Tabs. Indent lines with tabs instead of spaces ......
Read more >
Basic Editing in Visual Studio Code
Learn about the basic editing features of Visual Studio Code. Search, multiple selection, code formatting.
Read more >
How to configure Prettier and VSCode - Gleb Bahmutov
How to set up Prettier, ESLint and VSCode per project and have your JavaScript ... Print width; Ignoring files; Saving without formatting ...
Read more >
vscode prettier ignore not working - You.com | The AI Search ...
prettierrc or .editorconfig) detected, falling back to VS Code configuration ["INFO" - 23:32: ...
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