【问题标题】:JSX Support doesn't work anymore with gulp-eslint 5.0.0JSX 支持不再适用于 gulp-eslint 5.0.0
【发布时间】:2019-04-30 01:28:00
【问题描述】:

我已经升级到当前的 gulp-eslint 版本 5.0.0。

当我现在尝试 lint 我的代码时,我在 JSX 代码的开头遇到了常见的错误:

127:26 error Parsing error: Unexpected token =

我认为这是 eslint 本身的问题。所以我尝试使用全局安装的 eslint (5.9.0) 对我的代码进行 lint,并且在 jsx 部分没有错误。所有其他 linting 都是相同的。

我的eslintrc.json 的:

{
    "extends": "eslint:recommended",
    "parserOptions": {
        "ecmaVersion": 6
    },
    "rules": {
    },
    "env": {
        "node": true
    }
}

还有一个向下的文件夹:

{
    "extends": ["../.eslintrc.json", "plugin:react/recommended"],
    "settings": {
        "react": {
            "pragma": "React",
            "version": "15.0"
        }
    },
    "plugins": ["react"],
    "parserOptions": {
        "ecmaVersion": 5,
        "ecmaFeatures": {
            "jsx": true
        }
    },
    "env": {
        "node": false,
        "browser": true
    },
    "globals": {
        "angular": true,
        "React": true,
        "ReactDOM": true,
        "Uint8Array": true
    },
    "rules": {
        "jsx-quotes": [1, "prefer-single"],
        "react/prop-types": 0,
        "react/no-deprecated": 0
    }
}

附加信息:gulp-eslint 3.x 和 4.x 在相同的配置下工作正常。

有什么提示或建议吗?

【问题讨论】:

    标签: node.js gulp jsx eslint gulp-eslint


    【解决方案1】:

    经过数小时的搜索解决了! package-lock.json 中似乎存在旧依赖项。

    我删除了package-lock.json 并重新安装了所有带有npm i 的软件包。现在它按预期工作了。

    【讨论】:

      猜你喜欢
      • 2015-12-01
      • 2023-03-20
      • 2013-05-26
      • 2016-12-24
      • 2017-12-01
      • 1970-01-01
      • 2014-11-04
      • 2021-10-12
      • 2019-03-05
      相关资源
      最近更新 更多