Skip to content

Commit 79146fd

Browse files
authored
Merge pull request #89141 from Expensify/rory-lint-quiet-default
[No QA] Default lint output to errors only via --quiet
2 parents e489519 + 10bcbca commit 79146fd

2 files changed

Lines changed: 32 additions & 9 deletions

File tree

contributingGuides/LINTING.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,17 @@ npm run lint-changed
1414
# Lint specific files or directories:
1515
npm run lint -- src/components/Foo/index.tsx src/libs/bar.ts
1616

17+
# Include grandfathered seatbelt warnings in the output:
18+
npm run lint -- --show-warnings
19+
1720
# Continuously re-lint changed files as you edit:
1821
npm run lint-watch
1922
```
2023

2124
Prefer `npm run lint` (or `lint-changed` / `lint -- <files>`) over raw `npx eslint` invocations. Those wrappers increase the memory allocation to prevent OOM errors, and also include caching and concurrency flags for faster linting.
2225

26+
By default the wrapper passes `--quiet` to ESLint so only blocking errors are printed — seatbelt-grandfathered violations (which CI does not fail on) are suppressed from the output but still evaluated against the baseline. Pass `--show-warnings` when you want to see them too, e.g. when paying down baselined errors.
27+
2328
## eslint-seatbelt
2429
We use [eslint-seatbelt](https://github.com/justjake/eslint-seatbelt) to manage known lint errors.
2530

scripts/lint.sh

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,38 @@
33
# Run ESLint with the repo's standard flags (memory ceiling, shared content
44
# cache, auto concurrency). Delegate target selection to the caller:
55
#
6-
# ./scripts/lint.sh -> lint the whole repo
7-
# ./scripts/lint.sh src/foo.ts ... -> lint just the given paths
6+
# ./scripts/lint.sh -> lint the whole repo
7+
# ./scripts/lint.sh src/foo.ts ... -> lint just the given paths
8+
# ./scripts/lint.sh --show-warnings ... -> include grandfathered seatbelt warnings in the output
9+
#
10+
# By default we pass `--quiet` to ESLint so only blocking errors are printed.
11+
# eslint-seatbelt reclassifies grandfathered violations as warnings, so the
12+
# default output mirrors what CI cares about. Pass `--show-warnings` to
13+
# restore the full output (errors + warnings).
814

915
set -euo pipefail
1016

1117
# parse args
1218
USE_CACHE=true
19+
SHOW_WARNINGS=false
20+
PASSTHROUGH_ARGS=()
1321
for ARG in "$@"; do
14-
if [[ "$ARG" == "--no-cache" ]]; then
15-
USE_CACHE=false
16-
break
17-
fi
22+
case "$ARG" in
23+
--no-cache)
24+
USE_CACHE=false
25+
;;
26+
--show-warnings)
27+
SHOW_WARNINGS=true
28+
;;
29+
*)
30+
PASSTHROUGH_ARGS+=("$ARG")
31+
;;
32+
esac
1833
done
1934

2035
# Preserve default behavior of linting the whole repo when no target is passed.
21-
if [[ "$#" -eq 0 ]]; then
22-
set -- .
36+
if [[ "${#PASSTHROUGH_ARGS[@]}" -eq 0 ]]; then
37+
PASSTHROUGH_ARGS=(.)
2338
fi
2439

2540
# Build ESLint args
@@ -31,10 +46,13 @@ if [[ "$USE_CACHE" == "true" ]]; then
3146
--cache-strategy content
3247
)
3348
fi
49+
if [[ "$SHOW_WARNINGS" == "false" ]]; then
50+
ESLINT_ARGS+=(--quiet)
51+
fi
3452
ESLINT_ARGS+=(
3553
--concurrency=auto
3654
--no-warn-ignored
37-
"$@"
55+
"${PASSTHROUGH_ARGS[@]}"
3856
)
3957

4058
# Run ESLint with the repo's default memory ceiling and seatbelt behavior.

0 commit comments

Comments
 (0)