@JumJum Sorry for the delay and thanks very much for your code. This is exactly the kind of starting point I needed.
Prettier doesn't need an internet connection, either. Here is what I did based on your initial example using prettier: https://github.com/neshanjo/EspruinoWebIDE/tree/code-formatting-prettier
Anybody here interested in this, can just checkout my fork and run npm install followed by npm start.
My code also respects the indentation settings (tab width and tabs versus spaces).
Indeed, there is still some work to do:
Save the current cursor position
Hide the icon in Blockly mode
Add a keyboard shortcut
Maybe another icon.
I don't think, we need a settings page, though. I even think we should not have one in order to follow one code style. That's the idea behind prettier.
IMO, the main (only?) advantage of js-beautify over prettier is the smaller size. Prettier is more or less THE standard in modern JS development and available in many code editors and even from the command line. This is a nice feature, especially for BangleJS where every app uses its own code formatting style. Furthermore, it is actively developed by a large team, while js-beautify claims on their Github page that they are in need of more contributors.
Just my 2ct. I'd be very happy to have any kind of code formatting soon.
My next steps are to work on point 1 (see list above) and submit a MR. 2+3 should be done very easily by someone more familiar with the project.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
@JumJum Sorry for the delay and thanks very much for your code. This is exactly the kind of starting point I needed.
Prettier doesn't need an internet connection, either. Here is what I did based on your initial example using prettier: https://github.com/neshanjo/EspruinoWebIDE/tree/code-formatting-prettier
Anybody here interested in this, can just checkout my fork and run
npm install
followed bynpm start
.My code also respects the indentation settings (tab width and tabs versus spaces).
Indeed, there is still some work to do:
I don't think, we need a settings page, though. I even think we should not have one in order to follow one code style. That's the idea behind prettier.
I also made another branch using js-beautify: https://github.com/neshanjo/EspruinoWebIDE/tree/code-formatting-js-beautify
IMO, the main (only?) advantage of js-beautify over prettier is the smaller size. Prettier is more or less THE standard in modern JS development and available in many code editors and even from the command line. This is a nice feature, especially for BangleJS where every app uses its own code formatting style. Furthermore, it is actively developed by a large team, while js-beautify claims on their Github page that they are in need of more contributors.
Just my 2ct. I'd be very happy to have any kind of code formatting soon.
My next steps are to work on point 1 (see list above) and submit a MR. 2+3 should be done very easily by someone more familiar with the project.