1.2.0 • Published 4 months ago

@igoro00/prettier-config v1.2.0

Weekly downloads
-
License
ISC
Repository
github
Last release
4 months ago

Prettier Config

npm version

My very opinionated prettier config. If you're not me you probably shouldn't use it.

Table of Contents

Installation

  1. Make sure your project is using a Node version >= 10

  2. 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
    ```
  3. 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

  1. Install the Prettier extension: View → Extensions then find and install Prettier - Code formatter
  2. Reload the editor
  3. 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.

  1. Checkout and pull the master branch

  2. Run 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.

  3. Submit and merge a PR from the release branch into master

  4. 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 1pass

  5. npm 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 }
```