Skip to content

Commit

Permalink
Linting (#146)
Browse files Browse the repository at this point in the history
  • Loading branch information
niekcandaele committed Jul 5, 2020
1 parent 19ae0fb commit b7b049c
Show file tree
Hide file tree
Showing 383 changed files with 7,349 additions and 7,466 deletions.
40 changes: 20 additions & 20 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,30 +43,30 @@ module.exports = {
},

'rules': {
'callback-return': [2, ['callback', 'cb', 'next', 'done', 'proceed']],
'camelcase': [1, {'properties': 'always'}],
'comma-style': [2, 'last'],
'curly': [2],
'eqeqeq': [2, 'always'],
'eol-last': [1],
'handle-callback-err': [2],
'indent': [1, 2, {'SwitchCase': 1}],
'no-dupe-keys': [2],
'no-duplicate-case': [2],
'no-mixed-spaces-and-tabs': [2, 'smart-tabs'],
'no-return-assign': [2, 'always'],
'no-sequences': [2],
'no-trailing-spaces': [1],
'no-undef': [0],
'callback-return': [2, ['callback', 'cb', 'next', 'done', 'proceed']],
'camelcase': [1, { 'properties': 'always' }],
'comma-style': [2, 'last'],
'curly': [2],
'eqeqeq': [2, 'always'],
'eol-last': [1],
'handle-callback-err': [2],
'indent': [1, 2, { 'SwitchCase': 1 }],
'no-dupe-keys': [2],
'no-duplicate-case': [2],
'no-mixed-spaces-and-tabs': [2, 'smart-tabs'],
'no-return-assign': [2, 'always'],
'no-sequences': [2],
'no-trailing-spaces': [1],
'no-undef': [0],
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// ^^Note: If this "no-undef" rule is enabled (set to `[2]`), then model globals
// (e.g. `"User": true`) should also be included above under "globals".
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
'no-unexpected-multiline': [1],
'no-unused-vars': [1],
'one-var': [2, 'never'],
'quotes': [1, 'single', { 'avoidEscape': false, 'allowTemplateLiterals': true }],
'semi': [2, 'always']
'no-unexpected-multiline': [1],
'no-unused-vars': [1],
'one-var': [2, 'never'],
'quotes': [1, 'single', { 'avoidEscape': false, 'allowTemplateLiterals': true }],
'semi': [2, 'always']
}

};
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ env:
- CC_TEST_REPORTER_ID=60858e4981c4a2b71600ef66b26dcbff099fa8f5dff907a973d548764d4b6051
services:
- mysql
- redis-server
- redis
before_script:
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
- chmod +x ./cc-test-reporter
Expand All @@ -18,6 +18,7 @@ before_install:
install:
- npm install
script:
- npm run lint
- npm run cover
after_script:
- cat coverage/lcov.info | node_modules/.bin/coveralls
Expand Down
2 changes: 0 additions & 2 deletions api/controllers/AdminController.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
const { UI } = require('bull-board')

module.exports = {
bull: function (req, res, next) {
next();
Expand Down
110 changes: 55 additions & 55 deletions api/controllers/AuthController.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ module.exports = {
failureRedirect: `${process.env.CSMM_HOSTNAME}`,
})(req, res);
} catch (error) {
sails.log.warn(`!!! - STEAM AUTH ERROR - !!!!`)
sails.log.error(error)
res.send(`Steam authentication error. This should never occur! Please report this on the dev server`, req)
sails.log.warn(`!!! - STEAM AUTH ERROR - !!!!`);
sails.log.error(error);
res.send(`Steam authentication error. This should never occur! Please report this on the dev server`, req);
}


Expand All @@ -39,37 +39,37 @@ module.exports = {
passport.authenticate('steam', {
failureRedirect: '/login',
},
async function (err, user) {
if (err) {
sails.log.error(`Steam auth error - ${err}`);
return res.serverError(err);
};
sails.log.info(`User ${user.username} successfully logged in`);
req.session.userId = user.id;
req.session.user = user;
try {
let players = await Player.find({
steamId: user.steamId
});
let playerIds = players.map((player) => {
return player.id;
});
await User.addToCollection(user.id, 'players').members(playerIds);

if (req.session.redirectTo) {
res.redirect(req.session.redirectTo);
} else {
res.redirect(`/user/${user.id}/dashboard`);
}

} catch (error) {
sails.log.error(`AuthController - Error updating user profile ${error}`);
async function (err, user) {
if (err) {
sails.log.error(`Steam auth error - ${err}`);
return res.serverError(err);
};
sails.log.info(`User ${user.username} successfully logged in`);
req.session.userId = user.id;
req.session.user = user;
try {
let players = await Player.find({
steamId: user.steamId
});
let playerIds = players.map((player) => {
return player.id;
});
await User.addToCollection(user.id, 'players').members(playerIds);

if (req.session.redirectTo) {
res.redirect(req.session.redirectTo);
} else {
res.redirect(`/user/${user.id}/dashboard`);
}
})(req, res);

} catch (error) {
sails.log.error(`AuthController - Error updating user profile ${error}`);
}
})(req, res);
} catch (error) {
sails.log.warn(`!!! - STEAM AUTH ERROR - !!!!`)
sails.log.error(error)
res.send(`Steam authentication error. This should never occur! Please report this on the dev server`, req)
sails.log.warn(`!!! - STEAM AUTH ERROR - !!!!`);
sails.log.error(error);
res.send(`Steam authentication error. This should never occur! Please report this on the dev server`, req);
}


