eslint-plugin-node
eslint-plugin-node copied to clipboard
Rest/Spread properties are not supported until node 8.3.0
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.
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 :)
I have this issue, but non of my engines fields (if the exist) specify node that old (min supported I have is 12)
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?
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