Visual Studio Code: Fixing ESLint says “Parsing error: The keyword ‘let’ is reserved.”

If you install the esline plugin in Visual Studio Code, you get weird errors:

ESLint says "Parsing error: The keyword 'let' is reserved."

To fix this, you need to set up a config file in the root of your project.

You can do this by running:

eslint --init

Here is an example file you can also use:

module.exports = {
    "env": {
        "es6": true
    },
    "extends": "eslint:recommended",
    "parserOptions": {
        "ecmaFeatures": {
            "experimentalObjectRestSpread": true,
            "jsx": true
        },
        "sourceType": "module"
    },
    "plugins": [
        "react"
    ],
    "rules": {
        "indent": [2, 2],
        "linebreak-style": [
            "error",
            "windows"
        ],
        "quotes": [
            "error",
            "double"
        ],
        "semi": [
            "error",
            "always"
        ]
    }
};

If you want a good Javascript book, I got a lot out of Secrets of the Javascript Ninja.

1 reply

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *