Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade eslint; fix some new warnings and disable others #145

Merged
merged 1 commit into from
May 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
"new-cap": [0],
"no-else-return": [0],
"consistent-return": [0],
"prefer-rest-params": [0]
"prefer-rest-params": [0],
"object-curly-newline": [ "error", { "multiline": true, "consistent": true } ],
"prefer-destructuring": [0],
"no-multi-assign": [0],
"prefer-spread": [0]
}
}
4 changes: 2 additions & 2 deletions examples/addItems.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
'use strict';

const dynogels = require('../index');
const AWS = dynogels.AWS;
const Joi = require('joi');
const async = require('async');

const AWS = dynogels.AWS;
AWS.config.loadFromPath(`${process.env.HOME}/.ec2/credentials.json`);

const Account = dynogels.define('example-Account', {
Expand All @@ -20,7 +20,7 @@ const Account = dynogels.define('example-Account', {

dynogels.createTables({
'example-Account': { readCapacity: 1, writeCapacity: 10 },
}, err => {
}, (err) => {
if (err) {
console.log('Error creating tables', err);
process.exit(1);
Expand Down
11 changes: 7 additions & 4 deletions examples/basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
const dynogels = require('../index');
const _ = require('lodash');
const util = require('util');
const AWS = dynogels.AWS;
const Joi = require('joi');

const AWS = dynogels.AWS;
AWS.config.loadFromPath(`${process.env.HOME}/.ec2/credentials.json`);

const Account = dynogels.define('Foobar', {
Expand Down Expand Up @@ -45,7 +45,7 @@ const printScanResults = (err, data) => {
}
};

dynogels.createTables(err => {
dynogels.createTables((err) => {
if (err) {
console.log('failed to create table', err);
}
Expand All @@ -56,15 +56,18 @@ dynogels.createTables(err => {

// Create an account
const params = {
email: '[email protected]', name: 'test 11', age: 21, scores: [22, 55, 44],
email: '[email protected]',
name: 'test 11',
age: 21,
scores: [22, 55, 44],
list: ['a', 'b', 'c', 1, 2, 3],
settings: { nickname: 'tester' }
};

Account.create(params, (err, acc) => {
printAccountInfo(err, acc);

acc.set({ name: 'Test 11', age: 25 }).update(err => {
acc.set({ name: 'Test 11', age: 25 }).update((err) => {
console.log('account updated', err, acc.get());
});
});
Expand Down
12 changes: 6 additions & 6 deletions examples/batchGet.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
const dynogels = require('../index');
const async = require('async');
const _ = require('lodash');
const AWS = dynogels.AWS;
const Joi = require('joi');

const AWS = dynogels.AWS;
AWS.config.loadFromPath(`${process.env.HOME}/.ec2/credentials.json`);

const Account = dynogels.define('example-batch-get-account', {
Expand All @@ -29,7 +29,7 @@ const printAccountInfo = (err, acc) => {
}
};

const loadSeedData = callback => {
const loadSeedData = (callback) => {
callback = callback || _.noop;

async.times(15, (n, next) => {
Expand All @@ -41,29 +41,29 @@ const loadSeedData = callback => {
async.series([
async.apply(dynogels.createTables.bind(dynogels)),
loadSeedData
], err => {
], (err) => {
if (err) {
console.log('error', err);
process.exit(1);
}

// Get two accounts at once
Account.getItems(['[email protected]', '[email protected]'], (err, accounts) => {
accounts.forEach(acc => {
accounts.forEach((acc) => {
printAccountInfo(null, acc);
});
});

// Same as above but a strongly consistent read is used
Account.getItems(['[email protected]', '[email protected]'], { ConsistentRead: true }, (err, accounts) => {
accounts.forEach(acc => {
accounts.forEach((acc) => {
printAccountInfo(null, acc);
});
});

// Get two accounts, but only fetching the age attribute
Account.getItems(['[email protected]', '[email protected]'], { AttributesToGet: ['age'] }, (err, accounts) => {
accounts.forEach(acc => {
accounts.forEach((acc) => {
printAccountInfo(null, acc);
});
});
Expand Down
4 changes: 2 additions & 2 deletions examples/binary.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

const dynogels = require('../index');
const fs = require('fs');
const AWS = dynogels.AWS;
const Joi = require('joi');

const AWS = dynogels.AWS;
AWS.config.loadFromPath(`${process.env.HOME}/.ec2/credentials.json`);

const BinModel = dynogels.define('example-binary', {
Expand All @@ -26,7 +26,7 @@ const printFileInfo = (err, file) => {
}
};

dynogels.createTables(err => {
dynogels.createTables((err) => {
if (err) {
console.log('Error creating tables', err);
process.exit(1);
Expand Down
5 changes: 3 additions & 2 deletions examples/conditionalWrites.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
'use strict';

const dynogels = require('../index');
const AWS = dynogels.AWS;
const Joi = require('joi');

const AWS = dynogels.AWS;

dynogels.dynamoDriver(new AWS.DynamoDB({
endpoint: 'http://localhost:8000',
region: 'eu-west-1',
Expand All @@ -22,7 +23,7 @@ const Account = dynogels.define('example-Account', {

dynogels.createTables({
'example-Account': { readCapacity: 1, writeCapacity: 10 },
}, err => {
}, (err) => {
if (err) {
console.log('Error creating tables', err);
process.exit(1);
Expand Down
4 changes: 2 additions & 2 deletions examples/createTable.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
'use strict';

const dynogels = require('../index');
const AWS = dynogels.AWS;
const Joi = require('joi');

const AWS = dynogels.AWS;
AWS.config.loadFromPath(`${process.env.HOME}/.ec2/credentials.json`);

dynogels.define('example-Account', {
Expand Down Expand Up @@ -49,7 +49,7 @@ dynogels.createTables({
streamViewType: 'NEW_IMAGE'
}
}
}, err => {
}, (err) => {
if (err) {
console.log('Error creating tables', err);
} else {
Expand Down
4 changes: 2 additions & 2 deletions examples/dynamicKeys.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
'use strict';

const dynogels = require('../index');
const AWS = dynogels.AWS;
const Joi = require('joi');
const async = require('async');
const util = require('util');
const _ = require('lodash');

const AWS = dynogels.AWS;
AWS.config.loadFromPath(`${process.env.HOME}/.ec2/credentials.json`);

const DynamicModel = dynogels.define('example-dynamic-key', {
Expand Down Expand Up @@ -36,7 +36,7 @@ const printResults = (err, resp) => {

dynogels.createTables({
'example-Account': { readCapacity: 1, writeCapacity: 10 },
}, err => {
}, (err) => {
if (err) {
console.log('Error creating tables', err);
process.exit(1);
Expand Down
4 changes: 2 additions & 2 deletions examples/dynamicTableName.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
'use strict';

const dynogels = require('../index');
const AWS = dynogels.AWS;
const Joi = require('joi');

const AWS = dynogels.AWS;
AWS.config.loadFromPath(`${process.env.HOME}/.ec2/credentials.json`);

const Account = dynogels.define('example-tablename', {
Expand All @@ -30,7 +30,7 @@ const printAccountInfo = (err, acc) => {
}
};

dynogels.createTables(err => {
dynogels.createTables((err) => {
if (err) {
console.log('Failed to create tables', err);
} else {
Expand Down
32 changes: 15 additions & 17 deletions examples/globalSecondaryIndexes.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@
const dynogels = require('../index');
const _ = require('lodash');
const util = require('util');
const AWS = dynogels.AWS;
const Joi = require('joi');
const async = require('async');

// AWS.config.loadFromPath(`${process.env.HOME}/.ec2/credentials.json`);

// http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/GSI.html

const AWS = dynogels.AWS;
AWS.config.update({ region: 'us-east-1' });

const GameScore = dynogels.define('example-global-index', {
Expand Down Expand Up @@ -49,7 +47,7 @@ const data = [
{ userId: '103', gameTitle: 'Starship X', topScore: 42, wins: 4, losses: 19 },
];

const loadSeedData = callback => {
const loadSeedData = (callback) => {
callback = callback || _.noop;

async.each(data, (attrs, callback) => {
Expand All @@ -60,24 +58,24 @@ const loadSeedData = callback => {
async.series([
async.apply(dynogels.createTables.bind(dynogels)),
loadSeedData
], err => {
], (err) => {
if (err) {
console.log('error', err);
process.exit(1);
}

// Perform query against global secondary index
GameScore
.query('Galaxy Invaders')
.usingIndex('GameTitleIndex')
.where('topScore').gt(0)
.descending()
.exec((err, data) => {
if (err) {
console.log(err);
} else {
console.log('Found', data.Count, 'items');
console.log(util.inspect(_.pluck(data.Items, 'attrs')));
}
});
.query('Galaxy Invaders')
.usingIndex('GameTitleIndex')
.where('topScore').gt(0)
.descending()
.exec((err, data) => {
if (err) {
console.log(err);
} else {
console.log('Found', data.Count, 'items');
console.log(util.inspect(_.pluck(data.Items, 'attrs')));
}
});
});
10 changes: 5 additions & 5 deletions examples/hooks.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
'use strict';

const dynogels = require('../index');
const AWS = dynogels.AWS;
const Joi = require('joi');

const AWS = dynogels.AWS;
AWS.config.loadFromPath(`${process.env.HOME}/.ec2/credentials.json`);

const Account = dynogels.define('example-hook', {
Expand All @@ -29,19 +29,19 @@ Account.before('update', (data, next) => {
return next(null, data);
});

Account.after('create', item => {
Account.after('create', (item) => {
console.log('Account created', item.get());
});

Account.after('update', item => {
Account.after('update', (item) => {
console.log('Account updated', item.get());
});

Account.after('destroy', item => {
Account.after('destroy', (item) => {
console.log('Account destroyed', item.get());
});

dynogels.createTables(err => {
dynogels.createTables((err) => {
if (err) {
console.log('Error creating tables', err);
process.exit(1);
Expand Down
18 changes: 9 additions & 9 deletions examples/modelMethods.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

const dynogels = require('../index');
const Joi = require('joi');
const AWS = dynogels.AWS;

const AWS = dynogels.AWS;
AWS.config.loadFromPath(`${process.env.HOME}/.ec2/credentials.json`);

const Account = dynogels.define('example-model-methods-Account', {
Expand All @@ -17,17 +17,17 @@ const Account = dynogels.define('example-model-methods-Account', {
});

Account.prototype.sayHello = function () {
console.log(`Hello my name is ${this.get('name')} I\'m ${this.get('age')} years old`);
console.log(`Hello my name is ${this.get('name')} I'm ${this.get('age')} years old`);
};

Account.findByAgeRange = (low, high) => {
Account.scan()
.where('age').gte(low)
.where('age').lte(high)
.loadAll()
.exec((err, data) => {
data.Items.forEach(account => {
account.sayHello();
.where('age').gte(low)
.where('age').lte(high)
.loadAll()
.exec((err, data) => {
data.Items.forEach((account) => {
account.sayHello();
});
});
});
};
6 changes: 3 additions & 3 deletions examples/nestedAttributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ const util = require('util');
const _ = require('lodash');
const async = require('async');
const Joi = require('joi');
const AWS = dynogels.AWS;

const AWS = dynogels.AWS;
AWS.config.loadFromPath(`${process.env.HOME}/.ec2/credentials.json`);

const Movie = dynogels.define('example-nested-attribute', {
Expand Down Expand Up @@ -39,7 +39,7 @@ const printResults = (err, data) => {
console.log('----------------------------------------------------------------------');
};

const loadSeedData = callback => {
const loadSeedData = (callback) => {
callback = callback || _.noop;

async.times(10, (n, next) => {
Expand Down Expand Up @@ -101,7 +101,7 @@ const runExample = () => {
async.series([
async.apply(dynogels.createTables.bind(dynogels)),
loadSeedData
], err => {
], (err) => {
if (err) {
console.log('error', err);
process.exit(1);
Expand Down
Loading