简体   繁体   中英

Reactjs typescript disable linting for a specific folder

I use charting_library for a react/typescript project. I am getting these compilation errors due to linting and CL suggests ignoring these linting issues.

在此处输入图像描述

This is my tsconfig.json file

    {
  "compilerOptions": {
    "baseUrl": "src",
    "target": "es5",
    "lib": [
      "dom",
      "dom.iterable",
      "esnext"
    ],
    "downlevelIteration": true,
    "allowJs": false,
    "skipLibCheck": true,
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "noFallthroughCasesInSwitch": true,
    "module": "esnext",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "noEmit": true,
    "jsx": "react-jsx",
    "types":[
      "node",
      "webpack-env" // here
    ]
  },
  "include": [
    "src",
    "**/*.ts",
    "**/*.tsx",
    "types/*.d.ts",
    "**/*.d.ts"
  ]
}

I have added a separate file called tsconfig.eslint.json and tried to put the folder path like this

{
    "extends": "./tsconfig.json",
    "exclude": ["./src/pages/instuments/technicalAnalysis/charting_library/*js"]
  }

But this doesn't exclude the folder. How do I exclude the charting_libray folder from linting?

I'm not sure about that tsconfig.eslint.json file.

Since you want eslint to ignore that folder, you should create a .eslintignore in the root of your project.

In .eslintignore file, add/append this line:

src/pages/instuments/technicalAnalysis/charting_library/**/*.js

the **/*.js part matches all .js files in charting_library and subfolders of that folder.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM