Skip to content
Browse files

More linting, unneeded deps

  • Loading branch information...
1 parent dee3e00 commit 3e271a12241c1d4bcc54508e2146579cbe8c2dca @ltegman ltegman committed
Showing with 144 additions and 213 deletions.
  1. +0 −23 docs/.eslintrc
  2. +0 −24 docs/eslintrc.yaml
  3. +1 −1 gulpfile.js
  4. +1 −13 lib/bot/BotCommands.js
  5. +1 −3 lib/bot/cmds/thanks.js
  6. +6 −4 lib/utils/Utils.js
  7. +3 −10 package.json
  8. +132 −135 test/TestHelper.js
View
23 docs/.eslintrc
@@ -1,23 +0,0 @@
-{
- "env": {
- "browser": 0
- },
-
- "globals": {
- "require": 1,
- "console": 1
- "module": 1
- },
-
- "rules": {
- "quotes": [2, "double"],
- "strict": [2, "global"],
- "no-console": 0
- },
-
- "ecmaFeatures": {
- "blockBindings": true,
- "forOf": true,
- "jsx": true
- },
-}
View
24 docs/eslintrc.yaml
@@ -1,24 +0,0 @@
-rules:
- indent:
- - 2
- - 4
- quotes:
- - 2
- - double
- linebreak-style:
- - 2
- - unix
- semi:
- - 2
- - always
-
- no-unused-vars:
- - 2
- -
- vars: "none"
- args: "after-used"
-
-
-env:
- es6: true
- node: true
View
2 gulpfile.js
@@ -28,6 +28,6 @@ gulp.task('set-env', () => {
});
});
-gulp.task('default', ['set-env', 'test'], () => {
+gulp.task('default', ['lint', 'set-env', 'test'], () => {
});
View
14 lib/bot/BotCommands.js
@@ -4,8 +4,7 @@ const KBase = require('../bot/KBase'),
Utils = require('../../lib/utils/Utils'),
AppConfig = require('../../config/AppConfig'),
InputWrap = require('../bot/InputWrap'),
- _ = require('lodash'),
- stringy = require('stringy');
+ _ = require('lodash');
const newline = '\n';
@@ -50,17 +49,6 @@ const BotCommands = {
return '@' + username + ' said: ' + input.message.model.text;
},
- echojson: function(input) {
- // avoid circular refs
- const jsonString = stringy.stringify(input);
- console.log(jsonString);
- const safeObj = JSON.parse(jsonString);
- console.log(safeObj);
- const pretty = JSON.stringify(safeObj, null, 2);
-
- return '```json' + pretty + '```';
- },
-
botversion: function() {
return 'botVersion: ' + AppConfig.botVersion;
},
View
4 lib/bot/cmds/thanks.js
@@ -1,8 +1,6 @@
-/*jslint todo: true */
'use strict';
-const GBot = require('../../../lib/bot/GBot.js'),
- Utils = require('../../../lib/utils/Utils'),
+const Utils = require('../../../lib/utils/Utils'),
HttpWrap = require('../../../lib/utils/HttpWrap'),
TextLib = require('../../../lib/utils/TextLib');
View
10 lib/utils/Utils.js
@@ -2,8 +2,7 @@
require('dotenv').config({path: 'dot.env'});
-const assert = require('chai').assert,
- clc = require('cli-color'),
+const clc = require('cli-color'),
_ = require('lodash'),
AppConfig = require('../../config/AppConfig'),
MDNlinks = require('../../data/seed/bonfireMDNlinks');
@@ -149,7 +148,11 @@ const Utils = {
},
splitParams: function(text) {
- assert.isString(text);
+ if (typeof text !== 'string') {
+ this.warn('splitParams>', 'text is not a string');
+ return null;
+ }
+
let params;
const parts = text.split(' '),
keyword = parts.shift();
@@ -177,7 +180,6 @@ const Utils = {
isObject: function(obj, errmsg) {
errmsg = errmsg || 'not an object';
- return true;
if (typeof obj === 'object') {
// means OK
View
13 package.json
@@ -2,20 +2,15 @@
"name": "gitter-demo-app",
"version": "0.0.1",
"dependencies": {
- "chai": "",
"cli-color": "",
"dotenv": "^1.2.0",
"express": "~3.4.4",
- "glob": "",
"jade": "~0.35.0",
- "js-yaml": "",
"lodash": "^3.10.1",
- "node-gitter": "",
+ "node-gitter": "^1.2.8",
"passport": "~0.2.0",
"passport-oauth2": "~1.1.1",
- "request": "~2.27.0",
- "simple-node-logger": "",
- "stringy": ""
+ "request": "~2.27.0"
},
"devDependencies": {
"babel-eslint": "^4.1.6",
@@ -31,8 +26,6 @@
},
"scripts": {
"start": "node app.js",
- "pretest": "make restart-test-server",
- "test": "NODE_ENV=test mocha",
- "posttest": "make stop-test-server"
+ "test": "gulp"
}
}
View
267 test/TestHelper.js
@@ -1,150 +1,147 @@
-"use strict";
+'use strict';
+const GBot = require('../lib/bot/GBot');
-var GBot = require('../lib/bot/GBot');
-
-var TestHelper = {
- aboutInput: {
- keyword: 'about',
- params: '@bothelp ',
- message: {
- operation: 'create',
- model: {
- id: '55b95acb5bc8dc88744243ff',
- text: 'about @bothelp',
- html: 'about <span data-link-type="mention" data-screen-name="bothelp" class="mention">@bothelp</span> ',
- sent: '2015-07-29T22:59:23.187Z',
- editedAt: null,
- fromUser: {
- username: "testuser"
- },
- unread: true,
- readBy: 0,
- urls: [],
- mentions: [
- {screenName: 'dcsan'},
- {screenName: 'berkeleytrue'}
- ],
- issues: [],
- meta: {},
- v: 1
- },
- room: {
- path: '/rooms',
- id: '55b3d5780fc9f982beaaf7f4',
- name: 'camperbot/localdev',
- topic: ' testing',
- uri: 'camperbot/localdev',
- oneToOne: false,
- userCount: 5,
- unreadItems: 100,
- mentions: 27,
- lastAccessTime: '2015-07-29T14:41:04.820Z',
- lurk: false,
- url: '/camperbot/localdev',
- githubType: 'USER_CHANNEL',
- security: 'PUBLIC',
- noindex: false,
- v: 1,
- client: [Object],
- faye: [Object],
- _events: [Object]
- }
+const TestHelper = {
+ aboutInput: {
+ keyword: 'about',
+ params: '@bothelp ',
+ message: {
+ operation: 'create',
+ model: {
+ id: '55b95acb5bc8dc88744243ff',
+ text: 'about @bothelp',
+ html: 'about <span data-link-type="mention" data-screen-name' +
+ '="bothelp" class="mention">@bothelp</span> ',
+ sent: '2015-07-29T22:59:23.187Z',
+ editedAt: null,
+ fromUser: {
+ username: 'testuser'
},
- cleanText: 'about @bothelp ',
- command: true
+ unread: true,
+ readBy: 0,
+ urls: [],
+ mentions: [
+ {screenName: 'dcsan'},
+ {screenName: 'berkeleytrue'}
+ ],
+ issues: [],
+ meta: {},
+ v: 1
+ },
+ room: {
+ path: '/rooms',
+ id: '55b3d5780fc9f982beaaf7f4',
+ name: 'camperbot/localdev',
+ topic: ' testing',
+ uri: 'camperbot/localdev',
+ oneToOne: false,
+ userCount: 5,
+ unreadItems: 100,
+ mentions: 27,
+ lastAccessTime: '2015-07-29T14:41:04.820Z',
+ lurk: false,
+ url: '/camperbot/localdev',
+ githubType: 'USER_CHANNEL',
+ security: 'PUBLIC',
+ noindex: false,
+ v: 1,
+ client: [Object],
+ faye: [Object],
+ _events: [Object]
+ }
},
+ cleanText: 'about @bothelp ',
+ command: true
+ },
- stubInput: {
- keyword: 'hint',
- params: undefined,
- message: {
- operation: 'create',
- model: {
- id: '55b91175c35e438c74fc725c',
- text: 'hint',
- html: 'hint',
- sent: '2015-07-29T17:46:29.190Z',
- editedAt: null,
- fromUser: [Object],
- unread: true,
- readBy: 0,
- urls: [],
- mentions: [],
- issues: [],
- meta: {},
- v: 1
- },
- room: {
- path: '/rooms',
- id: '55b8fc980fc9f982beab6b19',
- name: 'bothelp/bonfire-factorialize-a-number',
- topic: '',
- uri: 'bothelp/bonfire-factorialize-a-number',
- oneToOne: false,
- userCount: 3,
- unreadItems: 9,
- mentions: 0,
- lastAccessTime: '2015-07-29T16:17:28.850Z',
- lurk: false,
- url: '/bothelp/bonfire-factorialize-a-number',
- githubType: 'USER_CHANNEL',
- security: 'PUBLIC',
- noindex: false,
- client: [Object],
- faye: [Object],
- _events: [Object]
- }
- },
- cleanText: 'hint',
- command: true
+ stubInput: {
+ keyword: 'hint',
+ params: null,
+ message: {
+ operation: 'create',
+ model: {
+ id: '55b91175c35e438c74fc725c',
+ text: 'hint',
+ html: 'hint',
+ sent: '2015-07-29T17:46:29.190Z',
+ editedAt: null,
+ fromUser: [Object],
+ unread: true,
+ readBy: 0,
+ urls: [],
+ mentions: [],
+ issues: [],
+ meta: {},
+ v: 1
+ },
+ room: {
+ path: '/rooms',
+ id: '55b8fc980fc9f982beab6b19',
+ name: 'bothelp/bonfire-factorialize-a-number',
+ topic: '',
+ uri: 'bothelp/bonfire-factorialize-a-number',
+ oneToOne: false,
+ userCount: 3,
+ unreadItems: 9,
+ mentions: 0,
+ lastAccessTime: '2015-07-29T16:17:28.850Z',
+ lurk: false,
+ url: '/bothelp/bonfire-factorialize-a-number',
+ githubType: 'USER_CHANNEL',
+ security: 'PUBLIC',
+ noindex: false,
+ client: [Object],
+ faye: [Object],
+ _events: [Object]
+ }
},
+ cleanText: 'hint',
+ command: true
+ },
- mockInput: function(roomName) {
- var input = {
- message: {
- room: {
- name: roomName
- }
- }
- };
- // clog(input);
- return input;
- },
+ mockInput: function(roomName) {
+ const input = {
+ message: {
+ room: {
+ name: roomName
+ }
+ }
+ };
- // used for tests
- // and also strings to commands
- // https://developer.gitter.im/docs/messages-resource
- // makeInputFromString: function (text) {
- // var message = {};
- // var model = {
- // text: text
- // };
- // message.model = model;
- // return message;
- // },
+ return input;
+ },
- makeInputFromString: function (text) {
- var input = TestHelper.aboutInput;
- input.message.model.text = text; // initialize before parsing
- //console.log("input1", input);
- input = GBot.parseInput(input.message); // add keywords etc.
- //console.log("input2", input);
- input.message.model.text = text;
- input.message.model.fromUser = {
- username: "testuser"
- };
- return input;
- },
+ // used for tests
+ // and also strings to commands
+ // https://developer.gitter.im/docs/messages-resource
+ // makeInputFromString: function (text) {
+ // var message = {};
+ // var model = {
+ // text: text
+ // };
+ // message.model = model;
+ // return message;
+ // },
- makeMessageFromString: function (text) {
- var input = TestHelper.makeInputFromString(text);
- return input.message;
- }
+ makeInputFromString: function(text) {
+ let input = TestHelper.aboutInput;
+ // initialize before parsing
+ input.message.model.text = text;
+ // add keywords etc.
+ input = GBot.parseInput(input.message);
+ input.message.model.text = text;
+ input.message.model.fromUser = {
+ username: 'testuser'
+ };
+ return input;
+ },
+ makeMessageFromString: function(text) {
+ const input = TestHelper.makeInputFromString(text);
+ return input.message;
+ }
};
-
-
module.exports = TestHelper;

0 comments on commit 3e271a1

Please sign in to comment.
Something went wrong with that request. Please try again.