簡體   English   中英

不確定要關閉哪些ESLint規則

[英]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-newlinecurlyobject-curly-newlineobject-property-newline

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM