Skip to content

Commit

Permalink
Fix lint errors for examples/todos-with-undo/
Browse files Browse the repository at this point in the history
  • Loading branch information
ellbee committed Oct 27, 2015
1 parent 677abce commit 3dface0
Show file tree
Hide file tree
Showing 10 changed files with 109 additions and 106 deletions.
14 changes: 7 additions & 7 deletions examples/todos-with-undo/actions.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
export const ADD_TODO = 'ADD_TODO';
export const COMPLETE_TODO = 'COMPLETE_TODO';
export const SET_VISIBILITY_FILTER = 'SET_VISIBILITY_FILTER';
export const ADD_TODO = 'ADD_TODO'
export const COMPLETE_TODO = 'COMPLETE_TODO'
export const SET_VISIBILITY_FILTER = 'SET_VISIBILITY_FILTER'

export const VisibilityFilters = {
SHOW_ALL: 'SHOW_ALL',
SHOW_COMPLETED: 'SHOW_COMPLETED',
SHOW_ACTIVE: 'SHOW_ACTIVE'
};
}

export function addTodo(text) {
return { type: ADD_TODO, text };
return { type: ADD_TODO, text }
}

export function completeTodo(index) {
return { type: COMPLETE_TODO, index };
return { type: COMPLETE_TODO, index }
}

export function setVisibilityFilter(filter) {
return { type: SET_VISIBILITY_FILTER, filter };
return { type: SET_VISIBILITY_FILTER, filter }
}
16 changes: 8 additions & 8 deletions examples/todos-with-undo/components/AddTodo.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import React, { Component, PropTypes } from 'react';
import React, { Component, PropTypes } from 'react'

export default class AddTodo extends Component {
handleSubmit(e) {
e.preventDefault();
const node = this.refs.input;
const text = node.value.trim();
e.preventDefault()
const node = this.refs.input
const text = node.value.trim()
if (text) {
this.props.onAddSubmit(text);
node.value = '';
this.props.onAddSubmit(text)
node.value = ''
}
}

Expand All @@ -21,10 +21,10 @@ export default class AddTodo extends Component {
</button>
</form>
</div>
);
)
}
}

AddTodo.propTypes = {
onAddSubmit: PropTypes.func.isRequired
};
}
18 changes: 9 additions & 9 deletions examples/todos-with-undo/components/Footer.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import React, { Component, PropTypes } from 'react';
import React, { Component, PropTypes } from 'react'

export default class Footer extends Component {
renderFilter(filter, name) {
if (filter === this.props.filter) {
return name;
return name
}

return (
<a href="#" onClick={e => {
e.preventDefault();
this.props.onFilterChange(filter);
e.preventDefault()
this.props.onFilterChange(filter)
}}>
{name}
</a>
);
)
}

renderFilters() {
Expand All @@ -28,7 +28,7 @@ export default class Footer extends Component {
{this.renderFilter('SHOW_ACTIVE', 'Active')}
.
</p>
);
)
}

renderUndo() {
Expand All @@ -37,7 +37,7 @@ export default class Footer extends Component {
<button onClick={this.props.onUndo} disabled={this.props.undoDisabled}>Undo</button>
<button onClick={this.props.onRedo} disabled={this.props.redoDisabled}>Redo</button>
</p>
);
)
}

render() {
Expand All @@ -46,7 +46,7 @@ export default class Footer extends Component {
{this.renderFilters()}
{this.renderUndo()}
</div>
);
)
}
}

Expand All @@ -61,4 +61,4 @@ Footer.propTypes = {
'SHOW_COMPLETED',
'SHOW_ACTIVE'
]).isRequired
};
}
6 changes: 3 additions & 3 deletions examples/todos-with-undo/components/Todo.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { Component, PropTypes } from 'react';
import React, { Component, PropTypes } from 'react'

export default class Todo extends Component {
render() {
Expand All @@ -11,12 +11,12 @@ export default class Todo extends Component {
}}>
{this.props.text}
</li>
);
)
}
}

Todo.propTypes = {
onClick: PropTypes.func.isRequired,
text: PropTypes.string.isRequired,
completed: PropTypes.bool.isRequired
};
}
8 changes: 4 additions & 4 deletions examples/todos-with-undo/components/TodoList.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { Component, PropTypes } from 'react';
import Todo from './Todo';
import React, { Component, PropTypes } from 'react'
import Todo from './Todo'

export default class TodoList extends Component {
render() {
Expand All @@ -11,7 +11,7 @@ export default class TodoList extends Component {
onClick={() => this.props.onTodoClick(index)} />
)}
</ul>
);
)
}
}

Expand All @@ -21,4 +21,4 @@ TodoList.propTypes = {
text: PropTypes.string.isRequired,
completed: PropTypes.bool.isRequired
}).isRequired).isRequired
};
}
38 changes: 19 additions & 19 deletions examples/todos-with-undo/containers/App.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import React, { Component, PropTypes } from 'react';
import { connect } from 'react-redux';
import { ActionCreators } from 'redux-undo';
import { addTodo, completeTodo, setVisibilityFilter, VisibilityFilters } from '../actions';
import AddTodo from '../components/AddTodo';
import TodoList from '../components/TodoList';
import Footer from '../components/Footer';
import React, { Component, PropTypes } from 'react'
import { connect } from 'react-redux'
import { ActionCreators } from 'redux-undo'
import { addTodo, completeTodo, setVisibilityFilter, VisibilityFilters } from '../actions'
import AddTodo from '../components/AddTodo'
import TodoList from '../components/TodoList'
import Footer from '../components/Footer'

