Skip to content
This repository has been archived by the owner on Oct 20, 2018. It is now read-only.

Commit

Permalink
Fix lint issues, failing test, update eslint, and solve missing confi…
Browse files Browse the repository at this point in the history
…g breaking build
  • Loading branch information
ltegman committed May 2, 2016
1 parent e69b762 commit efd9801
Show file tree
Hide file tree
Showing 27 changed files with 74 additions and 69 deletions.
24 changes: 12 additions & 12 deletions .eslintrc
@@ -1,6 +1,10 @@

{
"ecmaFeatures": {
"jsx": true
"parserOption": {
"ecmaVersion": 6,
"ecmaFeatures": {
"jsx": true
}
},
"env": {
"browser": true,
Expand All @@ -12,6 +16,7 @@
"react"
],
"globals": {
"Promise": true,
"window": true,
"$": true,
"ga": true,
Expand Down Expand Up @@ -58,7 +63,6 @@
"no-caller": 2,
"no-div-regex": 2,
"no-else-return": 0,
"no-empty-label": 2,
"no-eq-null": 1,
"no-eval": 2,
"no-extend-native": 2,
Expand Down Expand Up @@ -171,7 +175,7 @@
"one-var": 0,
"operator-assignment": 0,
"padded-blocks": 0,
"quote-props": 0,
"quote-props": [2, "as-needed"],
"quotes": [
2,
"single",
Expand All @@ -182,10 +186,7 @@
"always"
],
"sort-vars": 0,
"space-after-keywords": [
2,
"always"
],
"keyword-spacing": [ 2 ],
"space-before-function-paren": [
2,
"never"
Expand All @@ -197,7 +198,6 @@
"space-in-brackets": 0,
"space-in-parens": 0,
"space-infix-ops": 2,
"space-return-throw-case": 2,
"space-unary-ops": [
1,
{
Expand All @@ -214,7 +214,7 @@

"max-depth": 0,
"max-len": [
1,
2,
80,
2
],
Expand All @@ -227,12 +227,12 @@
"react/jsx-boolean-value": [1, "always"],
"jsx-quotes": [1, "prefer-single"],
"react/jsx-no-undef": 1,
"react/jsx-sort-props": 1,
"react/jsx-sort-props": [1, { "ignoreCase": true }],
"react/jsx-uses-react": 1,
"react/jsx-uses-vars": 1,
"react/no-did-mount-set-state": 2,
"react/no-did-update-set-state": 2,
"react/no-multi-comp": 2,
"react/no-multi-comp": [2, { "ignoreStateless": true } ],
"react/prop-types": 2,
"react/react-in-jsx-scope": 1,
"react/self-closing-comp": 1,
Expand Down
2 changes: 1 addition & 1 deletion app.js
@@ -1,6 +1,6 @@
'use strict';

require('dotenv').config({path: 'dot.env'});
require('dotenv').config({ path: 'dot.env' });

console.log('--------------- startup ------------------');

Expand Down
2 changes: 1 addition & 1 deletion data/RoomData.js
Expand Up @@ -140,7 +140,7 @@ var camperBotChatRooms = [
// @TODO Refactor into a room generator function
const camperBotRooms = [camperBotChatRooms]
.reduce((rooms, currRooms) => rooms.concat(currRooms))
.map(room => { return {name: room}; });
.map(room => { return { name: room }; });

const BotRoomData = {
// this is the demobot that ships with the app
Expand Down
2 changes: 1 addition & 1 deletion data/fcc.wiki
Submodule fcc.wiki updated 684 files
3 changes: 1 addition & 2 deletions data/rooms/RoomMessages.js
Expand Up @@ -101,9 +101,8 @@ const RoomMessages = {
// we have a winner!
return oneMessage;
}
} else {
return null;
}
return null;
}
};

Expand Down
2 changes: 1 addition & 1 deletion gulpfile.js
Expand Up @@ -4,7 +4,7 @@ const gulp = require('gulp'),
faucet = require('faucet'),
env = require('gulp-env');

require('dotenv').config({path: 'dot.env'});
require('dotenv').config({ path: 'dot.env' });

const scripts = ['config/*.js', 'data/rooms/*.js', 'data/*.js', 'lib/**/*.js',
'test/*.js', 'app.js', 'gulpfile.js'];
Expand Down
4 changes: 2 additions & 2 deletions lib/app/Rooms.js
Expand Up @@ -23,7 +23,7 @@ const Rooms = {
if (room) {
return room;
}
Utils.error('cant find room name:', name);
return Utils.error('cant find room name:', name);
},

isBonfire: function(name) {
Expand All @@ -43,7 +43,7 @@ const Rooms = {
if (room) {
return room;
}
Utils.error('Rooms.checkRoom> failed', how, tag);
return Utils.error('Rooms.checkRoom> failed', how, tag);
}
};

Expand Down
7 changes: 4 additions & 3 deletions lib/app/routes.js
Expand Up @@ -84,7 +84,7 @@ const Router = {
return res.redirect('/');
}

res.render('home', {
return res.render('home', {
user: req.user,
sessionToken: req.session.token,
rooms: []
Expand All @@ -104,7 +104,7 @@ const Router = {
});
console.log(rooms);

res.render('rooms', {
return res.render('rooms', {
user: req.user,
who: AppConfig.who(req),
token: req.session.token,
Expand Down Expand Up @@ -135,8 +135,9 @@ const Router = {
topicDmUri: AppConfig.topicDmUri()
};
clog('rooms.blob', blob);
res.render('home', blob);
return res.render('home', blob);
});
return null;
});

// Alive Status - returns 200/OK on GET
Expand Down
1 change: 1 addition & 0 deletions lib/bot/BotCommands.js
Expand Up @@ -177,6 +177,7 @@ const BotCommands = {
return '## welcome to FreeCodeCamp @' +
input.message.model.fromUser.username + '!';
}
return null;
},

hello: function(input, bot) {
Expand Down
1 change: 1 addition & 0 deletions lib/bot/InputWrap.js
Expand Up @@ -15,6 +15,7 @@ const InputWrap = {
return '@' + input.message.model.fromUser.username;
} catch (e) {
Utils.error('InputWrap', 'no fromUser', input);
return null;
}
},

Expand Down
4 changes: 3 additions & 1 deletion lib/bot/KBase.js
Expand Up @@ -44,7 +44,8 @@ const KBase = {
displayName: Utils.namify(topicName),
fileName: fileName,
data: data,
shortData: TextLib.fixRelativeLink(TextLib.trimLines(data), topicName),
shortData: TextLib.fixRelativeLink(TextLib.trimLines(data),
topicName),
dashedName: TextLib.dashedName(topicName)
};

Expand All @@ -68,6 +69,7 @@ const KBase = {

if (!KBase.allData) {
KBase.initSync();
return null;
} else {
const shortList = KBase.allData.filter(t => {
return (t.dashedName.includes(searchDashName));
Expand Down
1 change: 1 addition & 0 deletions lib/bot/cmds/bonfire.js
Expand Up @@ -28,6 +28,7 @@ const commands = {
if (!foundCmd) {
return this.searchBonfire(input, bot);
}
return null;
},

checkBonfireCommands: function(opts) {
Expand Down
3 changes: 2 additions & 1 deletion lib/bot/cmds/thanks.js
Expand Up @@ -71,6 +71,7 @@ const thanksCommands = {

const apiPath = '/api/users/about?username=' + name;
HttpWrap.callApi(apiPath, options, thanksCommands.showInfoCallback);
return null;
},

// called back from apiCall so can't use Global GBot here
Expand Down Expand Up @@ -114,7 +115,7 @@ const thanksCommands = {
Utils.warn('thanks>', 'blob>', blob);
str = 'api offline';
}
blob.bot.say(str, blob.input.message.room);
return blob.bot.say(str, blob.input.message.room);
}
};

Expand Down
13 changes: 6 additions & 7 deletions lib/gitter/GitterHelper.js
Expand Up @@ -18,8 +18,8 @@ const GitterHelper = {
uri: gitterHost + '/api/v1' + path,
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Bearer ' + AppConfig.token
Accept: 'application/json',
Authorization: 'Bearer ' + AppConfig.token
}
};
// opts takes priority
Expand Down Expand Up @@ -55,7 +55,7 @@ const GitterHelper = {
},

postMessage: function(text, roomId, callback, opts) {
const data = { 'text': text };
const data = { text: text };
opts = {
method: 'POST',
body: data,
Expand Down Expand Up @@ -91,15 +91,13 @@ const GitterHelper = {
cbParams.gitterRoom = cached;
return callback(cbParams);
} else {
this.fetch('/rooms', (err, rooms) => {
return this.fetch('/rooms', (err, rooms) => {
if (err) {
return callback(err);
}
if (!rooms) {
Utils.error('can\'t find rooms with roomUri', roomUri);
/* eslint-disable consistent-return */
return;
/* eslint-enable consistent-return */
return null;
}
const roomList = rooms.filter(rm => {
return rm.uri === roomUri;
Expand All @@ -110,6 +108,7 @@ const GitterHelper = {
cbParams.gitterRoom = room;
return callback(cbParams);
}
return null;
});
}
},
Expand Down
11 changes: 5 additions & 6 deletions lib/gitter/restApi.js
Expand Up @@ -38,8 +38,8 @@ const gitter = {
url: gitterHost + path,
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Bearer ' + token
Accept: 'application/json',
Authorization: 'Bearer ' + token
}
};

Expand All @@ -51,10 +51,9 @@ const gitter = {
if (err) { return cb(err); }

if (res.statusCode === 200) {
cb(null, body);
} else {
cb('err ' + res.statusCode);
return cb(null, body);
}
return cb('err ' + res.statusCode);
});
},

Expand All @@ -76,7 +75,7 @@ const gitter = {
postMessage: function(text, roomId) {
const token = this.stashToken();
roomId = roomId || AppConfig.roomId;
const data = { 'text': text };
const data = { text: text };
const opts = {
method: 'POST',
// body: JSON.stringify(data),
Expand Down
4 changes: 2 additions & 2 deletions lib/gitter/streamApi.js
Expand Up @@ -14,7 +14,7 @@ function listenToRoom(roomId, bot) {
path: '/v1/rooms/' + roomId + '/chatMessages',
method: 'GET',
headers: {
'Authorization': 'Bearer ' + token
Authorization: 'Bearer ' + token
}
};

Expand All @@ -37,5 +37,5 @@ function listenToRoom(roomId, bot) {
}

module.exports = {
'listenToRoom': listenToRoom
listenToRoom: listenToRoom
};
2 changes: 1 addition & 1 deletion lib/utils/HttpWrap.js
Expand Up @@ -12,7 +12,7 @@ const HttpWrap = {
timeout: 5000,
debug: false,
headers: {
'Authorization': AppConfig.apiKey
Authorization: AppConfig.apiKey
}
},

Expand Down
6 changes: 3 additions & 3 deletions lib/utils/TextLib.js
Expand Up @@ -16,10 +16,10 @@ const TextLib = {
line = line.split(' ').map((word) => {
if (word.match(linkMatchRegExp)) {
if (!word.match(/\:\/\//gi)) {
if (word.match(/\(\#(.+)/gi)){
word = word.replace(/\(\#(.+)/gi, '(' + baseUrl + topicName + '#' + '$1');
if (word.match(/\(\#(.+)/gi)) {
word = word.replace(/\(\#(.+)/gi, `(${baseUrl}${topicName}#$1`);
} else {
word = word.replace(/\((.+)\)/gi, '(' + baseUrl + '$1' + ')');
word = word.replace(/\((.+)\)/gi, `(${baseUrl}$1)`);
}
return word;
}
Expand Down
10 changes: 5 additions & 5 deletions lib/utils/Utils.js
@@ -1,6 +1,6 @@
'use strict';

require('dotenv').config({path: 'dot.env'});
require('dotenv').config({ path: 'dot.env' });

const clc = require('cli-color'),
_ = require('lodash'),
Expand All @@ -26,7 +26,7 @@ const Utils = {
},

// default
logLevel: 10,
logLevel: process.env.LOG_LEVEL || 10,

log: function(msg, obj) {
let where = '';
Expand All @@ -37,7 +37,7 @@ const Utils = {
},

clog: function(where, msg, obj) {
if (process.env.SERVER_ENV || this.logLevel < LOG_LEVEL_INFO) {
if (this.logLevel < LOG_LEVEL_INFO) {
return;
}
obj = obj || '';
Expand All @@ -58,7 +58,7 @@ const Utils = {
},

warn: function(where, msg, obj) {
if (process.env.SERVER_ENV || this.logLevel < LOG_LEVEL_WARN) {
if (this.logLevel < LOG_LEVEL_WARN) {
return;
}
obj = obj || '';
Expand All @@ -78,7 +78,7 @@ const Utils = {
},

error: function(where, msg, obj) {
if (process.env.SERVER_ENV || this.logLevel < LOG_LEVEL_ERROR) {
if (this.logLevel < LOG_LEVEL_ERROR) {
return;
}
obj = obj || '';
Expand Down

0 comments on commit efd9801

Please sign in to comment.