我正在使用React和ESlint配置一个新的应用程序。在我的.eslintrc.js
文件中,我正在扩展airbnb并覆盖他们的一些规则。
.eslintrc.js
module.exports = {
"parser": "babel-eslint",
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module",
"cmaFeatures": {
"jsx": true,
"modules": true,
"experimentalObjectRestSpread": true
}
},
"env": {
"browser": true,
"node": true,
"jest": true
},
"plugins": [
"react",
"jest",
"styled-components-config"
],
"extends": "airbnb",
"rules": {
"arrow-body-style": "off",
"arrow-parens": "off",
"comma-dangle": "off",
"consistent-return": "off",
"eol-last": "error",
"jsx-one-expression-per-line": "off",
}
}
当我启动我的webpack开发服务器时,终端没有错误,但在我的IDE(VSCode)中它仍然给我一个错误。
ConversationsCard.js
import React from 'react';
export const ConversationsCard = (props) => {
const { number } = props;
return (
<li>Conversation {number}</li> // error here `Conversation ` must be placed on a new lineeslint(react/jsx-one-expression-per-line
);
};
我没有全局安装ESlint所以应该看看我的.eslintrc.js
。我似乎无法弄清楚出了什么问题。我已经尝试将"off"
改为0
和其他一些东西。任何见解都会非常感激。
所以问题是我没有使用规则的正确名称。 ESLint正在抛出一个错误
jsx-one-expression-per-line
但是当你在.eslintrc.js
中声明规则时,它应该被声明为这样
"react/jsx-one-expression-per-line": "off",