Skip to content

Commit 5912aaa

Browse files
committed
Modernize existing tests. Remove dead code. Resolves #7.
1 parent 2d038e1 commit 5912aaa

21 files changed

+1528
-2423
lines changed

.eslintrc.js

Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
'use strict';
2+
3+
const OFF = 'off';
4+
const ERROR = 'error';
5+
const WARN = 'warn';
6+
const ALWAYS = 'always';
7+
const NEVER = 'never';
8+
9+
module.exports = {
10+
'parserOptions': {
11+
ecmaVersion: 2017
12+
},
13+
'env': {
14+
es6: true,
15+
node: true,
16+
mocha: true
17+
},
18+
'plugins': [
19+
'mocha'
20+
],
21+
'extends': 'eslint:recommended',
22+
'rules': {
23+
'indent': [
24+
ERROR,
25+
4,
26+
{
27+
SwitchCase: 1
28+
}
29+
],
30+
'linebreak-style': ERROR,
31+
'quotes': [
32+
WARN,
33+
'single',
34+
{
35+
avoidEscape: true,
36+
allowTemplateLiterals: true
37+
}
38+
],
39+
'semi': [
40+
ERROR,
41+
ALWAYS
42+
],
43+
'func-names': ERROR,
44+
'no-var': ERROR,
45+
'no-empty': ERROR,
46+
'no-empty-function': ERROR,
47+
'brace-style': [
48+
ERROR,
49+
'1tbs',
50+
{ allowSingleLine: true }
51+
],
52+
'no-multiple-empty-lines': ERROR,
53+
'no-multi-spaces': ERROR,
54+
'one-var': [
55+
ERROR,
56+
NEVER
57+
],
58+
'quote-props': [
59+
WARN,
60+
'consistent-as-needed'
61+
],
62+
'key-spacing': ERROR,
63+
'space-unary-ops': [
64+
ERROR,
65+
{
66+
words: true,
67+
nonwords: false
68+
}
69+
],
70+
'no-spaced-func': ERROR,
71+
'space-before-function-paren': [
72+
ERROR,
73+
{
74+
anonymous: ALWAYS,
75+
named: NEVER
76+
}
77+
],
78+
'arrow-body-style': [
79+
WARN,
80+
'as-needed'
81+
],
82+
'array-bracket-spacing': ERROR,
83+
'space-in-parens': ERROR,
84+
'comma-dangle': ERROR,
85+
'no-trailing-spaces': ERROR,
86+
'yoda': ERROR,
87+
'max-len': [
88+
ERROR,
89+
120
90+
],
91+
'camelcase': [
92+
ERROR,
93+
{
94+
properties: 'never'
95+
}
96+
],
97+
'new-cap': [
98+
WARN,
99+
{
100+
capIsNewExceptions: ['Q']
101+
}
102+
],
103+
'comma-style': ERROR,
104+
'curly': ERROR,
105+
'object-curly-spacing': [
106+
WARN,
107+
ALWAYS
108+
],
109+
'object-curly-newline': [
110+
ERROR,
111+
{
112+
ObjectExpression: {
113+
minProperties: 1
114+
},
115+
ObjectPattern: {
116+
multiline: true,
117+
minProperties: 5
118+
}
119+
}
120+
],
121+
'object-property-newline': ERROR,
122+
'template-curly-spacing': ERROR,
123+
'dot-notation': ERROR,
124+
'dot-location': [
125+
ERROR,
126+
'property'
127+
],
128+
'func-style': [
129+
ERROR,
130+
'declaration',
131+
{
132+
allowArrowFunctions: true
133+
}
134+
],
135+
'eol-last': ERROR,
136+
'space-infix-ops': ERROR,
137+
'keyword-spacing': ERROR,
138+
'space-before-blocks': ERROR,
139+
'no-invalid-this': ERROR,
140+
'consistent-this': ERROR,
141+
'no-this-before-super': ERROR,
142+
'no-unreachable': ERROR,
143+
'no-sparse-arrays': ERROR,
144+
'array-callback-return': ERROR,
145+
'strict': [
146+
WARN,
147+
'global'
148+
],
149+
'eqeqeq': ERROR,
150+
'no-use-before-define': WARN,
151+
'no-undef': ERROR,
152+
'no-unused-vars': WARN,
153+
'no-mixed-spaces-and-tabs': ERROR,
154+
'operator-linebreak': [
155+
ERROR,
156+
'before'
157+
],
158+
'no-console': [
159+
OFF
160+
],
161+
"mocha/no-exclusive-tests": "error"
162+
}
163+
};

.jscsrc

Lines changed: 0 additions & 1 deletion
This file was deleted.

.jshintrc

Lines changed: 0 additions & 1 deletion
This file was deleted.

gulpfile.js

Lines changed: 0 additions & 26 deletions
This file was deleted.

lib/actions/write.js

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict';
2+
13
const request = require('request-promise');
24
const co = require('co');
35
const csv = require('csv');
@@ -10,10 +12,7 @@ let signedUrl;
1012
let timeout;
1113
let rowCount = 0;
1214

13-
exports.init = init;
14-
exports.process = processAction;
15-
16-
function init(cfg) {
15+
exports.init = function init(cfg) {
1716
return co(function* gen() {
1817

1918
const delimiter = cfg.reader.delimiter || ',';
@@ -40,11 +39,11 @@ function init(cfg) {
4039

4140
stringifier.pipe(request.put(putUrl));
4241
});
43-
}
42+
};
4443

45-
function processAction(msg, cfg) {
44+
exports.process = function ProcessAction(msg, cfg) {
45+
// eslint-disable-next-line consistent-this
4646
const self = this;
47-
4847
const startRow = cfg.reader.startRow || 0;
4948

5049
if (startRow !== 0 && rowCount === 0) {
@@ -55,7 +54,7 @@ function processAction(msg, cfg) {
5554
clearTimeout(timeout);
5655
}
5756

58-
timeout = setTimeout(()=> {
57+
timeout = setTimeout(() => {
5958
console.log('Closing the stream due to inactivity');
6059
co(function* gen() {
6160
const finalRowCount = rowCount - startRow;
@@ -67,30 +66,30 @@ function processAction(msg, cfg) {
6766
});
6867
const fileName = messageToEmit.id + '.csv';
6968
messageToEmit.attachments[fileName] = {
70-
"content-type": "text/csv",
71-
url: signedUrl.get_url
69+
'content-type': 'text/csv',
70+
'url': signedUrl.get_url
7271
};
7372
signedUrl = null;
7473
rowCount = 0;
7574

7675
console.log('Emitting message %j', messageToEmit);
7776
self.emit('data', messageToEmit);
7877

79-
yield init(cfg);
78+
yield exports.init(cfg);
8079
});
8180
}, 10000);
8281

8382
if (startRow <= rowCount) {
8483
let row = msg.body;
85-
if( cfg.reader.columns) {
84+
if (cfg.reader.columns) {
8685
const columns = Object.keys(_.keyBy(cfg.reader.columns, 'property'));
8786
row = _.pick(msg.body, columns);
8887
}
8988
stringifier.write(row);
9089
}
9190
rowCount++;
9291
this.emit('end');
93-
}
92+
};
9493

9594
/**
9695

0 commit comments

Comments
 (0)