如何在Atom Editor上配置ESLint for React [英] How to config ESLint for React on Atom Editor

查看:57
本文介绍了如何在Atom Editor上配置ESLint for React的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Atom编辑器中,我安装了以下插件

In Atom Editor I installed the following plugins

  1. 线性
  2. linter-eslint

似乎他们不认识JSX语法.

It seems they don't recognize the JSX syntaxis.

我可以在命令行上使用它,但是必须使用其他插件,例如esprima-fbeslint-plugin-react.似乎没有适用于Atom Editor的插件,并且想知道你们中是否有人知道解决此问题的方法.

I have it working on the command line but had to use other plugins like esprima-fb and eslint-plugin-react. Looks like there are no such plugins for Atom Editor and would like to know if anyone of you knows a way to hack around this.

推荐答案

要使Eslint与React.js良好配合:

To get Eslint working nicely with React.js:

  1. 安装lint& linter-eslint插件
  2. 运行npm install eslint-plugin-react
  3. "plugins": ["react"]添加到您的.eslintrc配置文件中
  4. "ecmaFeatures": {"jsx": true}添加到您的.eslintrc配置文件中
  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

以下是.eslintrc配置文件的示例:

Here is an example of a .eslintrc config file:

{
    "env": {
        "browser": true,
        "node": true
    },

    "globals": {
        "React": true
    },

    "ecmaFeatures": {
        "jsx": true
    },

    "plugins": [
        "react"
    ]
}

此刻我正在使用Eslint v1.1.0.

I am using Eslint v1.1.0 at the moment.

旁注: 我必须同时安装eslint和eslint-plugin-react作为项目依赖项(例如npm install eslint eslint-plugin-react --save-dev).希望这会有所帮助.

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.

这篇关于如何在Atom Editor上配置ESLint for React的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