Skip to content

Commit f526071

Browse files
committed
Listed all the things
I made the default parseInt radix be 10. Hopefully this won’t cause any issues.
1 parent a8746a7 commit f526071

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+498
-437
lines changed

gulpfile.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ var karma = require('gulp-karma');
55
var package = require('./package.json');
66
var replace = require('gulp-replace');
77
var sourcemaps = require('gulp-sourcemaps');
8+
var tslint = require('gulp-tslint');
89
var tsProject = require('tsproject');
910
var uglify = require('gulp-uglify');
1011
var umd = require('gulp-wrap-umd');
@@ -88,7 +89,13 @@ gulp.task('watch', ['build'], function() {
8889
gulp.watch('src/**/*.ts', ['build']);
8990
});
9091

91-
gulp.task('build', ['clean', 'exceptionless', 'exceptionless.node']);
92+
gulp.task('lint', function() {
93+
return gulp.src(['src/**/*.ts', '!src/typings/**/*.ts'])
94+
.pipe(tslint())
95+
.pipe(tslint.report('verbose'));
96+
});
97+
98+
gulp.task('build', ['clean', 'lint', 'exceptionless', 'exceptionless.node']);
9299

93100
gulp.task('typescript.test', function() {
94101
return tsProject.src('src/tsconfig.test.json').pipe(gulp.dest('dist/temp'));

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
"gulp-karma": "0.0.5",
3232
"gulp-replace": "0.5.4",
3333
"gulp-sourcemaps": "1.6.0",
34+
"gulp-tslint": "^3.3.1",
3435
"gulp-uglify": "1.4.2",
3536
"gulp-wrap-umd": "0.2.1",
3637
"jasmine-core": "2.3.4",

src/EventBuilder.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { Configuration } from './configuration/Configuration';
21
import { ExceptionlessClient } from './ExceptionlessClient';
32
import { IEvent } from './models/IEvent';
43
import { IUserInfo } from './models/IUserInfo';
@@ -7,12 +6,12 @@ import { EventPluginContext } from './plugins/EventPluginContext';
76
import { Utils } from './Utils';
87

98
export class EventBuilder {
10-
private _validIdentifierErrorMessage:string = "must contain between 8 and 100 alphanumeric or '-' characters."; // optimization for minifier.
11-
129
public target:IEvent;
1310
public client:ExceptionlessClient;
1411
public pluginContextData:ContextData;
1512

13+
private _validIdentifierErrorMessage:string = 'must contain between 8 and 100 alphanumeric or \'-\' characters.'; // optimization for minifier.
14+
1615
constructor(event:IEvent, client:ExceptionlessClient, pluginContextData?:ContextData) {
1716
this.target = event;
1817
this.client = client;
@@ -62,10 +61,13 @@ export class EventBuilder {
6261
}
6362

6463
public setGeo(latitude: number, longitude: number): EventBuilder {
65-
if (latitude < -90.0 || latitude > 90.0)
64+
if (latitude < -90.0 || latitude > 90.0) {
6665
throw new Error('Must be a valid latitude value between -90.0 and 90.0.');
67-
if (longitude < -180.0 || longitude > 180.0)
66+
}
67+
68+
if (longitude < -180.0 || longitude > 180.0) {
6869
throw new Error('Must be a valid longitude value between -180.0 and 180.0.');
70+
}
6971

7072
this.target.geo = `${latitude},${longitude}`;
7173
return this;
@@ -75,7 +77,7 @@ export class EventBuilder {
7577
public setUserIdentity(identity:string): EventBuilder;
7678
public setUserIdentity(identity:string, name:string): EventBuilder;
7779
public setUserIdentity(userInfoOrIdentity:IUserInfo|string, name?:string): EventBuilder {
78-
var userInfo = typeof userInfoOrIdentity !== 'string' ? userInfoOrIdentity : { identity: userInfoOrIdentity, name: name };
80+
let userInfo = typeof userInfoOrIdentity !== 'string' ? userInfoOrIdentity : { identity: userInfoOrIdentity, name: name };
7981
if (!userInfo || (!userInfo.identity && !userInfo.name)) {
8082
return this;
8183
}
@@ -140,10 +142,10 @@ export class EventBuilder {
140142
}
141143

142144
for (var index = 0; index < value.length; index++) {
143-
var code = value.charCodeAt(index);
144-
var isDigit = (code >= 48) && (code <= 57);
145-
var isLetter = ((code >= 65) && (code <= 90)) || ((code >= 97) && (code <= 122));
146-
var isMinus = code === 45;
145+
let code = value.charCodeAt(index);
146+
let isDigit = (code >= 48) && (code <= 57);
147+
let isLetter = ((code >= 65) && (code <= 90)) || ((code >= 97) && (code <= 122));
148+
let isMinus = code === 45;
147149

148150
if (!(isDigit || isLetter) && !isMinus) {
149151
return false;

src/ExceptionlessClient-spec.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ import { EventPluginContext } from './plugins/EventPluginContext';
33

44
describe('ExceptionlessClient', () => {
55
it('should use event reference ids', (done) => {
6-
var error = new Error('From Unit Test');
6+
let error = new Error('From Unit Test');
77

8-
var client = new ExceptionlessClient('LhhP1C9gijpSKCslHHCvwdSIz298twx271n1l6xw', 'http://localhost:50000');
8+
let client = new ExceptionlessClient('LhhP1C9gijpSKCslHHCvwdSIz298twx271n1l6xw', 'http://localhost:50000');
99
expect(client.config.lastReferenceIdManager.getLast()).toBe(null);
1010
client.submitException(error, (context:EventPluginContext) => {
1111
expect(client.config.lastReferenceIdManager.getLast()).toBe(null);
1212
});
1313

14-
var numberOfPlugins = client.config.plugins.length;
14+
let numberOfPlugins = client.config.plugins.length;
1515
client.config.useReferenceIds();
1616
expect(client.config.plugins.length).toBe(numberOfPlugins + 1);
1717

@@ -27,26 +27,26 @@ describe('ExceptionlessClient', () => {
2727
}, 5000);
2828

2929
it('should accept null source', () => {
30-
var client = new ExceptionlessClient('LhhP1C9gijpSKCslHHCvwdSIz298twx271n1l6xw', 'http://localhost:50000');
31-
var builder = client.createLog(null, 'Unit Test message', 'Trace');
30+
let client = new ExceptionlessClient('LhhP1C9gijpSKCslHHCvwdSIz298twx271n1l6xw', 'http://localhost:50000');
31+
let builder = client.createLog(null, 'Unit Test message', 'Trace');
3232

3333
expect(builder.target.source).toBeUndefined();
3434
expect(builder.target.message).toBe('Unit Test message');
3535
expect(builder.target.data['@level']).toBe('Trace');
3636
});
3737

3838
it('should accept source and message', () => {
39-
var client = new ExceptionlessClient('LhhP1C9gijpSKCslHHCvwdSIz298twx271n1l6xw', 'http://localhost:50000');
40-
var builder = client.createLog('ExceptionlessClient', 'Unit Test message');
39+
let client = new ExceptionlessClient('LhhP1C9gijpSKCslHHCvwdSIz298twx271n1l6xw', 'http://localhost:50000');
40+
let builder = client.createLog('ExceptionlessClient', 'Unit Test message');
4141

4242
expect(builder.target.source).toBe('ExceptionlessClient');
4343
expect(builder.target.message).toBe('Unit Test message');
4444
expect(builder.target.data).toBeUndefined();
4545
});
4646

4747
it('should accept source and message', () => {
48-
var client = new ExceptionlessClient('LhhP1C9gijpSKCslHHCvwdSIz298twx271n1l6xw', 'http://localhost:50000');
49-
var builder = client.createLog('Unit Test message');
48+
let client = new ExceptionlessClient('LhhP1C9gijpSKCslHHCvwdSIz298twx271n1l6xw', 'http://localhost:50000');
49+
let builder = client.createLog('Unit Test message');
5050

5151
expect(builder.target.source).toBeUndefined();
5252
expect(builder.target.message).toBe('Unit Test message');

src/Utils-spec.ts

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
import { IEvent } from './models/IEvent';
21
import { Utils } from './Utils';
32

43
describe('Utils', () => {
54
it('should add range', () => {
6-
var target:string[];
5+
let target:string[];
76
expect(Utils.addRange(target)).toEqual([]);
87
expect(target).toBeUndefined();
98

@@ -16,15 +15,15 @@ describe('Utils', () => {
1615
});
1716

1817
it('should stringify circular reference', () => {
19-
var afoo:any = {a: 'foo'};
18+
let afoo:any = {a: 'foo'};
2019
afoo.b = afoo;
2120

2221
expect(Utils.stringify(afoo)).toBe('{"a":"foo"}');
2322
expect(Utils.stringify([{one: afoo, two: afoo}])).toBe('[{"one":{"a":"foo"}}]');
2423
});
2524

2625
describe('stringify', () => {
27-
var user:any = {
26+
let user:any = {
2827
id:1,
2928
name: 'Blake',
3029
password: '123456',
@@ -61,36 +60,36 @@ describe('Utils', () => {
6160
});
6261

6362
it('should stringify array', () => {
64-
var error = {
65-
"type": "error",
66-
"data": {
67-
"@error": {
68-
"type": "Error",
69-
"message": "string error message",
70-
"stack_trace": [
63+
let error = {
64+
'type': 'error',
65+
'data': {
66+
'@error': {
67+
'type': 'Error',
68+
'message': 'string error message',
69+
'stack_trace': [
7170
{
72-
"name": "throwStringErrorImpl",
73-
"parameters": [],
74-
"file_name": "http://localhost/index.js",
75-
"line_number": 22,
76-
"column": 9
71+
'name': 'throwStringErrorImpl',
72+
'parameters': [],
73+
'file_name': 'http://localhost/index.js',
74+
'line_number': 22,
75+
'column': 9
7776
},
7877
{
79-
"name": "throwStringError",
80-
"parameters": [],
81-
"file_name": "http://localhost/index.js",
82-
"line_number": 10,
83-
"column": 10
78+
'name': 'throwStringError',
79+
'parameters': [],
80+
'file_name': 'http://localhost/index.js',
81+
'line_number': 10,
82+
'column': 10
8483
}, {
85-
"name": "HTMLButtonElement.onclick",
86-
"parameters": [],
87-
"file_name": "http://localhost/",
88-
"line_number": 22,
89-
"column": 10
84+
'name': 'HTMLButtonElement.onclick',
85+
'parameters': [],
86+
'file_name': 'http://localhost/',
87+
'line_number': 22,
88+
'column': 10
9089
}]
91-
}, "@submission_method": "onerror"
90+
}, '@submission_method': 'onerror'
9291
},
93-
"tags": []
92+
'tags': []
9493
};
9594

9695
expect(Utils.stringify(error)).toBe(JSON.stringify(error));

src/Utils.ts

Lines changed: 33 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { IStackFrame } from './models/IStackFrame';
2-
31
export class Utils {
42
public static addRange<T>(target:T[], ...values:T[]) {
53
if (!target) {
@@ -10,7 +8,7 @@ export class Utils {
108
return target;
119
}
1210

13-
for (var index = 0; index < values.length; index++) {
11+
for (let index = 0; index < values.length; index++) {
1412
if (values[index] && target.indexOf(values[index]) < 0) {
1513
target.push(values[index]);
1614
}
@@ -24,9 +22,9 @@ export class Utils {
2422
return null;
2523
}
2624

27-
var hash:number = 0;
28-
for (var index = 0; index < source.length; index++) {
29-
var character = source.charCodeAt(index);
25+
let hash:number = 0;
26+
for (let index = 0; index < source.length; index++) {
27+
let character = source.charCodeAt(index);
3028
hash = ((hash << 5) - hash) + character;
3129
hash |= 0;
3230
}
@@ -35,11 +33,11 @@ export class Utils {
3533
}
3634

3735
public static getCookies(cookies:string): Object {
38-
var result:Object = {};
36+
let result:Object = {};
3937

40-
var parts:string[] = (cookies || '').split('; ');
41-
for (var index = 0; index < parts.length; index++) {
42-
var cookie:string[] = parts[index].split('=');
38+
let parts:string[] = (cookies || '').split('; ');
39+
for (let index = 0; index < parts.length; index++) {
40+
let cookie:string[] = parts[index].split('=');
4341
result[cookie[0]] = cookie[1];
4442
}
4543

@@ -55,15 +53,15 @@ export class Utils {
5553
}
5654

5755
public static merge(defaultValues:Object, values:Object) {
58-
var result:Object = {};
56+
let result:Object = {};
5957

60-
for (var key in defaultValues || {}) {
58+
for (let key in defaultValues || {}) {
6159
if (!!defaultValues[key]) {
6260
result[key] = defaultValues[key];
6361
}
6462
}
6563

66-
for (var key in values || {}) {
64+
for (let key in values || {}) {
6765
if (!!values[key]) {
6866
result[key] = values[key];
6967
}
@@ -77,8 +75,8 @@ export class Utils {
7775
return null;
7876
}
7977

80-
var versionRegex = /(v?((\d+)\.(\d+)(\.(\d+))?)(?:-([\dA-Za-z\-]+(?:\.[\dA-Za-z\-]+)*))?(?:\+([\dA-Za-z\-]+(?:\.[\dA-Za-z\-]+)*))?)/;
81-
var matches = versionRegex.exec(source);
78+
let versionRegex = /(v?((\d+)\.(\d+)(\.(\d+))?)(?:-([\dA-Za-z\-]+(?:\.[\dA-Za-z\-]+)*))?(?:\+([\dA-Za-z\-]+(?:\.[\dA-Za-z\-]+)*))?)/;
79+
let matches = versionRegex.exec(source);
8280
if (matches && matches.length > 0) {
8381
return matches[0];
8482
}
@@ -91,14 +89,14 @@ export class Utils {
9189
return null;
9290
}
9391

94-
var pairs:string[] = query.split('&');
92+
let pairs:string[] = query.split('&');
9593
if (pairs.length === 0) {
9694
return null;
9795
}
9896

99-
var result:Object = {};
100-
for (var index = 0; index < pairs.length; index++) {
101-
var pair = pairs[index].split('=');
97+
let result:Object = {};
98+
for (let index = 0; index < pairs.length; index++) {
99+
let pair = pairs[index].split('=');
102100
result[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]);
103101
}
104102

@@ -115,41 +113,44 @@ export class Utils {
115113
return false;
116114
}
117115

118-
var trim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;
116+
let trim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;
119117
pattern = pattern.toLowerCase().replace(trim, '');
120118
value = value.toLowerCase().replace(trim, '');
121119

122120
if (pattern.length <= 0) {
123121
return false;
124122
}
125123

126-
var startsWithWildcard:boolean = pattern[0] === '*';
124+
let startsWithWildcard:boolean = pattern[0] === '*';
127125
if (startsWithWildcard) {
128126
pattern = pattern.slice(1);
129127
}
130128

131-
var endsWithWildcard:boolean = pattern[pattern.length - 1] === '*';
129+
let endsWithWildcard:boolean = pattern[pattern.length - 1] === '*';
132130
if (endsWithWildcard) {
133131
pattern = pattern.substring(0, pattern.length - 1);
134132
}
135133

136-
if (startsWithWildcard && endsWithWildcard)
134+
if (startsWithWildcard && endsWithWildcard) {
137135
return value.indexOf(pattern) !== -1;
136+
}
138137

139-
if (startsWithWildcard)
138+
if (startsWithWildcard) {
140139
return value.lastIndexOf(pattern) === (value.length - pattern.length);
140+
}
141141

142-
if (endsWithWildcard)
142+
if (endsWithWildcard) {
143143
return value.indexOf(pattern) === 0;
144+
}
144145

145146
return value === pattern;
146147
}
147148

148-
function stringifyImpl(data:any, exclusions:string[]): string {
149-
var cache:string[] = [];
150-
return JSON.stringify(data, function(key:string, value:any) {
151-
for (var index = 0; index < (exclusions || []).length; index++) {
152-
if (checkForMatch(exclusions[index], key)){
149+
function stringifyImpl(obj:any, excludedKeys:string[]): string {
150+
let cache:string[] = [];
151+
return JSON.stringify(obj, function(key:string, value:any) {
152+
for (let index = 0; index < (excludedKeys || []).length; index++) {
153+
if (checkForMatch(excludedKeys[index], key)) {
153154
return;
154155
}
155156
}
@@ -168,8 +169,8 @@ export class Utils {
168169
}
169170

170171
if (({}).toString.call(data) === '[object Array]') {
171-
var result = [];
172-
for (var index = 0; index < data.length; index++) {
172+
let result = [];
173+
for (let index = 0; index < data.length; index++) {
173174
result[index] = JSON.parse(stringifyImpl(data[index], exclusions || []));
174175
}
175176

0 commit comments

Comments
 (0)