You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+20-8Lines changed: 20 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,6 +6,8 @@ Run ESLint on your changes only
6
6
7
7
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.
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`):
18
20
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
+
```
20
26
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)
22
32
23
33
Extend your config in **`.eslintrc`**:
24
34
25
35
```json
26
36
{
27
-
"extends": ["plugin:diff/staged"]
37
+
"extends": ["plugin:diff/diff"]
28
38
}
29
39
```
30
40
31
-
_Equivalent to `git diff HEAD --staged`_
41
+
_Equivalent to `git diff HEAD`_
32
42
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**
0 commit comments