如何为eslint nextline禁用多个规则 [英] How to disable multiple rules for eslint nextline
本文介绍了如何为eslint nextline禁用多个规则的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这个代码
const subTotal = orderInfo.details.reduce((acc,cv)=> acc + = Number(cv.price)* Number(cv.quantity),0);
我想为此行保留两个押金,不返回分配和不返回参数
我尝试过这种方式:
/* eslint-disable-next-line no-return-assign eslint-disable-next-line no-param-reassign */const subTotal = orderInfo.details.reduce((acc,cv)=> acc + = Number(cv.price)* Number(cv.quantity),0);
但是我的编辑器仍然显示 eslint(无返回分配)棉绒错误
解决方案
如果要禁用多个ESLint错误,可以执行以下操作(请注意逗号):
- 对于下一行:
//eslint-disable-next-line no-return-assign,no-param-ressign(您的代码...)
- 对于此行:
(您的代码...)//eslint-disable-line no-return-assign,no-param-ressign
- 或者对于整个代码块(请注意,这仅适用于多行注释语法):
/* eslint-disable no-return-assign,no-param-ressign */(您的代码...)/*启用不返回分配,不重新分配参数*/
请参阅ESLint文档的配置规则部分.
(尽管如果您不能始终遵循某些规则,那么可以简单地在 .eslintrc
文件中禁用这些错误可能是一个更好的选择.) >
I have this code
const subTotal = orderInfo.details.reduce((acc, cv) => acc += Number(cv.price) * Number(cv.quantity), 0);
I want to diable two eslint for this line, no-return-assign and no-param-reassign
I tried this way:
/* eslint-disable-next-line no-return-assign eslint-disable-next-line no-param-reassign */
const subTotal = orderInfo.details.reduce((acc, cv) => acc += Number(cv.price) * Number(cv.quantity), 0);
but my editor still showing eslint(no-return-assign) lint error
解决方案
If you want to disable multiple ESLint errors, you can do the following (note the commas):
- For the next line:
// eslint-disable-next-line no-return-assign, no-param-reassign
( your code... )
- For this line:
( your code... ) // eslint-disable-line no-return-assign, no-param-reassign
- Or alternatively for an entire code block (note that this only works with multi-line comment syntax):
/* eslint-disable no-return-assign, no-param-reassign */
( your code... )
/* eslint-enable no-return-assign, no-param-reassign */
See the Configuring Rules section of the ESLint documentation.
(Though it might be a better choice to simply disable these errors in your .eslintrc
file if you can't follow certain rules all the time.)
这篇关于如何为eslint nextline禁用多个规则的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文