Using Prettier in Gitea #12349

Closed
opened 2025-11-02 10:06:31 -06:00 by GiteaMirror · 22 comments
Owner

Originally created by @leon-win on GitHub (Jan 18, 2024).

Feature Description

Hello everyone!

I recently started working with the Gitea (mostly frontend).

And almost immediately I had a question -- why doesn’t it use Prettier?
I couldn't find the answer by searching in PRs and Issues))

Are there any fundamental reasons? Or just not have enough time to implement it?

Originally created by @leon-win on GitHub (Jan 18, 2024). ### Feature Description Hello everyone! I recently started working with the Gitea (mostly frontend). And almost immediately I had a question -- why doesn’t it use [Prettier](https://prettier.io/)? I couldn't find the answer by searching in PRs and Issues)) Are there any fundamental reasons? Or just not have enough time to implement it?
GiteaMirror added the proposal/rejectedtype/proposal labels 2025-11-02 10:06:31 -06:00
Author
Owner

@lunny commented on GitHub (Jan 19, 2024):

Which place do you think Gitea need that?

@lunny commented on GitHub (Jan 19, 2024): Which place do you think Gitea need that?
Author
Owner

@yardenshoham commented on GitHub (Jan 19, 2024):

We format with make fmt, is there a problem with the command?

@yardenshoham commented on GitHub (Jan 19, 2024): We format with `make fmt`, is there a problem with the command?
Author
Owner

@leon-win commented on GitHub (Jan 19, 2024):

@lunny, @yardenshoham, thank you for replies!

Which place do you think Gitea need that?

Prettier will work great for files inside web_src/ (*.css, *.js, *.json, *.vue).

We format with make fmt, is there a problem with the command?

As far as I understand, this command only formats *.tmpl files. But the project does not yet have a tool for automatically formatting static files.

The advantages of using an automatic formatter are described, for example, here, but in a nutshell it's: consistent code style and format, saving time and reducing the chances of human error.

Prettier is one of the best solutions for this, details can be found here.

If no one has any fundamental objections, then I can make a PR with the applying of the Prettier to Gitea.
However, we must be prepared for the fact that there will be a lot of changes (the initial formatting will affect almost all CSS, JavaScript and Vue files =)

@leon-win commented on GitHub (Jan 19, 2024): @lunny, @yardenshoham, thank you for replies! > Which place do you think Gitea need that? Prettier will work great for files inside `web_src/` (`*.css`, `*.js`, `*.json`, `*.vue`). > We format with make fmt, is there a problem with the command? As far as I understand, this command only formats `*.tmpl` files. But the project does not yet have a tool for automatically formatting static files. The advantages of using an automatic formatter are described, for example, [here](https://medium.com/@ryconoclast/why-you-should-use-a-code-formatter-4f02dd40db14), but in a nutshell it's: consistent code style and format, saving time and reducing the chances of human error. Prettier is one of the best solutions for this, details can be found [here](https://prettier.io/docs/en/why-prettier.html). If no one has any fundamental objections, then I can make a PR with the applying of the Prettier to Gitea. However, we must be prepared for the fact that there will be a lot of changes (the initial formatting will affect almost all CSS, JavaScript and Vue files =)
Author
Owner

@yardenshoham commented on GitHub (Jan 19, 2024):

We have eslint and I think it provides the same functionality? I just tried adding a space to an import and ran make lint and it printed an error
image

I then ran npx eslint --color --max-warnings=0 --ext js,vue web_src/js build *.config.js tests/e2e --fix and it reverted my change

cc @silverwind

@yardenshoham commented on GitHub (Jan 19, 2024): We have eslint and I think it provides the same functionality? I just tried adding a space to an import and ran `make lint` and it printed an error ![image](https://github.com/go-gitea/gitea/assets/20454870/1809e74d-e9af-484f-a064-073e7fe4e5ff) I then ran `npx eslint --color --max-warnings=0 --ext js,vue web_src/js build *.config.js tests/e2e --fix` and it reverted my change cc @silverwind
Author
Owner

@6543 commented on GitHub (Jan 19, 2024):

i'm for adding it, it is more strict as eslint

eslint focus on linting while prettier on formating.
so i'm for a tandem

@6543 commented on GitHub (Jan 19, 2024): i'm for adding it, it is more strict as eslint eslint focus on linting while prettier on formating. so i'm for a tandem
Author
Owner

@6543 commented on GitHub (Jan 19, 2024):

let me just make an experimet by adding a pipeline for linting it :)

@6543 commented on GitHub (Jan 19, 2024): let me just make an experimet by adding a pipeline for linting it :)
Author
Owner

