Skip to content

Commit f8807d7

Browse files
authored
docs: simplify configuration example for formatting any format Prettier supports (#997)
1 parent f7302f4 commit f8807d7

File tree

1 file changed

+4
-26
lines changed

1 file changed

+4
-26
lines changed

README.md

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -445,36 +445,14 @@ For example, here is `jest` running on all `.js` files with the `NODE_ENV` varia
445445
446446
</details>
447447
448-
### Automatically fix code style with `prettier` for any format prettier supports
448+
### Automatically fix code style with `prettier` for any format Prettier supports
449449
450450
<details>
451451
<summary>Click to expand</summary>
452452
453-
You need to add `micromatch` as a dev dependency.
454-
455-
```sh
456-
$ npm i --save-dev micromatch
457-
```
458-
459-
```js
460-
// lint-staged.config.js
461-
const micromatch = require('micromatch')
462-
const prettier = require('prettier')
463-
464-
const prettierSupportedExtensions = prettier
465-
.getSupportInfo()
466-
.languages.map(({ extensions }) => extensions)
467-
.flat()
468-
const addQuotes = (a) => `"${a}"`
469-
470-
module.exports = (allStagedFiles) => {
471-
const prettierFiles = micromatch(
472-
allStagedFiles,
473-
prettierSupportedExtensions.map((extension) => `**/*${extension}`)
474-
)
475-
return prettierFiles.length > 0
476-
? [`prettier --write ${prettierFiles.map(addQuotes).join(' ')}`]
477-
: []
453+
```json
454+
{
455+
"*": "prettier --ignore-unknown --write"
478456
}
479457
```
480458

0 commit comments

Comments
 (0)