I have the following scripts and eslint rules in my package.json:
"scripts": {
"build": "tsc",
"test": "jest tests/** --coverage",
"lint": "eslint './src/**/*.{js,ts,tsx}' --quiet --fix",
"prettier": "prettier --check './**/*.ts'",
"prettier-format": "prettier --config .prettierrc './**/*.ts' --write"
...
},
"lint-staged": {
"**/*.{js,jsx,ts,tsx}": [
"prettier --config .prettierrc './**/*.ts' --write",
"prettier --check './**/*.ts'",
"eslint './src/**/*.{js,ts,tsx}' --quiet --fix"
]
},
"pre-commit": [
"lint-staged"
],
When I run npm run lint I do not get any errors. But when my pre-commit hook runs, I get an error on the .eslintrc.js file:
/.../api/.eslintrc.js
1:15 error Require statement not part of import statement @typescript-eslint/no-var-requires
The line of code it's referencing has the following:
const _path = require('path');
I know I can instrument the code to force eslint to ignore this. But I do not understand why eslint is parsing .eslintrc.js in the first place as it is not located in the src folder (it's on the root folder on the same level of package.json).