@leon-win commented on GitHub (Jan 19, 2024):

We have eslint and I think it provides the same functionality?

ESLint is also good tool 👍
However, with its help you can solve only a part of the problems, mainly related to syntax checking and errors. While Prettier helps to format the display of code in a single style, that is, it complements ESLint.

There is comparison of Linters vs. Prettier

To make it more clear:

CSS
image

JavaScript
image

Vue.js
Screenshot from 2024-01-20 02-00-38

@leon-win commented on GitHub (Jan 19, 2024): > We have eslint and I think it provides the same functionality? ESLint is also good tool :+1: However, with its help you can solve only a part of the problems, mainly related to syntax checking and errors. While Prettier helps to format the display of code in a single style, that is, it complements ESLint. There is [comparison of Linters vs. Prettier](https://prettier.io/docs/en/comparison) To make it more clear: CSS ![image](https://github.com/go-gitea/gitea/assets/1682136/4865d36a-eca8-4613-9ffb-9dbedbe14739) JavaScript ![image](https://github.com/go-gitea/gitea/assets/1682136/1a634910-f2ba-437f-9596-adbe9d8be9a3) Vue.js ![Screenshot from 2024-01-20 02-00-38](https://github.com/go-gitea/gitea/assets/1682136/4b6ae605-8692-44d8-a113-9cbe121d0546)
Author
Owner

@lunny commented on GitHub (Jan 21, 2024):

How about biome?

@lunny commented on GitHub (Jan 21, 2024): How about biome?
Author
Owner

@denyskon commented on GitHub (Jan 21, 2024):

@lunny I suggested it and then deleted the comment immediately - I noticed biome doesn't support CSS currently, and I'm unsure about Vue.

@denyskon commented on GitHub (Jan 21, 2024): @lunny I suggested it and then deleted the comment immediately - I noticed biome doesn't support CSS currently, and I'm unsure about Vue.
Author
Owner

@wxiaoguang commented on GitHub (Jan 21, 2024):

I don't like prettier because it isn't smart enough.

For example, some code could only need one line, but prettier insist to use multiple lines, using prettier aggressively reduces readability IMO.


Indeed there are a lot of options for prettier, maybe some behaviors could be fine-tuned, but I just feel satisfied about current code style, so personally I have no motivation to introduce prettier or re-format all the frontend code (that's just my opinion, no block if major maintainers would like to re-format).

@wxiaoguang commented on GitHub (Jan 21, 2024): I don't like prettier because it isn't smart enough. For example, some code could only need one line, but prettier insist to use multiple lines, using prettier aggressively reduces readability IMO. ---- Indeed there are a lot of options for prettier, maybe some behaviors could be fine-tuned, but I just feel satisfied about current code style, so personally I have no motivation to introduce prettier or re-format all the frontend code (that's just my opinion, no block if major maintainers would like to re-format).
Author
Owner

@denyskon commented on GitHub (Jan 21, 2024):

I also agree that using prettier could break a lot. For example many of our helper classes are written as one-liners by design, and reformatting them to become 3+ lines will decrease readability and make files way longer. I'm satisfied with current formatting, and ESLint does a good job when enforcing important rules

@denyskon commented on GitHub (Jan 21, 2024): I also agree that using prettier could break a lot. For example many of our helper classes are written as one-liners by design, and reformatting them to become 3+ lines will decrease readability and make files way longer. I'm satisfied with current formatting, and ESLint does a good job when enforcing important rules
Author
Owner

@6543 commented on GitHub (Jan 21, 2024):

Well if we add it, i would say we can just tweek prettier to not do what we dislime and config it so it matches mostly what we alread use, so the diff should then be not huGe

@6543 commented on GitHub (Jan 21, 2024): Well if we add it, i would say we can just tweek prettier to not do what we dislime and config it so it matches mostly what we alread use, so the diff should then be not huGe
Author
Owner

@lunny commented on GitHub (Jan 22, 2024):

OK. I think we can close this one currently if there is no further arguments in 1 month.

@lunny commented on GitHub (Jan 22, 2024): OK. I think we can close this one currently if there is no further arguments in 1 month.
Author
Owner

@harryzcy commented on GitHub (Jan 23, 2024):

we can configure prettier to run against changed files, so existing files won't need any edits

@harryzcy commented on GitHub (Jan 23, 2024): we can configure prettier to run against changed files, so existing files won't need any edits
Author
Owner

@leon-win commented on GitHub (Jan 23, 2024):

OK. I think we can close this one currently if there is no further arguments in 1 month.

I will try to answer all questions and give arguments along the way 👌

I don't like prettier because it isn't smart enough.

For example, some code could only need one line, but prettier insist to use multiple lines, using prettier aggressively reduces readability IMO.

"IMO" is the key point in this case) I mean is that all developers may have their own subjective view of the correct (or best) formatting. And against this background, disputes often arise, which can take up time. The purpose of the formatter is to make the code style uniform. It doesn’t matter in what style, but what matters is that it’s consistent.

That is, Prettier is smart enough, but it has a different goal -- to make all the code in the same style. In order not to deal with questions of a subjective nature.

Indeed there are a lot of options for prettier, maybe some behaviors could be fine-tuned, but I just feel satisfied about current code style, so personally I have no motivation to introduce prettier or re-format all the frontend code (that's just my opinion, no block if major maintainers would like to re-format).

Unfortunately (or fortunately 🙂) on the contrary, it has very few settings. And this is not a drawback, but the essence of the approach.

I encourage everyone to read the description of Prettier Option Philosophy to understand the advantages of this approach.

I also agree that using prettier could break a lot. For example many of our helper classes are written as one-liners by design, and reformatting them to become 3+ lines will decrease readability and make files way longer. I'm satisfied with current formatting, and ESLint does a good job when enforcing important rules

"one-liners by design" sounds strange, as if the purpose of the code is not to perform some business function, but simply to look the right way. But that's not true, is it?)

About decreasing readability -- it is also very subjective. Yes, it will take some getting used to the new formatting. But this only needs to be done once. And it takes only several days.

But after this, work productivity increases! 🚀)) Because when opening any file in a project, the brain will not waste time adjusting to custom formatting. Moreover, not only in Gitea but in any project that uses the same formatting! This is why Prettier has almost no settings -- so that in any project, the formatting is the same and it is much easier for the developer to switch.

As for increasing the file size (number of lines), I think this is not a matter of formatting, but of architecture. If the file becomes too large, it needs to be decomposed. Trying to reduce the number of lines by formatting is masking the problem, not the solution.

ESLint is a very good tool, but it performs other tasks, I already wrote about this above. ESLint and Prettier complement each other.

Well if we add it, i would say we can just tweek prettier to not do what we dislime and config it so it matches mostly what we alread use, so the diff should then be not huGe

I think it's better to be ready for a large number of changed files right away)) because, as I noted above, Prettier is opinionated code formatter, that is, it implies an minimal configuration (and this is not a bug, but a feature of the approach). But it is possible to ignore code that does not need to be formatted, so we can apply it gradually, in parts (if for some reason it seems better).

we can configure prettier to run against changed files, so existing files won't need any edits

You can do it like this. But this greatly reduces the benefit of its implementation in my opinion)

