Set up ESLint, make it happy
This commit is contained in:
parent
c325168a20
commit
6a1d55c968
File diff suppressed because one or more lines are too long
22
client/.eslintrc
Normal file
22
client/.eslintrc
Normal file
@ -0,0 +1,22 @@
|
||||
{
|
||||
"ecmaFeatures": {
|
||||
"jsx": true
|
||||
},
|
||||
"env": {
|
||||
"browser": true,
|
||||
"node": true
|
||||
},
|
||||
"parser": "babel-eslint",
|
||||
"plugins": [
|
||||
"react"
|
||||
],
|
||||
"rules": {
|
||||
"quotes": [2, "single"],
|
||||
"strict": [2, "never"],
|
||||
"eol-last": [0],
|
||||
"new-cap": [2, { "capIsNew": false }],
|
||||
"react/jsx-uses-react": 2,
|
||||
"react/jsx-uses-vars": 2,
|
||||
"react/react-in-jsx-scope": 2
|
||||
}
|
||||
}
|
@ -8,6 +8,7 @@ var autoprefixer = require('gulp-autoprefixer');
|
||||
var uglify = require('gulp-uglify');
|
||||
var gzip = require('gulp-gzip');
|
||||
var concat = require('gulp-concat');
|
||||
var eslint = require('gulp-eslint');
|
||||
var browserify = require('browserify');
|
||||
var source = require('vinyl-source-stream');
|
||||
var streamify = require('gulp-streamify');
|
||||
@ -74,6 +75,13 @@ function js(watch) {
|
||||
return rebundle();
|
||||
}
|
||||
|
||||
gulp.task('lint', function() {
|
||||
return gulp.src('src/js/**/*.{js,jsx}')
|
||||
.pipe(eslint())
|
||||
.pipe(eslint.format())
|
||||
.pipe(eslint.failOnError());
|
||||
});
|
||||
|
||||
gulp.task('fonts', function() {
|
||||
return gulp.src('src/font/*')
|
||||
.pipe(gulp.dest('dist/font'));
|
||||
@ -116,7 +124,8 @@ gulp.task('watch', ['default'], function() {
|
||||
gulp.watch('dist/**/*.{html,css,js}', ['gzip:watch', 'bindata:watch'])
|
||||
gulp.watch('src/*.html', ['html']);
|
||||
gulp.watch('src/css/*.css', ['css']);
|
||||
gulp.watch('src/js/**/*.{js,jsx}', ['lint']);
|
||||
return js(true);
|
||||
});
|
||||
|
||||
gulp.task('default', ['html', 'css', 'js', 'fonts', 'config', 'gzip', 'bindata']);
|
||||
gulp.task('default', ['html', 'css', 'js', 'lint', 'fonts', 'config', 'gzip', 'bindata']);
|
@ -4,22 +4,26 @@
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"devDependencies": {
|
||||
"yargs": "~1.3.3",
|
||||
"babel-eslint": "^3.1.9",
|
||||
"babelify": "6.1.0",
|
||||
"browserify": "10.2.0",
|
||||
"eslint": "^0.22.1",
|
||||
"eslint-plugin-react": "^2.4.0",
|
||||
"gulp": "~3.8.10",
|
||||
"gulp-autoprefixer": "2.2.0",
|
||||
"gulp-concat": "~2.5.2",
|
||||
"gulp-eslint": "^0.12.0",
|
||||
"gulp-gzip": "0.0.8",
|
||||
"gulp-if": "~1.2.5",
|
||||
"gulp-minify-css": "1.1.1",
|
||||
"gulp-minify-html": "1.0.2",
|
||||
"gulp-streamify": "0.0.5",
|
||||
"gulp-uglify": "1.2.0",
|
||||
"reactify": "^1.1.1",
|
||||
"strictify": "~0.2.0",
|
||||
"vinyl-source-stream": "~1.0.0",
|
||||
"gulp-if": "~1.2.5",
|
||||
"gulp": "~3.8.10",
|
||||
"gulp-uglify": "1.2.0",
|
||||
"gulp-minify-css": "1.1.1",
|
||||
"gulp-streamify": "0.0.5",
|
||||
"gulp-minify-html": "1.0.2",
|
||||
"watchify": "3.2.1",
|
||||
"browserify": "10.2.0",
|
||||
"gulp-autoprefixer": "2.2.0",
|
||||
"gulp-gzip": "0.0.8",
|
||||
"babelify": "6.1.0",
|
||||
"gulp-concat": "~2.5.2",
|
||||
"reactify": "^1.1.1"
|
||||
"yargs": "~1.3.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"lodash": "3.8.0",
|
||||
|
@ -1,5 +1,4 @@
|
||||
var Reflux = require('reflux');
|
||||
var _ = require('lodash');
|
||||
|
||||
var socket = require('../socket');
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
var Reflux = require('reflux');
|
||||
var _ = require('lodash');
|
||||
|
||||
var socket = require('../socket');
|
||||
|
||||
|
@ -1,7 +1,5 @@
|
||||
var Reflux = require('reflux');
|
||||
|
||||
var routeActions = require('./route');
|
||||
|
||||
var tabActions = Reflux.createActions([
|
||||
'select'
|
||||
]);
|
||||
|
@ -43,7 +43,7 @@ messageActions.command.listen(function(line, channel, server) {
|
||||
break;
|
||||
|
||||
case 'topic':
|
||||
var topic = channelStore.getTopic(server, channel);
|
||||
let topic = channelStore.getTopic(server, channel);
|
||||
if (topic) {
|
||||
messageActions.add({
|
||||
server: server,
|
||||
@ -72,8 +72,8 @@ messageActions.command.listen(function(line, channel, server) {
|
||||
|
||||
case 'msg':
|
||||
if (params.length > 2) {
|
||||
var dest = params[1];
|
||||
var message = params.slice(2).join(' ');
|
||||
let dest = params[1];
|
||||
let message = params.slice(2).join(' ');
|
||||
|
||||
messageActions.send(message, dest, server);
|
||||
}
|
||||
@ -81,7 +81,7 @@ messageActions.command.listen(function(line, channel, server) {
|
||||
|
||||
case 'say':
|
||||
if (params.length > 1) {
|
||||
var message = params.slice(1).join(' ');
|
||||
let message = params.slice(1).join(' ');
|
||||
|
||||
messageActions.send(message, channel, server);
|
||||
}
|
||||
|
@ -1,8 +1,6 @@
|
||||
var React = require('react');
|
||||
var Reflux = require('reflux');
|
||||
var _ = require('lodash');
|
||||
var Infinite = require('react-infinite');
|
||||
var Autolinker = require('autolinker');
|
||||
|
||||
var MessageHeader = require('./MessageHeader.jsx');
|
||||
var MessageLine = require('./MessageLine.jsx');
|
||||
|
@ -1,5 +1,4 @@
|
||||
var React = require('react');
|
||||
var Reflux = require('reflux');
|
||||
var Autolinker = require('autolinker');
|
||||
|
||||
var util = require('../util');
|
||||
|
@ -1,6 +1,5 @@
|
||||
var React = require('react');
|
||||
var Reflux = require('reflux');
|
||||
var _ = require('lodash');
|
||||
|
||||
var util = require('../util');
|
||||
var searchStore = require('../stores/search');
|
||||
|
@ -1,6 +1,5 @@
|
||||
var React = require('react');
|
||||
var Reflux = require('reflux');
|
||||
var _ = require('lodash');
|
||||
|
||||
var TabListItem = require('./TabListItem.jsx');
|
||||
var channelStore = require('../stores/channel');
|
||||
|
@ -1,6 +1,5 @@
|
||||
var React = require('react');
|
||||
var Reflux = require('reflux');
|
||||
var _ = require('lodash');
|
||||
var Infinite = require('react-infinite');
|
||||
|
||||
var UserListItem = require('./UserListItem.jsx');
|
||||
|
@ -8,7 +8,7 @@ var PureMixin = require('../mixins/pure');
|
||||
var UserListItem = React.createClass({
|
||||
mixins: [PureMixin],
|
||||
|
||||
handleClick() {
|
||||
handleClick() {
|
||||
var server = selectedTabStore.getServer();
|
||||
|
||||
privateChatActions.open(server, this.props.user.nick);
|
||||
|
@ -6,9 +6,12 @@ var channelActions = require('./actions/channel');
|
||||
var messageActions = require('./actions/message');
|
||||
var serverActions = require('./actions/server');
|
||||
var routeActions = require('./actions/route');
|
||||
var tabActions = require('./actions/tab');
|
||||
var searchActions = require('./actions/search');
|
||||
|
||||
function withReason(message, reason) {
|
||||
return message + (reason ? ' (' + reason + ')' : '');
|
||||
}
|
||||
|
||||
socket.on('join', function(data) {
|
||||
channelActions.addUser(data.user, data.server, data.channels[0]);
|
||||
messageActions.inform(data.user + ' joined the channel', data.server, data.channels[0]);
|
||||
@ -90,10 +93,6 @@ socket.on('search', function(data) {
|
||||
searchActions.searchDone(data.results);
|
||||
});
|
||||
|
||||
serverActions.connect.listen(function(server, nick, opts) {
|
||||
serverActions.connect.listen(function(server) {
|
||||
messageActions.inform('Connecting...', server);
|
||||
});
|
||||
|
||||
function withReason(message, reason) {
|
||||
return message + (reason ? ' (' + reason + ')' : '');
|
||||
}
|
@ -12,6 +12,6 @@ module.exports = {
|
||||
}
|
||||
|
||||
return !shallowEqual(this.props, nextProps) ||
|
||||
!shallowEqual(this.state, nextState);
|
||||
!shallowEqual(this.state, nextState);
|
||||
}
|
||||
};
|
@ -12,7 +12,7 @@ class Socket extends EventEmitter {
|
||||
var msg = JSON.parse(e.data);
|
||||
|
||||
this.emit(msg.type, msg.response);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
send(type, data) {
|
||||
|
@ -14,6 +14,18 @@ var User = Immutable.Record({
|
||||
mode: ''
|
||||
});
|
||||
|
||||
function updateRenderName(user) {
|
||||
var name = user.nick;
|
||||
|
||||
if (user.mode.indexOf('o') !== -1) {
|
||||
name = '@' + name;
|
||||
} else if (user.mode.indexOf('v') !== -1) {
|
||||
name = '+' + name;
|
||||
}
|
||||
|
||||
return user.set('renderName', name);
|
||||
}
|
||||
|
||||
function createUser(nick, mode) {
|
||||
return updateRenderName(new User({
|
||||
nick: nick,
|
||||
@ -38,18 +50,6 @@ function loadUser(nick) {
|
||||
return createUser(nick, mode);
|
||||
}
|
||||
|
||||
function updateRenderName(user) {
|
||||
var name = user.nick;
|
||||
|
||||
if (user.mode.indexOf('o') !== -1) {
|
||||
name = '@' + name;
|
||||
} else if (user.mode.indexOf('v') !== -1) {
|
||||
name = '+' + name;
|
||||
}
|
||||
|
||||
return user.set('renderName', name);
|
||||
}
|
||||
|
||||
function compareUsers(a, b) {
|
||||
a = a.renderName.toLowerCase();
|
||||
b = b.renderName.toLowerCase();
|
||||
@ -142,8 +142,8 @@ var channelStore = Reflux.createStore({
|
||||
var i = channels.getIn([mode.server, mode.channel, 'users']).findIndex(u => u.nick === mode.user);
|
||||
|
||||
channels = channels.updateIn([mode.server, mode.channel, 'users', i], user => {
|
||||
_.each(mode.remove, function(mode) {
|
||||
user = user.set('mode', user.mode.replace(mode, ''));
|
||||
_.each(mode.remove, remove => {
|
||||
user = user.set('mode', user.mode.replace(remove, ''));
|
||||
});
|
||||
|
||||
user = user.set('mode', user.mode + mode.add);
|
||||
|
@ -1,5 +1,4 @@
|
||||
var Reflux = require('reflux');
|
||||
var _ = require('lodash');
|
||||
|
||||
var actions = require('../actions/inputHistory');
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
var Reflux = require('reflux');
|
||||
var _ = require('lodash');
|
||||
|
||||
var util = require('../util');
|
||||
var messageStore = require('./message');
|
||||
@ -13,14 +12,14 @@ var prev;
|
||||
|
||||
function updateCharWidth() {
|
||||
window.charWidth = util.stringWidth(' ', '16px Droid Sans Mono');
|
||||
window.messageIndent = 6 * charWidth;
|
||||
window.messageIndent = 6 * window.charWidth;
|
||||
}
|
||||
|
||||
function wrap() {
|
||||
var next = messageStore.getMessages(tab.server, tab.channel || tab.server);
|
||||
if (next !== prev) {
|
||||
prev = next;
|
||||
messages = util.wrapMessages(next, width, charWidth, messageIndent);
|
||||
messages = util.wrapMessages(next, width, window.charWidth, window.messageIndent);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -45,7 +44,7 @@ var messageLineStore = Reflux.createStore({
|
||||
|
||||
setWrapWidth(w) {
|
||||
width = w;
|
||||
messages = util.wrapMessages(messages, width, charWidth, messageIndent);
|
||||
messages = util.wrapMessages(messages, width, window.charWidth, window.messageIndent);
|
||||
this.trigger(messages);
|
||||
},
|
||||
|
||||
|
@ -112,7 +112,7 @@ var selectedTabStore = Reflux.createStore({
|
||||
},
|
||||
|
||||
loadChannels(channels) {
|
||||
_.each(channels, (channel) => {
|
||||
_.each(channels, (channel) => {
|
||||
if (channel.server === selectedTab.server &&
|
||||
channel.name !== selectedTab.channel &&
|
||||
channel.name.indexOf(selectedTab.channel) !== -1) {
|
||||
@ -156,23 +156,23 @@ var selectedTabStore = Reflux.createStore({
|
||||
getState
|
||||
});
|
||||
|
||||
selectedTabStore.listen(selectedTab => {
|
||||
var channel = selectedTab.channel;
|
||||
selectedTabStore.listen(tab => {
|
||||
var channel = tab.channel;
|
||||
|
||||
if (selectedTab.server) {
|
||||
if (tab.server) {
|
||||
if (channel) {
|
||||
while (channel[0] === '#') {
|
||||
channel = channel.slice(1);
|
||||
}
|
||||
routeActions.navigate('/' + selectedTab.server + '/' + channel);
|
||||
routeActions.navigate('/' + tab.server + '/' + channel);
|
||||
} else {
|
||||
routeActions.navigate('/' + selectedTab.server);
|
||||
routeActions.navigate('/' + tab.server);
|
||||
}
|
||||
} else if (serverStore.getState().size === 0) {
|
||||
routeActions.navigate('connect');
|
||||
}
|
||||
|
||||
localStorage.selectedTab = JSON.stringify(selectedTab);
|
||||
localStorage.selectedTab = JSON.stringify(tab);
|
||||
});
|
||||
|
||||
module.exports = selectedTabStore;
|
@ -2,15 +2,15 @@ var _ = require('lodash');
|
||||
|
||||
exports.UUID = function() {
|
||||
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
|
||||
var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8);
|
||||
return v.toString(16);
|
||||
var r = Math.random() * 16 | 0, v = c === 'x' ? r : (r & 0x3 | 0x8);
|
||||
return v.toString(16);
|
||||
});
|
||||
};
|
||||
|
||||
exports.timestamp = function(date) {
|
||||
date = date || new Date();
|
||||
|
||||
var h = _.padLeft(date.getHours(), 2, '0')
|
||||
var h = _.padLeft(date.getHours(), 2, '0');
|
||||
var m = _.padLeft(date.getMinutes(), 2, '0');
|
||||
|
||||
return h + ':' + m;
|
||||
|
Loading…
Reference in New Issue
Block a user