TheOdinProject / odin-bot-v2

The bot that breathes life into our Discord community
ISC License
47 stars 72 forks source link

Repo: Add .prettierrc #506

Closed MaoShizhong closed 1 day ago

MaoShizhong commented 3 months ago

Complete the following REQUIRED checkboxes:

The following checkbox is OPTIONAL:


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:

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.

cakegod commented 3 months ago

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

damon314159 commented 3 months ago

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