Skip to content

Commit acffca1

Browse files
committed
Update README.md
1 parent fff9d47 commit acffca1

File tree

1 file changed

+46
-27
lines changed

1 file changed

+46
-27
lines changed

README.md

Lines changed: 46 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,74 @@
11
# eslint-plugin-diff ![](https://img.shields.io/npm/dt/eslint-plugin-diff?style=flat-square&logo=npm&logoColor=white)
22

3-
Run ESLint on your changed lines only. Now with CI support!
3+
Run ESLint on your changed lines only.
44

55
## What problem does it solve?
66

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.
7+
The feedback your developers get in a pull-request should be focused on the changes they've made, but traditional setups don't allow for this. With this plugin you can run ESLint on your changed lines only, making all warnings and errors **relevant to you**, and at the same time avoiding becoming overwhelmed with linter errors.
88

9-
It can be used in CI environments as well.
9+
### 💰 Your company's budget is precious
1010

11-
## Installation
11+
When updating your linter or its dependencies, you often get new linter warnings and errors in your code, which can lead to a huge increase of the cost of your project if you try to fix all of them. This plugin allows you to run ESLint on only the changed lines of your code, so the new errors won't get triggered on the code other developers have already manually reviewed and approved.
1212

13-
```sh
14-
$ yarn add -D eslint-plugin-diff
15-
```
13+
### 🚀 Your team's velocity is important
1614

17-
## Usage
15+
Having a healthy and high-quality code-base is a pre-requisite for high velocity and having too many errors in your linter's output can get overwhelming, oftentimes disheartening the developers, at the cost of the quality of the code. Having a linter that runs on only the changed lines of your code will ensure your developers don't get overwhelmed, ensuring your code-base will remain healthy, and your team productive.
1816

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`):
17+
### 🧠 Your developers' focus is vital
2018

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-
```
19+
Let's face it – Developers are bombarded with errors and notifications about systems being broken, code being wrong and people requiring their attention. If a linter has too much output, it becomes a chore for your developers just to assess whether or not their changes actually caused an issue, or if it's just old code they haven't even touched. With this plugin, all the linter output your developers see will be related to whatever they have personally changed, requiring much less focus on parsing the linter's output.
20+
21+
### How does it solve it?
22+
23+
When creating pull-requests, this plugin will enable you to run ESLint on only the changed lines of your pull-request, increasing the focus of your code review. This is a great way to reduce the amount of time spent on code review while still maintaining a high quality code base and increase the quality of your feedback.
24+
25+
As an added bonus, it also makes introducing new ESLint rules (or updating 3rd party configs) in a large codebase trivial, because you avoid becoming blocked by new ESLint issues in already-approved code.
26+
27+
## Installation
28+
29+
Install the plugin and extend your ESLint config.
2630

27-
See [git's official documentation on the syntax](https://git-scm.com/docs/git-diff#Documentation/git-diff.txt-emgitdiffemltoptionsgtltcommitgt--ltpathgt82308203)
31+
### Install
2832

29-
It's recommended to use [`"plugin:diff/diff"` (see config)](#config-diff--diff-all-changes-since-head-staged-and-unstaged).
33+
```sh
34+
yarn add -D eslint eslint-plugin-diff
35+
```
3036

31-
### Config `diff` — Diff all changes since HEAD (staged and unstaged)
37+
### Extend config
3238

33-
Extend your config in **`.eslintrc`**:
39+
Extend your ESLint config with `"plugin:diff/diff"`:
3440

3541
```json
3642
{
3743
"extends": ["plugin:diff/diff"]
3844
}
3945
```
4046

41-
_Equivalent to `git diff HEAD`_
47+
You can also choose `"plugin:diff/staged"` if you prefer to lint only staged
48+
files.
4249

43-
### Config `staged` — Diff staged changes only
50+
## CI Setup
4451

45-
> **Useful for pre-commit hooks, e.g. when running ESLint with lint-staged**
52+
To lint all the changes of a PR, you only have to set
53+
`ESLINT_PLUGIN_DIFF_COMMIT` before running ESLint.
4654

47-
Extend your config in **`.eslintrc`**:
55+
### For GitHub Actions
4856

49-
```json
50-
{
51-
"extends": ["plugin:diff/staged"]
52-
}
57+
```sh
58+
export ESLINT_PLUGIN_DIFF_COMMIT="origin/$GITHUB_BASE_REF";
59+
npx --no-install eslint --ext .js,.ts,.tsx .
5360
```
5461

55-
_Equivalent to `git diff HEAD --staged`_
62+
### For BitBucket Pipelines
63+
64+
```sh
65+
export ESLINT_PLUGIN_DIFF_COMMIT="origin/$BITBUCKET_PR_DESTINATION_BRANCH";
66+
npx --no-install eslint --ext .js,.ts,.tsx .
67+
```
68+
69+
## Note
70+
71+
- You can use any valid commit syntax for `ESLINT_PLUGIN_DIFF_COMMIT`. See [git's official documentation on the syntax](https://git-scm.com/docs/git-diff#Documentation/git-diff.txt-emgitdiffemltoptionsgtltcommitgt--ltpathgt82308203)
72+
- You can choose to lint all changes (using `"plugin:diff/diff"`) or staged changes only (using `"plugin:diff/staged"`).
73+
- We recommend using `"plugin:diff/diff"`, which is equivalent to running `git diff HEAD`.
74+
- `"plugin:diff/staged"` is equivalent to running `git diff HEAD --staged`

0 commit comments

Comments
 (0)