How to config ESLint for React on Atom Editor

后端 未结 5 752
自闭症患者
自闭症患者 2020-12-12 20:52

In Atom Editor I installed the following plugins

  1. linter
  2. linter-eslint

It seems they don\'t recognize the JSX syntaxis.

I have

5条回答
  •  隐瞒了意图╮
    2020-12-12 20:57

    To get Eslint working nicely with React.js:

    1. Install linter & linter-eslint plugins
    2. Run npm install eslint-plugin-react
    3. Add "plugins": ["react"] to your .eslintrc config file
    4. Add "ecmaFeatures": {"jsx": true} to your .eslintrc config file

    Here is an example of a .eslintrc config file:

    {
        "env": {
            "browser": true,
            "node": true
        },
    
        "globals": {
            "React": true
        },
    
        "ecmaFeatures": {
            "jsx": true
        },
    
        "plugins": [
            "react"
        ]
    }
    

    I am using Eslint v1.1.0 at the moment.

    Side note: I had to install both eslint and eslint-plugin-react as project dependencies (e.g., npm install eslint eslint-plugin-react --save-dev). Hopefully this helps.

提交回复
热议问题