cfdocs icon indicating copy to clipboard operation
cfdocs copied to clipboard

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

Open atuttle opened this issue 7 years ago • 5 comments

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.

atuttle avatar Oct 26 '18 21:10 atuttle

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

pfreitag avatar Oct 30 '18 16:10 pfreitag

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.

atuttle avatar Nov 07 '18 16:11 atuttle

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

pfreitag avatar Nov 07 '18 16:11 pfreitag

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

KamasamaK avatar Nov 07 '18 18:11 KamasamaK

Please see https://github.com/foundeo/cfdocs/pull/1649 for committed rules for .prettierrc and .cflintrc. If people are okay with these rules, I can apply to JSON files.

psarin avatar Apr 20 '24 22:04 psarin