@igoro00/prettier-config v1.2.0
Prettier Config
My very opinionated prettier config. If you're not me you probably shouldn't use it.
Table of Contents
- Prettier Config - Table of Contents - Installation - Editor Integration & Autoformatting - VS Code - Sublime Text 3 - Atom - Publishing to npm - Enforced Rules
Installation
Make sure your project is using a Node version >=
10
Install dependencies
```bash npm install --save-dev @igoro00/prettier-config prettier@2.x.x # or yarn add --dev @igoro00/prettier-config prettier@2.x.x ```
Create a
prettier.config.js
file at the root of your project with the following:```js module.exports = require('@igoro00/prettier-config'); ```
Editor Integration & Autoformatting
VS Code
- Install the Prettier extension:
View → Extensions
then find and installPrettier - Code formatter
- Reload the editor
Open your settings JSON file and add the following
```json // Format on save with Prettier rules "editor.formatOnSave": true, // Tell the ESLint plugin to run on save "editor.codeActionsOnSave": { "source.fixAll.eslint": true }, // Turn off Prettier format on save, use ESLint to format instead "[javascript]": { "editor.formatOnSave": false }, "[vue]": { "editor.formatOnSave": false }, "eslint.alwaysShowStatus": true, // An array of language identifiers specify the files to be validated "eslint.options": { "extensions": [".html", ".js", ".vue", ".jsx"] }, ```
Sublime Text 3
https://packagecontrol.io/packages/JsPrettier
Atom
https://atom.io/packages/prettier-atom
Publishing to npm
Read npm's docs on How to Update a Package.
Checkout and pull the
master
branchRun the release script to bump the version numbers (the script will create a commit and push up the release branch to GitHub for you)
./scripts/release
Use semantic versioning to choose the appropriate version number.
Submit and merge a PR from the release branch into
master
Make sure you're logged into npm from the command line using
npm whoami
. If you're not logged in,npm login
with the credentials in 1passnpm publish
Enforced Rules
Check out all of Prettier's configuration options.
Line wrap at 100 characters.
Spaces are for separating words, not scope of code blocks!
Always print semicolons at the ends of statements.
```js
const greeting = 'hi';
```
Use an actual quotes instead of apostrophes.
```js
const quote = "With double quotes you don't have to escape apostrophes. It's better, isn't it?";
```
Always put trailing commas.
```js
const obj = {
a: 'hi',
b: 'hey',
};
```
Print spaces between brackets in object literals.
```js
{ foo: bar }
```