class App extends Component {
render() {
const { dispatch, visibleTodos, visibilityFilter } = this.props;
const { dispatch, visibleTodos, visibilityFilter } = this.props
return (
<div>
<AddTodo
Expand All @@ -24,7 +24,7 @@ class App extends Component {
undoDisabled={this.props.undoDisabled}
redoDisabled={this.props.redoDisabled} />
</div>
);
)
}
}

Expand All @@ -41,17 +41,17 @@ App.propTypes = {
]).isRequired,
undoDisabled: PropTypes.bool.isRequired,
redoDisabled: PropTypes.bool.isRequired
};
}

function selectTodos(todos, filter) {
switch (filter) {
default:
case VisibilityFilters.SHOW_ALL:
return todos;
case VisibilityFilters.SHOW_COMPLETED:
return todos.filter(todo => todo.completed);
case VisibilityFilters.SHOW_ACTIVE:
return todos.filter(todo => !todo.completed);
default:
case VisibilityFilters.SHOW_ALL:
return todos
case VisibilityFilters.SHOW_COMPLETED:
return todos.filter(todo => todo.completed)
case VisibilityFilters.SHOW_ACTIVE:
return todos.filter(todo => !todo.completed)
}
}

Expand All @@ -61,7 +61,7 @@ function select(state) {
redoDisabled: state.todos.future.length === 0,
visibleTodos: selectTodos(state.todos.present, state.visibilityFilter),
visibilityFilter: state.visibilityFilter
};
}
}

export default connect(select)(App);
export default connect(select)(App)
18 changes: 9 additions & 9 deletions examples/todos-with-undo/index.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import React from 'react';
import { render } from 'react-dom';
import { createStore } from 'redux';
import { Provider } from 'react-redux';
import App from './containers/App';
import todoApp from './reducers';
import React from 'react'
import { render } from 'react-dom'
import { createStore } from 'redux'
import { Provider } from 'react-redux'
import App from './containers/App'
import todoApp from './reducers'

const store = createStore(todoApp);
const store = createStore(todoApp)

const rootElement = document.getElementById('root');
const rootElement = document.getElementById('root')
render(
<Provider store={store}>
<App />
</Provider>,
rootElement
);
)
53 changes: 28 additions & 25 deletions examples/todos-with-undo/reducers.js
Original file line number Diff line number Diff line change
@@ -1,41 +1,44 @@
import { combineReducers } from 'redux';
import undoable, { distinctState } from 'redux-undo';
import { combineReducers } from 'redux'
import undoable, { distinctState } from 'redux-undo'

import { ADD_TODO, COMPLETE_TODO, SET_VISIBILITY_FILTER, VisibilityFilters } from './actions';
const { SHOW_ALL } = VisibilityFilters;
import { ADD_TODO, COMPLETE_TODO, SET_VISIBILITY_FILTER, VisibilityFilters } from './actions'
const { SHOW_ALL } = VisibilityFilters

function visibilityFilter(state = SHOW_ALL, action) {
switch (action.type) {
case SET_VISIBILITY_FILTER:
return action.filter;
default:
return state;
case SET_VISIBILITY_FILTER:
return action.filter
default:
return state
}
}

function todos(state = [], action) {
switch (action.type) {
case ADD_TODO:
return [...state, {
text: action.text,
completed: false
}];
case COMPLETE_TODO:
return [
...state.slice(0, action.index),
Object.assign({}, state[action.index], {
completed: true
}),
...state.slice(action.index + 1)
];
default:
return state;
case ADD_TODO:
return [
...state,
{
text: action.text,
completed: false
}
]
case COMPLETE_TODO:
return [
...state.slice(0, action.index),
Object.assign({}, state[action.index], {
completed: true
}),
...state.slice(action.index + 1)
]
default:
return state
}
}

const todoApp = combineReducers({
visibilityFilter,
todos: undoable(todos, { filter: distinctState() })
});
})

export default todoApp;
export default todoApp
28 changes: 14 additions & 14 deletions examples/todos-with-undo/server.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
var webpack = require('webpack');
var webpackDevMiddleware = require('webpack-dev-middleware');
var webpackHotMiddleware = require('webpack-hot-middleware');
var config = require('./webpack.config');
var webpack = require('webpack')
var webpackDevMiddleware = require('webpack-dev-middleware')
var webpackHotMiddleware = require('webpack-hot-middleware')
var config = require('./webpack.config')

var app = new require('express')();
var port = 3000;
var app = new require('express')()
var port = 3000

var compiler = webpack(config);
app.use(webpackDevMiddleware(compiler, { noInfo: true, publicPath: config.output.publicPath }));
app.use(webpackHotMiddleware(compiler));
var compiler = webpack(config)
app.use(webpackDevMiddleware(compiler, { noInfo: true, publicPath: config.output.publicPath }))
app.use(webpackHotMiddleware(compiler))

app.get("/", function(req, res) {
res.sendFile(__dirname + '/index.html');
});
res.sendFile(__dirname + '/index.html')
})

app.listen(port, function(error) {
if (error) {
console.error(error);
console.error(error)
} else {
console.info("==> 🌎 Listening on port %s. Open up http://localhost:%s/ in your browser.", port, port);
console.info("==> 🌎 Listening on port %s. Open up http://localhost:%s/ in your browser.", port, port)
}
});
})
Loading

0 comments on commit 3dface0

Please sign in to comment.