Skip to content

Commit 019d900

Browse files
authored
build: Convert core, hub, minimal and types to use eslint (#2794)
* build: Switch `@sentry/core` to using eslint * build: Switch `@sentry/hub` to using eslint * build: Switch `@sentry/minimal` to using eslint * build: Switch `@sentry/types` to using eslint
1 parent d44a1d9 commit 019d900

Some content is hidden

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

50 files changed

+377
-285
lines changed

.eslintignore

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,11 @@
22
# THIS WILL BE REMOVED AFTER WE FINISH ESLINT UPGRADE
33

44
packages/apm/**/*
5-
packages/core/**/*
65
packages/ember/**/*
76
packages/gatsby/**/*
8-
packages/hub/**/*
97
packages/integrations/**/*
10-
packages/minimal/**/*
118
packages/node/**/*
129
packages/react/**/*
1310
packages/tracing/**/*
14-
packages/types/**/*
1511
packages/typescript/**/*
1612
packages/utils/**/*

.eslintrc.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ module.exports = {
9393
files: ['*.test.ts', '*.test.tsx', '*.test.js', '*.test.jsx'],
9494
rules: {
9595
'max-lines': 'off',
96+
97+
'@typescript-eslint/explicit-function-return-type': 'off',
9698
},
9799
},
98100
{
@@ -123,5 +125,8 @@ module.exports = {
123125

124126
// Limit maximum file size to reduce complexity. Turned off in tests.
125127
'max-lines': 'error',
128+
129+
// We should require a whitespace beginning a comment
130+
'spaced-comment': 'error',
126131
},
127132
};

dangerfile.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import tslint from 'danger-plugin-tslint';
66
import { prettyResults } from 'danger-plugin-tslint/dist/prettyResults';
77
import { CLIEngine } from 'eslint';
88

9-
const PACKAGES = ['apm', 'core', 'hub', 'integrations', 'minimal', 'node', 'types', 'utils'];
9+
const PACKAGES = ['apm', 'integrations', 'node', 'utils'];
1010
const EXTENSIONS = ['.js', '.jsx', '.ts', '.tsx'];
1111

1212
/**

packages/browser/src/helpers.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,8 @@ export function wrap(
153153
},
154154
});
155155
}
156-
} catch (_oO) {
157-
/*no-empty*/
158-
}
156+
// eslint-disable-next-line no-empty
157+
} catch (_oO) {}
159158

160159
return sentryWrapped;
161160
}

packages/browser/test/integration/common/utils.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ function supportsOnunhandledRejection() {
5050
}
5151

5252
function isBelowIE11() {
53+
// eslint-disable-next-line spaced-comment
5354
return /*@cc_on!@*/ false == !false;
5455
}
5556

packages/browser/test/integration/polyfills/fetch.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*!
1+
/* !
22
* @overview whatwg-fetch - an implementation of Fetch API.
33
* @copyright Copyright (c) 2014-2016 GitHub, Inc.
44
* @license Licensed under MIT license

packages/browser/test/integration/polyfills/promise.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*!
1+
/* !
22
* @overview es6-promise - an implementation of Promise API.
33
* @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors (Conversion to ES6 API by Jake Archibald)
44
* @license Licensed under MIT license
@@ -222,7 +222,7 @@
222222
`value`
223223
*/
224224
function resolve$1(object) {
225-
/*jshint validthis:true */
225+
/* jshint validthis:true */
226226
var Constructor = this;
227227

228228
if (
@@ -722,7 +722,7 @@
722722
promise to settle.
723723
*/
724724
function race(entries) {
725-
/*jshint validthis:true */
725+
/* jshint validthis:true */
726726
var Constructor = this;
727727

728728
if (!isArray(entries)) {
@@ -774,7 +774,7 @@
774774
@return {Promise} a promise rejected with the given `reason`.
775775
*/
776776
function reject$1(reason) {
777-
/*jshint validthis:true */
777+
/* jshint validthis:true */
778778
var Constructor = this;
779779
var promise = new Constructor(noop);
780780
reject(promise, reason);

packages/browser/test/integration/suites/loader.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ if (IS_LOADER) {
4545
setTimeout(function() {
4646
Sentry.captureMessage("test");
4747
});
48-
undefinedMethod(); //trigger error
48+
undefinedMethod(); // trigger error
4949
}).then(function(summary) {
5050
assert.ok(summary.events[0].breadcrumbs);
5151
assert.lengthOf(summary.events[0].breadcrumbs, 1);

packages/core/.eslintrc.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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+
rules: {
21+
'@typescript-eslint/no-explicit-any': 'off',
22+
'@typescript-eslint/no-non-null-assertion': 'off',
23+
},
24+
},
25+
],
26+
};

packages/core/package.json

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
"prettier": "^1.17.0",
2929
"prettier-check": "^2.0.0",
3030
"rimraf": "^2.6.3",
31-
"tslint": "5.16.0",
3231
"typescript": "3.4.5"
3332
},
3433
"scripts": {
@@ -40,13 +39,13 @@
4039
"build:watch:esm": "tsc -p tsconfig.esm.json -w --preserveWatchOutput",
4140
"clean": "rimraf dist coverage",
4241
"link:yarn": "yarn link",
43-
"lint": "run-s lint:prettier lint:tslint",
42+
"lint": "run-s lint:prettier lint:eslint",
4443
"lint:prettier": "prettier-check \"{src,test}/**/*.ts\"",
45-
"lint:tslint": "tslint -t stylish -p .",
46-
"lint:tslint:json": "tslint --format json -p . | tee lint-results.json",
47-
"fix": "run-s fix:tslint fix:prettier",
44+
"lint:eslint": "eslint . --format stylish",
45+
"lint:eslint:json": "eslint . --format json | tee lint-results.json",
46+
"fix": "run-s fix:eslint fix:prettier",
4847
"fix:prettier": "prettier --write \"{src,test}/**/*.ts\"",
49-
"fix:tslint": "tslint --fix -t stylish -p .",
48+
"fix:eslint": "lint:eslint --fix",
5049
"test": "jest",
5150
"test:watch": "jest --watch"
5251
},

0 commit comments

Comments
 (0)