Lint показывает ошибку, когда я использую распространенный синтаксис и деструктуризацию - PullRequest
2 голосов
/ 01 октября 2019

У меня проблема с оператором спреда и деструктуризации. После npm запустите lint: js, я увижу:

TypeError: Cannot read property 'type' of undefined
Occurred while linting C:\Users\USER\hq-manager-frontend\frontend\src\common\functions\projects.js:8
    at checkDestructured (C:\Users\USER\hq-manager-frontend\frontend\node_modules\eslint\lib\rules\no-useless-rename.js:104:43)
    at C:\Users\USER\hq-manager-frontend\frontend\node_modules\eslint\lib\linter\safe-emitter.js:45:58

Использование для ReactJs

project.employees.map(({ billedHours, employee }) => {
      const result = billedHours.reduce((res, current) => {
        const { date, ...others } = current;
        return {
          ...res,
          [date]: {
            hours: others,
            activeDates: [],
          },
        };
      }, {});

.eslintrc.json

{
  "extends": ["airbnb", "prettier", "prettier/react"],
  "plugins": ["prettier"],
  "rules": {
    "react/jsx-filename-extension": [
      1,
      {
        "extensions": [".js", ".jsx"]
      }
    ],
    "react/jsx-props-no-spreading": 0,
    "react/no-unused-state": 1,
    "react/prop-types": 0,
    "no-underscore-dangle": 0,
    "import/imports-first": ["error", "absolute-first"],
    "import/newline-after-import": "error"
  },
  "globals": {
    "window": true,
    "document": true,
    "localStorage": true,
    "FormData": true,
    "FileReader": true,
    "Blob": true,
    "navigator": true
  },
  "parser": "babel-eslint"
}
...