尝试运行ESLint脚本

问题描述

尝试运行皮棉脚本时遇到问题 "lint:fix": "eslint --fix --ext .js,.jsx .” npm run lint:fix

我不断收到此错误提示,这似乎只是自从按照airbnb规则更新我的eslint部门以来(我使用npx install-peerdeps --dev eslint-config-airbnb

错误:

/Users/ME/Projects/MYPROJECT/node_modules/eslint/bin/eslint.js:93
        } catch {
                ^
SyntaxError: Unexpected token {
    at createScript (vm.js:80:10)
    at Object.runInThisContext (vm.js:139:10)
    at Module._compile (module.js:607:28)
    at Object.Module._extensions..js (module.js:654:10)
    at Module.load (module.js:556:32)
    at tryModuleLoad (module.js:499:12)
    at Function.Module._load (module.js:491:3)
    at Function.Module.runMain (module.js:684:10)
    at startup (bootstrap_node.js:187:16)
    at bootstrap_node.js:608:3

但是,可以按预期运行以下命令:npx eslint specific/file.js —fix

这是我的.eslintrc文件:

{
    "env": {
        "browser": true,"es2020": true
    },"extends": ["plugin:react/recommended","airbnb","prettier","prettier/react"],"parser": "babel-eslint","parserOptions": {
        "ecmaFeatures": {
            "jsx": true
        },"ecmaVersion": 2018,"sourceType": "module"
    },"plugins": ["react"],"rules": {}
}

这些是我目前的陪同部门:

    "eslint": "7.10.0","eslint-config-airbnb": "18.2.0","eslint-config-prettier": "^2.9.0","eslint-plugin-import": "2.22.1","eslint-plugin-jsx-a11y": "6.3.1","eslint-plugin-react": "7.21.3","eslint-plugin-react-hooks": "4.1.2","eslint-watch": "3.1.2",

任何帮助都会很棒!非常感谢!

解决方法

Optional catch binding在ES2019中引入。

指定的ESLint版本应与supports it(10或更高版本)的节点版本一起使用。

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...