Skip to content

Commit

Permalink
docs: Add better docs on running multiple commands
Browse files Browse the repository at this point in the history
Fix other examples
  • Loading branch information
okonet authored Jan 28, 2020
1 parent 4010db0 commit 7fac11f
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,19 @@ Supported are any executables installed locally or globally via `npm` as well as

Pass arguments to your commands separated by space as you would do in the shell. See [examples](#examples) below.

Starting from [v2.0.0](https://github.com/okonet/lint-staged/releases/tag/2.0.0) sequences of commands are supported. Pass an array of commands instead of a single one and they will run sequentially. This is useful for running autoformatting tools like `eslint --fix` or `stylefmt` but can be used for any arbitrary sequences.
## Running multiple commands in a sequence

You can run multiple commands in a sequence on every glob. To do so, pass an array of commands instead of a single one. This is useful for running autoformatting tools like `eslint --fix` or `stylefmt` but can be used for any arbitrary sequences.

For example:

```json
{
"*.js": ["eslint", "prettier --write"]
}
```

going to execute `eslint` and if it exits with `0` code, it will execute `prettier --write` on all staged `*.js` files.

## Using JS functions to customize tasks

Expand Down Expand Up @@ -332,23 +344,11 @@ For example, here is `jest` running on all `.js` files with the `NODE_ENV` varia
}
```

### Automatically fix code style with `prettier` for javascript + flow, typescript, markdown or html

```json
{
"*.{js,jsx}": "prettier --write"
}
```

```json
{
"*.{ts,tsx}": "prettier --write"
}
```
### Automatically fix code style with `prettier` for javascript, typescript, markdown, HTML, or CSS

```json
{
"*.{md,html}": "prettier --write"
"*.{js,jsx,ts,tsx,md,html,css}": "prettier --write"
}
```

Expand All @@ -365,7 +365,7 @@ For example, here is `jest` running on all `.js` files with the `NODE_ENV` varia

```json
{
"*.scss": "postcss --config path/to/your/config --replace", "stylelint"
"*.scss": ["postcss --config path/to/your/config --replace", "stylelint"]
}
```

Expand Down

0 comments on commit 7fac11f

Please sign in to comment.