gpt4 book ai didi

typescript - eslint 失败,无法读取配置文件 :/some/path/node_modules/@typescript-eslint/eslint-plugin/dist/configs/eslint-recommended

转载 作者:行者123 更新时间:2023-12-04 01:17:00 26 4
gpt4 key购买 nike

我正在按照说明从 here 设置 ESLint .
ESLint 失败并显示以下消息:

$ npm run lint

> IACS@1.0.0 lint /some/path/sscce-typescript-react-eslint
> eslint '*/**/*.{js,ts,tsx}' --quiet --fix

Error: Cannot read config file: /some/path/sscce-typescript-react-
eslint/node_modules/@typescript-eslint/eslint-plugin/dist/configs/eslint-recommended
Error: ENOENT: no such file or directory, open '/some/path/sscce-typescript-react-
eslint/node_modules/@typescript-eslint/eslint-plugin/dist/configs/eslint-recommended'
Referenced from: /some/path/sscce-typescript-react-eslint/node_modules/@typescript-
eslint/eslint-plugin/dist/index.js
Referenced from: /some/path/sscce-typescript-react-eslint/.eslintrc.js
确实存在具有以下名称的文件:
/some/path/sscce-typescript-react-eslint/node_modules/@typescript-eslint/eslint-plugin/dist/configs/eslint-recommended.js
...但显然 ESLint 并没有预料到 *.js扩展名,找不到文件。
最短的独立具体示例在 this github repo 中找到.
为了本网站的完整性,我的 package.json是:
{
"name": "IACS",
"version": "1.0.0",
"description": "react, typescript",
"main": "index.js",
"scripts": {
"dev": "webpack-dev-server --hot --inline --devtool source-map --progress --colors --port 8090",
"lint": "eslint '*/**/*.{js,ts,tsx}' --quiet --fix"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"@babel/core": "^7.8.7",
"@babel/plugin-proposal-class-properties": "^7.8.7",
"@babel/plugin-transform-async-to-generator": "^7.8.7",
"@babel/preset-env": "^7.8.7",
"@babel/preset-react": "^7.8.7",
"@babel/register": "^7.8.7",
"@babel/runtime": "^7.8.7",
"@types/jquery": "^3.5.1",
"@types/react": "^16.9.40",
"@types/react-dom": "^16.9.8",
"@typescript-eslint/eslint-plugin": "^3.7.1",
"@typescript-eslint/parser": "^3.7.1",
"babel-loader": "^8.0.5",
"cross-env": "^5.2.0",
"css-loader": "^2.1.0",
"eslint": "^5.16.0",
"eslint-config-airbnb": "^17.1.0",
"eslint-plugin-import": "^2.15.0",
"eslint-plugin-jsx-a11y": "^6.2.0",
"eslint-plugin-react": "^7.20.5",
"file-loader": "^3.0.1",
"html-webpack-plugin": "^3.2.0",
"null-loader": "^0.1.1",
"react-hot-loader": "^4.6.3",
"ts-loader": "^7.0.5",
"typescript": "^3.9.5",
"webpack": "^4.29.0",
"webpack-cli": "^3.3.*",
"webpack-dev-server": "^3.1.14"
},
"dependencies": {
"@babel/polyfill": "^7.8.7",
"jquery": "^3.5.1",
"react": "^16.8.0",
"react-dom": "^16.9.8"
}
}
和我的 .eslintrc.js是:
module.exports = {
parser: "@typescript-eslint/parser",
"plugins": ["@typescript-eslint"],
parserOptions: {
ecmaVersion: 2020,
sourceType: "module",
ecmaFeatures: {
jsx: true
}
},
settings: {
react: {
version: "detect"
}
},
extends: [
"plugin:react/recommended",
"plugin:@typescript-eslint/recommended"
],
rules: {
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"]
},
};

最佳答案

我最近在 windows 下遇到了同样的问题并更新了 eslint package.json 中的依赖项

"eslint": "^7.6.0"
解决了这个问题。
我希望这对您来说也是一个可行的解决方案。

关于typescript - eslint 失败,无法读取配置文件 :/some/path/node_modules/@typescript-eslint/eslint-plugin/dist/configs/eslint-recommended,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63170955/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com