【问题标题】:indentation error in eslint,es6eslint,es6 中的缩进错误
【发布时间】:2016-07-28 19:17:36
【问题描述】:

es6代码语法如下,

import React from 'react';

const App = ({ children }) => {
    let childrenData;
    if (children) {
        childrenData = (<div>{children}</div>);
    }
    return childrenData;
};

export default App;

eslint 出错

  5:2  error  Expected indentation of 4 space character but found 0  indent
  6:2  error  Expected indentation of 4 space character but found 0  indent
  7:3  error  Expected indentation of 4 space character but found 0  indent
  9:2  error  Expected indentation of 4 space character but found 0  indent

我的规则引擎看起来像这样,

"indent": [2, 4, {'SwitchCase': 1}],
"max-len": ["error", 200, 4],
"object-shorthand": ["error", "always", { "ignoreConstructors": true }],
"one-var": ["error", {
  "var": "always", // Exactly one var declaration per function
  "let": "always", // Exactly one let declaration per block
  "const": "never" // Exactly one declarator per const declaration per block
}],

你能帮我看看我哪里错了吗???

【问题讨论】:

  • 确定错误与该文件有关吗?
  • 你是不是不小心使用了标签页?
  • 是的,仅来自文件...没有标签 ..
  • 你用的是什么版本的 eslint?您也可以在此处针对最新的 eslint 版本测试您的代码。 eslint.org/demo
  • 你解决了吗?我也遇到了同样的问题

标签: ecmascript-6 webpack webpack-dev-server eslint


【解决方案1】:

Switchcase 在单引号之间,它应该在双引号之间,因为这是一个 JSON 文件。

【讨论】:

    猜你喜欢
    • 2021-08-11
    • 1970-01-01
    • 2022-08-18
    • 2019-01-16
    • 2018-08-19
    • 2018-07-24
    • 1970-01-01
    • 1970-01-01
    • 2018-05-22
    相关资源
    最近更新 更多