i'm actually working on a project and when I cloned my project on MacBook, after yarn
in shell for install packages, and atom .
for open my ATOM. ESLint got a "bug".
For example, for this code :
/*
* Package Import
*/
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { Link } from 'react-router-dom';
import classNames from 'classnames';
/*
* Code
*/
class UserDropdown extends Component {
/*
* PropTypes
*/
static propTypes = {
... // Code
}
/*
* State
*/
state = {
... // Code
};
/*
* Actions
*/
onLogOut = () => {
... // Code
};
ESLint tell me :
Error ESLint 'propTypes' is not defined. (no-undef) 22:10
Error ESLint 'state' is not defined. (no-undef) 32:3
Error ESLint 'onLogOut' is not defined. (no-undef) 52:3
I'm still using "babel-plugin-transform-class-properties": "^6.24.1"
,
and i declare it in my 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 my 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, and on Linux, it's OKAY. So, someone have an idea? If you need more code for understand, i can send it. Thanks you dude !
I had the same problem and it was because I had ESLint 4 installed. Check your package.json and make sure it’s not something like "eslint": "^3.19.0 || ^4.3.0"
. I’m using create-react-app, and it’s not compatible with ESLint 4 yet: https://github.com/facebookincubator/create-react-app/issues/2604
First you have to install babel-eslint as a dev dependency then in your .eslintrc file add:
"parser": "babel-eslint"
upgrade eslint
npm i -D eslint@latest
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With