Why do one-time big changes cause such fears?

If there are concerns that the code will become inoperative, then this is impossible.

I see only one potential problem: if at the time of merging PR with Prettier there are unmerged changes regarding static files (*.css, *.js, *.json, *.vue), then it will be necessary to merge the main branch to them and perform formatting. But I think it's not that difficult to do. Ready to help resolve conflicts if they arise =)

@leon-win commented on GitHub (Jan 23, 2024): > OK. I think we can close this one currently if there is no further arguments in 1 month. I will try to answer all questions and give arguments along the way :ok_hand: > I don't like prettier because it isn't smart enough. > > For example, some code could only need one line, but prettier insist to use multiple lines, using prettier aggressively reduces readability IMO. "IMO" is the key point in this case) I mean is that all developers may have their own subjective view of the correct (or best) formatting. And against this background, disputes often arise, which can take up time. The purpose of the formatter is to make the code style uniform. It doesn’t matter in **what** style, but what matters is that it’s **consistent**. That is, Prettier is smart enough, but it has a different goal -- to make all the code in the same style. In order not to deal with questions of a subjective nature. > Indeed there are a lot of options for prettier, maybe some behaviors could be fine-tuned, but I just feel satisfied about current code style, so personally I have no motivation to introduce prettier or re-format all the frontend code (that's just my opinion, no block if major maintainers would like to re-format). Unfortunately (or fortunately :slightly_smiling_face:) on the contrary, it has very few settings. And this is not a drawback, but the essence of the approach. I encourage everyone to read the description of [Prettier Option Philosophy](https://prettier.io/docs/en/option-philosophy.html) to understand the advantages of this approach. > I also agree that using prettier could break a lot. For example many of our helper classes are written as one-liners by design, and reformatting them to become 3+ lines will decrease readability and make files way longer. I'm satisfied with current formatting, and ESLint does a good job when enforcing important rules "one-liners by design" sounds strange, as if the purpose of the code is not to perform some business function, but simply to look the right way. But that's not true, is it?) About decreasing readability -- it is also very subjective. Yes, it will take some getting used to the new formatting. But this only needs to be done once. And it takes only several days. But after this, work productivity increases! :rocket:)) Because when opening any file in a project, the brain will not waste time adjusting to custom formatting. Moreover, not only in Gitea but in any [project that uses the same formatting](https://prettier.io/en/users/)! This is why Prettier has almost no settings -- so that in any project, the formatting is the same and it is much easier for the developer to switch. As for increasing the file size (number of lines), I think this is not a matter of formatting, but of architecture. If the file becomes too large, it needs to be decomposed. Trying to reduce the number of lines by formatting is masking the problem, not the solution. ESLint is a very good tool, but it performs other tasks, I already wrote about this above. ESLint and Prettier complement each other. > Well if we add it, i would say we can just tweek prettier to not do what we dislime and config it so it matches mostly what we alread use, so the diff should then be not huGe I think it's better to be ready for a large number of changed files right away)) because, as I noted above, [Prettier is opinionated code formatter](https://prettier.io/docs/en/), that is, it implies an minimal configuration (and this is not a bug, but a feature of the approach). But it is possible to [ignore code that does not need to be formatted](https://prettier.io/docs/en/ignore), so we can apply it gradually, in parts (if for some reason it seems better). > we can configure prettier to run against changed files, so existing files won't need any edits You can do it like this. But this greatly reduces the benefit of its implementation in my opinion) Why do one-time big changes cause such fears? If there are concerns that the code will become inoperative, [then this is impossible](https://prettier.io/docs/en/rationale#what-prettier-is-_not_-concerned-about). I see only one potential problem: if at the time of merging PR with Prettier there are unmerged changes regarding static files (`*.css`, `*.js`, `*.json`, `*.vue`), then it will be necessary to merge the main branch to them and perform formatting. But I think it's not that difficult to do. Ready to help resolve conflicts if they arise =)
Author
Owner

@lafriks commented on GitHub (Jan 24, 2024):

Imho prettier should be integrated as eslint plugin so linting can be done in single step not by running multiple tools

@lafriks commented on GitHub (Jan 24, 2024): Imho prettier should be integrated as eslint plugin so linting can be done in single step not by running multiple tools
Author
Owner

@leon-win commented on GitHub (Jan 25, 2024):

Imho prettier should be integrated as eslint plugin so linting can be done in single step not by running multiple tools

Technically this is possible, but this approach has more disadvantages.

What's wrong with using a special tool for each task?

For JavaScript linting -- JSLint,
For CSS linting -- Stylelint,
To format both (and more) -- Prettier.

This is the ideal way in my opinion.

@leon-win commented on GitHub (Jan 25, 2024): > Imho prettier should be integrated as eslint plugin so linting can be done in single step not by running multiple tools Technically this is possible, [but this approach has more disadvantages](https://prettier.io/docs/en/integrating-with-linters.html#notes). What's wrong with using a special tool for each task? For JavaScript linting -- JSLint, For CSS linting -- Stylelint, To format both (and more) -- Prettier. This is the ideal way in my opinion.
Author
Owner

@silverwind commented on GitHub (Feb 15, 2024):

I'm against prettier, especially for CSS. Often times formatting is used for good reason:

  • Visual grouping of simple selectors on one line:
.red { color: red }
.blue { color: blue }
  • Grouping of related selectors with no newline between:
.a {
 color: red;
}
.a .b {
  color: blue;
}

.b {
 color: red;
}
.b .b {
  color: blue;
}

Also in JS there are cases of compact single-line formats that prettier renders not too well, like this:

  expect(await pngChunks(await dataUriToBlob(pngNoPhys))).toEqual([
    {name: 'IHDR', data: new Uint8Array([0, 0, 0, 1, 0, 0, 0, 1, 8, 0, 0, 0, 0])},
    {name: 'IDAT', data: new Uint8Array([8, 29, 1, 2, 0, 253, 255, 0, 0, 0, 2, 0, 1])},
    {name: 'IEND', data: new Uint8Array([])},
  ]);

A automatic formatter can never be as good as humans. While I do understand the benefits of uniform formatting, I think we can catch such cases easily during review. Take this example which prettier blows up from 29 to 55 lines, almost doubling the line count for no good reason.

@silverwind commented on GitHub (Feb 15, 2024): I'm against prettier, especially for CSS. Often times formatting is used for good reason: - Visual grouping of simple selectors on one line: ````css .red { color: red } .blue { color: blue } ```` - Grouping of related selectors with no newline between: ````css .a { color: red; } .a .b { color: blue; } .b { color: red; } .b .b { color: blue; } ```` Also in JS there are cases of compact single-line formats that prettier renders not too well, like this: ````js expect(await pngChunks(await dataUriToBlob(pngNoPhys))).toEqual([ {name: 'IHDR', data: new Uint8Array([0, 0, 0, 1, 0, 0, 0, 1, 8, 0, 0, 0, 0])}, {name: 'IDAT', data: new Uint8Array([8, 29, 1, 2, 0, 253, 255, 0, 0, 0, 2, 0, 1])}, {name: 'IEND', data: new Uint8Array([])}, ]); ```` A automatic formatter can never be as good as humans. While I do understand the benefits of uniform formatting, I think we can catch such cases easily during review. Take [this example](https://prettier.io/playground/#N4Igxg9gdgLgprEAuEBLAtgBwgJxgAmEygHMBhACwFcoBrAZwBp9iSBJKAMwgF99OcEdPgDkAOgD0GAIYk4YgFb0RAbgA6UDZCj0CrAHIQAChQCe9fAF5RAE2kxpSGXImsVAI2n04ANgAsjKgAagBCAPIASgDuAAwA0gDiJBAAgmkp+gDKAKoUAKLZJOkpecUhZMVpPpyYMEHFACLZADZ5AIpBbWwAEm15FUYAzBKVRSEAXnBGEXFRZQBSEdkArHk4tPMkW5aWqlrQuiykJuZWtvaOznCupB5evgHB4dHxSanpWbkFRelsxWQVP5pBoATgAjPNMON-gANEJsADqMIAsmkQgBNZrpBHzNoAMXm2VQABU5uk8nlWh0umCAExhNr6ABaYBSbBI6LYITaKQAMgAOEgJAAeNnG42RMRSOz2UG0h1YeSwMFMZxEdgcTnQsmubk83n8jFlGi8pjl-BoYBgqGg+A10myOBJEBCzQg7gAFPaqE6AJSEDT4fA4OAwH1QfDSKLSVAED1RmMEEhuzzNYkUVD0MScUNgChei4+1C+31idwpj2+9RQHgaDTwXQekSsSg0Bg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BDBQ2Q1Dh6dwcO4LhOtkAcRAFQbwxJpDuGnhI-OcB0AsJsEvGwvJpCkBPHIPEuBtQnyTjvC+EAQA8B4EAA) which prettier blows up from 29 to 55 lines, almost doubling the line count for no good reason.
Author
Owner

@leon-win commented on GitHub (Feb 19, 2024):

@silverwind, hi!
All of the above examples show the subjective tastes of one particular developer. That is, for example, you like compact one-line fragments, someone else may not like them. In order not to waste time discussing the formatting used, drawing up guidelines and potential disputes, such a formatter is needed. Prettier always formats everything in the same style. This is its purpose, not a flaw or defect.

A automatic formatter can never be as good as humans. While I do understand the benefits of uniform formatting, I think we can catch such cases easily during review.

Discussing formatting in a code review is exactly what everyone tries to avoid))) This is a real anti-pattern. This takes time away from understanding the business essence and logic of changes. You can read more on the page Why Prettier?

