【问题标题】:Eslint is watching file that are in eslintignoreEslint 正在观看 eslintignore 中的文件
【发布时间】:2021-02-14 04:40:07
【问题描述】:

我有一个由 Webpack 捆绑的 TypeScript 项目。现在我想添加一些 Eslint。但是有一个问题 - Eslint 监视编译的文件,即使它们在 .eslintignore

.eslintignore:

./app

如您所见,Eslint 尝试查看 app 目录,但出现错误,因为我在 tsconfig.json

中排除了此目录
{
  "compilerOptions": {
    "module": "es2020",
    "target": "es6",
    "jsx": "react",
    "allowJs": true,
    "sourceMap": true,
    "moduleResolution": "node",
    "experimentalDecorators": true
  },
  "include": ["./**/*"],
  "exclude": [
    "node_modules/**/*",
    "app/**/*"
  ]
}

Eslint 不观看 node_modules,但它们不在 .eslintignore 中。但它会监视 app 目录,该目录位于 .eslintignore 中。我该如何解决?


编辑:

这是我的代码结构:

【问题讨论】:

    标签: javascript typescript webpack eslint


    【解决方案1】:

    根据文档,看起来我们不需要. 前面的点. 我认为我们只需将其保留为app

    .eslintignore:

    app
    // or blob pattern
    app/**/*.js
    

    【讨论】:

    • 如果我删除这个点,Eslint 将只查看./ 目录中的文件而不是更深的文件。我的意思是,没有点 ./views/app/appView.ts 是看不到的
    • 不确定你的意思,但你能分享你的项目结构吗?
    • 您是否只想忽略上面截图中静态目录中的所有 js 文件?
    • app 目录中的所有文件。这个目录是由 Webpack 创建的
    • 好的,谢谢。但正如我从文档中了解到的那样,只需添加 app 也应该有效。为什么不是?
    猜你喜欢
    • 1970-01-01
    • 2022-10-25
    • 2018-11-04
    • 2018-04-24
    • 1970-01-01
    • 2023-04-03
    • 1970-01-01
    • 2016-12-02
    • 2015-08-27
    相关资源
    最近更新 更多