将ESLint与Airbnb样式和制表符一起使用(React.js)

ver*_*otr 3 javascript reactjs eslint webpack

我正在研究React.js应用程序而我正在尝试将我的代码丢失.我将ESLint与Airbnb风格一起使用,但我有以下错误:

../src/Test.jsx
  4:2   error  Unexpected tab character                                no-tabs
  5:2   error  Unexpected tab character                                no-tabs
  5:3   error  Expected indentation of 2 space characters but found 0  react/jsx-indent
  6:2   error  Unexpected tab character                                no-tabs
Run Code Online (Sandbox Code Playgroud)

这是我的代码:

Test.jsx:

import React from 'react';

function Test() {
    return (
        <h1>Test</h1>
    );
}

export default Test;
Run Code Online (Sandbox Code Playgroud)

.eslintrc:

{
  "env": {
    "browser": true,
    "es6": true,
    "node": true
  },
  "extends": "airbnb",
  "parser": "babel-eslint",
  "rules": {
    "indent": [2, "tab", { "SwitchCase": 1, "VariableDeclarator": 1 }],
    "react/prop-types": 0,
    "react/jsx-indent-props": [2, "tab"],
  }
}
Run Code Online (Sandbox Code Playgroud)

如您所见,我想缩进标签.

webpack.config.js:

loaders: [{
  test: /\.jsx$|\.js$/,
  loaders: ["babel-loader", "eslint-loader"],
  exclude: /node_modules/
},
...
]
Run Code Online (Sandbox Code Playgroud)

我也试图缩进为什么2个空格,没有成功.我真的不明白为什么我有这些错误.你有好主意吗?

谢谢!

ver*_*otr 8

正如@ mark-willian告诉我的那样,我在.eslintrc中添加了一些行并且它有效:

{
    "env": {
        "browser": true,
        "es6": true,
        "node": true
    },
    "extends": "airbnb",
    "parser": "babel-eslint",
    "rules": {
        "indent": [2, "tab", { "SwitchCase": 1, "VariableDeclarator": 1 }],
        "no-tabs": 0,
        "react/prop-types": 0,
        "react/jsx-indent": [2, "tab"],
        "react/jsx-indent-props": [2, "tab"],
    }
}
Run Code Online (Sandbox Code Playgroud)

谢谢你的所有答案.