Skip to content

Commit 5a55bfe

Browse files
committed
Update README.md
1 parent bfb8eb4 commit 5a55bfe

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

README.md

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ Run ESLint on your changes only
66

77
Introducing new ESLint rules (or updating 3rd party configs) in a large codebase can be tedious. This plugin allows your team to ease into new rules by only linting all new/modified code, eventually migrating to the new/updated rules.
88

9+
It can be used in CI environments as well.
10+
911
## Installation
1012

1113
```sh
@@ -14,30 +16,40 @@ $ yarn add -D eslint-plugin-diff
1416

1517
## Usage
1618

17-
It's recommended to use [`"plugin:diff/staged"` (see config)](#config-staged-diff-staged-changes-only).
19+
If you want to define which commit or commit-range to diff between (useful in CI), you can set the environment variable `ESLINT_PLUGIN_DIFF_COMMIT` (otherwise the plugin will default to `HEAD`):
1820

19-
### Config `staged` — Diff staged changes only
21+
```sh
22+
$ ESLINT_PLUGIN_DIFF_COMMIT="a8fdc20..5a9f19c" yarn run eslint .
23+
# or
24+
$ ESLINT_PLUGIN_DIFF_COMMIT="${GITHUB_SHA}.." yarn run eslint .
25+
```
2026

21-
> **Useful for pre-commit hooks, e.g. when running ESLint with lint-staged**
27+
See [git's official documentation on the syntax](https://git-scm.com/docs/git-diff#Documentation/git-diff.txt-emgitdiffemltoptionsgtltcommitgt--ltpathgt82308203)
28+
29+
It's recommended to use [`"plugin:diff/diff"` (see config)](#config-diff--diff-all-changes-since-head-staged-and-unstaged).
30+
31+
### Config `diff` — Diff all changes since HEAD (staged and unstaged)
2232

2333
Extend your config in **`.eslintrc`**:
2434

2535
```json
2636
{
27-
"extends": ["plugin:diff/staged"]
37+
"extends": ["plugin:diff/diff"]
2838
}
2939
```
3040

31-
_Equivalent to `git diff HEAD --staged`_
41+
_Equivalent to `git diff HEAD`_
3242

33-
### Config `diff` — Diff all changes since HEAD (staged and unstaged)
43+
### Config `staged` — Diff staged changes only
44+
45+
> **Useful for pre-commit hooks, e.g. when running ESLint with lint-staged**
3446
3547
Extend your config in **`.eslintrc`**:
3648

3749
```json
3850
{
39-
"extends": ["plugin:diff/diff"]
51+
"extends": ["plugin:diff/staged"]
4052
}
4153
```
4254

43-
_Equivalent to `git diff HEAD`_
55+
_Equivalent to `git diff HEAD --staged`_

0 commit comments

Comments
 (0)