March 26, 2020
I want to use eslint to fix things in my code without changing the eslint config that is committed in my project. Why? I’m not sure.
Use npx to install the eslint plug-in I want:
Run eslint. The arguments add to the configuration in the project already. This targets one file:
npx eslint --plugin import --rule "import/order: 2" --rule "import/newline-after-import: 2" --fix src/components/form.tsx
--fix more files? This can find
.ts files changed in the last 15 commits. It is fragile and will blow up if a .ts file has been deleted.
npx eslint --plugin import --rule "import/order: 2" --rule "import/newline-after-import: 2" $(git diff --name-only HEAD HEAD~15 | grep .ts)
$(...)is a bash substituted command
git diffis getting names of files that changed in the last 15 commits