reactjs - Bug ESlint with class React, example : 'state' is not defined. (no-undef) -
i'm working on project , when cloned project on macbook, after yarn
in shell install packages, , atom .
open atom. eslint got "bug".
for example, code :
/* * package import */ import react, { component } 'react'; import proptypes 'prop-types'; import { link } 'react-router-dom'; import classnames 'classnames'; /* * code */ class userdropdown extends component { /* * proptypes */ static proptypes = { ... // code } /* * state */ state = { ... // code }; /* * actions */ onlogout = () => { ... // code };
eslint tell me :
error eslint 'proptypes' not defined. (no-undef) 22:10 error eslint 'state' not defined. (no-undef) 32:3 error eslint 'onlogout' not defined. (no-undef) 52:3
i'm still using "babel-plugin-transform-class-properties": "^6.24.1"
, , declare in brunch-config :
my brunch-config.coffee
plugins: babel: presets: ['latest', 'react'] plugins: [ 'transform-class-properties' 'transform-object-rest-spread' ]
my .eslintrc
{ "extends": "airbnb", "parser": "babel-eslint", "env": { "browser": true }, "rules": { "brace-style": ["error", "stroustrup"], "no-param-reassign": ["error", { "props": false }], "no-mixed-operators": ["error", { "allowsameprecedence": true }], "jsx-a11y/no-static-element-interactions": "off", "react/jsx-filename-extension": "off", "react/forbid-prop-types": "off", "react/no-unescaped-entities": "off", "linebreak-style": "off" }, "settings": { "import/resolver": { "node": { "paths": ["app/"] } } } }
and packages.json
"devdependencies": { "auto-reload-brunch": "^2.7.1", "autoprefixer": "^6.7.7", "babel-brunch": "^6.1.1", "babel-eslint": "^7.2.3", "babel-plugin-transform-class-properties": "^6.24.1", "babel-plugin-transform-object-rest-spread": "^6.23.0", "babel-preset-react": "^6.24.1", "babel-register": "^6.24.1", "babel-resolver": "^1.1.0", "brunch": "^2.10.9", "chai": "^3.5.0", "enzyme": "^2.8.2", "eslint": "^3.19.0", "eslint-config-airbnb": "^14.1.0", "eslint-import-resolver-node": "^0.3.0", "eslint-plugin-import": "^2.2.0", "eslint-plugin-jsx-a11y": "^4.0.0", "eslint-plugin-react": "^6.10.3",
i'm working on 2 computer, , on linux, it's okay. so, have idea? if need more code understand, can send it. dude !
i had same problem , because had eslint 4 installed. check package.json , make sure it’s not "eslint": "^3.19.0 || ^4.3.0"
. i’m using create-react-app, , it’s not compatible eslint 4 yet: https://github.com/facebookincubator/create-react-app/issues/2604
Comments
Post a Comment