Skip to content

Commit 8b38062

Browse files
committed
build: Switch @sentry/integrations to using eslint
1 parent 6229e27 commit 8b38062

18 files changed

+143
-105
lines changed

.eslintignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# THIS IS A TEMPORARY FILE
22
# THIS WILL BE REMOVED AFTER WE FINISH ESLINT UPGRADE
33

4-
packages/integrations/**/*
54
packages/node/**/*
65
packages/react/**/*
76
packages/tracing/**/*

dangerfile.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { CLIEngine } from 'eslint';
66
import { resolve } from 'path';
77
import { promisify } from 'util';
88

9-
const PACKAGES = ['integrations', 'node'];
9+
const PACKAGES = ['node'];
1010
const EXTENSIONS = ['.js', '.jsx', '.ts', '.tsx'];
1111

1212
/**

packages/integrations/.eslintrc.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
module.exports = {
2+
root: true,
3+
env: {
4+
es6: true,
5+
},
6+
parserOptions: {
7+
ecmaVersion: 2018,
8+
},
9+
extends: ['../../.eslintrc.js'],
10+
ignorePatterns: ['build/**/*', 'dist/**/*', 'esm/**/*', 'examples/**/*', 'scripts/**/*'],
11+
overrides: [
12+
{
13+
files: ['*.ts', '*.tsx', '*.d.ts'],
14+
parserOptions: {
15+
project: './tsconfig.json',
16+
},
17+
},
18+
{
19+
files: ['test/**/*'],
20+
env: {
21+
mocha: true,
22+
},
23+
rules: {
24+
'@typescript-eslint/no-explicit-any': 'off',
25+
'@typescript-eslint/no-non-null-assertion': 'off',
26+
},
27+
},
28+
],
29+
};

packages/integrations/package.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,12 @@
4545
"build:bundle": "rollup --config",
4646
"clean": "rimraf dist coverage esm build .rpt2_cache",
4747
"link:yarn": "yarn link",
48-
"lint": "run-s lint:prettier lint:tslint",
48+
"lint": "run-s lint:prettier lint:eslint",
4949
"lint:prettier": "prettier-check \"{src,test}/**/*.ts\"",
50-
"lint:tslint": "tslint -t stylish -p .",
51-
"lint:tslint:json": "tslint --format json -p . | tee lint-results.json",
52-
"fix": "run-s fix:tslint fix:prettier",
50+
"lint:eslint": "eslint . --cache --cache-location '../../eslintcache/' --format stylish",
51+
"fix": "run-s fix:eslint fix:prettier",
5352
"fix:prettier": "prettier --write \"{src,test}/**/*.ts\"",
54-
"fix:tslint": "tslint --fix -t stylish -p .",
53+
"fix:eslint": "eslint . --format stylish --fix",
5554
"test": "jest",
5655
"test:watch": "jest --watch"
5756
},

packages/integrations/rollup.config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
import * as fs from 'fs';
2+
13
import { terser } from 'rollup-plugin-terser';
24
import typescript from 'rollup-plugin-typescript2';
35
import resolve from 'rollup-plugin-node-resolve';
46
import commonjs from 'rollup-plugin-commonjs';
5-
import * as fs from 'fs';
67

