use git diff to generate file list
git diff --name-only master
add ext filter
git diff --name-only master | grep -E "(.js$|.ts$|.tsx$)"
ignore deleted files
git diff --name-only --diff-filter=ACMRTUXB master | grep -E "(.js$|.ts$|.tsx$)"
add eslint to package.json
....
"scripts":
"lint:script": "eslint -c eslintrc.js $(git diff --name-only --diff-filter=ACMRTUXB master | grep -E \"(.js$|.ts$|.tsx$)\")"
sample with circle ci here
....
"scripts":
"lint:script": "eslint -c eslintrc.js $(git diff --name-only --diff-filter=ACMRTUXB origin/master | grep -E \"(.js$|.ts$|.tsx$)\")"
will need grep fallback for empty result cases
....
"scripts":
"lint:style": "stylelint --config .stylelintrc.js $(git diff --name-only --diff-filter=ACMRTUXB origin/master | grep -E \"(.js$|.ts$|.tsx$)\" || echo \".stylelintrc.js\")"
NOTE: make sure our local branch is up to date (merge origin/master)
stylelint --config .stylelintrc.js$(git diff --name-only --diff-filter=ACMRTUXB origin/master | grep -E "(.js$ |.ts$|.tsx$)" || echo ".stylelintrc.js")
There is an error. Instead " we should use ' - otherwise it doesn't work on git-bush and git-actions (ubuntu)
Script tries to fix '.stylelintrc.js' instead of skipping! Echo doesn't work in expected way on git-bush (windows OS). Any ideas?