The issue: creating a 'comma-dangle' error in function. if using --fix, it adds a comma which causes the application to not compile but fixes the error. if i don't add comma, it causes the error in eslint
the specific line causing the issue
{ expiresIn: 28 * 24 * 60 * 60 },
Package.json
```{
"name": "workspace",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "jest",
"start-dev": "nodemon ./bin/www",
"start": "node ./bin/www"
},
"author": "",
"license": "ISC",
"dependencies": {
"bcrypt": "^1.0.3",
"body-parser": "~1.18.2",
"cookie-parser": "~1.4.3",
"debug": "~2.6.9",
"dotenv": "^4.0.0",
"express": "~4.15.5",
"jsonwebtoken": "^8.1.0",
"mongoose": "^4.13.4",
"morgan": "~1.9.0",
"socket.io": "^2.0.4",
"underscore": "^1.8.3",
"uuid": "^3.1.0",
"winston": "^2.4.0",
"winston-daily-rotate-file": "^1.7.2"
},
"devDependencies": {
"eslint": "^4.11.0",
"eslint-config-airbnb": "^16.1.0",
"eslint-config-airbnb-base": "^12.1.0",
"eslint-plugin-import": "^2.8.0",
"eslint-plugin-jsx-a11y": "^6.0.2",
"eslint-plugin-react": "^7.5.1",
"jest": "^21.2.1"
}
}
function creating issue
```router.post('/', (req, res) => {
User.findOne({ email: req.body.email })
.then((user) => {
if (!user) {
User.create({
username: req.body.username,
password: req.body.password,
email: req.body.email,
firstname: req.body.firstname,
surname: req.body.surname,
id: v4(),
})
.then((createduser) => {
const myToken = jwt.sign(
{ user: user.id },
'secret',
{ expiresIn: 28 * 24 * 60 * 60 },
);
res.json({
type: 'success',
payload: {
token: myToken,
userId: createduser.id,
username: createduser.username,
},
});
});
} else {
res.json({ type: 'error', payload: 'user already exists' });
}
})
.catch((err) => {
res.json({ type: 'error', payload: err });
});
});
This guide requires you be using https://npmjs.com/babel-preset-airbnb or the equivalent. What's your .eslintrc and .babelrc look like?
(also, you don't need eslint-config-airbnb-base as a top-level dep, if you already have eslint-config-airbnb)
.eslintrc just extends airbnb. babel isnt being used. would that fix it?
Absolutely. Our guide and linter config require usage of babel.
thanks for that. Set up babel, got it running perfectly. thanks for your help :)
Most helpful comment
thanks for that. Set up babel, got it running perfectly. thanks for your help :)