LuteOrg / lute-v3

LUTE = Learning Using Texts: learn languages through reading. Python/Flask.
MIT License
422 stars 46 forks source link

Add "prettier" code reformatting for HTML and JS #100

Open jzohrab opened 9 months ago

jzohrab commented 9 months ago

Currently the code uses "black" for python reformatting. Sometimes it's a hassle, but overall I think it's good as it takes the guesswork out of code formatting, which can only be good for an open-source project.

This issue should just be about adding prettify (or a similar tool), and checking a few things:

I use emacs, others use different editors, so suggestions for the wiki docs (in this repo's wiki) would be good

After this is done, I think it's best to run all the code through the prettify method, just to get it done in one big bang.

fanyingfx commented 9 months ago

I found the Djlint can lint/check/reformat the jinja2 template file

For the js file, using something like the prettier?

jzohrab commented 9 months ago

I don't know what the standard is, or if there is one. I don't have a particular preference, just need something that works and takes out the guesswork.

robby1066 commented 9 months ago

The question I have about prettier (still wrapping my head around it) is will it require node/npm to be properly setup on the developer's machine? Seems reasonable that a lot of people already have that, but I wonder about the overhead that potentially introduces?

Djlint seems like it would be relatively straightforward to add as a pre-commit check.

Currently everything that happens server side is pure python, right?

jzohrab commented 9 months ago

Djlint seems like it would be relatively straightforward to add as a pre-commit check.

Right, npm etc that might be overhead for some. djlint might be the fastest way to get something together, and if it doesn't work out in the long run, at least it's a step in the right direction.

Currently everything that happens server side is pure python, right?

Yes, so any devs will have python installed to work on it. This check would be happening during dev/commit and in CI. And if it's in the requirements.txt, then it will be loaded and ready to go.

webofpies commented 9 months ago

I use Prettier with VSCode, no need for node/npm. It also supports most editors Can also be added as pre-commit hook