Skip to content

Commit 9b3daa6

Browse files
committed
Bump eslint lib and conf and apply it 🧑‍⚖️
1 parent 59510a8 commit 9b3daa6

File tree

13 files changed

+764
-389
lines changed

13 files changed

+764
-389
lines changed

.eslintrc.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ module.exports = {
1616
'promise/no-native': 'off',
1717
'no-param-reassign': 'off',
1818
'import/no-extraneous-dependencies': 'off',
19+
'node/no-extraneous-require': [
20+
'error',
21+
{
22+
allowModules: ['ava', 'aws-sdk']
23+
}
24+
],
1925
'unicorn/no-unreadable-array-destructuring': 'off',
2026
'unicorn/consistent-function-scoping': 'off'
2127
},
@@ -25,6 +31,12 @@ module.exports = {
2531
rules: {
2632
'import/no-extraneous-dependencies': 'off'
2733
}
34+
},
35+
{
36+
files: ['ava.config.js'],
37+
rules: {
38+
'node/no-unsupported-features/es-syntax': 'off'
39+
}
2840
}
2941
]
3042
};

package-lock.json

Lines changed: 689 additions & 346 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222
"serverless": "^1.73.1"
2323
},
2424
"devDependencies": {
25-
"@coorpacademy/eslint-plugin-coorpacademy": "^9.3.1",
25+
"@coorpacademy/eslint-plugin-coorpacademy": "^10.2.0",
2626
"ava": "^3.12.1",
27-
"eslint": "^6.8.0",
27+
"eslint": "^7.9.0",
2828
"nyc": "^15.1.0"
2929
}
3030
}

packages/dynamodb-streams-readable/src/index.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ function DynamoDBStreamReadable(client, arn, options) {
6464
}
6565

