socker210
socker210

Reputation: 137

eslint-config-standard with @babel/plugin-proposal-class-properties

Problem

I'm setting up eslint with eslint-config-standard.
I'm also using babel plugin that @babel/plugin-proposal-class-properties.

I tried lint my javascript files by "eslint index.js" command, and I got error that "[eslint]: Parsing error: Unexpected token =".

So i installed babel-eslint, and I updated the file ".eslintrc" like this:

{
    "extends": ["standard"],
    "parser": "babel-eslint",
    "rules": {
        "eol-last": 0
    }
}

The above configuration is solved error that "[eslint]: Parsing error: Unexpected token =", but i got new problem that eslint-config-standard configuration wasn't work anymore.

Question

I want to use eslint-config-standard with experimental javascript code.
But i don't know how to use those together and whether is it possible.

How to use those together?


p.s. Sorry for my bad English :(

Upvotes: 10

Views: 1314

Answers (1)

Veljko Blagojevic
Veljko Blagojevic

Reputation: 427

Yes it is possible. You just need to install a wrapper for Babel's parser used for ESLint and plugin.

https://github.com/babel/babel-eslint

https://github.com/babel/eslint-plugin-babel

$ npm install eslint babel-eslint eslint-plugin-babel --save-dev
# or
$ yarn add eslint babel-eslint eslint-plugin-babel -D

And then, inside your .eslintrc you need to add

"parser": "babel-eslint",
"plugins": ["babel"],

Also, if it doesn't work on the first try, you may need to restart your code editor. Good luck! :)

Upvotes: 3

Related Questions