Skip to content

Commit 7fac11f

Browse files
authored
docs: Add better docs on running multiple commands
Fix other examples
1 parent 4010db0 commit 7fac11f

1 file changed

Lines changed: 16 additions & 16 deletions

File tree

README.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,19 @@ Supported are any executables installed locally or globally via `npm` as well as
166166

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

169-
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.
169+
## Running multiple commands in a sequence
170+
171+
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.
172+
173+
For example:
174+
175+
```json
176+
{
177+
"*.js": ["eslint", "prettier --write"]
178+
}
179+
```
180+
181+
going to execute `eslint` and if it exits with `0` code, it will execute `prettier --write` on all staged `*.js` files.
170182

171183
## Using JS functions to customize tasks
172184

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

335-
### Automatically fix code style with `prettier` for javascript + flow, typescript, markdown or html
336-
337-
```json
338-
{
339-
"*.{js,jsx}": "prettier --write"
340-
}
341-
```
342-
343-
```json
344-
{
345-
"*.{ts,tsx}": "prettier --write"
346-
}
347-
```
347+
### Automatically fix code style with `prettier` for javascript, typescript, markdown, HTML, or CSS
348348

349349
```json
350350
{
351-
"*.{md,html}": "prettier --write"
351+
"*.{js,jsx,ts,tsx,md,html,css}": "prettier --write"
352352
}
353353
```
354354

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

366366
```json
367367
{
368-
"*.scss": "postcss --config path/to/your/config --replace", "stylelint"
368+
"*.scss": ["postcss --config path/to/your/config --replace", "stylelint"]
369369
}
370370
```
371371

0 commit comments

Comments
 (0)