@19h47/prettier-config v2.0.0
prettier-config
19h47's prettier configuration.
Installation
yarn
yarn install 19h47/prettier-configIf you don't have it installed already, also install prettier as a devDependency.
yarn install --dev prettierUsage
We export Prettier configurations for your usage.
Default Config
Create a prettier.config.js file at the root of your project that contains:
module.exports = require('@19h47/prettier-config');Editor Integration
Visual Studio Code
- Install Prettier extension:
View → Extensionsthen find and install Prettier - Code formatter - Reload the editor
- In your user settings
Code -> Preferences -> Settingsaddeditor.formatOnSave: true
Enforced Rules
Check out all of Prettier's configuration options.
Print Width
Line wrap at 100 characters.
Tab Width
2 spaces per indentation-level.
Tabs
Indent lines with spaces, not tabs.
Semicolons
Always print semicolons at the ends of statements.
const greeting = 'hi';Quote
Use single quotes instead of double quotes.
const quote = 'single quotes are better';Trailing Commas
Use trailing commas wherever possible.
const obj = { a: 'hi', b: 'hey', };Bracket Spacing
Print spaces between brackets in object literals.
{ foo: bar; }JSX Brackets
Put the
>of a multi-line JSX element at the end of the last line instead of being alone on the next line (does not apply to self closing elements).<button className="prettier-class" id="prettier-id" onClick={this.handleClick}> Click Here </button>Arrow Function Parentheses
Omit parens when possible.
x => x;