我正在开发一个 Vite + React + TypeScript 项目,并使用以下配置的 ESLint:
相关 ESLint 配置(.eslintrc.json)
{
"extends": [
"eslint:recommended",
"airbnb/hooks",
"airbnb-typescript",
"plugin:react/recommended",
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended"
],
"parserOptions": {
"project": "./tsconfig.json"
},
"rules": {
"react-hooks/exhaustive-deps": "off",
"@typescript-eslint/no-explicit-any": "off",
"import/order": [
"error",
{
"groups": [["external", "builtin"], "internal", "parent", "sibling", "index"],
"alphabetize": { "order": "asc", "caseInsensitive": true }
}
]
},
"settings": {
"import/resolver": {
"typescript": { "project": "./tsconfig.json" }
}
}
}
问题:
当我运行 ESLint(eslint . --ext .ts,.tsx
)时,没有出现任何错误,但我的一些队友(使用 Windows)看到了多个 linting 错误。
环境差异:
我: macOS(没有 ESLint 错误)
队友: Windows(看到 ESLint 错误)
这可能是路径解析、行尾 ( LF
vs. CRLF
) 或区分大小写的问题吗?任何见解都会有所帮助!
我尝试过的:
确保所有队友都拥有相同
node_modules
的eslint
版本。删除
node_modules
和package-lock.json
,然后重新安装(npm install
)。检查全局 ESLint 设置(禁用全局 ESLint)。
使用仅启用 ESLint 和 Prettier 的VS Code 。
手动运行 ESLint(在 VS Code 之外)。
真是愚蠢的问题
尝试在你的 package.json 上使用它