Skip to content
This repository was archived by the owner on Apr 17, 2020. It is now read-only.

Commit 6a6d983

Browse files
committed
fixed up the linting
1 parent 2302838 commit 6a6d983

File tree

8 files changed

+191
-191
lines changed

8 files changed

+191
-191
lines changed

Diff for: .eslintrc.js

+17-15
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,23 @@
11
module.exports = {
22
root: true,
3+
extends: [
4+
'simplabs',
5+
'simplabs/plugins/ember',
6+
],
37
parserOptions: {
48
ecmaVersion: 2017,
59
sourceType: 'module'
610
},
7-
plugins: [
8-
'ember'
9-
],
10-
extends: [
11-
'eslint:recommended',
12-
'plugin:ember/recommended'
13-
],
14-
env: {
15-
browser: true
16-
},
17-
rules: {
18-
},
1911
overrides: [
2012
// node files
2113
{
2214
files: [
23-
'.template-lintrc.js',
2415
'ember-cli-build.js',
16+
'fastboot-server.js',
2517
'index.js',
2618
'testem.js',
27-
'blueprints/*/index.js',
2819
'config/**/*.js',
29-
'tests/dummy/config/**/*.js'
20+
'tests/**/*.js'
3021
],
3122
excludedFiles: [
3223
'addon/**',
@@ -44,8 +35,19 @@ module.exports = {
4435
},
4536
plugins: ['node'],
4637
rules: Object.assign({}, require('eslint-plugin-node').configs.recommended.rules, {
38+
"node/no-extraneous-require": "off",
39+
"node/no-unpublished-require": "off"
4740
// add your custom rules and overrides for node files here
4841
})
42+
}, {
43+
files: [
44+
"lib/**/*.js",
45+
"tests/**/*-nodetest.js",
46+
],
47+
env: {
48+
node: true,
49+
mocha: true
50+
}
4951
}
5052
]
5153
};

Diff for: lib/notify.js

+19-22
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,38 @@
1-
var RSVP = require('rsvp');
2-
var CoreObject = require('core-object');
3-
var request = require('request');
4-
var merge = require('lodash/object/merge');
5-
6-
var post = RSVP.denodeify(request.post);
1+
const RSVP = require('rsvp');
2+
const CoreObject = require('core-object');
3+
const request = require('request');
4+
const merge = require('lodash/object/merge');
75

86
function optsValid(opts) {
97
return opts.url && opts.headers && opts.method && opts.body;
108
}
119

1210
module.exports = CoreObject.extend({
13-
init: function(options) {
11+
init(options) {
1412
this._plugin = options.plugin;
1513

1614
this._client = this._plugin.readConfig('httpClient') || request;
1715
},
1816

19-
_defaults: function() {
17+
_defaults() {
2018
return {
2119
method: 'POST',
2220
headers: {},
2321
json: true
24-
}
22+
};
2523
},
2624

27-
send: function(serviceKey, opts) {
28-
var opts = opts || {};
29-
var plugin = this._plugin;
30-
var makeRequest = RSVP.denodeify(this._client);
31-
var critical = (('critical' in opts) ? delete opts.critical : false);
25+
send(serviceKey, opts = {}) {
26+
let plugin = this._plugin;
27+
let makeRequest = RSVP.denodeify(this._client);
28+
let critical = (('critical' in opts) ? delete opts.critical : false);
3229

33-
var requestOpts = merge(this._defaults(), opts);
30+
let requestOpts = merge(this._defaults(), opts);
3431

3532
if (optsValid(requestOpts)) {
3633
return makeRequest(requestOpts)
3734
.then(function(response) {
38-
var body = '';
35+
let body = '';
3936

4037
if (response && response.body) {
4138
body = response.body;
@@ -45,27 +42,27 @@ module.exports = CoreObject.extend({
4542
body = JSON.stringify(body);
4643
}
4744

48-
if (critical && !(300 > response.statusCode && response.statusCode >= 200)) {
45+
if (critical && !(response.statusCode < 300 && response.statusCode >= 200)) {
4946
return RSVP.reject(response.statusCode);
5047
}
5148

52-
plugin.log(serviceKey + ' => ' + body);
53-
}.bind(this))
49+
plugin.log(`${serviceKey} => ${body}`);
50+
})
5451
.catch(function(error) {
55-
var errorMessage = serviceKey + ' => ' + error;
52+
let errorMessage = `${serviceKey} => ${error}`;
5653

5754
if (critical) {
5855
return RSVP.reject(error);
5956
}
6057
plugin.log(errorMessage, { color: 'red' });
6158
});
6259
} else {
63-
var warningMessage = 'No request issued! Request options invalid! You have to specify `url`, `headers`, `method` and `body`.';
60+
let warningMessage = 'No request issued! Request options invalid! You have to specify `url`, `headers`, `method` and `body`.';
6461

6562
if (critical) {
6663
return RSVP.reject(warningMessage);
6764
}
68-
plugin.log(serviceKey+' => '+warningMessage, { color: 'yellow', verbose: true });
65+
plugin.log(`${serviceKey} => ${warningMessage}`, { color: 'yellow', verbose: true });
6966
return RSVP.resolve();
7067
}
7168
}

Diff for: lib/service.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
var CoreObject = require('core-object');
2-
var merge = require('lodash/object/merge');
3-
var mapValues = require('lodash/object/mapValues');
4-
var pick = require('lodash/object/pick');
1+
const CoreObject = require('core-object');
2+
const merge = require('lodash/object/merge');
3+
const mapValues = require('lodash/object/mapValues');
4+
const pick = require('lodash/object/pick');
55

66
module.exports = CoreObject.extend({
7-
init: function(options) {
7+
init(options) {
88
this.serviceOptions = merge(options.defaults, options.user, options.hook || {});
99
},
1010

11-
buildServiceCall: function(context) {
12-
var opts = mapValues(this.serviceOptions, function(value) {
11+
buildServiceCall(context) {
12+
let opts = mapValues(this.serviceOptions, function(value) {
1313
return typeof value === 'function' ? value.bind(this.serviceOptions)(context) : value;
1414
}.bind(this));
1515

Diff for: package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@
5252
"ember-source": "~3.4.0",
5353
"ember-source-channel-url": "^1.1.0",
5454
"ember-try": "^1.0.0",
55-
"eslint-plugin-ember": "^5.2.0",
55+
"eslint-config-simplabs": "^0.4.0",
56+
"eslint-plugin-ember": "^3.6.2",
57+
"eslint-plugin-mocha": "^4.11.0",
5658
"eslint-plugin-node": "^7.0.1",
5759
"glob": "^5.0.15",
5860
"loader.js": "^4.7.0",

Diff for: tests/runner.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
'use strict';
22

3-
var glob = require('glob');
4-
var Mocha = require('mocha');
3+
let glob = require('glob');
4+
let Mocha = require('mocha');
55

6-
var mocha = new Mocha({
6+
let mocha = new Mocha({
77
reporter: 'spec'
88
});
99

10-
var arg = process.argv[2];
11-
var root = 'tests/';
10+
let arg = process.argv[2];
11+
let root = 'tests/';
1212

1313
function addFiles(mocha, files) {
1414
glob.sync(root + files).forEach(mocha.addFile.bind(mocha));
@@ -22,6 +22,6 @@ if (arg === 'all') {
2222

2323
mocha.run(function(failures) {
2424
process.on('exit', function() {
25-
process.exit(failures);
25+
process.exit(failures); // eslint-disable-line
2626
});
2727
});

Diff for: tests/unit/index-nodetest.js

+16-16
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const Promise = require('rsvp');
22
const chai = require('chai');
3-
const chaiAsPromised = require("chai-as-promised");
3+
const chaiAsPromised = require('chai-as-promised');
44

55
chai.use(chaiAsPromised);
66

@@ -12,7 +12,7 @@ describe('webhooks plugin', function() {
1212
let BUGSNAG_URI = 'http://notify.bugsnag.com/deploy';
1313

1414
before(function() {
15-
subject = require('../../index');
15+
subject = require('../../index'); // eslint-disable-line node/no-missing-require
1616
});
1717

1818
beforeEach(function() {
@@ -24,7 +24,7 @@ describe('webhooks plugin', function() {
2424

2525
callbackReturnValue = undefined;
2626

27-
mockHTTP = function(context) {
27+
mockHTTP = function() {
2828
return function(opts, cb) {
2929
serviceCalls.push({
3030
url: opts.url,
@@ -34,13 +34,13 @@ describe('webhooks plugin', function() {
3434
});
3535

3636
cb(callbackReturnValue);
37-
}
37+
};
3838
};
3939

4040
mockUi = {
4141
messages: [],
42-
write: function() {},
43-
writeLine: function(message) {
42+
write() {},
43+
writeLine(message) {
4444
this.messages.push(message);
4545
}
4646
};
@@ -52,7 +52,7 @@ describe('webhooks plugin', function() {
5252

5353
if (!opts.verbose || (opts.verbose && this.ui.verbose)) {
5454
this.ui.write('| ');
55-
this.ui.writeLine('- ' + message);
55+
this.ui.writeLine(`- ${message}`);
5656
}
5757
};
5858

@@ -61,19 +61,19 @@ describe('webhooks plugin', function() {
6161

6262
config: {
6363
webhooks: {
64-
services: services,
64+
services,
6565
httpClient: mockHTTP
6666
}
6767
}
68-
}
68+
};
6969
});
7070

7171
it('has a name', function() {
7272
assert.equal(plugin.name, 'webhooks');
7373
});
7474

7575
describe('configuring services', function() {
76-
it("warns of services that are configured but have not hook turned on", function() {
76+
it('warns of services that are configured but have not hook turned on', function() {
7777
services.bugsnag = {
7878
apiKey: '1234'
7979
};
@@ -84,12 +84,12 @@ describe('webhooks plugin', function() {
8484

8585
plugin.beforeHook(context);
8686
plugin.configure(context);
87+
plugin.setup(context);
8788

88-
let promise = plugin.setup(context);
8989
let messages = mockUi.messages;
9090

9191
assert.isAbove(messages.length, 0);
92-
assert.equal(messages[0], '- Warning! bugsnag - Service configuration found but no hook specified in deploy configuration. Service will not be notified.')
92+
assert.equal(messages[0], '- Warning! bugsnag - Service configuration found but no hook specified in deploy configuration. Service will not be notified.');
9393
});
9494

9595
describe('preconfigured services', function() {
@@ -121,7 +121,7 @@ describe('webhooks plugin', function() {
121121

122122
it('calls custom-url for preconfigured services when url is passed via config', function() {
123123
let CUSTOM_BUGSNAG_URI = 'http://bugsnag.simplabs.com/deploy';
124-
services.bugsnag.url = CUSTOM_BUGSNAG_URI;
124+
services.bugsnag.url = CUSTOM_BUGSNAG_URI;
125125

126126
plugin.beforeHook(context);
127127
plugin.configure(context);
@@ -222,13 +222,13 @@ describe('webhooks plugin', function() {
222222
return assert.isFulfilled(promise)
223223
.then(function() {
224224
assert.equal(serviceCalls.length, 0);
225-
})
225+
});
226226
});
227227

228228
it('is possible to specify hooks where slack should be notified', function() {
229229
let webhookURL = 'https://hooks.slack.com/services/my-webhook-url';
230230
services.slack = {
231-
webhookURL: webhookURL,
231+
webhookURL,
232232

233233
didDeploy: {
234234
body: {
@@ -276,7 +276,7 @@ describe('webhooks plugin', function() {
276276
assert.equal(serviceCalls.length, 2);
277277

278278
let didActivateMessage = serviceCalls[0];
279-
let didDeployMessage = serviceCalls[1];
279+
let didDeployMessage = serviceCalls[1];
280280

281281
assert.deepEqual(didActivateMessage.body, { text: 'didActivate' });
282282
assert.deepEqual(didActivateMessage.url, webhookURL);

0 commit comments

Comments
 (0)