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.

formatOnSave not using `.jsbeautifyrc`

See original GitHub issue

Operating System (+Version): Mac 10.11.6 VS Code Version: 1.11.2 beautify Version: 1.0.2

Issue: I would like to use vscode’s built in formatOnSave hook to trigger the beautify extension’s reformatting of .js, .css, and .html files. While running beautify from the command palette works fine, formatOnSave falls back to vscode formatting config and not my .jsbeautifyrc.

VSCode:

{
    "editor.formatOnSave": true
    , "beautify.config": "~/.jsbeautifyrc"
}

I’ve also tried using an absolute path for beautify.confg.

~/.jsbeautifyrc

{
    "end_with_newline": true
    , "indent_char": " "
    , "indent_size": 4
    , "indent_with_tabs": false
    , "max_preserve_newlines": 2
    , "wrap_line_length": 120
    , "indent_body_inner_html": false
    , "indent_scripts": "normal"
    , "wrap_attributes": "force-aligned"
    , "newline_between_rules": false
    , "break_chained_methods": false
    , "comma_first": true
    , "keep_array_indentation": false
    , "keep_function_indentation": false
    , "operator_position": "after-newline"
    , "space_before_conditional": true
    , "space_in_paren": true
    , "space_in_empty_paren": false
}

Action performed

Save file

Expected results

Expect the above formatting config to be respected.

Actual results

Plain vscode formatting applied. Obvious differences from config include chained method call line breaks, no spaces in function parens

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
HookyQRcommented, Apr 26, 2017

Hey @alexsasharegan and @wbuck, I’ve been away for a while. Taking a look now. Seems like it’s a VS Code issue. There’s no difference in the extension code on how it handles regular formatting and format on save. I may have missed an API change, or they could have broken the formatter lookup order.

Hold tight. I’m on it.

0reactions
wbuckcommented, Apr 29, 2017

Thanks for looking in to it. I had a feeling it was a VS Code issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

VS Code reverting js-beautify code formatting on save
I submitted an issue on the github repo. You can follow it at formatOnSave not using .jsbeautifyrc #133 Maybe post your settings for...
Read more >
Prettier + Format On Save = Never worry about ... - Scott Sauber
In my last post, I mentioned a tip to using the Format on Save option in VS ... I love about it is...
Read more >
Beautify - Visual Studio Marketplace
For help on the settings in the .jsbeautifyrc see Settings.md ... When not using a multi-root workspace: ... formatOnSave" is true.
Read more >
Formatting In Visual Studio Code: EditorConfig And js-beautify
I dont want to write my own formatter, so I use js-beautify for this. ... If there is a valid .jsbeautifyrc in the...
Read more >
HTML-CSS-JS Prettify - Package Control
This will work with either HTML, CSS, JavaScript, JSON, React and Vue files. ... To stop using the formatting style defined in the...
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