Skip to content

Commit 7b87d92

Browse files
authored
Merge pull request #221 from gerges/task/fix-lint-warnings
Fix outstanding lint warnings
2 parents dc4bffd + 1f57c50 commit 7b87d92

File tree

7 files changed

+65
-61
lines changed

7 files changed

+65
-61
lines changed

src/console-polyfill.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
try {
2+
/* eslint-disable no-console */
23
if (!(window.console && console.log)) {
4+
/* eslint-enable no-console */
35
console = {
4-
log: function(){},
5-
debug: function(){},
6-
info: function(){},
7-
warn: function(){},
8-
error: function(){}
9-
};
6+
log: function() {},
7+
debug: function() {},
8+
info: function() {},
9+
warn: function() {},
10+
error: function() {},
11+
}
1012
}
11-
} catch(e) {}
13+
} catch(e) {
14+
// ignored
15+
}

src/create-react-mixin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export default function(reactor) {
2626
each(this.getDataBindings(), (getter, key) => {
2727
const unwatchFn = reactor.observe(getter, (val) => {
2828
this.setState({
29-
[key]: val
29+
[key]: val,
3030
})
3131
})
3232

src/reactor/cache.js

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { List, Map, OrderedSet, Record } from 'immutable'
1+
import { Map, OrderedSet, Record } from 'immutable'
22

33
export const CacheEntry = Record({
44
value: null,
@@ -28,7 +28,7 @@ export class BasicCache {
2828
* @param {Immutable.Map} cache
2929
*/
3030
constructor(cache = Map()) {
31-
this.cache = cache;
31+
this.cache = cache
3232
}
3333

3434
/**
@@ -65,7 +65,7 @@ export class BasicCache {
6565
* @return {BasicCache}
6666
*/
6767
hit(item) {
68-
return this;
68+
return this
6969
}
7070

7171
/**
@@ -78,7 +78,7 @@ export class BasicCache {
7878
return new BasicCache(
7979
this.cache.update(item, existingEntry => {
8080
if (existingEntry && existingEntry.dispatchId > entry.dispatchId) {
81-
throw new Error("Refusing to cache older value")
81+
throw new Error('Refusing to cache older value')
8282
}
8383
return entry
8484
})
@@ -106,10 +106,10 @@ const DEFAULT_LRU_EVICT_COUNT = 1
106106
export class LRUCache {
107107

108108
constructor(limit = DEFAULT_LRU_LIMIT, evictCount = DEFAULT_LRU_EVICT_COUNT, cache = new BasicCache(), lru = OrderedSet()) {
109-
this.limit = limit;
109+
this.limit = limit
110110
this.evictCount = evictCount
111-
this.cache = cache;
112-
this.lru = lru;
111+
this.cache = cache
112+
this.lru = lru
113113
}
114114

115115
/**
@@ -147,7 +147,7 @@ export class LRUCache {
147147
*/
148148
hit(item) {
149149
if (!this.cache.has(item)) {
150-
return this;
150+
return this
151151
}
152152

153153
// remove it first to reorder in lru OrderedSet
@@ -162,6 +162,7 @@ export class LRUCache {
162162
* @return {LRUCache}
163163
*/
164164
miss(item, entry) {
165+
var lruCache
165166
if (this.lru.size >= this.limit) {
166167
if (this.has(item)) {
167168
return new LRUCache(
@@ -175,22 +176,23 @@ export class LRUCache {
175176
const cache = (this.lru
176177
.take(this.evictCount)
177178
.reduce((c, evictItem) => c.evict(evictItem), this.cache)
178-
.miss(item, entry));
179+
.miss(item, entry))
179180

180-
return new LRUCache(
181+
lruCache = new LRUCache(
181182
this.limit,
182183
this.evictCount,
183184
cache,
184185
this.lru.skip(this.evictCount).add(item)
185186
)
186187
} else {
187-
return new LRUCache(
188+
lruCache = new LRUCache(
188189
this.limit,
189190
this.evictCount,
190191
this.cache.miss(item, entry),
191192
this.lru.add(item)
192193
)
193194
}
195+
return lruCache
194196
}
195197

196198
/**
@@ -200,7 +202,7 @@ export class LRUCache {
200202
*/
201203
evict(item) {
202204
if (!this.cache.has(item)) {
203-
return this;
205+
return this
204206
}
205207

206208
return new LRUCache(

src/reactor/fns.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export function replaceStores(reactorState, stores) {
7575
*/
7676
export function dispatch(reactorState, actionType, payload) {
7777
if (actionType === undefined && getOption(reactorState, 'throwOnUndefinedActionType')) {
78-
throw new Error('`dispatch` cannot be called with an `undefined` action type.');
78+
throw new Error('`dispatch` cannot be called with an `undefined` action type.')
7979
}
8080

8181
const currState = reactorState.get('state')

tests/cache-tests.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import Immutable, { Map } from 'immutable'
2-
import { toImmutable } from '../src/immutable-helpers'
3-
import { BasicCache, LRUCache } from '../src/reactor/cache'
2+
import { LRUCache } from '../src/reactor/cache'
43

54

65
describe('Cache', () => {
@@ -16,9 +15,9 @@ describe('Cache', () => {
1615

1716
expect(cache.asMap().isEmpty()).toBe(true)
1817

19-
var a = {foo: "bar"}
20-
var b = {bar: "baz"}
21-
var c = {baz: "foo"}
18+
var a = {foo: 'bar'}
19+
var b = {bar: 'baz'}
20+
var c = {baz: 'foo'}
2221

2322
cache = cache.miss('a', a)
2423

tests/reactor-fns-tests.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import { Map, Set, is } from 'immutable'
33
import { Store } from '../src/main'
44
import * as fns from '../src/reactor/fns'
5-
import { ReactorState, ObserverState, DEBUG_OPTIONS } from '../src/reactor/records'
5+
import { ReactorState, ObserverState } from '../src/reactor/records'
66
import { toImmutable } from '../src/immutable-helpers'
77

88
describe('reactor fns', () => {
@@ -571,7 +571,7 @@ describe('reactor fns', () => {
571571
})
572572

573573
expect(function() {
574-
const result = fns.getOption(reactorState, 'unknownOption')
574+
fns.getOption(reactorState, 'unknownOption')
575575
}).toThrow()
576576
})
577577
})

0 commit comments

Comments
 (0)