Prettier

My defaults:

module.exports = {
  'arrowParens': 'avoid',
  'bracketSpacing': false,
  'singleQuote': true,
  'trailingComma': 'all',
};
  • arrowParens: avoid - allows input => output
  • bracketSpacing: false - more concise. Exception: Ember, where generated files have bracket spacing
  • singleQuote: true - easier to type single quotes
  • trailingComma: all - simplifies diffs and line rearrangement
    • es5 instead for untranspiled Node

ESLint Integration

https://prettier.io/docs/en/integrating-with-linters.html

eslint-config-prettier

https://github.com/prettier/eslint-config-prettier

Turns off rules that conflict with Prettier. Recommended.

{
  "extends": [
    "some-other-config-you-use",
    "prettier"
  ]
}

eslint-plugin-prettier

https://github.com/prettier/eslint-plugin-prettier

Runs Prettier via ESLint. Not recommended.

{
  "plugins": ["prettier"],
  "extends": ["plugin:prettier/recommended"]
  "rules": {
    "prettier/prettier": "error"
  }
}