Skip to content

Commit

Permalink
Merge pull request #1596 from thclark/master
Browse files Browse the repository at this point in the history
  • Loading branch information
feross authored Nov 11, 2020
2 parents e7f22a9 + 530258c commit e228c05
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
9 changes: 9 additions & 0 deletions .pre-commit-hooks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
- id: standard
name: standard
entry: standard --fix
language: node
files: "\\.(\
js|jsx\
|ts|tsx\
|mjs|cjs\
)$"
33 changes: 32 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,12 @@ $ standard --plugin html '**/*.html'

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

Funny you should ask!
Yes! Hooks are great for ensuring that unstyled code never even makes it into your repo.
Never give style feedback on a pull request again!

You even have a choice...

### Install your own hook

```bash
#!/bin/bash
Expand All @@ -669,6 +674,32 @@ if [[ $? -ne 0 ]]; then
fi
```

### Use a `pre-commit` hook

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.

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:
```yaml
- repo: https:/standard/standard
rev: master
hooks:
- id: standard
```
Alternatively, for more advanced styling configurations, use `standard` within the [eslint hook](https:/pre-commit/mirrors-eslint):
```yaml
- repo: https:/pre-commit/mirrors-eslint
rev: master
hooks:
- id: eslint
files: \.[jt]sx?$ # *.js, *.jsx, *.ts and *.tsx
types: [file]
additional_dependencies:
- eslint@latest
- eslint-config-standard@latest
# and whatever other plugins...
```

## How do I make the output all colorful and pretty?

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

0 comments on commit e228c05

Please sign in to comment.