4

I’m having issues when trying to run a lint script "lint:fix": "eslint --fix --ext .js,.jsx .” npm run lint:fix

I keep getting this error prompted and it only seems to have come about since updating my eslint deps in line with the airbnb rules (I used npx install-peerdeps --dev eslint-config-airbnb)

Error:

/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

However, running the following works as expected: npx eslint specific/file.js —fix



This is my .eslintrc file:



{
    "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": {}
}

And these are my current eslint deps:



    "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",

Any help would be great!

 Thanks a lot!

1 Answer 1

3

Optional catch binding was introduced in ES2019.

The specified ESLint version should be used with Node version that supports it (10 or later).

Sign up to request clarification or add additional context in comments.

5 Comments

changing my ecmaVersion to 2019 still seems to have this issue. Any ideas what the problem may be?
Sorry, was in the middle of editing. The problem is that Node version is too old for this ESLint ersion.
No problem! I'm also using node v12.18.4
The error clearly suggests that the problem is in Node itself. This may happen if there are multiple Node versions for some reason, this may depend on your environment. Make sure this specific command uses the one you expect, node -e "console.log(process.execPath,process.version)" && node node_modules/eslint/bin/eslint.js .. Alternatively, a plain way is to edit (and then revert it) node_modules/eslint/bin/eslint.js and do console.log(process.execPath,process.version) there.
You're right! It was a node issue, not an eslint problem! The version in node in package.json vs the version I had running locally were years apart! Thanks a lot for your help!!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.