Skip to content

Commit

Permalink
Merge pull request #221 from gerges/task/fix-lint-warnings
Browse files Browse the repository at this point in the history
Fix outstanding lint warnings
  • Loading branch information
jordangarcia committed Sep 19, 2016
2 parents dc4bffd + 1f57c50 commit 7b87d92
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 61 deletions.
18 changes: 11 additions & 7 deletions src/console-polyfill.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
try {
/* eslint-disable no-console */
if (!(window.console && console.log)) {
/* eslint-enable no-console */
console = {
log: function(){},
debug: function(){},
info: function(){},
warn: function(){},
error: function(){}
};
log: function() {},
debug: function() {},
info: function() {},
warn: function() {},
error: function() {},
}
}
} catch(e) {}
} catch(e) {
// ignored
}
2 changes: 1 addition & 1 deletion src/create-react-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default function(reactor) {
each(this.getDataBindings(), (getter, key) => {
const unwatchFn = reactor.observe(getter, (val) => {
this.setState({
[key]: val
[key]: val,
})
})

Expand Down
26 changes: 14 additions & 12 deletions src/reactor/cache.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { List, Map, OrderedSet, Record } from 'immutable'
import { Map, OrderedSet, Record } from 'immutable'

export const CacheEntry = Record({
value: null,
Expand Down Expand Up @@ -28,7 +28,7 @@ export class BasicCache {
* @param {Immutable.Map} cache
*/
constructor(cache = Map()) {
this.cache = cache;
this.cache = cache
}

/**
Expand Down Expand Up @@ -65,7 +65,7 @@ export class BasicCache {
* @return {BasicCache}
*/
hit(item) {
return this;
return this
}

/**
Expand All @@ -78,7 +78,7 @@ export class BasicCache {
return new BasicCache(
this.cache.update(item, existingEntry => {
if (existingEntry && existingEntry.dispatchId > entry.dispatchId) {
throw new Error("Refusing to cache older value")
throw new Error('Refusing to cache older value')
}
return entry
})
Expand Down Expand Up @@ -106,10 +106,10 @@ const DEFAULT_LRU_EVICT_COUNT = 1
export class LRUCache {

constructor(limit = DEFAULT_LRU_LIMIT, evictCount = DEFAULT_LRU_EVICT_COUNT, cache = new BasicCache(), lru = OrderedSet()) {
this.limit = limit;
this.limit = limit
this.evictCount = evictCount
this.cache = cache;
this.lru = lru;
this.cache = cache
this.lru = lru
}

/**
Expand Down Expand Up @@ -147,7 +147,7 @@ export class LRUCache {
*/
hit(item) {
if (!this.cache.has(item)) {
return this;
return this
}

// remove it first to reorder in lru OrderedSet
Expand All @@ -162,6 +162,7 @@ export class LRUCache {
* @return {LRUCache}
*/
miss(item, entry) {
var lruCache
if (this.lru.size >= this.limit) {
if (this.has(item)) {
return new LRUCache(
Expand All @@ -175,22 +176,23 @@ export class LRUCache {
const cache = (this.lru
.take(this.evictCount)
.reduce((c, evictItem) => c.evict(evictItem), this.cache)
.miss(item, entry));
.miss(item, entry))

return new LRUCache(
lruCache = new LRUCache(
this.limit,
this.evictCount,
cache,
this.lru.skip(this.evictCount).add(item)
)
} else {
return new LRUCache(
lruCache = new LRUCache(
this.limit,
this.evictCount,
this.cache.miss(item, entry),
this.lru.add(item)
)
}
return lruCache
}

/**
Expand All @@ -200,7 +202,7 @@ export class LRUCache {
*/
evict(item) {
if (!this.cache.has(item)) {
return this;
return this
}

return new LRUCache(
Expand Down
2 changes: 1 addition & 1 deletion src/reactor/fns.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export function replaceStores(reactorState, stores) {
*/
export function dispatch(reactorState, actionType, payload) {
if (actionType === undefined && getOption(reactorState, 'throwOnUndefinedActionType')) {
throw new Error('`dispatch` cannot be called with an `undefined` action type.');
throw new Error('`dispatch` cannot be called with an `undefined` action type.')
}

const currState = reactorState.get('state')
Expand Down
9 changes: 4 additions & 5 deletions tests/cache-tests.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import Immutable, { Map } from 'immutable'
import { toImmutable } from '../src/immutable-helpers'
import { BasicCache, LRUCache } from '../src/reactor/cache'
import { LRUCache } from '../src/reactor/cache'


describe('Cache', () => {
Expand All @@ -16,9 +15,9 @@ describe('Cache', () => {

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

var a = {foo: "bar"}
var b = {bar: "baz"}
var c = {baz: "foo"}
var a = {foo: 'bar'}
var b = {bar: 'baz'}
var c = {baz: 'foo'}

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

Expand Down
4 changes: 2 additions & 2 deletions tests/reactor-fns-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { Map, Set, is } from 'immutable'
import { Store } from '../src/main'
import * as fns from '../src/reactor/fns'
import { ReactorState, ObserverState, DEBUG_OPTIONS } from '../src/reactor/records'
import { ReactorState, ObserverState } from '../src/reactor/records'
import { toImmutable } from '../src/immutable-helpers'

describe('reactor fns', () => {
Expand Down Expand Up @@ -571,7 +571,7 @@ describe('reactor fns', () => {
})

expect(function() {
const result = fns.getOption(reactorState, 'unknownOption')
fns.getOption(reactorState, 'unknownOption')
}).toThrow()
})
})
Expand Down

0 comments on commit 7b87d92

Please sign in to comment.