Eslint 配置错误。 ESLint 找不到要扩展的配置 "dev"

Eslint config error. ESLint couldn't find the config "dev" to extend from

我正在尝试将 eslint 设置为 TS 反应项目,但是 运行 进入错误:

> eslint .


Oops! Something went wrong! :(

ESLint: 6.8.0.

ESLint couldn't find the config "dev" to extend from. Please check that the name of the config is correct.

The config "dev" was referenced from the config file in "C:\Users\User\Desktop\priority-style-react\example\node_modules\@csstools\convert-colors\package.json".

If you still have problems, please stop by https://gitter.im/eslint/eslint to chat with the team.

我的 package.json 看起来像:

{
  "name": "######",
  "version": "####",
  "description": "none",
  "author": "iLavs",
  "license": "MIT",
  "repository": "#####",
  "main": "dist/index.js",
  "module": "dist/index.es.js",
  "jsnext:main": "dist/index.es.js",
  "engines": {
    "node": ">=8",
    "npm": ">=5"
  },
  "scripts": {
    "lint": "eslint .",
    "build": "rollup -c",
    "start": "rollup -c -w",
  },
  "dependencies": {
    "classnames": "^2.2.6"
  },
  "peerDependencies": {
    "prop-types": "15.x",
    "react": "^15.0.0 || ^16.0.0",
    "react-dom": "^15.0.0 || ^16.0.0"
  },
  "devDependencies": {
    "@babel/core": "^7.8.4",
    "@babel/plugin-proposal-class-properties": "^7.8.3",
    "@babel/preset-env": "^7.8.4",
    "@babel/preset-react": "^7.8.3",
    "@babel/preset-typescript": "^7.8.3",
    "@svgr/rollup": "^2.4.1",
    "awesome-typescript-loader": "^5.2.1",
    "babel-loader": "^8.0.6",
    "babel-plugin-import": "^1.12.0",
    "babel-plugin-require-context-hook": "^1.0.0",
    "babel-runtime": "^6.26.0",
    "cross-env": "^5.2.1",
    "declaration-bundler-webpack-plugin": "^1.0.3",
    "eslint": "^6.8.0",
    "eslint-config-airbnb": "^18.0.1",
    "eslint-plugin-import": "^2.20.1",
    "eslint-plugin-jsx-a11y": "^6.2.3",
    "eslint-plugin-react": "^7.18.3",
    "eslint-plugin-react-hooks": "^1.7.0",
    "markdown-loader": "^5.1.0",
    "mini-css-extract-plugin": "^0.7.0",
    "postcss-loader": "^2.1.6",
    "prettier": "^1.19.1",
    "react": "^16.12.0",
    "rollup": "^1.27.1",
    "rollup-plugin-babel": "^4.3.3",
    "rollup-plugin-commonjs": "^10.1.0",
    "rollup-plugin-node-resolve": "^5.2.0",
    "rollup-plugin-peer-deps-external": "^2.2.0",
    "rollup-plugin-postcss": "^2.0.3",
    "rollup-plugin-typescript2": "^0.25.2",
    "rollup-plugin-url": "^3.0.0",
    "sass-loader": "^7.1.0",
    "ts-loader": "^2.3.7",
    "ts-loader-decleration": "^0.10.4",
    "typescript": "^3.7.2",
    "url-loader": "^2.0.1"
  },
  "files": [
    "dist",
    "fonts",
    "style"
  ]
}

我的.eslintrc.js:

module.exports = {
  env: {
    browser: true,
    es6: true,
  },
  extends: [
    'plugin:react/recommended',
    'airbnb',
  ],
  globals: {
    Atomics: 'readonly',
    SharedArrayBuffer: 'readonly',
  },
  parser: '@typescript-eslint/parser',
  parserOptions: {
    ecmaFeatures: {
      jsx: true,
    },
    ecmaVersion: 2018,
    sourceType: 'module',
  },
  plugins: [
    'react',
    '@typescript-eslint',
  ],
  rules: {
  },
};

有人可以帮助我吗?

终于,我解决了这个问题。我删除了我的 package-lock.file 并重新安装了所有依赖项。问题解决了。

这可能是个问题,因为节点模块上的 eslint 运行。尝试将 --ignore-pattern node_modules 添加到您的 eslint 命令

如果您 运行 在 CI 管道中使用 docker,请记住将 eslintrc.js 文件复制到图像中。

COPY .eslintrc.js ./ 在你的 Dockerfile 中 ;)