The answer is: do not run Eslint globally for all files.
I think what you want is to prevent the offending code to be commited to repository (of course, it's already there, commited before linting was introduced, but you want to prevent new commits to be made that contain eslint errors).
This means that it makes sense to run Eslint only on those files, that have changes in them and are about to be commited to repo, i.e. staged files.
There is a package that does exactly that, lint-staged.
In your package.json, you add a configuration like this:
"scripts": {
"lint": "eslint --fix",
},
"lint-staged": {
"*.{js,mjs,cjs,jsx,ts,tsx,vue}": [
"npm run lint"
]
}
Then when you run npm run lint-staged
, only the files that are staged will be passed as argument to lint command, so only those will be linted.
Usually it makes sense to combine lint-staged with husky to automatically run linting and some other checks like formatting as a pre-commit hook (i.e. each time when you try to make a commit those checks will be executed)
This way you can make sure that no code that contains errors will be commited.