Install through VS Code extensions. Search for
Visual Studio Code Market Place: Sort JS Objects
Can also be installed in VS Code: Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Highlight a valid block of JS/TS code and open the command palette using
All of ES6, Typescript and legacy decorators should be support. Pull requests are welcome!
How does it work?
sort-js-object finds the highlighted text in the current editor, then using this text builds a AST using @babel/parser, then reorder node arrays on tree using @babel/traverse.