Expand All @@ -81,28 +81,28 @@ module.exports = {
passport.authenticate('discord', {
failureRedirect: '/'
},
async function (err, discordProfile) {
if (err) {
sails.log.error(`Discord auth error - ${err}`);
return res.serverError(err);
};

try {
await User.update({
id: req.session.userId
}, {
discordId: discordProfile.id,
});
sails.log.debug(`User ${req.session.userId} updated discord info successfully`);
res.redirect(`/user/${req.session.userId}/dashboard`);
} catch (error) {
sails.log.error(`AuthController:discordReturn - Error updating user profile ${error}`);
}
async function (err, discordProfile) {
if (err) {
sails.log.error(`Discord auth error - ${err}`);
return res.serverError(err);
};

try {
await User.update({
id: req.session.userId
}, {
discordId: discordProfile.id,
});
sails.log.debug(`User ${req.session.userId} updated discord info successfully`);
res.redirect(`/user/${req.session.userId}/dashboard`);
} catch (error) {
sails.log.error(`AuthController:discordReturn - Error updating user profile ${error}`);
}

})(req, res);
})(req, res);
} catch (error) {
sails.log.error(error)
res.send(`Discord authentication error. This should never occur! Please report this on the dev server`)
sails.log.error(error);
res.send(`Discord authentication error. This should never occur! Please report this on the dev server`);
}


Expand All @@ -113,14 +113,14 @@ module.exports = {
* @description login via discord
*/

discordLogin: function (req, res, next) {
discordLogin: function (req, res) {
try {
passport.authenticate('discord', {
failureRedirect: `${process.env.CSMM_HOSTNAME}`
})(req, res);
} catch (error) {
sails.log.error(error)
res.send(`Discord authentication error. This should never occur! Please report this on the dev server`)
sails.log.error(error);
res.send(`Discord authentication error. This should never occur! Please report this on the dev server`);
}


Expand Down
8 changes: 4 additions & 4 deletions api/controllers/BannedItemList/add-banned-item.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
module.exports = {
friendlyName: "Add bannedItem",
friendlyName: 'Add bannedItem',

description: "Add an item to the list of bannedItems",
description: 'Add an item to the list of bannedItems',

inputs: {
bannedItem: {
required: true,
type: "string"
type: 'string'
},

serverId: {
required: true,
type: "string"
type: 'string'
}
},

Expand Down
6 changes: 3 additions & 3 deletions api/controllers/BannedItemList/get-banned-items.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
module.exports = {
friendlyName: "Get bannedItems",
friendlyName: 'Get bannedItems',

description: "Gets the list of bannedItems",
description: 'Gets the list of bannedItems',

inputs: {
serverId: {
required: true,
type: "string"
type: 'string'
}
},

Expand Down
8 changes: 4 additions & 4 deletions api/controllers/BannedItemList/remove-banned-item.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
module.exports = {
friendlyName: "Remove bannedItem",
friendlyName: 'Remove bannedItem',

description: "Remove an item from the list of bannedItems",
description: 'Remove an item from the list of bannedItems',

inputs: {
bannedItem: {
required: true,
type: "string"
type: 'string'
},

serverId: {
required: true,
type: "string"
type: 'string'
}
},

Expand Down
8 changes: 4 additions & 4 deletions api/controllers/BannedItemList/set-banned-item-status.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
module.exports = {
friendlyName: "set bannedItem status",
friendlyName: 'set bannedItem status',

description: "Set the status for bannedItems to enabled or disabled",
description: 'Set the status for bannedItems to enabled or disabled',

inputs: {
status: {
required: true,
type: "boolean"
type: 'boolean'
},

serverId: {
required: true,
type: "string"
type: 'string'
}
},

Expand Down
8 changes: 4 additions & 4 deletions api/controllers/BannedItemList/set-command.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
module.exports = {
friendlyName: "set bannedItem command",
friendlyName: 'set bannedItem command',

description: "Set the command for bannedItems to execute",
description: 'Set the command for bannedItems to execute',

inputs: {
command: {
required: true,
type: "string"
type: 'string'
},

serverId: {
required: true,
type: "string"
type: 'string'
}
},

Expand Down
2 changes: 1 addition & 1 deletion api/controllers/CommandReply/add-reply.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const replyTypes = require('../../../api/hooks/sdtdCommands/replyTypes.js')
const replyTypes = require('../../../api/hooks/sdtdCommands/replyTypes.js');
module.exports = {
friendlyName: 'Add reply',
description: '',
Expand Down
2 changes: 1 addition & 1 deletion api/controllers/CommandReply/delete-reply.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ module.exports = {

await CommandReply.destroy({
id: inputs.replyId,
})
});

return exits.success();

Expand Down
2 changes: 1 addition & 1 deletion api/controllers/CommandReply/get-reply.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const replyTypes = require('../../../api/hooks/sdtdCommands/replyTypes.js')
const replyTypes = require('../../../api/hooks/sdtdCommands/replyTypes.js');
module.exports = {
friendlyName: 'Get reply',
description: '',
Expand Down
Loading

0 comments on commit b7b049c

Please sign in to comment.