Skip to content

Commit

Permalink
Satisfy linting rules
Browse files Browse the repository at this point in the history
  • Loading branch information
nmay231 committed Dec 18, 2019
1 parent 323b321 commit ef25eea
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/debug.js
Expand Up @@ -20,7 +20,7 @@ function initBuffer () {

/* istanbul ignore next: debug messaging is not tested */
function printBuffer () {
let { header, prev, next, action, msgs } = displayBuffer
const { header, prev, next, action, msgs } = displayBuffer
if (console.group) {
console.groupCollapsed(...header)
console.log(...prev)
Expand Down
6 changes: 4 additions & 2 deletions src/reducer.js
Expand Up @@ -7,7 +7,7 @@ function createHistory (state, ignoreInitialState) {
// ignoreInitialState essentially prevents the user from undoing to the
// beginning, in the case that the undoable reducer handles initialization
// in a way that can't be redone simply
let history = newHistory([], state, [])
const history = newHistory([], state, [])
if (ignoreInitialState) {
history._latestUnfiltered = null
}
Expand Down Expand Up @@ -207,6 +207,7 @@ export default function undoable (reducer, rawConfig = {}) {
return history
}

/* eslint-disable-next-line no-case-declarations */
const filtered = typeof config.filter === 'function' && !config.filter(
action,
res,
Expand All @@ -215,7 +216,7 @@ export default function undoable (reducer, rawConfig = {}) {

if (filtered) {
// if filtering an action, merely update the present
let filteredState = newHistory(
const filteredState = newHistory(
history.past,
res,
history.future,
Expand All @@ -229,6 +230,7 @@ export default function undoable (reducer, rawConfig = {}) {
return filteredState
}

/* eslint-disable-next-line no-case-declarations */
const group = config.groupBy(action, res, history)
if (group != null && group === history.group) {
// if grouping with the previous action, only update the present
Expand Down
2 changes: 1 addition & 1 deletion test/combineFilters.spec.js
Expand Up @@ -52,7 +52,7 @@ function runTestCombineFilters () {
})

it('should not call remaining filters if one already returned false', () => {
let act = { hasBeenCalled: false }
const act = { hasBeenCalled: false }
const combined = combineFilters(checkStateNot1, checkStateNot2, checkIfCalled)

combined(act, 2)
Expand Down
26 changes: 13 additions & 13 deletions test/index.spec.js
Expand Up @@ -29,7 +29,7 @@ runTests('Initial State equals 100', {
})
runTests('Initial State that looks like a history', {
undoableConfig: {},
initialStoreState: { 'present': 0 },
initialStoreState: { present: 0 },
testConfig: {
checkSlices: true
}
Expand Down Expand Up @@ -275,7 +275,7 @@ function runTests (label, { undoableConfig = {}, initialStoreState, testConfig }
})

it('should not record non state changing actions', () => {
let dummyState = mockUndoableReducer(incrementedState, { type: 'DUMMY' })
const dummyState = mockUndoableReducer(incrementedState, { type: 'DUMMY' })
expect(dummyState).to.deep.equal(incrementedState)
})

Expand All @@ -287,24 +287,24 @@ function runTests (label, { undoableConfig = {}, initialStoreState, testConfig }
...undoableConfig,
syncFilter: true
})
let unsynchronized = mockUndoableReducer(mockInitialState, excludedAction)
let synchronized = synchronizedFilteredReducer(mockInitialState, excludedAction)
const unsynchronized = mockUndoableReducer(mockInitialState, excludedAction)
const synchronized = synchronizedFilteredReducer(mockInitialState, excludedAction)
expect(unsynchronized.present).to.deep.equal(synchronized.present)
expect(unsynchronized._latestUnfiltered).to.not.deep.equal(synchronized._latestUnfiltered)
expect(synchronized.present).to.deep.equal(synchronized._latestUnfiltered)
}
})

it('should not record undefined actions', () => {
let dummyState = mockUndoableReducer(incrementedState, undefined)
const dummyState = mockUndoableReducer(incrementedState, undefined)
expect(dummyState).to.deep.equal(incrementedState)
})

it('should reset upon init actions', () => {
let reInitializedState
if (undoableConfig && undoableConfig.initTypes) {
if (undoableConfig.initTypes.length > 0) {
let initType = Array.isArray(undoableConfig.initTypes) ? undoableConfig.initTypes[0] : undoableConfig.initTypes
const initType = Array.isArray(undoableConfig.initTypes) ? undoableConfig.initTypes[0] : undoableConfig.initTypes
reInitializedState = mockUndoableReducer(incrementedState, { type: initType })
expect(reInitializedState).to.deep.equal(mockInitialState)
} else {
Expand All @@ -319,7 +319,7 @@ function runTests (label, { undoableConfig = {}, initialStoreState, testConfig }
})

it('should increment when action is dispatched to store', () => {
let expectedResult = store.getState().present + 1
const expectedResult = store.getState().present + 1
store.dispatch({ type: 'INCREMENT' })
expect(store.getState().present).to.equal(expectedResult)
})
Expand Down Expand Up @@ -457,7 +457,7 @@ function runTests (label, { undoableConfig = {}, initialStoreState, testConfig }
})

it('should do nothing if \'past\' is empty', () => {
let undoInitialState = mockUndoableReducer(mockInitialState, ActionCreators.undo())
const undoInitialState = mockUndoableReducer(mockInitialState, ActionCreators.undo())
if (!mockInitialState.past.length) {
expect(undoInitialState.present).to.deep.equal(mockInitialState.present)
}
Expand Down Expand Up @@ -527,7 +527,7 @@ function runTests (label, { undoableConfig = {}, initialStoreState, testConfig }
})

it('should do nothing if \'future\' is empty', () => {
let secondRedoState = mockUndoableReducer(redoState, ActionCreators.redo())
const secondRedoState = mockUndoableReducer(redoState, ActionCreators.redo())
if (!redoState.future.length) {
expect(secondRedoState.present).to.deep.equal(redoState.present)
}
Expand Down Expand Up @@ -563,7 +563,7 @@ function runTests (label, { undoableConfig = {}, initialStoreState, testConfig }
})

it('should do nothing if past index is out of bounds', () => {
let jumpToOutOfBounds = mockUndoableReducer(incrementedState, ActionCreators.jumpToPast(-1))
const jumpToOutOfBounds = mockUndoableReducer(incrementedState, ActionCreators.jumpToPast(-1))
expect(jumpToOutOfBounds).to.deep.equal(incrementedState)
})

Expand Down Expand Up @@ -599,7 +599,7 @@ function runTests (label, { undoableConfig = {}, initialStoreState, testConfig }
})

it('should do nothing if future index is out of bounds', () => {
let jumpToOutOfBounds = mockUndoableReducer(mockInitialState, ActionCreators.jumpToFuture(-1))
const jumpToOutOfBounds = mockUndoableReducer(mockInitialState, ActionCreators.jumpToFuture(-1))
expect(jumpToOutOfBounds).to.deep.equal(mockInitialState)
})

Expand Down Expand Up @@ -632,7 +632,7 @@ function runTests (label, { undoableConfig = {}, initialStoreState, testConfig }
let doubleUndoState
let doubleRedoState
before('perform a jump action', () => {
let doubleIncrementedState = mockUndoableReducer(incrementedState, { type: 'INCREMENT' })
const doubleIncrementedState = mockUndoableReducer(incrementedState, { type: 'INCREMENT' })
jumpToPastState = mockUndoableReducer(doubleIncrementedState, ActionCreators.jump(jumpStepsToPast))
jumpToFutureState = mockUndoableReducer(mockInitialState, ActionCreators.jump(jumpStepsToFuture))
doubleUndoState = mockUndoableReducer(doubleIncrementedState, ActionCreators.undo())
Expand All @@ -654,7 +654,7 @@ function runTests (label, { undoableConfig = {}, initialStoreState, testConfig }
})

it('should do nothing if steps is 0', () => {
let jumpToCurrentState = mockUndoableReducer(mockInitialState, ActionCreators.jump(0))
const jumpToCurrentState = mockUndoableReducer(mockInitialState, ActionCreators.jump(0))
expect(jumpToCurrentState).to.deep.equal(mockInitialState)
})

Expand Down

0 comments on commit ef25eea

Please sign in to comment.