eslint-plugin-node icon indicating copy to clipboard operation
eslint-plugin-node copied to clipboard

Rest/Spread properties are not supported until node 8.3.0

Open moezbenrebah opened this issue 3 years ago • 4 comments

Hi everyone, I'm running into an issue with Eslint when I try to create a copy of "req.query" like so:

const queryObj = { ...req.query };

My node version is 14. I tried this solution but still the same issue. .eslint.rc :

{
  "extends": ["airbnb", "prettier", "plugin:node/recommended", "eslint:recommended"],
  "plugins": ["prettier"],
  "parserOptions": {
    "ecmaVersion": 2020
  },
  "rules": {
    "prettier/prettier": "off",
    "spaced-comment": "off",
    "no-console": "warn",
    "consistent-return": "off",
    "func-names": "off",
    "object-shorthand": "off",
    "no-process-exit": "off",
    "no-param-reassign": "off",
    "no-return-await": "off",
    "no-underscore-dangle": "off",
    "class-methods-use-this": "off",
    "prefer-destructuring": ["error", { "object": true, "array": false }],
    "no-unused-vars": ["error", { "argsIgnorePattern": "req|res|next|value" }]
  }
}

package.json :

{
  "name": "go_ahead_travel",
  "version": "1.0.0",
  "engines": {
    "node": ">=8.0.0"
  },
  "description": "booking web application",
  "main": "app.js",
  "scripts": {
    "start": "nodemon server.js",
    "start:prod": "NODE_ENV=production nodemon server.js"
  },
  "author": "Moez Ben Rebah",
  "license": "ISC",
  "dependencies": {
    "dotenv": "^10.0.0",
    "eslint-config-problems": "^6.0.0",
    "express": "^4.17.2",
    "mongoose": "^6.1.3",
    "morgan": "^1.10.0",
    "nodemon": "^2.0.15"
  },
  "devDependencies": {
    "eslint": "^8.5.0",
    "eslint-config-airbnb": "^19.0.2",
    "eslint-config-prettier": "^8.3.0",
    "eslint-plugin-import": "^2.25.3",
    "eslint-plugin-jsx-a11y": "^6.5.1",
    "eslint-plugin-node": "^11.1.0",
    "eslint-plugin-prettier": "^4.0.0",
    "eslint-plugin-react": "^7.27.1",
    "prettier": "^2.5.1"
  }
}

Also, I installed this package: "eslint-config-problems" but still with effect! Any hints please will be appreciated.

moezbenrebah avatar Dec 28 '21 12:12 moezbenrebah

The engines field in the package.json you posted says the app/library/whatnot works with node 8.0.0. The rule is telling you the code you use to copy the request object won't work for what you have configured. Either raise the minimum node version to 8.3.0, change the way you are copying the object, or disable the rule :)

roikoren755 avatar Dec 29 '21 23:12 roikoren755

I have this issue, but non of my engines fields (if the exist) specify node that old (min supported I have is 12)

NullVoxPopuli avatar May 14 '22 19:05 NullVoxPopuli

Had the same issue but without specifying any possible version for node engines. Any ideas how to fix that? Or I need to hardcode version of node which I suppose to use to get eslint know about it?

vladikopl01 avatar Jun 26 '22 17:06 vladikopl01

The default for this package, if there's no other configuration, is to set the node requirement to >=8.0.0, so that might be it

roikoren755 avatar Jun 26 '22 17:06 roikoren755