ESLint规则被忽略

时间:2017-05-25 11:45:33

标签: eslint

只是试图让SFC和ESLint抱怨

我在.eslinrc

中有规则
{
  "env": {
    "es6": true,
    "browser": true
  },
  "extends": "airbnb",
  "rules": {
    "semi": [2, "never"],
    "no-unexpected-multiline": 2,
    "no-console": 0,
    "react/prefer-stateless-function": [0, {
      "ignorePureComponents": true
    }],
    "comma-dangle": ["error", "never"],
    "arrow-body-style": ["error", "never"]
  }
}

甚至在错误的正上方添加了/* eslint arrow-body-style: ["error", "never"]*/,其他人遇到了这个问题?

我做错了什么

ESLINT RULE PLZ!!

1 个答案:

答案 0 :(得分:2)

您可以在导出之前使用禁用下一行:

// eslint-disable-next-line arrow-body-style
export onst Hi = () > {
 [...]
}

也许你也可以尝试在.eslinrc中用"arrow-body-style": ["error", "never"]替换"arrow-body-style": "off"

顺便说一句,如果您只是想避免此错误,请使用以下代码替换您的代码:

import React from 'react';

export const Hi = () => (
  <div>
    <h1>Hi</h1>
  </div>
);

export default Hi;