34
35
Fork
You've already forked website
45

Adjust formatter configuration/tool #104

Open
opened 2023年02月17日 23:24:06 +01:00 by oliverpool · 2 comments

A prettier config with pre-commit hook has been added in #80, with the default configuration.

Some concerns regarding the formatting were raised in the following PRs: #98 #102.

  • Sometimes classnames are on one line, sometimes one class per line
  • Standalone tags get a trailing slash added
  • Some tags get split with identation <a[NEWLINE+INDENT]>some text</a[NEWLINE+INDENT]>

Since the introduction of the pre-commit hooks was positively received, I think that it is fair to state that having a preferred way to format the code is a nice thing to have.

However how this code should be formatted wasn't discussed at all.

The goal of this issue is to find a consensus regarding the formatting tool.

I see two possibilities:


Since I am personally happy with any configuration (as long as there is one :), my only must-haves for this consensus are:

  • it should be able to format the most filetypes present in this repo (.ts, .js. .astro, .md)
  • work as a pre-commit hook (probably possible for any tool)

@fsologureng @crystal @Ryuno-Ki since you raised concerns, what are your have "must-haves" or wishes regarding this issue? (btw, thank you for raising those concerns. If at least 3 people have spoken up about this issue it means that it is worth speaking about!)

A prettier config with pre-commit hook has been added in #80, with the default configuration. Some concerns regarding the formatting were raised in the following PRs: #98 #102. - Sometimes classnames are on one line, sometimes one class per line - Standalone tags get a trailing slash added - Some tags get split with identation `<a[NEWLINE+INDENT]>some text</a[NEWLINE+INDENT]>` Since the introduction of the pre-commit hooks was positively received, I think that it is fair to state that having a preferred way to format the code is a nice thing to have. However how this code should be formatted wasn't discussed at all. The goal of this issue is to find a consensus regarding the formatting tool. I see two possibilities: - tweak the config of prettier (within its limitation, for instance https://github.com/prettier/prettier/issues/5246) - or switch to another tool --- Since I am personally happy with any configuration (as long as there is one :), my only must-haves for this consensus are: - it should be able to format the most filetypes present in this repo (.ts, .js. .astro, .md) - work as a pre-commit hook (probably possible for any tool) @fsologureng @crystal @Ryuno-Ki since you raised concerns, what are your have "must-haves" or wishes regarding this issue? (btw, thank you for raising those concerns. If at least 3 people have spoken up about this issue it means that it is worth speaking about!)
oliverpool changed title from (削除) Change (削除ここまで) to Adjust formatter configuration/tool 2023年02月17日 23:30:20 +01:00
Contributor
Copy link

Thank you @oliverpool for opening this issue.

Sometimes classnames are on one line, sometimes one class per line

I think, this is an attempt to keep the maximum character length below a certain treshold to avoid horizontal scrolling.

Standalone tags get a trailing slash added

I'm a fan of this (because I learned HTML when XHTML was still a popular choice).

Some tags get split with identation <a[NEWLINE+INDENT]>some text</a[NEWLINE+INDENT]>

I've seen some projects using a variant of this (mainly Angular) to allow for easier scanning of attributes. That being said, I have a different personal opinion on this. I'm willing to accept what the majority is willing to choose.

When it comes to configuring Prettier, https://prettier.io/docs/en/options.html should be kept in mind (as in: there are limits on what we can tweak).

Thank you @oliverpool for opening this issue. > Sometimes classnames are on one line, sometimes one class per line I think, this is an attempt to keep the maximum character length below a certain treshold to avoid horizontal scrolling. > Standalone tags get a trailing slash added I'm a fan of this (because I learned HTML when XHTML was still a popular choice). > Some tags get split with identation <a[NEWLINE+INDENT]>some text</a[NEWLINE+INDENT]> I've seen some projects using a variant of this (mainly Angular) to allow for easier scanning of attributes. That being said, I have a different personal opinion on this. I'm willing to accept what the majority is willing to choose. When it comes to configuring Prettier, https://prettier.io/docs/en/options.html should be kept in mind (as in: there are limits on what we can tweak).

Hi, thanks for this @oliverpool.

I'm against the added trailing slash because even though I'm a fan of XHTML, that feature is out of spec for plain HTML, which leads to false positives in the validator (at least the W3C one).

I would like to see prose wrap changed to preserve; I think we are all comfortable with the wrap done by our preferred editor. Furthermore, any edition which extends a line of a long paragraph further the wrapping limit should trig a wrap of all the subsequent non-changed lines, which is an undesirable change.

Regarding single attribute per line, I think it is a good measure to track narrow changes to certain attributes.

Hi, thanks for this @oliverpool. I'm against the added trailing slash because even though I'm a fan of XHTML, that feature is out of spec for plain HTML, which leads to false positives in the validator (at least the W3C one). I would like to see [prose wrap](https://prettier.io/docs/en/options.html#prose-wrap) changed to `preserve`; I think we are all comfortable with the wrap done by our preferred editor. Furthermore, any edition which extends a line of a long paragraph further the wrapping limit should trig a wrap of all the subsequent non-changed lines, which is an undesirable change. Regarding [single attribute per line](https://prettier.io/docs/en/options.html#single-attribute-per-line), I think it is a good measure to track narrow changes to certain attributes.
Sign in to join this conversation.
No Branch/Tag specified
main
preview-link-status
nightfire
2022年12月14日-main
No results found.
Labels
Clear labels
404

Broken links or missing content
Accessibility

Accessibility
Blog post
Documentation

Forgejo Documentation
Internationalisation

i18n and l10n
User research - Accessibility

Requires input about accessibility features, likely involves user testing.
User research - Blocked

Do not pick as-is! We are happy if you can help, but please coordinate with ongoing redesign in this area.
User research - Community

Community features, such as discovering other people's work or otherwise feeling welcome on a Forgejo instance.
User research - Config (instance)

Instance-wide configuration, authentication and other admin-only needs.
User research - Errors

How to deal with errors in the application and write helpful error messages.
User research - Filters

How filter and search is being worked with.
User research - Future backlog

The issue might be inspiring for future design work.
User research - Git workflow

AGit, fork-based and new Git workflow, PR creation etc
User research - Labels

Active research about Labels
User research - Moderation

Moderation Featuers for Admins are undergoing active User Research
User research - Needs input

Use this label to let the User Research team know their input is requested.
User research - Notifications/Dashboard

Research on how users should know what to do next.
User research - Rendering

Text rendering, markup languages etc
User research - Repo creation

Active research about the New Repo dialog.
User research - Repo units

The repo sections, disabling them and the "Add more" button.
User research - Security
User research - Settings (in-app)

How to structure in-app settings in the future?
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
forgejo/website#104
Reference in a new issue
forgejo/website
No description provided.
Delete branch "%!s()"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?