[英]Unsure of what ESLint rule to turn off
I have been working on an application and recently wrote a Mongoose aggregate query to return some data to an API. 我一直在开发应用程序,最近编写了Mongoose聚合查询,以将一些数据返回给API。 My workspace is setup using prettier and eslint. 我的工作区是使用漂亮和eslint设置的。
Here is my .eslintrc
这是我的.eslintrc
{
"extends": ["plugin:prettier/recommended"],
"parserOptions": {
"ecmaVersion": 8,
"ecmaFeatures": {
"experimentalObjectRestSpread": true
},
"sourceType": "module"
},
"rules": {
"prettier/prettier": ["error", {
"singleQuote": true
}],
"max-len": 0
}
}
I have prettier set to ignore js
files and have eslint handle them. 我已经设置了更漂亮的设置来忽略js
文件,并由eslint处理它们。 The resulting code looks like this after formatting by eslint. 用eslint格式化后,结果代码如下所示。
// rehire by employee ID
app.get('/employee/:empID', (req, res) => {
const empID = req.params.empID;
Rehires.aggregate(
[
{ $match: { 'data.EMPLOYEE_ID': empID } },
{
$project: {
data: {
$filter: {
input: '$data',
as: 'data',
cond: { $eq: ['$$data.EMPLOYEE_ID', empID] }
}
}
}
}
],
(err, employees) => {
// check if employees
if (!employees || employees.length === 0) {
return res.status(404).json({
error: `No rehire file(s) exist that contain an Employee ID of ${empID}`
});
}
//employees exist
return res.json(employees);
}
);
});
I am unsure of what eslint rules to turn off so this isn't 30 lines of code. 我不确定要关闭什么托管规则,所以这不是30行代码。 What rules enforce all these newlines? 什么规则强制执行所有这些换行符?
Format the code like you want, use eslint
without the --fix
option , and it should report all the offending syntax with a mention of the respective rule. 格式化代码像你想,使用eslint
没有 --fix
选项 ,它应该有相应规则的提报所有有问题的语法。
My guess (I didn't try it) would be function-paren-newline
, curly
, object-curly-newline
and object-property-newline
. 我的猜测(我没有尝试的话)将是function-paren-newline
, curly
, object-curly-newline
和object-property-newline
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.