Skip to content

Commit 0388e5e

Browse files
committed
Update eslint
1 parent 51e9b99 commit 0388e5e

File tree

7 files changed

+38
-28
lines changed

7 files changed

+38
-28
lines changed

.eslintrc

+2-8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"extends": "airbnb",
33
"parser": "babel-eslint",
4-
"plugins": ["mocha", "babel", "flowtype"],
4+
"plugins": ["mocha", "flowtype"],
55
"env": {
66
"mocha": true,
77
"browser": true,
@@ -22,13 +22,7 @@
2222
"flowtype/space-after-type-colon": [1, "always"],
2323
"flowtype/space-before-type-colon": [1, "never"],
2424
"flowtype/type-id-match": [1, "^([A-Z][a-z0-9]+)+Type$"],
25-
"flowtype/use-flow-type": 1,
26-
"babel/new-cap": 1,
27-
"babel/array-bracket-spacing": 1,
28-
"babel/object-shorthand": 1,
29-
"babel/no-await-in-loop": 1,
30-
"babel/flow-object-type": 1,
31-
"babel/func-params-comma-dangle": 1
25+
"flowtype/use-flow-type": 1
3226
},
3327
"settings": {
3428
"import/resolver": {

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,10 @@
100100
"flow:status": "flow status; test $? -eq 0 -o $? -eq 2",
101101
"flow:stop": "flow stop",
102102
"flow:watch": "npm run flow:status && chokidar './src/**/*.js' './test/**/*.js' -c 'npm run flow:status'",
103+
"lint": "esw -w './src/**/*.js' './test/**/*.js'",
103104
"prepublish": "npm run build",
104105
"test": "mocha",
105106
"test:coverage": "istanbul cover node_modules/mocha/bin/_mocha",
106-
"test:lint": "esw -w './src/**/*-test.js' './test/**/*.js'",
107107
"test:watch": "mocha --watch --reporter progress"
108108
}
109109
}

src/csp.operations.js

+15-4
Original file line numberDiff line numberDiff line change
@@ -390,9 +390,13 @@ const ID_ATTR = '__csp_channel_id';
390390
function chanId(ch) {
391391
let id = ch[ID_ATTR];
392392

393-
if (id === undefined) {
394-
id = ch[ID_ATTR] = genId();
393+
if (!id) {
394+
const generatedId = genId();
395+
396+
id = generatedId;
397+
ch[ID_ATTR] = generatedId;
395398
}
399+
396400
return id;
397401
}
398402

@@ -584,10 +588,13 @@ class Mix {
584588
let chanData = this.stateMap[id];
585589

586590
if (!chanData) {
587-
chanData = this.stateMap[id] = {
591+
const defaultVal = {
588592
channel: ch,
589593
state: {},
590594
};
595+
596+
chanData = defaultVal;
597+
this.stateMap[id] = defaultVal;
591598
}
592599
Object.keys(updateState).forEach((mode) => {
593600
chanData.state[mode] = updateState[mode];
@@ -671,8 +678,12 @@ class Pub {
671678
_ensureMult(topic) {
672679
let m = this.mults[topic];
673680
const bufferFn = this.bufferFn;
681+
674682
if (!m) {
675-
m = this.mults[topic] = mult(chan(bufferFn(topic)));
683+
const defaultVal = mult(chan(bufferFn(topic)));
684+
685+
m = defaultVal;
686+
this.mults[topic] = defaultVal;
676687
}
677688
return m;
678689
}

src/impl/buffers.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
// @flow
2-
function acopy<T>(src: Array<T>, srcStart: number,
3-
dest: Array<T>, destStart: number,
4-
len: number): void {
2+
function acopy<T>(
3+
src: Array<T>, srcStart: number,
4+
dest: Array<T>, destStart: number,
5+
len: number,
6+
): void {
57
for (let count = 0; count < len; count += 1) {
68
dest[destStart + count] = src[srcStart + count];
79
}

src/impl/channels.js

+10-7
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,6 @@ export class Channel {
191191
if (this.buf) {
192192
this.xform['@@transducer/result'](this.buf);
193193

194-
// flow-ignore
195194
while (this.buf.count() > 0 && this.takes.length > 0) {
196195
const taker = this.takes.pop();
197196

@@ -240,9 +239,11 @@ function defaultExceptionHandler(err: Error): typeof CLOSED {
240239
return CLOSED;
241240
}
242241

243-
function handleEx<T>(buf: BufferType<T>,
244-
exHandler: ?Function,
245-
e: Error): BufferType<T> {
242+
function handleEx<T>(
243+
buf: BufferType<T>,
244+
exHandler: ?Function,
245+
e: Error,
246+
): BufferType<T> {
246247
const def = (exHandler || defaultExceptionHandler)(e);
247248

248249
if (def !== CLOSED) {
@@ -273,9 +274,11 @@ function handleException<T>(exHandler: ?Function): Function {
273274

274275
// XXX: This is inconsistent. We should either call the reducing
275276
// function xform, or call the transducers xform, not both
276-
export function chan(buf: ?BufferType<mixed>,
277-
xform: ?Function,
278-
exHandler: ?Function): Channel {
277+
export function chan(
278+
buf: ?BufferType<mixed>,
279+
xform: ?Function,
280+
exHandler: ?Function,
281+
): Channel {
279282
let newXForm: typeof AddTransformer;
280283

281284
if (xform) {

src/impl/select.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ import { AltHandler } from './handlers';
88
import { AltResult, DEFAULT } from './results';
99

1010
// TODO: Accept a priority function or something
11-
export function doAlts(
11+
export function doAlts( // eslint-disable-line
1212
operations: Channel[] | [Channel, mixed][],
1313
callback: Function,
14-
options: Object
14+
options: Object,
1515
) {
1616
if (operations.length === 0) {
1717
throw new Error('Empty alt list');
@@ -29,13 +29,13 @@ export function doAlts(
2929
if (operation instanceof Channel) {
3030
ch = operation;
3131
result = ch.take(
32-
new AltHandler(flag, (value: mixed) => callback(new AltResult(value, ch)))
32+
new AltHandler(flag, (value: mixed) => callback(new AltResult(value, ch))),
3333
);
3434
} else {
3535
ch = operation[0];
3636
result = ch.put(
3737
operation[1],
38-
new AltHandler(flag, (value: mixed) => callback(new AltResult(value, ch)))
38+
new AltHandler(flag, (value: mixed) => callback(new AltResult(value, ch))),
3939
);
4040
}
4141

src/impl/timers.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import { queueDelay } from './dispatch';
33
import { chan, Channel } from './channels';
44

5-
export function timeout(msecs: number): Channel {
5+
export function timeout(msecs: number): Channel { // eslint-disable-line
66
const ch: Channel = chan();
77

88
queueDelay(() => ch.close(), msecs);

0 commit comments

Comments
 (0)