forked from reduxjs/redux
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix lint errors for examples/todos-with-undo/
- Loading branch information
Showing
10 changed files
with
109 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
); | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
}); | ||
}) |
Oops, something went wrong.