gpt4 book ai didi

javascript - Eslint 无法读取配置文件

转载 作者:行者123 更新时间:2023-11-29 20:51:33 24 4
gpt4 key购买 nike

我正在设置我的第一个 eslint。出于某种原因,它在其他计算机上工作,除了我的..

我正在使用 VScode

一打开我的编辑器,我就收到以下消息:无法读取配置文件:
/Users/user/Documents/repos/project/C:/mydirectory/.eslintrc.json 错误:ENOENT:没有那个文件或目录,打开
来源:ESLint(扩展)

.eslintrc.json 在我的根目录中。

这是我的配置文件:

{
"parser": "babel-eslint",
"extends": "airbnb",
"env": {
"browser": true,
"jest": true
},
"rules": {
"quote-props": [2, "as-needed"],
"comma-dangle": "error",
"no-console": ["warn", { "allow": ["warn", "error"] }],
"no-debugger": "error",
"react/prop-types": 0,
"import/no-extraneous-dependencies": ["error", { "devDependencies": true }],
"object-curly-newline": ["error", { "multiline": true }],
"no-underscore-dangle": 0,
"jsx-a11y/click-events-have-key-events": 0,
"jsx-a11y/anchor-is-valid": 0,
"no-await-in-loop": 0,
"no-unused-expressions": ["error", { "allowShortCircuit": true, "allowTernary": true }],
"arrow-parens": ["error", "as-needed"],
"no-unused-vars": ["error", { "argsIgnorePattern": "^_" }],
"import/prefer-default-export": 0,
"react/no-find-dom-node": 0,
"no-shadow": 0,
"max-len": 0,
"consistent-return": 0,
"no-plusplus": 0,
"spaced-comment": 0,
"react/react-in-jsx-scope": 0,
"react/jsx-filename-extension": 0,
"indent": ["error", 4],
"react/jsx-indent": ["error", 4],
"react/jsx-indent-props": ["error", 4]
}
}

这是我的package.json

{
"name": "project",
"version": "0.1.0",
"private": true,
"dependencies": {
"@internal/project": "latest",
"@rematch/core": "^0.6.0",
"ag-grid": "^18.1.1",
"ag-grid-react": "^18.1.0",
"babel-core": "^6.26.3",
"babel-eslint": "^8.2.5",
"babel-jest": "^23.4.0",
"babel-loader": "^7.1.5",
"babel-plugin-transform-decorators": "^6.24.1",
"babel-plugin-transform-decorators-legacy": "^1.3.5",
"babel-preset-react-app": "^3.1.2",
"babel-runtime": "^6.26.0",
"classnames": "^2.2.6",
"css-loader": "^1.0.0",
"dotenv": "^6.0.0",
"dotenv-expand": "^4.2.0",
"eslint": "^5.1.0",
"eslint-config-react-app": "^2.1.0",
"eslint-loader": "^2.0.0",
"eslint-plugin-flowtype": "^2.50.0",
"eslint-plugin-import": "^2.13.0",
"eslint-plugin-jsx-a11y": "^6.1.0",
"eslint-plugin-react": "^7.10.0",
"graphql": "^0.13.2",
"graphql-tag": "^2.9.2",
"jest": "^23.4.0",
"lodash": "^4.17.10",
"object-assign": "^4.1.1",
"promise": "^8.0.1",
"prop-types": "^15.6.2",
"react": "^16.4.1",
"react-apollo": "^2.1.9",
"react-dom": "^16.4.1",
"react-jss": "^8.6.1",
"react-loadable": "^5.4.0",
"react-router-dom": "^4.3.1",
"react-scripts": "1.1.4"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"lint": "eslint --ext .js --ext .jsx src",
"eject": "react-scripts eject"
},
"jest": {
"collectCoverageFrom": [
"src/**/*.{js,jsx,mjs}"
],
"setupFiles": [
"<rootDir>/config/polyfills.js"
],
"testMatch": [
"<rootDir>/src/**/__tests__/**/*.{js,jsx,mjs}",
"<rootDir>/src/**/?(*.)(spec|test).{js,jsx,mjs}"
],
"testEnvironment": "node",
"testURL": "http://localhost",
"transform": {
"^.+\\.(js|jsx|mjs)$": "<rootDir>/node_modules/babel-jest",
"^.+\\.css$": "<rootDir>/config/jest/cssTransform.js",
"^(?!.*\\.(js|jsx|mjs|css|json)$)": "<rootDir>/config/jest/fileTransform.js"
},
"transformIgnorePatterns": [
"[/\\\\]node_modules[/\\\\].+\\.(js|jsx|mjs)$"
],
"moduleNameMapper": {
"^react-native$": "react-native-web"
},
"moduleFileExtensions": [
"web.js",
"js",
"json",
"web.jsx",
"jsx",
"node",
"mjs"
]
},
"babel": {
"presets": [
"react-app"
],
"plugins": [
"transform-decorators-legacy"
]
},
"eslintConfig": {
"extends": "react-app"
},
"devDependencies": {
"eslint-config-airbnb": "^17.0.0"
}
}

我已经尝试了几种方法,包括:添加 { "root": true },从项目中打开,安装/卸载 eslint 扩展

最佳答案

看起来这与 VSCode 相关,配置文件应该使用您的配置路径进行设置。见指南here

eslintOptions.configFile 应该是配置文件的绝对路径。

关于javascript - Eslint 无法读取配置文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51617453/

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