Skip to content

Commit

Permalink
Upgrade eslint/standard setup (#169)
Browse files Browse the repository at this point in the history
* Upgrade eslint/standard setup

* Pacify the linter

* Updated yarn.lock

Despite --frozen-lockfile :/

* More linter pacification

* Fix test failure

* Use eslint not standard
  • Loading branch information
idan committed Jul 6, 2017
1 parent aaf4232 commit ba2d4b3
Show file tree
Hide file tree
Showing 32 changed files with 458 additions and 629 deletions.
2 changes: 1 addition & 1 deletion commands/consumer_groups_destroy.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const VERSION = 'v0'
function * destroyConsumerGroup (context, heroku) {
yield withCluster(heroku, context.app, context.args.CLUSTER, function * (addon) {
yield cli.confirmApp(context.app, context.flags.confirm,
`This command will affect the cluster: ${addon.name}, which is on ${context.app}`)
`This command will affect the cluster: ${addon.name}, which is on ${context.app}`)

yield cli.action(`Deleting consumer group ${context.args.CONSUMER_GROUP}`, co(function * () {
return yield request(heroku, {
Expand Down
4 changes: 2 additions & 2 deletions commands/fail.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const VERSION = 'v0'
function * fail (context, heroku) {
yield withCluster(heroku, context.app, context.args.CLUSTER, function * (addon) {
yield cli.confirmApp(context.app, context.flags.confirm,
`This command will affect the cluster: ${addon.name}, which is on ${context.app}\n\nThis command will forcibly terminate nodes in your cluster at random.\nYou should only run this command in controlled testing scenarios.`)
`This command will affect the cluster: ${addon.name}, which is on ${context.app}\n\nThis command will forcibly terminate nodes in your cluster at random.\nYou should only run this command in controlled testing scenarios.`)

let response = yield cli.action('Triggering failure', co(function * () {
return yield request(heroku, {
Expand Down Expand Up @@ -51,7 +51,7 @@ module.exports = {
hasValue: false },
{ name: 'zookeeper',
description: 'induce failure on one of the cluster\'s Zookeeper nodes instead',
hasValue: false },
hasValue: false },
{ name: 'confirm',
description: 'pass the app name to skip the manual confirmation prompt',
hasValue: true,
Expand Down
4 changes: 2 additions & 2 deletions commands/topics.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,6 @@ let cmd = {
module.exports = {
cmd,
deprecated: Object.assign({}, cmd, { command: 'list',
hidden: true,
run: cli.command(co.wrap(deprecated(listTopics, cmd.command))) })
hidden: true,
run: cli.command(co.wrap(deprecated(listTopics, cmd.command))) })
}
4 changes: 2 additions & 2 deletions commands/topics_create.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,6 @@ let cmd = {
module.exports = {
cmd,
deprecated: Object.assign({}, cmd, { command: 'create',
hidden: true,
run: cli.command(co.wrap(deprecated(createTopic, cmd.command))) })
hidden: true,
run: cli.command(co.wrap(deprecated(createTopic, cmd.command))) })
}
6 changes: 3 additions & 3 deletions commands/topics_destroy.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const VERSION = 'v0'
function * destroyTopic (context, heroku) {
yield withCluster(heroku, context.app, context.args.CLUSTER, function * (addon) {
yield cli.confirmApp(context.app, context.flags.confirm,
`This command will affect the cluster: ${addon.name}, which is on ${context.app}`)
`This command will affect the cluster: ${addon.name}, which is on ${context.app}`)

yield cli.action(`Deleting topic ${context.args.TOPIC}`, co(function * () {
const topicName = context.args.TOPIC
Expand Down Expand Up @@ -59,6 +59,6 @@ let cmd = {
module.exports = {
cmd,
deprecated: Object.assign({}, cmd, { command: 'delete',
hidden: true,
run: cli.command(co.wrap(deprecated(destroyTopic, cmd.command))) })
hidden: true,
run: cli.command(co.wrap(deprecated(destroyTopic, cmd.command))) })
}
4 changes: 2 additions & 2 deletions commands/topics_info.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,6 @@ let cmd = {
module.exports = {
cmd,
deprecated: Object.assign({}, cmd, { command: 'topic',
hidden: true,
run: cli.command(co.wrap(deprecated(kafkaTopic, cmd.command))) })
hidden: true,
run: cli.command(co.wrap(deprecated(kafkaTopic, cmd.command))) })
}
4 changes: 2 additions & 2 deletions commands/topics_tail.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ let cmd = {
module.exports = {
cmd,
deprecated: Object.assign({}, cmd, { command: 'tail',
hidden: true,
run: cli.command(co.wrap(deprecated(tail, cmd.command))) }),
hidden: true,
run: cli.command(co.wrap(deprecated(tail, cmd.command))) }),
// N.B.: exporting this here and relying on the exported version lets
// us mock it out in tests
process
Expand Down
4 changes: 2 additions & 2 deletions commands/topics_write.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,6 @@ let cmd = {
module.exports = {
cmd,
deprecated: Object.assign({}, cmd, { command: 'write',
hidden: true,
run: cli.command(co.wrap(deprecated(write, cmd.command))) })
hidden: true,
run: cli.command(co.wrap(deprecated(write, cmd.command))) })
}
2 changes: 1 addition & 1 deletion commands/upgrade.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const VERSION = 'v0'
function * upgradeCluster (context, heroku) {
yield withCluster(heroku, context.app, context.args.CLUSTER, function * (addon) {
yield cli.confirmApp(context.app, context.flags.confirm,
`This command will upgrade the brokers of the cluster to version ${context.flags.version}.
`This command will upgrade the brokers of the cluster to version ${context.flags.version}.
Upgrading the cluster involves rolling restarts of brokers, and takes some time, depending on the
size of the cluster.`)

Expand Down
13 changes: 8 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,17 @@
"chai": "^3.5.0",
"chai-as-promised": "^5.3.0",
"coveralls": "^2.11.12",
"eslint": "^2.1.0",
"eslint-config-standard": "^6.0.0",
"eslint": "^4.1.1",
"eslint-config-standard": "^10.2.1",
"eslint-plugin-import": "^2.7.0",
"eslint-plugin-node": "^5.1.0",
"eslint-plugin-promise": "^3.5.0",
"eslint-plugin-standard": "^3.0.1",
"mocha": "^3.0.2",
"nock": "^8.0.0",
"np": "2.15.0",
"nyc": "^8.1.0",
"proxyquire": "^1.7.10",
"standard": "8.0.0"
"proxyquire": "^1.7.10"
},
"files": [
"commands",
Expand All @@ -45,6 +48,6 @@
"qtest": "mocha",
"release": "np",
"standardize": "standard --fix",
"test": "standard && nyc mocha"
"test": "eslint commands lib test && nyc mocha"
}
}
5 changes: 3 additions & 2 deletions test/commands/consumer_groups_create_test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use strict'
/* eslint standard/no-callback-literal: off, no-unused-expressions: off */

const expect = require('chai').expect
const mocha = require('mocha')
Expand Down Expand Up @@ -51,7 +52,7 @@ describe('kafka:consumer-groups:create', () => {
).reply(200)

return cmd.run({app: 'myapp',
args: { CONSUMER_GROUP: 'consumer-group-1' }})
args: { CONSUMER_GROUP: 'consumer-group-1' }})
.then(() => {
expect(cli.stdout).to.equal('Use `heroku kafka:consumer-groups` to list your consumer groups.\n')
})
Expand All @@ -67,7 +68,7 @@ describe('kafka:consumer-groups:create', () => {
).reply(400, {message: 'this command is not required or enabled on dedicated clusters'})

return cmd.run({app: 'myapp',
args: { CONSUMER_GROUP: 'consumer-group-1' }})
args: { CONSUMER_GROUP: 'consumer-group-1' }})
.then(() => {
expect(cli.stderr).to.equal(`Creating consumer group consumer-group-1... !\n ▸ kafka-1 does not need consumer groups managed explicitly, so this command\n ▸ does nothing\n`)
})
Expand Down
19 changes: 10 additions & 9 deletions test/commands/consumer_groups_destroy_test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use strict'
/* eslint standard/no-callback-literal: off, no-unused-expressions: off */

const expect = require('chai').expect
const mocha = require('mocha')
Expand Down Expand Up @@ -66,8 +67,8 @@ describe('kafka:consumer-groups:destroy', () => {
).reply(200)

return cmd.run({app: 'myapp',
args: { CONSUMER_GROUP: 'consumer-group-1' },
flags: { confirm: 'myapp' }})
args: { CONSUMER_GROUP: 'consumer-group-1' },
flags: { confirm: 'myapp' }})
.then(() => {
expect(cli.stdout).to.equal('Your consumer group has been deleted\n')
})
Expand All @@ -89,12 +90,12 @@ describe('kafka:consumer-groups:destroy', () => {
lastMsg = null

return cmd.run({app: 'myapp',
args: { CONSUMER_GROUP: 'consumer-group-1' },
flags: { confirm: 'myapp' }})
.then(() => {
expect(lastApp).to.equal('myapp')
expect(lastConfirm).to.equal('myapp')
expect(lastMsg).to.equal(message)
})
args: { CONSUMER_GROUP: 'consumer-group-1' },
flags: { confirm: 'myapp' }})
.then(() => {
expect(lastApp).to.equal('myapp')
expect(lastConfirm).to.equal('myapp')
expect(lastMsg).to.equal(message)
})
})
})
1 change: 1 addition & 0 deletions test/commands/consumer_groups_test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use strict'
/* eslint standard/no-callback-literal: off, no-unused-expressions: off */

const expect = require('chai').expect
const mocha = require('mocha')
Expand Down
1 change: 1 addition & 0 deletions test/commands/credentials_rotate_test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use strict'
/* eslint standard/no-callback-literal: off, no-unused-expressions: off */

const expect = require('chai').expect
const mocha = require('mocha')
Expand Down
65 changes: 33 additions & 32 deletions test/commands/fail_test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use strict'
/* eslint standard/no-callback-literal: off, no-unused-expressions: off */

const expect = require('chai').expect
const mocha = require('mocha')
Expand Down Expand Up @@ -59,55 +60,55 @@ describe('kafka:fail', () => {
kafka.post(failUrl('00000000-0000-0000-0000-000000000000')).reply(200, { message: 'Triggered failure on node 1.2.3.4' })

return cmd.run({app: 'myapp', args: {}, flags: {confirm: 'myapp'}})
.then(() => {
expect(lastApp).to.equal('myapp')
expect(lastConfirm).to.equal('myapp')
expect(lastMsg).to.equal(message)
})
.then(() => {
expect(lastApp).to.equal('myapp')
expect(lastConfirm).to.equal('myapp')
expect(lastMsg).to.equal(message)
})
})

it('triggers failure', () => {
kafka.post(failUrl('00000000-0000-0000-0000-000000000000', {confirm: 'myapp',
catastrophic: false,
zookeeper: false}))
.reply(200, { message: 'Triggered failure on node 1.2.3.4' })
catastrophic: false,
zookeeper: false}))
.reply(200, { message: 'Triggered failure on node 1.2.3.4' })

return cmd.run({app: 'myapp',
args: {},
flags: {confirm: 'myapp',
catastrophic: false,
zookeeper: false}})
.then(() => expect(cli.stderr).to.equal('Triggering failure... done\n'))
.then(() => expect(cli.stdout).to.equal('Triggered failure on node 1.2.3.4\n'))
args: {},
flags: {confirm: 'myapp',
catastrophic: false,
zookeeper: false}})
.then(() => expect(cli.stderr).to.equal('Triggering failure... done\n'))
.then(() => expect(cli.stdout).to.equal('Triggered failure on node 1.2.3.4\n'))
})

it('passes the --catastrophic flag', () => {
kafka.post(failUrl('00000000-0000-0000-0000-000000000000', {confirm: 'myapp',
catastrophic: true,
zookeeper: false}))
.reply(200, { message: 'Triggered failure on node 1.2.3.4' })
catastrophic: true,
zookeeper: false}))
.reply(200, { message: 'Triggered failure on node 1.2.3.4' })

return cmd.run({app: 'myapp',
args: {},
flags: {confirm: 'myapp',
catastrophic: true,
zookeeper: false}})
.then(() => expect(cli.stderr).to.equal('Triggering failure... done\n'))
.then(() => expect(cli.stdout).to.equal('Triggered failure on node 1.2.3.4\n'))
args: {},
flags: {confirm: 'myapp',
catastrophic: true,
zookeeper: false}})
.then(() => expect(cli.stderr).to.equal('Triggering failure... done\n'))
.then(() => expect(cli.stdout).to.equal('Triggered failure on node 1.2.3.4\n'))
})

it('passes the --zookeeper flag', () => {
kafka.post(failUrl('00000000-0000-0000-0000-000000000000', {confirm: 'myapp',
catastrophic: false,
zookeeper: true}))
.reply(200, { message: 'Triggered failure on node 1.2.3.4' })
catastrophic: false,
zookeeper: true}))
.reply(200, { message: 'Triggered failure on node 1.2.3.4' })

return cmd.run({app: 'myapp',
args: {},
flags: {confirm: 'myapp',
catastrophic: false,
zookeeper: true}})
.then(() => expect(cli.stderr).to.equal('Triggering failure... done\n'))
.then(() => expect(cli.stdout).to.equal('Triggered failure on node 1.2.3.4\n'))
args: {},
flags: {confirm: 'myapp',
catastrophic: false,
zookeeper: true}})
.then(() => expect(cli.stderr).to.equal('Triggering failure... done\n'))
.then(() => expect(cli.stdout).to.equal('Triggered failure on node 1.2.3.4\n'))
})
})
1 change: 1 addition & 0 deletions test/commands/host_test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use strict'
/* eslint standard/no-callback-literal: off, no-unused-expressions: off */

const expect = require('chai').expect
const mocha = require('mocha')
Expand Down
1 change: 1 addition & 0 deletions test/commands/info_test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use strict'
/* eslint standard/no-callback-literal: off, no-unused-expressions: off */

const expect = require('chai').expect
const mocha = require('mocha')
Expand Down
Loading

0 comments on commit ba2d4b3

Please sign in to comment.