Skip to content

Commit 18d625f

Browse files
talissoncostaclaude
andcommitted
ci(frontend): lint changed lines via eslint-plugin-diff
The previous job linted whole changed files, so touching a file with the frontend's pre-existing eslint backlog failed the PR on errors it never introduced — pushing contributors toward project-wide `lint:fix` (see #7733). eslint-plugin-diff's `plugin:diff/ci` config filters lint messages to lines changed vs the PR base. It is a no-op locally and in editors, running only under CI (the `CI` env var GitHub Actions sets). Pure eslint + git — no token — so it works on fork PRs too. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 4be6fa0 commit 18d625f

4 files changed

Lines changed: 23 additions & 14 deletions

File tree

.github/workflows/frontend-pull-request.yml

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -58,18 +58,9 @@ jobs:
5858
- name: Install dependencies
5959
run: npm ci
6060

61-
# Diff-scoped: the frontend has a large pre-existing eslint/tsc backlog,
62-
# so a whole-repo gate isn't viable yet.
63-
- name: Lint changed files
61+
# Lints only the lines this PR changed (eslint-plugin-diff), so the
62+
# pre-existing backlog doesn't fail PRs. Fork-safe: pure eslint + git.
63+
- name: Lint changed lines
6464
env:
65-
BASE_SHA: ${{ github.event.pull_request.base.sha }}
66-
run: |
67-
CHANGED=$(git diff --name-only --diff-filter=ACMR --relative \
68-
"$BASE_SHA" HEAD -- '*.ts' '*.tsx' '*.js')
69-
if [ -z "$CHANGED" ]; then
70-
echo "No frontend JS/TS files changed — skipping."
71-
exit 0
72-
fi
73-
echo "Linting changed files:"
74-
echo "$CHANGED"
75-
echo "$CHANGED" | xargs npx eslint
65+
ESLINT_PLUGIN_DIFF_COMMIT: ${{ github.event.pull_request.base.sha }}
66+
run: npm run lint

frontend/.eslintrc.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ module.exports = {
1111
'plugin:prettier/recommended',
1212
'plugin:@dword-design/import-alias/recommended',
1313
'plugin:storybook/recommended',
14+
// Lints only changed lines in CI (no-op locally), so the pre-existing
15+
// eslint backlog doesn't fail PRs that merely touch a file.
16+
'plugin:diff/ci',
1417
],
1518
'globals': {
1619
'$': true,

frontend/package-lock.json

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@
161161
"chromatic": "^15.2.0",
162162
"eslint": "^8.0.1",
163163
"eslint-config-prettier": "^8.3.0",
164+
"eslint-plugin-diff": "^2.1.7",
164165
"eslint-plugin-import": "2.27.5",
165166
"eslint-plugin-import-alias": "^1.2.0",
166167
"eslint-plugin-prettier": "^3.4.0",

0 commit comments

Comments
 (0)