Skip to content

Add a .prettierrc (or .prettierrc.json) to auto-format JSON (and JS) files #1027

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

Open
atuttle opened this issue Oct 26, 2018 · 5 comments
Open

Comments

@atuttle
Copy link
Contributor

atuttle commented Oct 26, 2018

Prettier is great. Having a definitions file will ensure that (at least for people who have the extension installed in their editor), the files are all consistently formatted.

@pfreitag
Copy link
Member

Good idea -- if you want to submit a PR we can see how well it might work.

@atuttle
Copy link
Contributor Author

atuttle commented Nov 7, 2018

Here's the config I would recommend, but it does incorporate some of my own personal preferences.

{
  "arrowParens": "avoid",
  "bracketSpacing": true,
  "htmlWhitespaceSensitivity": "css",
  "insertPragma": false,
  "jsxBracketSameLine": false,
  "jsxSingleQuote": false,
  "parser": "json",
  "printWidth": 80,
  "proseWrap": "preserve",
  "requirePragma": false,
  "semi": true,
  "singleQuote": false,
  "tabWidth": 4,
  "trailingComma": "none",
  "useTabs": true
}

Here's an easy way to try the different options and pick the config you like. There's a "copy config json" button at the bottom once you've got settings you're happy with.

@pfreitag
Copy link
Member

pfreitag commented Nov 7, 2018

Cool - that looks good to me, @shaedrich @KamasamaK what do you think?

@KamasamaK
Copy link
Contributor

I've never used Prettier, but it seems like a good idea to enforce (formatting) standards for the project.

@psarin
Copy link

psarin commented Apr 20, 2024

Please see #1649 for committed rules for .prettierrc and .cflintrc. If people are okay with these rules, I can apply to JSON files.

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

No branches or pull requests

4 participants