78
const terserInstance = terser({
89
mangle: {

packages/integrations/src/angular.ts

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,6 @@ const angularPattern = /^\[((?:[$a-zA-Z0-9]+:)?(?:[$a-zA-Z0-9]+))\] (.*?)\n?(\S+
1010
* Provides an $exceptionHandler for AngularJS
1111
*/
1212
export class Angular implements Integration {
13-
/**
14-
* @inheritDoc
15-
*/
16-
public name: string = Angular.id;
17-
1813
/**
1914
* @inheritDoc
2015
*/
@@ -25,9 +20,15 @@ export class Angular implements Integration {
2520
*/
2621
public static moduleName: string = 'ngSentry';
2722

23+
/**
24+
* @inheritDoc
25+
*/
26+
public name: string = Angular.id;
27+
2828
/**
2929
* Angular's instance
3030
*/
31+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
3132
private readonly _angular: any;
3233

3334
/**
@@ -38,8 +39,9 @@ export class Angular implements Integration {
3839
/**
3940
* @inheritDoc
4041
*/
42+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
4143
public constructor(options: { angular?: any } = {}) {
42-
// tslint:disable-next-line: no-unsafe-any
44+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
4345
this._angular = options.angular || getGlobalObject<any>().angular;
4446
}
4547

@@ -57,7 +59,8 @@ export class Angular implements Integration {
5759
// tslint:disable: no-unsafe-any
5860
this._angular.module(Angular.moduleName, []).config([
5961
'$provide',
60-
($provide: any) => {
62+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
63+
($provide: any): void => {
6164
$provide.decorator('$exceptionHandler', ['$delegate', this._$exceptionHandlerDecorator.bind(this)]);
6265
},
6366
]);
@@ -67,9 +70,9 @@ export class Angular implements Integration {
6770
/**
6871
* Angular's exceptionHandler for Sentry integration
6972
*/
70-
// tslint:disable-next-line: no-unsafe-any
73+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
7174
private _$exceptionHandlerDecorator($delegate: any): any {
72-
return (exception: Error, cause?: string) => {
75+
return (exception: Error, cause?: string): void => {
7376
const hub = this._getCurrentHub && this._getCurrentHub();
7477

7578
if (hub && hub.getIntegration(Angular)) {

packages/integrations/src/captureconsole.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ export class CaptureConsole implements Integration {
88
/**
99
* @inheritDoc
1010
*/
11-
public name: string = CaptureConsole.id;
11+
public static id: string = 'CaptureConsole';
1212

1313
/**
1414
* @inheritDoc
1515
*/
16-
public static id: string = 'CaptureConsole';
16+
public name: string = CaptureConsole.id;
1717

1818
/**
1919
* @inheritDoc
@@ -42,7 +42,8 @@ export class CaptureConsole implements Integration {
4242
return;
4343
}
4444

45-
fill(global.console, level, (originalConsoleLevel: () => any) => (...args: any[]) => {
45+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
46+
fill(global.console, level, (originalConsoleLevel: () => any) => (...args: any[]): void => {
4647
const hub = getCurrentHub();
4748

4849
if (hub.getIntegration(CaptureConsole)) {

packages/integrations/src/debug.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ export class Debug implements Integration {
1212
/**
1313
* @inheritDoc
1414
*/
15-
public name: string = Debug.id;
15+
public static id: string = 'Debug';
1616

1717
/**
1818
* @inheritDoc
1919
*/
20-
public static id: string = 'Debug';
20+
public name: string = Debug.id;
2121

2222
/** JSDoc */
2323
private readonly _options: DebugOptions;
@@ -40,12 +40,12 @@ export class Debug implements Integration {
4040
addGlobalEventProcessor((event: Event, hint?: EventHint) => {
4141
const self = getCurrentHub().getIntegration(Debug);
4242
if (self) {
43-
// tslint:disable:no-console
44-
// tslint:disable:no-debugger
4543
if (self._options.debugger) {
44+
// eslint-disable-next-line no-debugger
4645
debugger;
4746
}
4847

48+
/* eslint-disable no-console */
4949
consoleSandbox(() => {
5050
if (self._options.stringify) {
5151
console.log(JSON.stringify(event, null, 2));
@@ -59,6 +59,7 @@ export class Debug implements Integration {
5959
}
6060
}
6161
});
62+
/* eslint-enable no-console */
6263
}
6364
return event;
6465
});

packages/integrations/src/dedupe.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export class Dedupe implements Integration {
55
/**
66
* @inheritDoc
77
*/
8-
private _previousEvent?: Event;
8+
public static id: string = 'Dedupe';
99

1010
/**
1111
* @inheritDoc
@@ -15,7 +15,7 @@ export class Dedupe implements Integration {
1515
/**
1616
* @inheritDoc
1717
*/
18-
public static id: string = 'Dedupe';
18+
private _previousEvent?: Event;
1919

2020
/**
2121
* @inheritDoc
@@ -92,7 +92,7 @@ export class Dedupe implements Integration {
9292

9393
if (exception) {
9494
try {
95-
// @ts-ignore
95+
// @ts-ignore Object could be undefined
9696
return exception.values[0].stacktrace.frames;
9797
} catch (_oO) {
9898
return undefined;

packages/integrations/src/ember.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,32 @@ export class Ember implements Integration {
66
/**
77
* @inheritDoc
88
*/
9-
public name: string = Ember.id;
9+
public static id: string = 'Ember';
10+
1011
/**
1112
* @inheritDoc
1213
*/
13-
public static id: string = 'Ember';
14+
public name: string = Ember.id;
1415

1516
/**
1617
* @inheritDoc
1718
*/
18-
private readonly _Ember: any; // tslint:disable-line:variable-name
19+
// eslint-disable-next-line @typescript-eslint/naming-convention, @typescript-eslint/no-explicit-any
20+
private readonly _Ember: any;
1921

2022
/**
2123
* @inheritDoc
2224
*/
25+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
2326
public constructor(options: { Ember?: any } = {}) {
24-
// tslint:disable-next-line: no-unsafe-any
27+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
2528
this._Ember = options.Ember || getGlobalObject<any>().Ember;
2629
}
2730

2831
/**
2932
* @inheritDoc
3033
*/
3134
public setupOnce(_: (callback: EventProcessor) => void, getCurrentHub: () => Hub): void {
32-
// tslint:disable:no-unsafe-any
33-
3435
if (!this._Ember) {
3536
logger.error('EmberIntegration is missing an Ember instance');
3637
return;
@@ -50,6 +51,7 @@ export class Ember implements Integration {
5051
}
5152
};
5253

54+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
5355
this._Ember.RSVP.on('error', (reason: any): void => {
5456
if (getCurrentHub().getIntegration(Ember)) {
5557
getCurrentHub().withScope(scope => {

0 commit comments

Comments
 (0)