8000 Add JSCS and fix most warnings · stacktracejs/error-stack-parser@86a1adf · GitHub
[go: up one dir, main page]

Skip to content

Commit 86a1adf

Browse files
committed
Add JSCS and fix most warnings
1 parent ded5d77 commit 86a1adf

File tree

6 files changed

+380
-346
lines changed

6 files changed

+380
-346
lines changed

.editorconfig

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,17 @@ charset = utf-8
1010
trim_trailing_whitespace = true
1111
insert_final_newline = true
1212

13-
[*.js]
13+
[*.{js,json}]
1414
indent_style = space
1515
indent_size = 4
1616

17-
[*.json]
17+
[.{jshintrc,jscsrc}]
1818
indent_style = space
1919
indent_size = 4
2020

21+
[*.{yml,yaml}]
22+
indent_style = space
23+
indent_size = 2
24+
2125
[*.md]
2226
trim_trailing_whitespace = false

.jscsrc

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"preset": "google",
3+
"fileExtensions": [
4+
".js"
5+
],
6+
"requireSemicolons": true,
7+
"requireParenthesesAroundIIFE": true,
8+
"maximumLineLength": 120,
9+
"validateLineBreaks": "LF",
10+
"validateIndentation": 4,
11+
"disallowTrailingComma": true,
12+
"disallowSpacesInsideObjectBrackets": null,
13+
"disallowImplicitTypeConversion": [
14+
"string"
15+
],
16+
"jsDoc": {
17+
"checkAnnotations": "closurecompiler",
18+
"checkParamNames": true,
19+
"requireParamTypes": true,
20+
"checkRedundantParams": true,
21+
"checkReturnTypes": true,
22+
"checkRedundantReturns": true,
23+
"requireReturnTypes": true,
24+
"checkTypes": "capitalizedNativeCase",
25+
"checkRedundantAccess": true,
26+
"requireNewlineAfterDescription": true
27+
}
28+
}

