How to execute automatic javascript project with full indentation?

I want auto-indentation to be a complete javascript project. How can I do this using WebStorm or another tool?

+4
source share
3 answers
  • Select the project root folder / source root folder in the Project tool window on the left.
  • From the main menu, select "Code" | Reformat Code (or click Ctrl+Alt+L)
+3
source

This project , called js-beautify, can help you. It exists as an npm or python package.

Then you can use find to iterate over all js files in your directory:

find . -name '*.js' -exec js-beautify -r {} \;

: js . svn/ git, .

0

Create a file in the project root: .editorconfig with the contents

# http://editorconfig.org
root = true
[*]
charset = utf-8
indent_style = space
indent_size = 2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

Adjust ident_size for yourself.

Restart WebStorm, accept that WebStrom must use the editor configuration file.

Press: ctrl + alt + L

Or: Code> Conversion Code

0
source

Source: https://habr.com/ru/post/1660700/


All Articles