Babel-eslint: static class properties false positive

Created on 26 May 2016  Â·  2Comments  Â·  Source: babel/babel-eslint

I've done quite a bit of googling on this, I'm trying to write a react component and babel-eslint does NOT like static class properties. I'm about 70% sure I've just misconfigured the .eslintrc file....

screen shot 2016-05-26 at 10 54 20 am

$ npm run lint

> [email protected] lint ~/personal_repos/billistic
> eslint ./public/src/components/glyph

~/personal_repos/billistic/public/src/components/glyph/index.js
  4:23  error  Parsing error: Unexpected token =

✖ 1 problem (1 error, 0 warnings)


npm ERR! Darwin 15.5.0
npm ERR! argv "~/.nvm/versions/node/v5.11.0/bin/node" "~/.nvm/versions/node/v5.11.0/bin/npm" "run" "lint"
npm ERR! node v5.11.0
npm ERR! npm  v3.8.6

.eslintrc

---
extends: eslint-config-airbnb
env:
  browser: true
  node: true
  mocha: true

parserOptions:
  ecmaVersion: 7

rules:
  react/no-multi-comp: 0
  react/contextTypes: 1
  import/default: 0
  import/no-duplicates: 0
  import/named: 0
  import/namespace: 0
  import/no-unresolved: 0
  import/no-named-as-default: 2
  comma-dangle: 0
  indent:
  - 2
  - 2
  - SwitchCase: 1
  no-console: 0
  no-alert: 0

plugins:
  - react
  - import

settings:
  import/parser: babel-eslint
  import/resolve:
    moduleDirectory:
    - node_modules
    - src

globals:
  __DEVELOPMENT__: true
  __CLIENT__: true
  __SERVER__: true
  __DISABLE_SSR__: true
  __DEVTOOLS__: true
  socket: true
  webpackIsomorphicTools: true

.babelrc

{
  "presets": ["react", "es2015", "stage-1"]
}

Most helpful comment

Your config should contain

parser: babel-eslint

http://eslint.org/docs/user-guide/configuring#specifying-parser

I'm also not sure what this is doing, never seen that before:

settings:
  import/parser: babel-eslint

All 2 comments

Your config should contain

parser: babel-eslint

http://eslint.org/docs/user-guide/configuring#specifying-parser

I'm also not sure what this is doing, never seen that before:

settings:
  import/parser: babel-eslint

Solved it by going back to json and adding in things one at a time. I tried to switch it back to yaml but it breaks when I do. ah well, it works this way.

{
  "extends": [
    "eslint:recommended",
    "plugin:react/recommended"
  ],

  "parser": "babel-eslint",
  "parserOptions": {
    "ecmaVersion": 6,
    "sourceType": "module"
  },

  "rules": {
    "no-console": 0,
    "no-alert": 0,
    "indent": ["error", 2, { "SwitchCase": 1 }],
    "import/default": 0,
    "import/no-duplicates": 0,
    "import/named": 0,
    "import/namespace": 0,
    "import/no-unresolved": 0,
    "import/no-named-as-default": 2
  },

  "globals": {
    "__DEVELOPMENT__": true,
    "__CLIENT__": true,
    "__SERVER__": true,
    "__DISABLE_SSR__": true,
    "__DEVTOOLS__": true,
    "socket": true,
    "webpackIsomorphicTools": true
  },

  "plugins": [
    "babel",
    "react",
    "import"
  ]
}
Was this page helpful?
0 / 5 - 0 ratings