在我们的项目中,我们使用了tslint,但最近迁移到了eslint。运行命令
"eslint \"packages/**/*.{ts,tsx}\""
在我的本地计算机(Windows)上报告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);
但是这些类型似乎是正确的,typescript也没有抱怨它们。
是什么原因导致两台机器之间的起毛结果不同?