Update airbnb eslint config to 3.0.0

This commit is contained in:
Ken-Håvard Lieng 2016-01-05 19:29:22 +01:00
parent 9db0341973
commit 7c72cac71f
13 changed files with 114 additions and 99 deletions

File diff suppressed because one or more lines are too long

View File

@ -1,27 +1,27 @@
{ {
"name": "irc", "name": "dispatch",
"version": "0.0.0", "version": "0.0.0",
"description": "", "description": "",
"main": "index.js", "main": "index.js",
"devDependencies": { "devDependencies": {
"babel-core": "^6.3.26", "babel-core": "^6.3.26",
"babel-eslint": "^5.0.0-beta6", "babel-eslint": "^5.0.0-beta6",
"babel-loader": "^6.2.0", "babel-loader": "^6.2.1",
"babel-plugin-react-transform": "^2.0.0", "babel-plugin-react-transform": "^2.0.0",
"babel-plugin-transform-decorators-legacy": "^1.3.4", "babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-preset-es2015": "^6.3.13", "babel-preset-es2015": "^6.3.13",
"babel-preset-react": "^6.3.13", "babel-preset-react": "^6.3.13",
"babel-preset-stage-0": "^6.3.13", "babel-preset-stage-0": "^6.3.13",
"eslint": "^1.10.3", "eslint": "^1.10.3",
"eslint-config-airbnb": "^2.1.1", "eslint-config-airbnb": "^3.0.0",
"eslint-loader": "^1.1.1", "eslint-loader": "^1.2.0",
"eslint-plugin-react": "^3.13.1", "eslint-plugin-react": "^3.14.0",
"express": "^4.13.3", "express": "^4.13.3",
"gulp": "~3.9.0", "gulp": "^3.9.0",
"gulp-autoprefixer": "3.1.0", "gulp-autoprefixer": "3.1.0",
"gulp-cached": "^1.1.0", "gulp-cached": "^1.1.0",
"gulp-concat": "~2.6.0", "gulp-concat": "^2.6.0",
"gulp-cssnano": "^2.0.0", "gulp-cssnano": "^2.1.0",
"gulp-gzip": "1.2.0", "gulp-gzip": "1.2.0",
"gulp-htmlmin": "^1.3.0", "gulp-htmlmin": "^1.3.0",
"gulp-util": "^3.0.7", "gulp-util": "^3.0.7",
@ -43,14 +43,14 @@
"immutable": "^3.7.6", "immutable": "^3.7.6",
"lodash": "^3.10.1", "lodash": "^3.10.1",
"pure-render-decorator": "^0.2.0", "pure-render-decorator": "^0.2.0",
"react": "^0.14.3", "react": "^0.14.5",
"react-dom": "^0.14.3", "react-dom": "^0.14.5",
"react-infinite": "0.7.3", "react-infinite": "0.7.3",
"react-redux": "^4.0.5", "react-redux": "^4.0.6",
"react-router": "^1.0.3", "react-router": "^1.0.3",
"redux": "^3.0.5", "redux": "^3.0.5",
"redux-simple-router": "^1.0.2", "redux-simple-router": "^1.0.2",
"redux-thunk": "^1.0.2", "redux-thunk": "^1.0.3",
"reselect": "^2.0.1" "reselect": "^2.0.1"
} }
} }

View File

