Respect `disable_tab_width_auto_detection` when Prettier config is present
See original GitHub issueExplain the Issue and Expected Behavior
By default JsPrettier derives tabWidth
Prettier option from indentation detected by Sublime Text (which is controlled by disable_tab_width_auto_detection
setting). However, if there is a Prettier config file present, this setting isn’t respected instead falling back to Prettier default setting tabWidth: 2
even if tabWidth
isn’t set in Prettier config file.
It is expected for JsPrettier to obey disable_tab_width_auto_detection
parameter unless tabWidth
is set in Prettier config file as described in README.md
.
Prettier version
1.16.4
JsPrettier Plug-in Version
1.25.0
Platform Details
- Sublime Text Version:
3.2
- Sublime Text Build:
3200
- Sublime Text Architecture:
x64
- Operating System Name:
macOS
- Operating System Version:
10.14.3 (18D109)
- Operating System Architecture:
x64
Generated Prettier command line arguments
[JsPrettier DEBUG]: Prettier config file discovered at '/Users/schrodinger_cat/.prettierrc.json'
-----------------------------------------
JsPrettier DEBUG - Prettier CLI Command
-----------------------------------------
/usr/local/bin/prettier --stdin --config /Users/schrodinger_cat/.prettierrc.json --config-precedence cli-override --parser babel --use-tabs false --stdin-filepath /Users/schrodinger_cat/Documents/Source/macos/dotfiles/Library/Scripts/Applications/Transmit/SyncFavourite.js --loglevel debug --cursor-offset 706
Prettier reported the following output:
[debug] normalized argv: {"_":[],"color":true,"editorconfig":true,"stdin":true,"use-tabs":false,"config":"/Users/schrodinger_cat/.prettierrc.json","config-precedence":"cli-override","parser":"babel","stdin-filepath":"/Users/schrodinger_cat/Documents/Source/macos/dotfiles/Library/Scripts/Applications/Transmit/SyncFavourite.js","loglevel":"debug","cursor-offset":706,"plugin-search-dir":[],"plugin":[],"ignore-path":".prettierignore","debug-repeat":0}
[debug] load config file from '/Users/schrodinger_cat/.prettierrc.json'
[debug] loaded options `{"semi":false,"singleQuote":true}`
[debug] applied config-precedence (cli-override): {"filepath":"/Users/schrodinger_cat/Documents/Source/macos/dotfiles/Library/Scripts/Applications/Transmit/SyncFavourite.js","cursorOffset":706,"parser":"babel","semi":false,"singleQuote":true,"useTabs":false}
Prettier process finished with exit code 0.
Is the same behavior observed when run against Prettier directly?
Yes.
The contents of your User/JsPrettier.sublime-settings
file
Empty.
The contents of your <project_name>.sublime-project
file
Empty.
The contents of your .prettierrc.json
file
Doesn’t contain tabWidth
parameter:
{
"semi": false,
"singleQuote": true
}
Steps to reproduce the behavior
- Create Prettier config file without
tabWidth
parameter set. - Omit
disable_tab_width_auto_detection
parameter or set it tofalse
in JsPrettier settings. - Open file where Sublime Text detects indentation
4
. - Use JsPrettier to format file.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:9 (3 by maintainers)
Top Results From Across the Web
Configuration File - Prettier
This is to make sure that when a project is copied to another computer, Prettier's behavior stays the same. Otherwise, Prettier wouldn't be...
Read more >How to configure Prettier and VSCode - Gleb Bahmutov
I like using JSON configuration format so my code editor helps me. In fact, VSCode understands the Prettier configuration file format via the ......
Read more >Prettier does not consistently respect .prettierrc, .eslintrc nor ...
eslintrc file and even vscode settings with the same 80 print-width settings, but the extension just doesn't respect it. It does try to...
Read more >visual studio code - prettier settings for vscode - Stack Overflow
For those trying to quickly change Prettier settings for VS Code. Here are the steps: Go to FILE -> PREFERENCES -> SETTINGS.
Read more >How to use Prettier with ESLint - Robin Wieruch
How to combine Prettier and ESLint for VSCode, Sublime, ... The Prettier configuration file itself and the "format on save"-feature should ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Especially since the plugin seems to be already ignoring
parser
anduseTabs
settings from config files:Maybe it’s still a bug?
I think using detected Sublime Text indentation for
tabWidth
unlessdisable_tab_width_auto_detection
is set totrue
is the most logical behaviour.This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.