gpt4 book ai didi

reactjs - 在某些函数 **names** 上禁用 max-lines-per-function

转载 作者:行者123 更新时间:2023-12-04 12:00:48 43 4
gpt4 key购买 nike

我正在使用 ESLint 的 max-lines-per-function 以确保我及时重构。我的 React 组件 render函数几乎总是超过我的 25 行,我想知道,除了添加禁用注释之外,是否有办法禁用某些函数的 ESLint 规则 姓名 (例如 render )?

最佳答案

您可以使用 ESLint 插件 eslint-plugin-react-func .它还有一个规则叫做 max-lines-per-function ,但此规则将跳过任何包含 JSX 元素的函数

 npm i eslint-plugin-react-func -D
或者
 yarn add eslint-plugin-react-func -D
在您的 .eslintrc.* 文件中
{
"rules": {
"react-func/max-lines-per-function": [
"warn",
{
"max": 25,
"skipBlankLines": true,
"skipComments": true,
"IIFEs": true
}
],
},
"plugins": ["react-func"]
}

关于reactjs - 在某些函数 **names** 上禁用 max-lines-per-function,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58918684/

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