Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 :(

like image 381
socker210 Avatar asked Dec 15 '18 11:12

socker210


1 Answers

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! :)

like image 172
Veljko Blagojevic Avatar answered Sep 18 '22 23:09

Veljko Blagojevic