[英]Unsure of what ESLint rule to turn off
我一直在開發應用程序,最近編寫了Mongoose聚合查詢,以將一些數據返回給API。 我的工作區是使用漂亮和eslint設置的。
這是我的.eslintrc
{
"extends": ["plugin:prettier/recommended"],
"parserOptions": {
"ecmaVersion": 8,
"ecmaFeatures": {
"experimentalObjectRestSpread": true
},
"sourceType": "module"
},
"rules": {
"prettier/prettier": ["error", {
"singleQuote": true
}],
"max-len": 0
}
}
我已經設置了更漂亮的設置來忽略js
文件,並由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);
}
);
});
我不確定要關閉什么托管規則,所以這不是30行代碼。 什么規則強制執行所有這些換行符?
格式化代碼像你想,使用eslint
沒有 --fix
選項 ,它應該有相應規則的提報所有有問題的語法。
我的猜測(我沒有嘗試的話)將是function-paren-newline
, curly
, object-curly-newline
和object-property-newline
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.