lint-staged.sh 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -3
- package/lint-staged.sh +2 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
> Run linters against Git staged files
|
|
4
4
|
|
|
5
|
-
`lint-staged.sh` is a shell script to evaluate a command with the list of [Git](https://git-scm.com) staged files as its arguments, filtered by globs.
|
|
5
|
+
`lint-staged.sh` is a shell script to evaluate a command with the list of [Git](https://git-scm.com) staged files as its arguments, filtered by globs. There are no additional features.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
> [!TIP]
|
|
8
|
+
> If you use [lint-staged](https://github.com/lint-staged/lint-staged) to check if staged files are valid — _but not automatically fix them_ — you might be interested in this simpler shell script.
|
|
8
9
|
|
|
9
10
|
## Example
|
|
10
11
|
|
|
@@ -22,7 +23,7 @@ prettier --check index.js README.md
|
|
|
22
23
|
|
|
23
24
|
## Installation
|
|
24
25
|
|
|
25
|
-
Copy the `lint-staged.sh` file from this repo somewhere and run it. It should work in the [Bourne shell (`sh`)](https://en.wikipedia.org/wiki/Bourne_shell).
|
|
26
|
+
Copy the [`lint-staged.sh`](./lint-staged.sh) file from this repo somewhere and run it. It should work in the [Bourne shell (`sh`)](https://en.wikipedia.org/wiki/Bourne_shell).
|
|
26
27
|
|
|
27
28
|
You probably want to run `lint-staged.sh` in a Git `pre-commit` hook so that you can abort the commit if one of your commands fails.
|
|
28
29
|
|
|
@@ -32,3 +33,13 @@ For example, create the file `.git/hooks/pre-commit` (and make it executable):
|
|
|
32
33
|
#!/bin/sh
|
|
33
34
|
lint-staged.sh "prettier --check" "*.js" "*.json" "*.md"
|
|
34
35
|
```
|
|
36
|
+
|
|
37
|
+
If you are using [`npm`](https://www.npmjs.com), you can install `lint-staged.sh` and [Husky](https://github.com/typicode/husky) from there:
|
|
38
|
+
|
|
39
|
+
```shell
|
|
40
|
+
npm install --save-dev lint-staged.sh husky
|
|
41
|
+
npx husky init
|
|
42
|
+
|
|
43
|
+
# Adjust this file according to your needs
|
|
44
|
+
edit .husky/pre-commit
|
|
45
|
+
```
|
package/lint-staged.sh
CHANGED