yasuyk / web-beautify

Format HTML, CSS and JavaScript/JSON by js-beautify
GNU General Public License v3.0
219 stars 21 forks source link

Typical format for .jsbeautifyrc is ignored. #24

Open ghost opened 7 years ago

ghost commented 7 years ago

Hi, so I was using web-beautify without a .jsbeautifyrc file until recently, when I needed to change the indent_size for scss files to be 2. That's when I realized the typical .jsbeautifyrc format is ignored. When I use the below:

{ "indent_size": 2, "indent_char": " ", "eol": "\n", "indent_level": 0, "indent_with_tabs": false, "preserve_newlines": true, "max_preserve_newlines": 10, "jslint_happy": false, "space_after_anon_function": false, "brace_style": "collapse", "keep_array_indentation": false, "keep_function_indentation": false, "space_before_conditional": true, "break_chained_methods": false, "eval_code": false, "unescape_strings": false, "wrap_line_length": 0, "wrap_attributes": "auto", "wrap_attributes_indent_size": 4, "end_with_newline": false }

, web-beautify works great and indents my js file as per expected. But once I added the css and html objects (the typical way it is with other editors) like the below:

{ "html": { //rules here }, "css": { // rules here }, "js": { // rules here } }

, web-beautify stops working, and it doesn't even read the original js segment. It's only until I took out the js segment and put it on its own like in my first example does web-beautify work again.

Can somebody please enlighten me as to how exactly I should be formatting my .jsbeautifyrc so that web-beautify understands the options for HTML CSS and JS? Thanks.

yasuyk commented 7 years ago

@Uebyn Sorry for the late reply. If you still interested in this issue, let me know following the information.

ghost commented 7 years ago

Hi, thanks for your reply. Here you go:

/usr/local/bin/css-beautify -> /usr/local/lib/node_modules/js-beautify/js/bin/css-beautify.js /usr/local/bin/html-beautify -> /usr/local/lib/node_modules/js-beautify/js/bin/html-beautify.js /usr/local/bin/js-beautify -> /usr/local/lib/node_modules/js-beautify/js/bin/js-beautify.js js-beautify@1.6.4 /usr/local/lib/node_modules/js-beautify ├── nopt@3.0.6 (abbrev@1.0.9) ├── config-chain@1.1.11 (ini@1.3.4, proto-list@1.2.4) ├── mkdirp@0.5.1 (minimist@0.0.8) └── editorconfig@0.13.2 (sigmund@1.0.1, commander@2.9.0, lru-cache@3.2.0, bluebird@3.4.6)

yasuyk commented 7 years ago

@Uebyn Thank you for the reply.

web-beautify use command line interface of js-beautify. It seems that something wrong with the command line interface of js-beautify from version 1.5.5. Could you try js-beautify 1.5.4?

FYI, see #23

neocryses commented 7 years ago

@yasuyk Hi,

I've been getting the same issue and trying with js-beautify 1.5.4 didn't solve it.

Here's my information:

ghost commented 7 years ago

Same here - 1.5.4 didn't solve it. On 1.5.4, once I change the format to this:

{ "js": { "indent_size": 2, "indent_char": " ", "eol": "\n", "indent_level": 0, "indent_with_tabs": false, "preserve_newlines": true, "max_preserve_newlines": 10, "jslint_happy": false, "space_after_anon_function": true, "brace_style": "collapse", "keep_array_indentation": false, "keep_function_indentation": false, "space_before_conditional": true, "break_chained_methods": false, "eval_code": false, "unescape_strings": false, "wrap_line_length": 0, "wrap_attributes": "auto", "wrap_attributes_indent_size": 4, "end_with_newline": true, "selector_separator_newline": true, "newline_between_rules": true } }

, js-beautify ignores my indent_size and defaults the indentation to 4 spaces instead.