. After installingBabel, a new problem arose. The formatting plug-in hung. . . .I tried two or three plug-ins (jsfmtetc.), but they were not ideal.
esformatter-jsx can be used, but the indentation of JSX
and the weird indentation of statements such as switch are terrible. Finally, when I was about to change IDE, I saw that one of the configuration items of the VSCode formatting plug-in is esformatter-jsx, and you can also choose prettier
. prettier official website (Science Internet): https://prettier.io/docs/en/install.html You can see that Facebook is using it to optimize the code of the React
The downloaded package contains
Executenpm i -g prettier
bin-prettier.js, which is the ontology.
sublime text3 Directly search prettier in
to download, open its User configuration item, add it as follows and save it. Pay attention to modify your local node and
paths<pre class="brush:php;toolbar:false">{ "debug": false, "prettier_cli_path": "/usr/local/lib/node_modules/prettier/bin-prettier.js", "node_path": "/usr/local/bin/node", "auto_format_on_save": false, "auto_format_on_save_excludes": [], "allow_inline_formatting": false, "custom_file_extensions": [], "max_file_size_limit": -1, "additional_cli_args": {}, "prettier_options": { "printWidth": 80, "singleQuote": false, "trailingComma": "none", "bracketSpacing": true, "jsxBracketSameLine": false, "parser": "babylon", "semi": true, "requirePragma": false, "proseWrap": "preserve", "arrowParens": "avoid" } }</pre>Add<pre class="brush:php;toolbar:false">{ "keys": ["super+shift+c"], "command": "format_javascript" }</pre>to the shortcut key configuration. For details, go to Check the plug-in author's Readme on github
The functions of the plug-in are not all functions. You can use instructions on the command line to format the code (can it also be quoted directly in the project?)




