Take this example which prettier blows up from 29 to 55 lines, almost doubling the line count for no good reason.

As for the example, for my taste it’s better with formatting (because I’m used to working with this formatting, and I perceive it well and quickly).

I would also add blank lines between expect in the source code and disable formatting for "data:image/png;base64" constants (they really look awkward after formatting). So, in my opinion, this is ideal:

image

What is the reason for the fear of increasing the number of lines? Gitea has files that are thousands of lines long! And of course this is a lot, but I think we all understand that we need to reduce their size not by formatting, but by decomposition? =)

@leon-win commented on GitHub (Feb 19, 2024): @silverwind, hi! All of the above examples show the subjective tastes of one particular developer. That is, for example, you like compact one-line fragments, someone else may not like them. In order not to waste time discussing the formatting used, drawing up guidelines and potential disputes, such a formatter is needed. Prettier always formats everything in the same style. This is its purpose, not a flaw or defect. > A automatic formatter can never be as good as humans. While I do understand the benefits of uniform formatting, I think we can catch such cases easily during review. Discussing formatting in a code review is exactly what everyone tries to avoid))) This is a real anti-pattern. This takes time away from understanding the business essence and logic of changes. You can read more on the page [Why Prettier?](https://prettier.io/docs/en/why-prettier) > Take [this example](https://prettier.io/playground/#N4Igxg9gdgLgprEAuEBLAtgBwgJxgAmEygHMBhACwFcoBrAZwBp9iSBJKAMwgF99OcEdPgDkAOgD0GAIYk4YgFb0RAbgA6UDZCj0Cr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zk4newXBI0ZBAo6utnHNuWMva5Hp4wTROPtFZMU8L1MwwZR2s9OiPI8uqO3RupBKrUj2OdjfMC4TxMRaLlNVRLNbfSAjAgBAtQ2joyCgNIQEQFERh2wg9DICAp7RuYpsgO4wFgLQoaZBJvLKXAyCcKe3hm770j+4HmCx8pJDIDAOBUHAZveOgqAp2nGcgAdTr3rAp7EnAOC3k6f3h5H+f0EnzRwG0VAQPANfNFHIBKMKmQN03Ldt0gEcd-nx6t1MgiYK7KBeAAtF+cA2Iv3upzGzRJ2QQjam7p7NN79ekI3KQwKnqDuFQ8BGOXIdfu3ncUDA6DNAiGYNgnYBwJkLuxqgABusamDdmAegrsza-3ThwJesBMhgCdLUFIUAbCZBVI3O++dMCCG8AiYCmA3YYL+uXX+YczbKW8HgIwwESDbyHrXM2CccBkLdp4dwcA950KdLABEgsKDIH5OBEAIZjyoBDBQ2Q1Dh6dwcO4LhOtkAcRAFQbwxJpDuGnhI-OcB0AsJsEvGwvJpCkBPHIPEuBtQnyTjvC+EAQA8B4EAA) which prettier blows up from 29 to 55 lines, almost doubling the line count for no good reason. As for the example, for my taste it’s better with formatting (because I’m used to working with this formatting, and I perceive it well and quickly). I would also add blank lines between `expect` in the source code and disable formatting for "data:image/png;base64" constants (they really look awkward after formatting). So, in my opinion, this is ideal: ![image](https://github.com/go-gitea/gitea/assets/1682136/5e347886-0c9d-46ca-80d9-d66f8013cee6) What is the reason for the fear of increasing the number of lines? Gitea has files that are thousands of lines long! And of course this is a lot, but I think we all understand that we need to reduce their size not by formatting, but by decomposition? =)
Author
Owner

@silverwind commented on GitHub (Feb 19, 2024):

In the JS example, I find our formatting easier to read because name and data are vertically aligned, but prettier broke the alignment with the last element where it thought to fit it on one line. Likely this can be tweaked with max line length option and I would recommend around 110 based on my current screen width of 112, thought others should chime in as well.

If you wanna try adding it, add separate make targets make fmt-js, make fmt-go (current fmt) and make fmt (combines both). Find the set of options that introduce the smallest diff. Only do JS, no CSS. Also need to disable/uninstall formatting-related eslint rules.

@silverwind commented on GitHub (Feb 19, 2024): In the JS example, I find our formatting easier to read because `name` and `data` are vertically aligned, but prettier broke the alignment with the last element where it thought to fit it on one line. Likely this can be tweaked with max line length option and I would recommend around 110 based on my current screen width of 112, thought others should chime in as well. If you wanna try adding it, add separate make targets `make fmt-js`, `make fmt-go` (current `fmt`) and `make fmt` (combines both). Find the set of options that introduce the smallest diff. Only do JS, no CSS. Also need to disable/uninstall formatting-related eslint rules.
Author
Owner

@6543 commented on GitHub (Feb 20, 2024):

TOC decided to not use it ...

... still thanks to all who participated and point out the different view points, use-cases, edge-cases, etc .. ❤️

@6543 commented on GitHub (Feb 20, 2024): # TOC decided to not use it ... ## ... still thanks to all who participated and point out the different view points, use-cases, edge-cases, etc .. :heart:
Author
Owner

@silverwind commented on GitHub (Feb 22, 2024):

Yeah I think we are better off without for now.

On Topic: Golang also has a formatter which we use, and it produces such great diffs like this because of its stupid alignment.

@silverwind commented on GitHub (Feb 22, 2024): Yeah I think we are better off without for now. On Topic: Golang also has a formatter which we use, and it produces [such great diffs like this](https://github.com/go-gitea/gitea/pull/29311/files#r1498673764) because of its stupid alignment.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#12349