ESLint parses files under node_modules although they are excluded in the ESLint config

60 Views Asked by At

I'm working on a project that consists of a server and a client. Below you can see my project structure:

enter image description here

The server is a NestJS project, the client is a React Native project.

I have globally configured the ESLint in the SUNNY-DAYS-APP folder. See the code below:

eslintrc.js

module.exports = {
  parser: '@typescript-eslint/parser',
  parserOptions: {
    ecmaVersion: 2018,
    sourceType: 'module'
  },
  extends: [
    'plugin:react/recommended',
    'plugin:react-hooks/recommended',
    'plugin:@typescript-eslint/recommended',
    'plugin:import/errors',
    'plugin:import/warnings',
    'plugin:import/typescript',
    'plugin:jsx-a11y/recommended',
    'prettier',
    'plugin:prettier/recommended'
  ],
  ignorePatterns: [
    'node_modules/**/*',
    'client/node_modules/**/*',
    'client/vendor/**/*',
    'server/node_modules/**/*',
    'server/test/**/*',
    '**/node_modules/**'
  ],
  rules: {
    'import/no-unresolved': 'off',
    'no-unused-vars': 'off',
    '@typescript-eslint/no-explicit-any': 'off',
    '@typescript-eslint/no-unused-vars': 'off',
    '@typescript-eslint/no-var-requires': 'off',
    'react/prop-types': 'off',
    'react/jsx-uses-react': 'off',
    'react/react-in-jsx-scope': 'off',
    '@typescript-eslint/explicit-module-boundary-types': 'off'
  },
  settings: {
    react: {
      version: '18.2.0'
    }
  }
};

.eslintignore

node_modules/
.husky/
.vscode/
server/dist/
server/node_modules/
client/node_modules/

Also, here is my global package.json:

{
  "name": "sunny-days-app",
  "version": "1.0.0",
  "description": "Weather app",
  "author": "Serhii Chernikov",
  "license": "ISC",
  "scripts": {
    "format": "prettier --write \"./**/*.{js,jsx,ts,tsx,json,css,md}\"",
    "lint": "eslint --fix \"./**/*.{js,jsx,ts,tsx,json}\"",
    "prepare": "husky install"
  },
  "husky": {
    "hooks": {
      "pre-commit": "lint-staged --parallel"
    }
  },
  "lint-staged": {
    "./**/*.{js,ts,json,md}": [
      "prettier --write",
      "eslint"
    ],
    "client/**/*.{js,ts,jsx,tsx,json,css,md,html}": [
      "prettier --write"
    ],
    "client/**/*.{js,ts,jsx,tsx}": [
      "eslint"
    ],
    "server/**/*.{js,ts,json,md}": [
      "prettier --write"
    ],
    "server/**/*.{js,ts}": [
      "eslint"
    ]
  },
  "repository": {
    "type": "git",
    "url": "https://git.sysgears.com/sergey.chernikov/sunny-days-app.git"
  },
  "devDependencies": {
    "@typescript-eslint/eslint-plugin": "^6.13.2",
    "@typescript-eslint/parser": "^6.13.2",
    "eslint-config-prettier": "^9.1.0",
    "eslint-plugin-import": "^2.29.0",
    "eslint-plugin-jsx-a11y": "^6.8.0",
    "eslint-plugin-prettier": "^5.0.1",
    "eslint-plugin-react": "^7.33.2",
    "eslint-plugin-react-hooks": "^4.6.0",
    "husky": "^8.0.3",
    "lint-staged": "^15.2.0",
    "prettier": "^3.1.0"
  }
}

The problem is: when I run npm run lint I get this error:

> [email protected] lint
> eslint --fix "./**/*.{js,jsx,ts,tsx,json}"


Error while parsing /Users/sergeychernikov/Documents/Development/workspaces/vs-code-workspace/sunny-days-app/client/node_modules/react-native/index.js
Line 14, column 32: ';' expected.
`parseForESLint` from parser `/Users/sergeychernikov/Documents/Development/workspaces/vs-code-workspace/sunny-days-app/node_modules/@typescript-eslint/parser/dist/index.js` is invalid and will just be ignored

So it seems to me that ESLint parses the node_modules folder in the client, although I excluded it in the .eslintrc.js and eslintignore. Also, I'm confused with the second message (...is invalid and will just be ignored). Did I do something wrong in the configuration?

0

There are 0 best solutions below