简体   繁体   English

Reactjs typescript 禁用特定文件夹的 linting

[英]Reactjs typescript disable linting for a specific folder

I use charting_library for a react/typescript project.我将 charting_library 用于 react/typescript 项目。 I am getting these compilation errors due to linting and CL suggests ignoring these linting issues.由于 linting,我收到了这些编译错误,CL 建议忽略这些 linting 问题。

在此处输入图像描述

This is my tsconfig.json file这是我的 tsconfig.json 文件

    {
  "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我添加了一个名为 tsconfig.eslint.json 的单独文件,并尝试像这样放置文件夹路径

{
    "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?如何从 linting 中排除 charting_libray 文件夹?

I'm not sure about that tsconfig.eslint.json file.我不确定tsconfig.eslint.json文件。

Since you want eslint to ignore that folder, you should create a .eslintignore in the root of your project.由于您希望eslint忽略该文件夹,因此您应该在项目的根目录中创建一个.eslintignore

In .eslintignore file, add/append this line:.eslintignore文件中,添加/追加这一行:

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

the **/*.js part matches all .js files in charting_library and subfolders of that folder. **/*.js部分匹配charting_library和该文件夹的子文件夹中的所有.js文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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