Home > Mobile >  Reactjs typescript disable linting for a specific folder
Reactjs typescript disable linting for a specific folder

Time:01-05

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.

enter image description here

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?

CodePudding user response:

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.

  •  Tags:  
  • Related