【问题标题】:ESLint: Invalid Options when create-next-appESLint:create-next-app 时选项无效
【发布时间】:2022-01-19 11:28:18
【问题描述】:

我正在创建一个新的 Next.js 应用程序。 当我运行yarn create-next-app 并开始在 Visual Studio Code 中编写 javascript 代码时,ESlint 扩展在每次我输入数字时都会抛出一个错误。 当然,eslint 也不起作用。

错误是:

ESLint: Invalid Options: - Unknown options: env, parserOptions, rules - 'parserOptions' has been removed. Please use the 'overrideConfig.parserOptions' option instead. - 'rules' has been removed. Please use the 'overrideConfig.rules' option instead.. Please see the 'ESLint' output channel for details.

这是用于立即视觉识别的图像:

Eslint extension error on Visual Studio Code

这是我的package.json文件(Next.js给出的默认package.json):

{
  "name": "myApp",
  "private": true,
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start",
    "lint": "next lint"
  },
  "dependencies": {
    "next": "12.0.7",
    "react": "17.0.2",
    "react-dom": "17.0.2"
  },
  "devDependencies": {
    "eslint": "8.4.1",
    "eslint-config-next": "12.0.7"
  }
}

感谢您的帮助。

【问题讨论】:

    标签: javascript visual-studio-code next.js eslint


    【解决方案1】:

    通过在我的 settings.json vscode 文件中将esling.options 的内容包装到overrideConfig 中自行解决,如下所示:

    "eslint.options": {
        "overrideConfig": {
          "env": {
            "browser": true,
            "es6": true
          },
          "parserOptions": {
            "ecmaVersion": 2019,
            "sourceType": "module",
            "ecmaFeatures": {
              "jsx": true
            }
          },
          "rules": {
            "no-debugger": "off"
          }
        }
      },
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-07-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-11-28
      • 1970-01-01
      • 2020-09-11
      • 1970-01-01
      相关资源
      最近更新 更多