6666
pending++;
67-
client.getShardIterator(params, function(err, data) {
67+
client.getShardIterator(params, function (err, data) {
6868
pending--;
6969
if (err) return callback(err);
7070
iterator = data.ShardIterator;
@@ -74,14 +74,14 @@ function DynamoDBStreamReadable(client, arn, options) {
7474

7575
function describeStream(callback) {
7676
pending++;
77-
client.describeStream({StreamArn: arn}, function(err, data) {
77+
client.describeStream({StreamArn: arn}, function (err, data) {
7878
pending--;
7979
if (err) return callback(err);
8080

8181
const shardId = options.shardId
82-
? data.StreamDescription.Shards.filter(function(shard) {
82+
? data.StreamDescription.Shards.filter(function (shard) {
8383
return shard.ShardId === options.shardId;
84-
}).map(function(shard) {
84+
}).map(function (shard) {
8585
return shard.ShardId;
8686
})[0]
8787
: data.StreamDescription.Shards[0].ShardId;
@@ -101,12 +101,12 @@ function DynamoDBStreamReadable(client, arn, options) {
101101
ShardIterator: iterator,
102102
Limit: options.limit
103103
},
104-
function(err, data) {
104+
function (err, data) {
105105
pending--;
106106

107107
if (err) {
108108
if (err.name === 'TrimmedDataAccessException') {
109-
return describeStream(function(e) {
109+
return describeStream(function (e) {
110110
if (e) return checkpoint.emit('error', e);
111111
read(callback);
112112
});
@@ -130,26 +130,26 @@ function DynamoDBStreamReadable(client, arn, options) {
130130
);
131131
}
132132

133-
readable._read = function() {
133+
readable._read = function () {
134134
function gotRecords(err, data) {
135135
if (err) return checkpoint.emit('error', err);
136136
setTimeout(readable.push.bind(readable), options.readInterval || 500, data.Records);
137137
}
138138

139139
if (iterator) return read(gotRecords);
140140

141-
describeStream(function(err) {
141+
describeStream(function (err) {
142142
if (err) return checkpoint.emit('error', err);
143143
read(gotRecords);
144144
});
145145
};
146146

147-
checkpoint._transform = function(data, enc, callback) {
147+
checkpoint._transform = function (data, enc, callback) {
148148
checkpoint.emit('checkpoint', data.slice(-1)[0].dynamodb.SequenceNumber);
149149
callback(null, data);
150150
};
151151

152-
checkpoint._flush = function(callback) {
152+
checkpoint._flush = function (callback) {
153153
ended = true;
154154
callback();
155155
};
@@ -164,7 +164,7 @@ function DynamoDBStreamReadable(client, arn, options) {
164164
* @memberof DynamoDBStreamClient
165165
* @returns {DynamoDBStreamClient}
166166
*/
167-
checkpoint.close = function() {
167+
checkpoint.close = function () {
168168
drain = true;
169169
if (!ended) readable._read();
170170
return checkpoint;

packages/dynamodb-streams-readable/test/index.js

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ const DynamoDBStreams = require('aws-sdk/clients/dynamodbstreams');
55
const DynamoDBStreamReadable = require('..');
66

77
const fromCallback = fun =>
8-
new Promise((resolve, reject) => fun((err, data) => (err ? reject(err) : resolve(data))));
8+
new Promise((resolve, reject) => {
9+
fun((err, data) => (err ? reject(err) : resolve(data)));
10+
});
911
const wait = duration => fromCallback(cb => setTimeout(cb, duration));
1012
const batchWriteItem = (dynamodb, tableName, items) =>
1113
fromCallback(cb =>
@@ -152,25 +154,25 @@ test.serial('reads ongoing records', t => {
152154

153155
let count = 0;
154156
return Promise.all([
155-
new Promise((resolve, reject) =>
157+
new Promise((resolve, reject) => {
156158
readable
157-
.on('data', function(recordSet) {
159+
.on('data', function (recordSet) {
158160
recordSet.forEach(record => {
159161
t.deepEqual(record.dynamodb.Keys.Id, documents[count].Item.Id);
160162
count = count + 1;
161163
});
162164
if (count > documents.length) t.fail('should not read extra records');
163165
if (count === documents.length) readable.close();
164166
})
165-
.on('end', function() {
167+
.on('end', function () {
166168
t.deepEqual(count, documents.length, `read ${documents.length} records`);
167169
resolve();
168170
})
169-
.on('error', function(err) {
171+
.on('error', function (err) {
170172
t.fail('should not error');
171173
reject(err);
172-
})
173-
),
174+
});
175+
}),
174176
wait(100).then(() => batchWriteItem(dynamodb, tableName, documents))
175177
]);
176178
});
@@ -209,29 +211,29 @@ test.serial('reads latest records', async t => {
209211

210212
let count = 0;
211213
return Promise.all([
212-
new Promise((resolve, reject) =>
214+
new Promise((resolve, reject) => {
213215
readable
214-
.on('data', function(recordSet) {
216+
.on('data', function (recordSet) {
215217
recordSet.forEach(record => {
216218
t.deepEqual(record.dynamodb.Keys.Id, subsequentDocuments[count].Item.Id);
217219
count = count + 1;
218220
});
219221
if (count > subsequentDocuments.length) t.fail('should not read extra records');
220222
if (count === subsequentDocuments.length) readable.close();
221223
})
222-
.on('end', function() {
224+
.on('end', function () {
223225
t.deepEqual(
224226
count,
225227
subsequentDocuments.length,
226228
`read ${subsequentDocuments.length} records`
227229
);
228230
resolve();
229231
})
230-
.on('error', function(err) {
232+
.on('error', function (err) {
231233
t.fail('should not error');
232234
reject(err);
233-
})
234-
),
235+
});
236+
}),
235237
wait(100).then(() => batchWriteItem(dynamodb, tableName, subsequentDocuments))
236238
]);
237239
});
@@ -261,9 +263,9 @@ test.serial('emits checkpoints, obeys limits', t => {
261263
let count = 0;
262264
let checkpoints = 0;
263265
return Promise.all([
264-
new Promise((resolve, reject) =>
266+
new Promise((resolve, reject) => {
265267
readable
266-
.on('data', function(recordSet) {
268+
.on('data', function (recordSet) {
267269
t.is(recordSet.length, 1, 'obeys requested limit');
268270
recordSet.forEach(record => {
269271
t.deepEqual(record.dynamodb.Keys.Id, documents[count].Item.Id);
@@ -272,19 +274,19 @@ test.serial('emits checkpoints, obeys limits', t => {
272274
if (count > documents.length) t.fail('should not read extra records');
273275
if (count === documents.length) readable.close();
274276
})
275-
.on('checkpoint', function(sequenceNum) {
277+
.on('checkpoint', function (sequenceNum) {
276278
if (typeof sequenceNum !== 'string') t.fail('invalid sequenceNum emitted');
277279
checkpoints = checkpoints + 1;
278280
})
279-
.on('end', function() {
281+
.on('end', function () {
280282
t.deepEqual(count, documents.length, `read ${documents.length} records`);
281283
resolve();
282284
})
283-
.on('error', function(err) {
285+
.on('error', function (err) {
284286
t.fail('should not error');
285287
reject(err);
286-
})
287-
),
288+
});
289+
}),
288290
batchWriteItem(dynamodb, tableName, documents)
289291
]);
290292
});

packages/serverless-offline-dynamodb-streams/src/dynamodb-streams.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ const {assign} = require('lodash/fp');
66
const DynamodbStreamsEventDefinition = require('./dynamodb-streams-event-definition');
77
const DynamodbStreamsEvent = require('./dynamodb-streams-event');
88

9-
const delay = timeout => new Promise(resolve => setTimeout(resolve, timeout));
9+
const delay = timeout =>
10+
new Promise(resolve => {
11+
setTimeout(resolve, timeout);
12+
});
1013

1114
class DynamodbStreams {
1215
constructor(lambda, options) {

packages/serverless-offline-kinesis/src/kinesis.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ const {assign} = require('lodash/fp');
55
const KinesisEventDefinition = require('./kinesis-event-definition');
66
const KinesisEvent = require('./kinesis-event');
77

8-
const delay = timeout => new Promise(resolve => setTimeout(resolve, timeout));
8+
const delay = timeout =>
9+
new Promise(resolve => {
10+
setTimeout(resolve, timeout);
11+
});
912

1013
class Kinesis {
1114
constructor(lambda, options) {

packages/serverless-offline-s3/src/s3.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ const {assign, toNumber} = require('lodash/fp');
44
const S3EventDefinition = require('./s3-event-definition');
55
const S3Event = require('./s3-event');
66

7-
const delay = timeout => new Promise(resolve => setTimeout(resolve, timeout));
7+
const delay = timeout =>
8+
new Promise(resolve => {
9+
setTimeout(resolve, timeout);
10+
});
811

912
class S3 {
1013
constructor(lambda, resources, options) {

packages/serverless-offline-sqs/src/sqs.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ const {logWarning} = require('serverless-offline/dist/serverlessLog');
66
const SQSEventDefinition = require('./sqs-event-definition');
77
const SQSEvent = require('./sqs-event');
88

9-
const delay = timeout => new Promise(resolve => setTimeout(resolve, timeout));
9+
const delay = timeout =>
10+
new Promise(resolve => {
11+
setTimeout(resolve, timeout);
12+
});
1013

1114
class SQS {
1215
constructor(lambda, resources, options) {

packages/serverless-offline-ssm-provider/src/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ const fs = require('fs');
22
const {fromPairs, get, map, pipe, split, trim} = require('lodash/fp');
33

44
const fromCallback = fun => (...args) =>
5-
new Promise((resolve, reject) =>
6-
fun(...args, (err, data) => (err ? reject(err) : resolve(data)))
7-
);
5+
new Promise((resolve, reject) => {
6+
fun(...args, (err, data) => (err ? reject(err) : resolve(data)));
7+
});
88
const readFile = fromCallback(fs.readFile);
99

1010
const getValues = (path = '.ssm') => {

0 commit comments

Comments
 (0)