Skip to content

Commit e228c05

Browse files
authored
Merge pull request #1596 from thclark/master
2 parents e7f22a9 + 530258c commit e228c05

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-1
lines changed

.pre-commit-hooks.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
- id: standard
2+
name: standard
3+
entry: standard --fix
4+
language: node
5+
files: "\\.(\
6+
js|jsx\
7+
|ts|tsx\
8+
|mjs|cjs\
9+
)$"

README.md

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,12 @@ $ standard --plugin html '**/*.html'
649649

650650
## Is there a Git `pre-commit` hook?
651651

652-
Funny you should ask!
652+
Yes! Hooks are great for ensuring that unstyled code never even makes it into your repo.
653+
Never give style feedback on a pull request again!
654+
655+
You even have a choice...
656+
657+
### Install your own hook
653658

654659
```bash
655660
#!/bin/bash
@@ -669,6 +674,32 @@ if [[ $? -ne 0 ]]; then
669674
fi
670675
```
671676

677+
### Use a `pre-commit` hook
678+
679+
The [pre-commit](https://pre-commit.com/) library allows hooks to be declared within a `.pre-commit-config.yaml` configuration file in the repo, and therefore more easily maintained across a team.
680+
681+
Users of pre-commit can simply add `standard` to their `.pre-commit-config.yaml` file, which will automatically fix `.js`, `.jsx`, `.ts`, `.tsx`, `.mjs` and `.cjs` files:
682+
```yaml
683+
- repo: https://github.com/standard/standard
684+
rev: master
685+
hooks:
686+
- id: standard
687+
```
688+
689+
Alternatively, for more advanced styling configurations, use `standard` within the [eslint hook](https://github.com/pre-commit/mirrors-eslint):
690+
```yaml
691+
- repo: https://github.com/pre-commit/mirrors-eslint
692+
rev: master
693+
hooks:
694+
- id: eslint
695+
files: \.[jt]sx?$ # *.js, *.jsx, *.ts and *.tsx
696+
types: [file]
697+
additional_dependencies:
698+
- eslint@latest
699+
- eslint-config-standard@latest
700+
# and whatever other plugins...
701+
```
702+
672703
## How do I make the output all colorful and pretty?
673704

674705
The built-in output is simple and straightforward, but if you like shiny things,

0 commit comments

Comments
 (0)