Skip to content

Commit 4bd93ba

Browse files
committed
Update eslint & remove jscs
1 parent 4dfcef3 commit 4bd93ba

File tree

6 files changed

+58
-53
lines changed

6 files changed

+58
-53
lines changed

.eslintrc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
{
2-
"extends": "gulp"
2+
"root": true,
3+
"extends": [
4+
"standard",
5+
"gulp"
6+
]
37
}

.jscsrc

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

index.js

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ var nonEnum = ['message', 'name', 'stack'];
88
var ignored = union(nonEnum, ['__safety', '_stack', 'plugin', 'showProperties', 'showStack']);
99
var props = ['fileName', 'lineNumber', 'message', 'name', 'plugin', 'showProperties', 'showStack', 'stack'];
1010

11-
function PluginError(plugin, message, options) {
11+
function PluginError (plugin, message, options) {
1212
if (!(this instanceof PluginError)) {
1313
throw new Error('Call PluginError using new');
1414
}
@@ -22,13 +22,13 @@ function PluginError(plugin, message, options) {
2222
var keys = union(Object.keys(opts.error), nonEnum);
2323

2424
// These properties are not enumerable, so we have to add them explicitly.
25-
keys.forEach(function(prop) {
25+
keys.forEach(function (prop) {
2626
self[prop] = opts.error[prop];
2727
});
2828
}
2929

3030
// Opts object can override
31-
props.forEach(function(prop) {
31+
props.forEach(function (prop) {
3232
if (prop in opts) {
3333
this[prop] = opts[prop];
3434
}
@@ -39,7 +39,6 @@ function PluginError(plugin, message, options) {
3939
this.name = 'Error';
4040
}
4141
if (!this.stack) {
42-
4342
/**
4443
* `Error.captureStackTrace` appends a stack property which
4544
* relies on the toString method of the object it is applied to.
@@ -50,10 +49,11 @@ function PluginError(plugin, message, options) {
5049
*/
5150

5251
var safety = {};
53-
safety.toString = function() {
52+
safety.toString = function () {
5453
return this._messageWithDetails() + '\nStack:';
5554
}.bind(this);
5655

56+
// eslint-disable-next-line no-caller
5757
Error.captureStackTrace(safety, arguments.callee || this.constructor);
5858
this.__safety = safety;
5959
}
@@ -71,7 +71,7 @@ util.inherits(PluginError, Error);
7171
* Output a formatted message with details
7272
*/
7373

74-
PluginError.prototype._messageWithDetails = function() {
74+
PluginError.prototype._messageWithDetails = function () {
7575
var msg = 'Message:\n ' + this.message;
7676
var details = this._messageDetails();
7777
if (details !== '') {
@@ -84,7 +84,7 @@ PluginError.prototype._messageWithDetails = function() {
8484
* Output actual message details
8585
*/
8686

87-
PluginError.prototype._messageDetails = function() {
87+
PluginError.prototype._messageDetails = function () {
8888
if (!this.showProperties) {
8989
return '';
9090
}
@@ -111,8 +111,8 @@ PluginError.prototype._messageDetails = function() {
111111
* Override the `toString` method
112112
*/
113113

114-
PluginError.prototype.toString = function() {
115-
var detailsWithStack = function(stack) {
114+
PluginError.prototype.toString = function () {
115+
var detailsWithStack = function (stack) {
116116
return this._messageWithDetails() + '\nStack:\n' + stack;
117117
}.bind(this);
118118

@@ -121,10 +121,8 @@ PluginError.prototype.toString = function() {
121121
// If there is no wrapped error, use the stack captured in the PluginError ctor
122122
if (this.__safety) {
123123
msg = this.__safety.stack;
124-
125124
} else if (this._stack) {
126125
msg = detailsWithStack(this._stack);
127-
128126
} else {
129127
// Stack from wrapped error
130128
msg = detailsWithStack(this.stack);
@@ -137,7 +135,7 @@ PluginError.prototype.toString = function() {
137135
};
138136

139137
// Format the output message
140-
function message(msg, thisArg) {
138+
function message (msg, thisArg) {
141139
var sig = colors.red(thisArg.name);
142140
sig += ' in plugin ';
143141
sig += '"' + colors.cyan(thisArg.plugin) + '"';
@@ -150,7 +148,7 @@ function message(msg, thisArg) {
150148
* Set default options based on arguments.
151149
*/
152150

153-
function setDefaults(plugin, message, opts) {
151+
function setDefaults (plugin, message, opts) {
154152
if (typeof plugin === 'object') {
155153
return defaults(plugin);
156154
}
@@ -176,10 +174,10 @@ function setDefaults(plugin, message, opts) {
176174
* @return {Object}
177175
*/
178176

179-
function defaults(opts) {
177+
function defaults (opts) {
180178
return extend({
181179
showStack: false,
182-
showProperties: true,
180+
showProperties: true
183181
}, opts);
184182
}
185183

package.json

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
"index.js"
2020
],
2121
"scripts": {
22-
"lint": "eslint . && jscs index.js test/",
23-
"pretest": "npm run lint",
22+
"lint:eslint": "eslint .",
23+
"pretest": "npm-run-all --parallel lint:*",
2424
"test": "mocha --async-only && npm run test-types",
2525
"test-types": "tsc -p test/types",
2626
"cover": "istanbul cover _mocha --report lcovonly",
@@ -33,14 +33,18 @@
3333
"extend-shallow": "^3.0.2"
3434
},
3535
"devDependencies": {
36-
"eslint": "^1.7.3",
37-
"eslint-config-gulp": "^2.0.0",
36+
"eslint": "^4.16.0",
37+
"eslint-config-gulp": "github:BurtHarris/eslint-config-gulp#workitem_10",
38+
"eslint-config-standard": "^11.0.0-beta.0",
39+
"eslint-plugin-import": "^2.8.0",
40+
"eslint-plugin-node": "^5.2.1",
41+
"eslint-plugin-promise": "^3.6.0",
42+
"eslint-plugin-standard": "^3.0.1",
3843
"expect": "^1.20.2",
3944
"istanbul": "^0.4.3",
4045
"istanbul-coveralls": "^1.0.3",
41-
"jscs": "^2.3.5",
42-
"jscs-preset-gulp": "^1.0.0",
4346
"mocha": "^3.0.0",
47+
"npm-run-all": "^4.1.2",
4448
"typescript": "^2.6.2"
4549
},
4650
"keywords": [

test/.eslintrc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
{
2-
"extends": "gulp/test"
2+
"env": {
3+
"mocha": true
4+
}
35
}

test/index.js

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,75 +4,75 @@ var expect = require('expect');
44

55
var PluginError = require('../');
66

7-
describe('PluginError()', function() {
8-
it('should default name to Error', function(done) {
7+
describe('PluginError()', function () {
8+
it('should default name to Error', function (done) {
99
var err = new PluginError('test', 'something broke');
1010
expect(err.name).toEqual('Error');
1111
done();
1212
});
1313

14-
it('should default name to Error, even when wrapped error has no name', function(done) {
14+
it('should default name to Error, even when wrapped error has no name', function (done) {
1515
var realErr = { message: 'something broke' };
1616
var err = new PluginError('test', realErr);
1717
expect(err.name).toEqual('Error');
1818
done();
1919
});
2020

21-
it('should print the plugin name in toString', function(done) {
21+
it('should print the plugin name in toString', function (done) {
2222
var err = new PluginError('test', 'something broke');
2323
expect(err.toString()).toContain('test');
2424
done();
2525
});
2626

27-
it('should not include the stack by default in toString', function(done) {
27+
it('should not include the stack by default in toString', function (done) {
2828
var err = new PluginError('test', 'something broke');
2929
// Just check that there are no 'at' lines
3030
expect(err.toString()).toNotContain('at');
3131
done();
3232
});
3333

34-
it('should include the stack when specified in toString', function(done) {
34+
it('should include the stack when specified in toString', function (done) {
3535
var err = new PluginError('test', 'something broke', { stack: 'at huh', showStack: true });
3636
// Just check that there are 'at' lines
3737
expect(err.toString()).toContain('at');
3838
done();
3939
});
4040

41-
it('should take arguments as one object', function(done) {
41+
it('should take arguments as one object', function (done) {
4242
var err = new PluginError({
4343
plugin: 'test',
44-
message: 'something broke',
44+
message: 'something broke'
4545
});
4646
expect(err.plugin).toEqual('test');
4747
expect(err.message).toEqual('something broke');
4848
done();
4949
});
5050

51-
it('should take arguments as plugin name and one object', function(done) {
51+
it('should take arguments as plugin name and one object', function (done) {
5252
var err = new PluginError('test', {
53-
message: 'something broke',
53+
message: 'something broke'
5454
});
5555
expect(err.plugin).toEqual('test');
5656
expect(err.message).toEqual('something broke');
5757
done();
5858
});
5959

60-
it('should take arguments as plugin name and message', function(done) {
60+
it('should take arguments as plugin name and message', function (done) {
6161
var err = new PluginError('test', 'something broke');
6262
expect(err.plugin).toEqual('test');
6363
expect(err.message).toEqual('something broke');
6464
done();
6565
});
6666

67-
it('should take arguments as plugin name, message, and one object', function(done) {
67+
it('should take arguments as plugin name, message, and one object', function (done) {
6868
var err = new PluginError('test', 'something broke', { showStack: true });
6969
expect(err.plugin).toEqual('test');
7070
expect(err.message).toEqual('something broke');
7171
expect(err.showStack).toEqual(true);
7272
done();
7373
});
7474

75-
it('should take arguments as plugin name, error, and one object', function(done) {
75+
it('should take arguments as plugin name, error, and one object', function (done) {
7676
var realErr = new Error('something broke');
7777
realErr.fileName = 'original.js';
7878
var err = new PluginError('test', realErr, { showStack: true, fileName: 'override.js' });
@@ -83,7 +83,7 @@ describe('PluginError()', function() {
8383
done();
8484
});
8585

86-
it('should take properties from error', function(done) {
86+
it('should take properties from error', function (done) {
8787
var realErr = new Error('something broke');
8888
realErr.abstractProperty = 'abstract';
8989
var err = new PluginError('test', realErr);
@@ -93,19 +93,19 @@ describe('PluginError()', function() {
9393
done();
9494
});
9595

96-
it('should be configured to show properties by default', function(done) {
96+
it('should be configured to show properties by default', function (done) {
9797
var err = new PluginError('test', 'something broke');
9898
expect(err.showProperties).toBe(true);
9999
done();
100100
});
101101

102-
it('should not be configured to take option to show properties', function(done) {
102+
it('should not be configured to take option to show properties', function (done) {
103103
var err = new PluginError('test', 'something broke', { showProperties: false });
104104
expect(err.showProperties).toBe(false);
105105
done();
106106
});
107107

108-
it('should show properties', function(done) {
108+
it('should show properties', function (done) {
109109
var err = new PluginError('test', 'it broke', { showProperties: true });
110110
err.fileName = 'original.js';
111111
err.lineNumber = 35;
@@ -115,7 +115,7 @@ describe('PluginError()', function() {
115115
done();
116116
});
117117

118-
it('should show properties', function(done) {
118+
it('should show properties', function (done) {
119119
var realErr = new Error('something broke');
120120
realErr.fileName = 'original.js';
121121
realErr.lineNumber = 35;
@@ -125,7 +125,7 @@ describe('PluginError()', function() {
125125
done();
126126
});
127127

128-
it('should not show properties', function(done) {
128+
it('should not show properties', function (done) {
129129
var realErr = new Error('something broke');
130130
realErr.fileName = 'original.js';
131131
realErr.lineNumber = 35;
@@ -135,7 +135,7 @@ describe('PluginError()', function() {
135135
done();
136136
});
137137

138-
it('should not show properties, but should show stack', function(done) {
138+
it('should not show properties, but should show stack', function (done) {
139139
var err = new PluginError('test', 'it broke', { stack: 'test stack', showStack: true, showProperties: false });
140140
err.fileName = 'original.js';
141141
err.lineNumber = 35;
@@ -145,7 +145,7 @@ describe('PluginError()', function() {
145145
done();
146146
});
147147

148-
it('should not show properties, but should show stack for real error', function(done) {
148+
it('should not show properties, but should show stack for real error', function (done) {
149149
var realErr = new Error('something broke');
150150
realErr.fileName = 'original.js';
151151
realErr.lineNumber = 35;
@@ -157,7 +157,7 @@ describe('PluginError()', function() {
157157
done();
158158
});
159159

160-
it('should not show properties, but should show stack for _stack', function(done) {
160+
it('should not show properties, but should show stack for _stack', function (done) {
161161
var realErr = new Error('something broke');
162162
realErr.fileName = 'original.js';
163163
realErr.lineNumber = 35;
@@ -169,7 +169,7 @@ describe('PluginError()', function() {
169169
done();
170170
});
171171

172-
it('should show properties and stack', function(done) {
172+
it('should show properties and stack', function (done) {
173173
var realErr = new Error('something broke');
174174
realErr.fileName = 'original.js';
175175
realErr.stack = 'test stack';
@@ -180,7 +180,7 @@ describe('PluginError()', function() {
180180
done();
181181
});
182182

183-
it('should show properties added after the error is created', function(done) {
183+
it('should show properties added after the error is created', function (done) {
184184
var realErr = new Error('something broke');
185185
var err = new PluginError('test', realErr);
186186
err.fileName = 'original.js';
@@ -189,7 +189,7 @@ describe('PluginError()', function() {
189189
done();
190190
});
191191

192-
it('should toString quickly', function(done) {
192+
it('should toString quickly', function (done) {
193193
this.timeout(100);
194194

195195
var err = new PluginError('test', 'it broke', { showStack: true });
@@ -198,7 +198,7 @@ describe('PluginError()', function() {
198198
done();
199199
});
200200

201-
it('should toString quickly with original error', function(done) {
201+
it('should toString quickly with original error', function (done) {
202202
this.timeout(100);
203203

204204
var realErr = new Error('it broke');
@@ -208,7 +208,7 @@ describe('PluginError()', function() {
208208
done();
209209
});
210210

211-
it('should not show "Details:" if there are no properties to show', function(done) {
211+
it('should not show "Details:" if there are no properties to show', function (done) {
212212
var err = new PluginError('plugin', 'message');
213213
expect(err.toString().indexOf('Details:')).toEqual(-1);
214214
done();

0 commit comments

Comments
 (0)