gpt4 book ai didi

javascript - 如果 div 为空,Eslint airbnb 会强制执行自关闭 div 标签。如何禁用此规则?

转载 作者:行者123 更新时间:2023-11-30 06:21:15 25 4
gpt4 key购买 nike

如果 div 元素为空,Airbnb linting 规则会删除结束的 div 标签,例如:

<div></div>

被替换为

<div/>

我的 .eslintrc 文件是这样的:

{
"extends": ["airbnb", "plugin:prettier/recommended"],
"parser": "babel-eslint",
"parserOptions": {
"ecmaVersion": 9,
"ecmaFeatures": {
"impliedStrict": true,
"jsx": true
}
},
"env": {
"node": true,
"es6": true
},
"plugins": ["react"],
"rules": {
"react/jsx-filename-extension": ["off"],
"react/prefer-stateless-function": ["off"],
"arrow-body-style": ["error", "always"],
"react/self-closing-comp": [
"error",
{
"component": true,
"html": false
}
]
}
}

最佳答案

“react/self-closing-comp”设置为“off”。

 {
"extends": ["airbnb", "plugin:prettier/recommended"],
"parser": "babel-eslint",
"parserOptions": {
"ecmaVersion": 9,
"ecmaFeatures": {
"impliedStrict": true,
"jsx": true
}
},
"env": {
"node": true,
"es6": true
},
"plugins": ["react"],
"rules": {
"react/jsx-filename-extension": ["off"],
"react/prefer-stateless-function": ["off"],
"arrow-body-style": ["error", "always"],
"react/self-closing-comp": "off"
}
}

关于javascript - 如果 div 为空,Eslint airbnb 会强制执行自关闭 div 标签。如何禁用此规则?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52939112/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com