@ -68,7 +68,7 @@ export function setNick(nick, server) {
socket: { socket: {
type: 'nick', type: 'nick',
data: { data: {
new: nick, 'new': nick,
server server
} }
} }

View File

@ -7,10 +7,10 @@ import Navicon from '../components/Navicon';
@pure @pure
export default class ChatTitle extends Component { export default class ChatTitle extends Component {
handleLeaveClick = () => { handleLeaveClick = () => {
const { tab, channel, disconnect, part, closePrivateChat } = this.props; const { tab, disconnect, part, closePrivateChat } = this.props;
if (tab.channel) { if (tab.channel) {
part([channel.get('name')], tab.server); part([tab.channel], tab.server);
} else if (tab.user) { } else if (tab.user) {
closePrivateChat(tab.server, tab.user); closePrivateChat(tab.server, tab.user);
} else { } else {

View File

@ -17,8 +17,12 @@ export default class MessageHeader extends Component {
render() { render() {
const { message } = this.props; const { message } = this.props;
const line = Autolinker.link(message.lines[0], { stripPrefix: false }); const line = Autolinker.link(message.lines[0], { stripPrefix: false });
const classes = ['message'];
let sender = null; let sender = null;
let messageClass = 'message';
if (message.type) {
classes.push(`message-${message.type}`);
}
if (message.from) { if (message.from) {
sender = ( sender = (
@ -31,12 +35,8 @@ export default class MessageHeader extends Component {
); );
} }
if (message.type) {
messageClass += ' message-' + message.type;
}
return ( return (
<p className={messageClass}> <p className={classes.join(' ')}>
<span className="message-time">{timestamp(message.time)}</span> <span className="message-time">{timestamp(message.time)}</span>
{sender} {sender}
<span dangerouslySetInnerHTML={{ __html: ' ' + line }}></span> <span dangerouslySetInnerHTML={{ __html: ' ' + line }}></span>

View File

@ -5,11 +5,12 @@ import pure from 'pure-render-decorator';
@pure @pure
export default class MessageLine extends Component { export default class MessageLine extends Component {
render() { render() {
const line = Autolinker.link(this.props.line, { stripPrefix: false }); const { line, type } = this.props;
const content = Autolinker.link(line, { stripPrefix: false });
const classes = ['message'];
let messageClass = 'message'; if (type) {
if (this.props.type) { classes.push(`message-${type}`);
messageClass += ' message-' + this.props.type;
} }
const style = { const style = {
@ -17,8 +18,8 @@ export default class MessageLine extends Component {
}; };
return ( return (
<p className={messageClass} style={style}> <p className={classes.join(' ')} style={style}>
<span dangerouslySetInnerHTML={{ __html: line }}></span> <span dangerouslySetInnerHTML={{ __html: content }}></span>
</p> </p>
); );
} }

View File

@ -5,10 +5,11 @@ import { toggleMenu } from '../actions/tab';
@pure @pure
class Navicon extends Component { class Navicon extends Component {
handleClick = () => this.props.dispatch(toggleMenu())
render() { render() {
const { dispatch } = this.props;
return ( return (
<i className="icon-menu navicon" onClick={() => dispatch(toggleMenu())}></i> <i className="icon-menu navicon" onClick={this.handleClick}></i>
); );
} }
} }

View File

@ -10,25 +10,27 @@ export default class Search extends Component {
} }
} }
render() { handleSearch = e => this.props.onSearch(e.target.value)
const { search, onSearch } = this.props;
const results = search.results.map(result => {
return (
<p key={result.id}>{timestamp(new Date(result.time * 1000))} {result.from} {result.content}</p>
);
});
render() {
const { search } = this.props;
const style = { const style = {
display: search.show ? 'block' : 'none' display: search.show ? 'block' : 'none'
}; };
const results = search.results.map(result => (
<p key={result.id}>
{timestamp(new Date(result.time * 1000))} {result.from} {result.content}
</p>
));
return ( return (
<div className="search" style={style}> <div className="search" style={style}>
<input <input
ref="input" ref="input"
className="search-input" className="search-input"
type="text" type="text"
onChange={e => onSearch(e.target.value)} onChange={this.handleSearch}
/> />
<div className="search-results">{results}</div> <div className="search-results">{results}</div>
</div> </div>

View File

@ -4,10 +4,9 @@ import TabListItem from './TabListItem';
@pure @pure
export default class TabList extends Component { export default class TabList extends Component {
handleTabClick = (server, channel, pm) => { handleTabClick = (server, target) => {
const { select, hideMenu } = this.props; this.props.select(server, target, target && target.charAt(0) !== '#');
select(server, channel, pm); this.props.hideMenu();
hideMenu();
} }
handleConnectClick = () => { handleConnectClick = () => {
@ -29,35 +28,39 @@ export default class TabList extends Component {
tabs.push( tabs.push(
<TabListItem <TabListItem
key={address} key={address}
server server={address}
content={servers.getIn([address, 'name'])} content={servers.getIn([address, 'name'])}
selected={selected.server === address && selected.channel === null && selected.user === null} selected={
onClick={() => this.handleTabClick(address)} selected.server === address &&
selected.channel === null &&
selected.user === null
}
onClick={this.handleTabClick}
/> />
); );
server.forEach((channel, name) => { server.forEach((channel, name) => tabs.push(
tabs.push(
<TabListItem <TabListItem
key={address + channel.get('name')} key={address + name}
content={channel.get('name')} server={address}
target={name}
content={name}
selected={selected.server === address && selected.channel === name} selected={selected.server === address && selected.channel === name}
onClick={() => this.handleTabClick(address, channel.get('name'))} onClick={this.handleTabClick}
/> />
); ));
});
if (privateChats.has(address)) { if (privateChats.has(address)) {
privateChats.get(address).forEach(nick => { privateChats.get(address).forEach(nick => tabs.push(
tabs.push(
<TabListItem <TabListItem
key={address + nick} key={address + nick}
server={address}
target={nick}
content={nick} content={nick}
selected={selected.server === address && selected.user === nick} selected={selected.server === address && selected.user === nick}
onClick={() => this.handleTabClick(address, nick, true)} onClick={this.handleTabClick}
/> />
); ));
});
} }
}); });

View File

@ -3,19 +3,25 @@ import pure from 'pure-render-decorator';
@pure @pure
export default class TabListItem extends Component { export default class TabListItem extends Component {
handleClick = () => {
const { server, target, onClick } = this.props;
onClick(server, target);
}
render() { render() {
const { target, content, selected } = this.props;
const classes = []; const classes = [];
if (this.props.server) { if (!target) {
classes.push('tab-server'); classes.push('tab-server');
} }
if (this.props.selected) { if (selected) {
classes.push('selected'); classes.push('selected');
} }
return ( return (
<p className={classes.join(' ')} onClick={this.props.onClick}>{this.props.content}</p> <p className={classes.join(' ')} onClick={this.handleClick}>{content}</p>
); );
} }
} }

View File

@ -29,8 +29,7 @@ export default class UserList extends Component {
if (!tab.channel) { if (!tab.channel) {
style.display = 'none'; style.display = 'none';
} else { } else {
this.props.users.forEach(user => { this.props.users.forEach(user => users.push(
users.push(
<UserListItem <UserListItem
key={user.nick} key={user.nick}
user={user} user={user}
@ -38,8 +37,7 @@ export default class UserList extends Component {
openPrivateChat={openPrivateChat} openPrivateChat={openPrivateChat}
select={select} select={select}
/> />
); ));
});
} }
return ( return (

View File

@ -55,6 +55,13 @@ class Chat extends Component {
} }
} }
handleSearch = phrase => {
const { dispatch, tab } = this.props;
if (tab.channel) {
dispatch(searchMessages(tab.server, tab.channel, phrase));
}
}
render() { render() {
const { tab, channel, search, history, dispatch } = this.props; const { tab, channel, search, history, dispatch } = this.props;
@ -72,8 +79,7 @@ class Chat extends Component {
<ChatTitle {...this.props } /> <ChatTitle {...this.props } />
<Search <Search
search={search} search={search}
onSearch={phrase => tab.channel && onSearch={this.handleSearch}
dispatch(searchMessages(tab.server, tab.channel, phrase))}
/> />
<MessageBox {...this.props } /> <MessageBox {...this.props } />
<MessageInput <MessageInput
@ -115,7 +121,7 @@ function mapStateToProps(state) {
let title; let title;
if (tab.channel) { if (tab.channel) {
title = channel.get('name'); title = tab.channel;
} else if (tab.user) { } else if (tab.user) {
title = tab.user; title = tab.user;
} else { } else {

View File

@ -79,10 +79,7 @@ export default createReducer(Map(), {
[actions.SOCKET_JOIN](state, action) { [actions.SOCKET_JOIN](state, action) {
const { server, channels, user } = action; const { server, channels, user } = action;
const channel = channels[0]; return state.updateIn([server, channels[0], 'users'], List(), users => {
return state
.setIn([server, channel, 'name'], channels[0])
.updateIn([server, channel, 'users'], List(), users => {
return users.push(createUser(user)).sort(compareUsers); return users.push(createUser(user)).sort(compareUsers);
}); });
}, },
@ -91,7 +88,9 @@ export default createReducer(Map(), {
const { server, channels, user } = action; const { server, channels, user } = action;
const channel = channels[0]; const channel = channels[0];
if (state.hasIn([server, channel])) { if (state.hasIn([server, channel])) {
return state.updateIn([server, channel, 'users'], users => users.filter(u => u.nick !== user)); return state.updateIn([server, channel, 'users'], users =>
users.filter(u => u.nick !== user)
);
} }
return state; return state;
}, },
@ -156,8 +155,7 @@ export default createReducer(Map(), {
action.data.forEach(channel => { action.data.forEach(channel => {
s.setIn([channel.server, channel.name], Map({ s.setIn([channel.server, channel.name], Map({
users: List(), users: List(),
topic: channel.topic, topic: channel.topic
name: channel.name
})); }));
}); });
}); });