error-stack-parser.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
(function (root, factory) {
1+
(function(root, factory) {
22
'use strict';
33
// Universal Module Definition (UMD) to support AMD, CommonJS/Node.js, Rhino, and browsers.
44

@@ -84,11 +84,11 @@
8484
},
8585

8686
parseV8OrIE: function ErrorStackParser$$parseV8OrIE(error) {
87-
var filtered = _filter(error.stack.split('\n'), function (line) {
87+
var filtered = _filter(error.stack.split('\n'), function(line) {
8888
return !!line.match(CHROME_IE_STACK_REGEXP);
8989
}, this);
9090

91-
return _map(filtered, function (line) {
91+
return _map(filtered, function(line) {
9292
if (line.indexOf('(eval ') > -1) {
9393
// Throw away eval information until we implement stacktrace.js/stackframe#8
9494
line = line.replace(/eval code/g, 'eval').replace(/(\(eval at [^\()]*)|(\)\,.*$)/g, '');
@@ -103,11 +103,11 @@
103103
},
104104

105105
parseFFOrSafari: function ErrorStackParser$$parseFFOrSafari(error) {
106-
var filtered = _filter(error.stack.split('\n'), function (line) {
106+
var filtered = _filter(error.stack.split('\n'), function(line) {
107107
return !line.match(SAFARI_NATIVE_CODE_REGEXP);
108108
}, this);
109109

110-
return _map(filtered, function (line) {
110+
return _map(filtered, function(line) {
111111
// Throw away eval information until we implement stacktrace.js/stackframe#8
112112
if (line.indexOf(' > eval') > -1) {
113113
line = line.replace(/ line (\d+)(?: > eval line \d+)* > eval\:\d+\:\d+/g, ':$1');
@@ -168,12 +168,11 @@
168168

169169
// Opera 10.65+ Error.stack very similar to FF/Safari
170170
parseOpera11: function ErrorStackParser$$parseOpera11(error) {
171-
var filtered = _filter(error.stack.split('\n'), function (line) {
172-
return !!line.match(FIREFOX_SAFARI_STACK_REGEXP) &&
173-
!line.match(/^Error created at/);
171+
var filtered = _filter(error.stack.split('\n'), function(line) {
172+
return !!line.match(FIREFOX_SAFARI_STACK_REGEXP) && !line.match(/^Error created at/);
174173
}, this);
175174

176-
return _map(filtered, function (line) {
175+
return _map(filtered, function(line) {
177176
var tokens = line.split('@');
178177
var locationParts = this.extractLocation(tokens.pop());
179178
var functionCall = (tokens.shift() || '');

package.json

Lines changed: 62 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,64 @@
11
{
2-
"name": "error-stack-parser",
3-
"description": "Extract meaning from JS Errors",
4-
"maintainers": [
5-
"Eric Wendelin <me@eriwen.com> (http://www.eriwen.com)",
6-
"Victor Homyakov <vkhomyackov@gmail.com> (https://github.com/victor-homyakov)",
7-
"Oliver Salzburg (https://github.com/oliversalzburg)"
8-
],
9-
"version": "1.3.3",
10-
"license": "Unlicense",
11-
"keywords": [
12-
"stacktrace",
13-
"error",
14-
"stack",
15-
"parser"
16-
],
17-
"homepage": "https://www.stacktracejs.com",
18-
"dependencies": {
19-
"stackframe": "^0.3.1"
20-
},
21-
"repository": {
22-
"type": "git",
23-
"url": "git://github.com/stacktracejs/error-stack-parser.git"
24-
},
25-
"devDependencies": {
26-
"colors": "^1.1.2",
27-
"del": "^1.2.1",
28-
"gulp": "^3.9.0",
29-
"gulp-concat": "^2.6.0",
30-
"gulp-coveralls": "^0.1.4",
31-
"gulp-jshint": "^2.0.0",
32-
"gulp-sourcemaps": "^1.6.0",
33-
"gulp-uglify": "^1.5.1",
34-
"jasmine": "^2.3.2",
35-
"jasmine-core": "^2.3.4",
36-
"jshint": "^2.8.0",
37-
"karma": "~0.13",
38-
"karma-chrome-launcher": "^0.1.12",
39-
"karma-coverage": "^0.5.3",
40-
"karma-firefox-launcher": "^0.1.7",
41-
"karma-ie-launcher": "^0.2.0",
42-
"karma-jasmine": "^0.3.6",
43-
"karma-opera-launcher": "^0.1.0",
44-
"karma-phantomjs2-launcher": "^0.3.2",
45-
"karma-safari-launcher": "^0.1.1",
46-
"karma-sauce-launcher": "^0.3.0",
47-
"karma-spec-reporter": "0.0.23",
48-
"run-sequence": "^1.1.5"
49-
},
50-
"bugs": {
51-
"url": "https://github.com/stacktracejs/error-stack-parser/issues"
52-
},
53-
"main": "./error-stack-parser.js",
54-
"files": [
55-
"LICENSE",
56-
"README.md",
57-
"error-stack-parser.js",
58-
"dist/"
59-
],
60-
"scripts": {
61-
"test": "gulp test"
62-
}
2+
"name": "error-stack-parser",
3+
"description": "Extract meaning from JS Errors",
4+
"maintainers": [
5+
"Eric Wendelin <me@eriwen.com> (http://www.eriwen.com)",
6+
"Victor Homyakov <vkhomyackov@gmail.com> (https://github.com/victor-homyakov)",
7+
"Oliver Salzburg (https://github.com/oliversalzburg)"
8+
],
9+
"version": "1.3.3",
10+
"license": "Unlicense",
11+
"keywords": [
12+
"stacktrace",
13+
"error",
14+
"stack",
15+
"parser"
16+
],
17+
"homepage": "https://www.stacktracejs.com",
18+
"dependencies": {
19+
"stackframe": "^0.3.1"
20+
},
21+
"repository": {
22+
"type": "git",
23+
"url": "git://github.com/stacktracejs/error-stack-parser.git"
24+
},
25+
"devDependencies": {
26+
"colors": "^1.1.2",
27+
"del": "^1.2.1",
28+
"gulp": "^3.9.0",
29+
"gulp-concat": "^2.6.0",
30+
"gulp-coveralls": "^0.1.4",
31+
"gulp-jshint": "^2.0.0",
32+
"gulp-sourcemaps": "^1.6.0",
33+
"gulp-uglify": "^1.5.1",
34+
"jasmine": "^2.3.2",
35+
"jasmine-core": "^2.3.4",
36+
"jscs": "^2.9.0",
37+
"jshint": "^2.8.0",
38+
"karma": "~0.13",
39+
"karma-chrome-launcher": "^0.1.12",
40+
"karma-coverage": "^0.5.3",
41+
"karma-firefox-launcher": "^0.1.7",
42+
"karma-ie-launcher": "^0.2.0",
43+
"karma-jasmine": "^0.3.6",
44+
"karma-opera-launcher": "^0.1.0",
45+
"karma-phantomjs2-launcher": "^0.3.2",
46+
"karma-safari-launcher": "^0.1.1",
47+
"karma-sauce-launcher": "^0.3.0",
48+
"karma-spec-reporter": "0.0.23",
49+
"run-sequence": "^1.1.5"
50+
},
51+
"bugs": {
52+
"url": "https://github.com/stacktracejs/error-stack-parser/issues"
53+
},
54+
"main": "./error-stack-parser.js",
55+
"files": [
56+
"LICENSE",
57+
"README.md",
58+
"error-stack-parser.js",
59+
"dist/"
60+
],
61+
"scripts": {
62+
"test": "gulp test"
63+
}
6364
}

spec/error-stack-parser-spec.js

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1+
// jscs:disable maximumLineLength
12
/* global StackFrame: false, ErrorStackParser: false, CapturedExceptions: false */
2-
describe('ErrorStackParser', function () {
3-
describe('#parse', function () {
3+
describe('ErrorStackParser', function() {
4+
describe('#parse', function() {
45
var unit = ErrorStackParser;
5-
it('should not parse IE 9 Error', function () {
6-
expect(function () {
6+
it('should not parse IE 9 Error', function() {
7+
expect(function() {
78
unit.parse(CapturedExceptions.IE_9);
89
}).toThrow(new Error('Cannot parse given Error object'));
910
});
1011

11-
it('should parse Safari 6 Error.stack', function () {
12+
it('should parse Safari 6 Error.stack', function() {
1213
var stackFrames = unit.parse(CapturedExceptions.SAFARI_6);
1314
expect(stackFrames).toBeTruthy();
1415
expect(stackFrames.length).toBe(3);
@@ -17,7 +18,7 @@ describe('ErrorStackParser', function () {
1718
expect(stackFrames[2]).toMatchStackFrame(['onclick', undefined, 'http://path/to/file.js', 82]);
1819
});
1920

20-
it('should parse Safari 7 Error.stack', function () {
21+
it('should parse Safari 7 Error.stack', function() {
2122
var stackFrames = unit.parse(CapturedExceptions.SAFARI_7);
2223
expect(stackFrames).toBeTruthy();
2324
expect(stackFrames.length).toBe(3);
@@ -26,7 +27,7 @@ describe('ErrorStackParser', function () {
2627
expect(stackFrames[2]).toMatchStackFrame(['bar', undefined, 'http://path/to/file.js', 108, 107]);
2728
});
2829

29-
it('should parse Safari 8 Error.stack', function () {
30+
it('should parse Safari 8 Error.stack', function() {
3031
var stackFrames = unit.parse(CapturedExceptions.SAFARI_8);
3132
expect(stackFrames).toBeTruthy();
3233
expect(stackFrames.length).toBe(3);
@@ -46,7 +47,7 @@ describe('ErrorStackParser', function () {
4647
expect(stackFrames[4]).toMatchStackFrame(['global code', undefined, 'http://localhost:8080/file.js', 33, 18]);
4748
});
4849

49-
it('should parse Firefox 31 Error.stack', function () {
50+
it('should parse Firefox 31 Error.stack', function() {
5051
var stackFrames = unit.parse(CapturedExceptions.FIREFOX_31);
5152
expect(stackFrames).toBeTruthy();
5253
expect(stackFrames.length).toBe(2);
@@ -65,15 +66,15 @@ describe('ErrorStackParser', function () {
6566
expect(stackFrames[4]).toMatchStackFrame([undefined, undefined, 'http://localhost:8080/file.js', 33, 9]);
6667
});
6768

68-
it('should parse function names containing @ in Firefox 43 Error.stack', function () {
69+
it('should parse function names containing @ in Firefox 43 Error.stack', function() {
6970
var stackFrames = unit.parse(CapturedExceptions.FIREFOX_43_FUNCTION_NAME_WITH_AT_SIGN);
7071
expect(stackFrames).toBeTruthy();
7172
expect(stackFrames.length).toBe(2);
7273
expect(stackFrames[0]).toMatchStackFrame(['obj["@fn"]', undefined, 'Scratchpad/1', 10, 29]);
7374
expect(stackFrames[1]).toMatchStackFrame([undefined, undefined, 'Scratchpad/1', 11, 1]);
7475
});
7576

76-
it('should parse V8 Error.stack', function () {
77+
it('should parse V8 Error.stack', function() {
7778
var stackFrames = unit.parse(CapturedExceptions.CHROME_15);
7879
expect(stackFrames).toBeTruthy();
7980
expect(stackFrames.length).toBe(4);
@@ -83,20 +84,20 @@ describe('ErrorStackParser', function () {
8384
expect(stackFrames[3]).toMatchStackFrame([undefined, undefined, 'http://path/to/file.js', 24, 4]);
8485
});
8586

86-
it('should parse V8 entries with no location', function () {
87-
var stackFrames = unit.parse({stack: "Error\n at Array.forEach (native)"});
87+
it('should parse V8 entries with no location', function() {
88+
var stackFrames = unit.parse({stack: 'Error\n at Array.forEach (native)'});
8889
expect(stackFrames.length).toBe(1);
8990
expect(stackFrames[0]).toMatchStackFrame(['Array.forEach', undefined, '(native)', undefined, undefined]);
9091
});
9192

92-
it('should parse V8 Error.stack entries with port numbers', function () {
93+
it('should parse V8 Error.stack entries with port numbers', function() {
9394
var stackFrames = unit.parse(CapturedExceptions.CHROME_36);
9495
expect(stackFrames).toBeTruthy();
9596
expect(stackFrames.length).toBe(2);
9697
expect(stackFrames[0]).toMatchStackFrame(['dumpExceptionError', undefined, 'http://localhost:8080/file.js', 41, 27]);
9798
});
9899

99-
it('should parse error stacks with Constructors', function () {
100+
it('should parse error stacks with Constructors', function() {
100101
var stackFrames = unit.parse(CapturedExceptions.CHROME_46);
101102
expect(stackFrames).toBeTruthy();
102103
expect(stackFrames.length).toBe(2);
@@ -115,7 +116,7 @@ describe('ErrorStackParser', function () {
115116
expect(stackFrames[4]).toMatchStackFrame([undefined, undefined, 'http://localhost:8080/file.js', 31, 13]);
116117
});
117118

118-
it('should parse IE 10 Error stacks', function () {
119+
it('should parse IE 10 Error stacks', function() {
119120
var stackFrames = unit.parse(CapturedExceptions.IE_10);
120121
expect(stackFrames).toBeTruthy();
121122
expect(stackFrames.length).toBe(3);
@@ -124,7 +125,7 @@ describe('ErrorStackParser', function () {
124125
expect(stackFrames[2]).toMatchStackFrame(['bar', undefined, 'http://path/to/file.js', 82, 1]);
125126
});
126127

127-
it('should parse IE 11 Error stacks', function () {
128+
it('should parse IE 11 Error stacks', function() {
128129
var stackFrames = unit.parse(CapturedExceptions.IE_11);
129130
expect(stackFrames).toBeTruthy();
130131
expect(stackFrames.length).toBe(3);
@@ -155,7 +156,7 @@ describe('ErrorStackParser', function () {
155156
expect(stackFrames[4]).toMatchStackFrame([undefined, undefined, 'http://localhost:8080/file.js', 31, 13]);
156157
});
157158

158-
it('should parse Opera 9.27 Error messages', function () {
159+
it('should parse Opera 9.27 Error messages', function() {
159160
var stackFrames = unit.parse(CapturedExceptions.OPERA_927);
160161
expect(stackFrames).toBeTruthy();
161162
expect(stackFrames.length).toBe(3);
@@ -164,7 +165,7 @@ describe('ErrorStackParser', function () {
164165
expect(stackFrames[2]).toMatchStackFrame([undefined, undefined, 'http://path/to/file.js', 18]);
165166
});
166167

167-
it('should parse Opera 10 Error messages', function () {
168+
it('should parse Opera 10 Error messages', function() {
168169
var stackFrames = unit.parse(CapturedExceptions.OPERA_10);
169170
expect(stackFrames).toBeTruthy();
170171
expect(stackFrames.length).toBe(7);
@@ -177,7 +178,7 @@ describe('ErrorStackParser', function () {
177178
expect(stackFrames[6]).toMatchStackFrame([undefined, undefined, 'http://path/to/file.js', 15]);
178179
});
179180

180-
it('should parse Opera 11 Error messages', function () {
181+
it('should parse Opera 11 Error messages', function() {
181182
var stackFrames = unit.parse(CapturedExceptions.OPERA_11);
182183
expect(stackFrames).toBeTruthy();
183184
expect(stackFrames.length).toBe(4);
@@ -187,7 +188,7 @@ describe('ErrorStackParser', function () {
187188
expect(stackFrames[3]).toMatchStackFrame([undefined, undefined, 'http://path/to/file.js', 15]);
188189
});
189190

190-
it('should parse Opera 25 Error stacks', function () {
191+
it('should parse Opera 25 Error stacks', function() {
191192
var stackFrames = unit.parse(CapturedExceptions.OPERA_25);
192193
expect(stackFrames).toBeTruthy();
193194
expect(stackFrames.length).toBe(3);
@@ -196,11 +197,11 @@ describe('ErrorStackParser', function () {
196197
expect(stackFrames[2]).toMatchStackFrame(['bar', undefined, 'http://path/to/file.js', 108, 168]);
197198
});
198199

199-
it('should handle newlines in Error stack messages', function () {
200+
it('should handle newlines in Error stack messages', function() {
200201
var stackFrames = unit.parse({
201-
stack: "Error: Problem at this\nlocation. Error code:1234\n" +
202-
" at http://path/to/file.js:47:22\n" +
203-
" at foo (http://path/to/file.js:52:15)"
202+
stack: 'Error: Problem at this\nlocation. Error code:1234\n' +
203+
' at http://path/to/file.js:47:22\n' +
204+
' at foo (http://path/to/file.js:52:15)'
204205
});
205206

206207
expect(stackFrames.length).toBe(2);

0 commit comments

Comments
 (0)
0