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

Repo: Add .prettierrc #506

Open
2 of 4 tasks
MaoShizhong opened this issue Mar 8, 2024 · 2 comments
Open
2 of 4 tasks

Repo: Add .prettierrc #506

MaoShizhong opened this issue Mar 8, 2024 · 2 comments
Labels
Status: Needs Review This issue/PR needs an initial or additional review

Comments

@MaoShizhong
Copy link
Contributor

MaoShizhong commented Mar 8, 2024

Complete the following REQUIRED checkboxes:

  • I have thoroughly read and understand The Odin Project Contributing Guide

  • The title of this issue follows the command name: brief description of request format, e.g. /help: add optional @user parameter

The following checkbox is OPTIONAL:

  • I would like to be assigned this issue to work on it

1. Description of the Feature Request:
Currently, prettier is listed as a project dependency (also a little odd it's not listed as a devDep).

On several occasions, if someone is using the VSCode PRettier extension (very common due to the curriculum recommendations), format-on-save or muscle memory with a keybind can kick in which leads to needing to make a new commit reverting any unintentional formatting changes (e.g. quotes, spacing, indents etc.)

This can be solved by adding a root-level .prettierrc file containing the following:

{
    "arrowParens": "always",
    "bracketSpacing": true,
    "bracketSameLine": false,
    "endOfLine": "lf",
    "htmlWhitespaceSensitivity": "css",
    "insertPragma": false,
    "printWidth": 80,
    "proseWrap": "preserve",
    "quoteProps": "as-needed",
    "semi": true,
    "singleQuote": true,
    "tabWidth": 2,
    "trailingComma": "all",
    "useTabs": false
}

The above is the ruleset I found to be the closest formatting to most of the JS files and will result in the fewest unintentional changes.
The only real changes to expect would be a few line-break changes due to the 80 printWidth value (80 seems to fit more files than 100, and IMHO is a little more readable for many of the ones that do end up shifting due to it). Perhaps also a few trailing commas (setting to 'es5' removes quite a few from function args in some files).

But as far as I can see, there shouldn't be many changes other than those, and even those should only be limited to the odd line in the odd file.

2. Acceptance Criteria:

  • Add a top-level .prettierrc file with the above ruleset

3. Additional Information:
If approved, the work should be simple so would be happy for anyone to claim it if so. But if it goes unclaimed for a while after approval, I'll knock it out quick.

@MaoShizhong MaoShizhong added the Status: Needs Review This issue/PR needs an initial or additional review label Mar 8, 2024
@cakegod
Copy link
Contributor

cakegod commented Mar 20, 2024

This should enable us to format everything with prettier . -w.

@damon314159
Copy link

You can even have a GH actions bot run that command in the workflow to ensure nothing is merged without matching

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Needs Review This issue/PR needs an initial or additional review
Projects
None yet
Development

No branches or pull requests

3 participants