Skip to content

Commit 0ee150d

Browse files
committed
Merge branch 'update-readme-recipes'
2 parents 4f8e941 + 7419a0b commit 0ee150d

File tree

1 file changed

+49
-5
lines changed

1 file changed

+49
-5
lines changed

README.md

Lines changed: 49 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,19 @@ Many codebases don't start off with good linting standards and adopting a lintin
55

66
`git-diff-lint` is configurable with many popular linters and faithfully preserves the linter exit code meaning it works great as a status check or git pre-push hook.
77

8-
## Installation:
8+
## Installation
99
Just download and add command to your system path:
1010

1111
```bash
1212
curl -O https://raw.githubusercontent.com/codeocelot/git-diff-lint/master/git-diff-lint
1313
export PATH=$PATH/$(pwd)
14-
echo "export PATH=\$PATH:$(pwd)" >> ~/.bashrc # add to .bashrc to make available to future console sessions
14+
# add to zshrc to use in future sessions
15+
echo "export PATH=\$PATH:$(pwd)" >> ~/.zshrc
16+
# or add to bashrc
17+
echo "export PATH=\$PATH:$(pwd)" >> ~/.bashrc
1518
```
1619

17-
## Usage:
20+
## Usage
1821

1922
```bash
2023
$ git-diff-lint -x eslint -e .js
@@ -32,9 +35,9 @@ Executes linter command with the list of modified files compared to parent git b
3235
| -e | EXT | file regex expression | `\.py$` |
3336
| -h | \<none\> | Show help message and exit |
3437

35-
### Recipes
38+
## Recipes
3639

37-
#### ESLint:
40+
#### ESLint
3841

3942
- Lint .js & .jsx files with ESlint:
4043

@@ -43,3 +46,44 @@ git-diff-lint -x "npx eslint" -e ".js$|.jsx" -b stage
4346
# alternatively, using env vars:
4447
EXT=".js$|.jsx$" LINT="npx eslint" BRANCH=stage git-diff-lint
4548
```
49+
50+
#### Node package.json
51+
52+
Escaping strings is annoying in package.json, but doable.
53+
54+
```json
55+
{
56+
"name": "your-project",
57+
"scripts": {
58+
"lint": "EXT=\".js$|.jsx$|.ts$|.tsx$\" LINT=\"npx eslint --ext .js,.jsx,.ts,.tsx\" ./tools/git-diff-lint/git-diff-lint"
59+
}
60+
}
61+
```
62+
63+
Or create a script file and call it.
64+
65+
```bash
66+
# lint.sh
67+
git-diff-lint -x "npx eslint" -e ".js$|.jsx" -b stage
68+
```
69+
70+
```json
71+
{
72+
"name": "your-project",
73+
"scripts": {
74+
"lint": "./lint.sh"
75+
}
76+
}
77+
```
78+
79+
## Contributing
80+
81+
Have any ideas on how to make this tool more useful? PRs are greatly appreciated. Since this project doesn't have a test suite, please make sure your contribution doesn't break existing functionality and within your PR, please document how to test your proposed feature.
82+
83+
I prefer if you use [commitizen](https://github.com/commitizen/cz-cli) to format your commits, but any reasonable committing strategy is fine.
84+
85+
If you have ideas on how to write tests for this project, please share!
86+
87+
## License
88+
89+
MIT Licensed. Go forth and create, but please provide attribution back to this project.

0 commit comments

Comments
 (0)