Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add prettier config #1610

Open
uncenter opened this issue Sep 14, 2023 · 4 comments · May be fixed by #1651
Open

Add prettier config #1610

uncenter opened this issue Sep 14, 2023 · 4 comments · May be fixed by #1651

Comments

@uncenter
Copy link
Contributor

There is a package script for formatting with prettier and it's installed as a dev dependency but there isn't a configuration file.

"format": "prettier --write '**/*.{js,css,html,md}'"

I can suggest my own configuration but I think it would be best for Zach to suggest one - they should be comfortable with whatever we choose!

@uncenter
Copy link
Contributor Author

Related to 11ty/eleventy-plugin-rss#42. Maybe we can adopt a consistent prettier configuration across the 11ty repos?

@uncenter
Copy link
Contributor Author

eleventy-plugin-syntaxhighlight and eleventy-plugin-rss use this EditorConfig:

root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
charset = utf-8

2 space indentation with final newline.

eleventy-base-blog uses the same config except for the indent_style (uses tabs):

root = true

[*]
indent_style = tab
indent_size = 2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
charset = utf-8

eleventy-img goes back to the eleventy-plugin-syntaxhighlight/eleventy-plugin-rss config (which uses spaces) except for this weird insert_final_newline rule:

root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
insert_final_newline = false
trim_trailing_whitespace = true
charset = utf-8

[*.js]
insert_final_newline = true

eleventy uses a similar config to eleventy-img:

root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
insert_final_newline = false
trim_trailing_whitespace = true
charset = utf-8

[*.js]
insert_final_newline = true

[/test/stubs*/**]
insert_final_newline = unset
trim_trailing_whitespace = false

and this website itself uses tabs + the weird newline rule:

root = true

[*]
indent_style = tab
indent_size = 2
end_of_line = lf
insert_final_newline = false
trim_trailing_whitespace = true
charset = utf-8

[*.js]
insert_final_newline = true
indent_style = tab

[*.json]
indent_style = tab

[*.css]
insert_final_newline = true
indent_style = tab

And the only actual prettier configuration is this, just specifying arrowParens and the printWidth:

{
  "arrowParens": "always",
  "printWidth": 100
}

Looks like we can't decide between tabs and spaces but the indent_size should be 2?

@uncenter
Copy link
Contributor Author

For the most part we can stick to using EditorConfig since prettier respects that (for rules like indent_style, indent_size/tab_width, the other basics) but we should think about these prettier-specific rules:

semi: use semicolons at the end of lines
trailingComma: add trailing commas "wherever possible in multi-line comma-separated syntactic structures" (better for diffs)
singleQuote: use single quotes instead of double quotes

@uncenter
Copy link
Contributor Author

Would love an update on this. Hoping to contribute but lacking this config makes it difficult!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant