为什么 Eslint 在不同机器上报告的结果不同?

时间:2021-03-26 14:28:53

标签: reactjs typescript eslint tslint

在我们的项目中,我们使用的是 tslint,但最近迁移到了 eslint。在我的本地机器 (Windows) 上运行命令 "eslint \"packages/**/*.{ts,tsx}\"" 会报告 1 个错误和 409 个警告,但在 linux 机器上运行相同的命令会报告 1 个错误和 2746 个警告。

在两台机器上运行带有 --env-info 标志的 linter 的结果是一样的

Node version: v12.16.1
npm version: v6.13.4
Local ESLint version: v7.22.0 (Currently used)
Global ESLint version: Not found

插件的版本似乎也匹配。

文件夹结构如下:

.eslintrc.js
tsconfig.json
package.json
.eslintignore
packages/ (contains subprojects which don't have their own eslint config files)

配置文件的内容:

.eslintrc.js 文件

module.exports = {
    "root": true,
    "env": {
        "browser": true,
        "node": true,
    },
    "parser": "@typescript-eslint/parser",
    "parserOptions": {
        "project": "./tsconfig.json",
        "sourceType": "module"
    },
    "plugins": [
        "eslint-plugin-jsdoc",
        "eslint-plugin-import",
        "eslint-plugin-react",
        "eslint-plugin-prefer-arrow",
        "react-hooks",
        "@typescript-eslint"
    ],
    "settings": {
        "react": {
            "version": "17.0.0",
        },
    },
    "rules": {...}
}

tsconfig.json

{
  "compilerOptions": {
    "target": "es5",
    "lib": [
      "dom",
      "dom.iterable",
      "esnext"
    ],
    "allowJs": true,
    "skipLibCheck": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "noEmit": true,
    "esModuleInterop": true,
    "module": "esnext",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "strictPropertyInitialization": false,
    "jsx": "preserve"
  },
  "exclude": [
    "node_modules",
    "**/*.md",
    "**/dist/**"
  ],
  "include": [
    "next-env.d.ts",
    "**/*.ts",
    "**/*.tsx"
  ]
}

我还检查了 Linux 机器报告的一些警告,但我的本地 Windows 机器没有。例如,以下行都报告警告“任何类型值的不安全调用”

const {breakPoints} = useTheme();
const currentBreak = useCurrentBreakPoint(breakPoints);

但类型似乎是正确的,打字稿也没有抱怨它们。

什么可能导致两台机器之间的 linting 结果存在差异?

0 个答案:

没有答案
相关问题