I used the following Yarn script, and that seems to provide the desired result:
"lint:js": "sh -c 'eslint --cache ${@:-.}' --"
This allows me to run lint:js
from lint-staged and it only lints the staged files, and I can also manually run yarn lint:js
and it lints all JS files.