Skip to content

Commit

Permalink
Chore: Add format script to run prettier
Browse files Browse the repository at this point in the history
Run the format script and commit updates
  • Loading branch information
BPScott committed Sep 27, 2018
1 parent 869f56d commit d46aa6d
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 34 deletions.
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
package.json
CHANGELOG.md

# this file doesn't exist, but we use it as a filename that should be ignored
# by prettier in the tests
Expand Down
12 changes: 6 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
language: node_js
cache: yarn
node_js:
- '4'
- '6'
- '7'
- '8'
- '9'
- "4"
- "6"
- "7"
- "8"
- "9"
env:
- ESLINT_VERSION=latest
- ESLINT_VERSION=3.15.0
before_script:
- if [[ $ESLINT_VERSION != "latest" ]]; then
yarn upgrade "eslint@$ESLINT_VERSION";
yarn upgrade "eslint@$ESLINT_VERSION";
fi
3 changes: 1 addition & 2 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
The MIT License (MIT)
=====================
# The MIT License (MIT)

Copyright © 2017 Andres Suarez and Teddy Katz

Expand Down
50 changes: 24 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@ Then, in your `.eslintrc.json`:

```json
{
"plugins": [
"prettier"
],
"plugins": ["prettier"],
"rules": {
"prettier/prettier": "error"
}
Expand All @@ -62,25 +60,23 @@ To integrate this plugin with `eslint-config-prettier`, you can use the `"recomm

1. In addition to the above installation instructions, install `eslint-config-prettier`:

```sh
npm install --save-dev eslint-config-prettier
```
```sh
npm install --save-dev eslint-config-prettier
```

2. Then you need to add `plugin:prettier/recommended` as the last extension in your `.eslintrc.json`:

```json
{
"extends": [
"plugin:prettier/recommended"
]
}
```
```json
{
"extends": ["plugin:prettier/recommended"]
}
```

This does three things:

* Enables `eslint-plugin-prettier`.
* Sets the `prettier/prettier` rule to `"error"`.
* Extends the `eslint-config-prettier` configuration.
- Enables `eslint-plugin-prettier`.
- Sets the `prettier/prettier` rule to `"error"`.
- Extends the `eslint-config-prettier` configuration.

You can then set Prettier's own options inside a `.prettierrc` file.
Expand All @@ -103,9 +99,10 @@ For the list of every available exclusion rule set, please see the [readme of es
> Note: While it is possible to pass options to Prettier via your ESLint configuration file, it is not recommended because editor extensions such as `prettier-atom` and `prettier-vscode` **will** read [`.prettierrc`](https://prettier.io/docs/en/configuration.html), but **won't** read settings from ESLint, which can lead to an inconsistent experience.

* The first option:
- The first option:

- Objects are passed directly to Prettier as [options](https://prettier.io/docs/en/options.html). Example:

```json
"prettier/prettier": ["error", {"singleQuote": true, "parser": "flow"}]
```
Expand All @@ -127,9 +124,10 @@ For the list of every available exclusion rule set, please see the [readme of es
"parser": "flow"
}]
```
NB: This option will merge and override any config set with `.prettierrc` files (for Prettier < 1.7.0, [config files are ignored](https://github.com/prettier/eslint-plugin-prettier/issues/46))

* The second option:
NB: This option will merge and override any config set with `.prettierrc` files (for Prettier < 1.7.0, [config files are ignored](https://github.com/prettier/eslint-plugin-prettier/issues/46))

- The second option:

- A string with a pragma that triggers this rule. By default, this rule applies to all files. However, if you set a pragma (this option), only files with that pragma in the heading docblock will be checked. All pragmas must start with `@`. Example:

Expand All @@ -156,26 +154,26 @@ For the list of every available exclusion rule set, please see the [readme of es
```

_This option is useful if you're migrating a large codebase and already use pragmas like `@flow`._
- An object with the following options
- `pragma`: Also sets the aforementioned `pragma`: a string with a pragma that triggers this rule. By default, this rule applies to all files. However, if you set a pragma (this option), only files with that pragma in the heading docblock will be checked. All pragmas must start with `@`.
```json
"prettier/prettier": ["error", null, {
"pragma": "@prettier"
}]
```
- `usePrettierrc`: Enables loading of the Prettier configuration file, (default: `true`). May be useful if you are using multiple tools that conflict with each other, or do not wish to mix your ESLint settings with your Prettier configuration.
```json
"prettier/prettier": ["error", null, {
"usePrettierrc": false
}]
```
* The rule is autofixable -- if you run `eslint` with the `--fix` flag, your code will be formatted according to `prettier` style.
- The rule is autofixable -- if you run `eslint` with the `--fix` flag, your code will be formatted according to `prettier` style.
---
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"scripts": {
"lint": "eslint .",
"test": "npm run lint && mocha",
"format": "yarn run prettier '**/*.{js,json,md,yml}' --write && yarn run lint --fix",
"generate-release": "node-release-script"
},
"repository": {
Expand Down

0 comments on commit d46aa6d

Please sign in to comment.