Skip to content

Commit 8eb7286

Browse files
authored
build: Switch integrations, node, react, tracing to eslint (#2806)
* build: Switch @sentry/integrations to using eslint * build: Remove tslint danger * build: Switch @sentry/node to using eslint * build: Switch @sentry/react to using eslint * build: Switch @sentry/tracing to using eslint * remove remaining tslint references * Add unsafe any rule
1 parent 6229e27 commit 8eb7286

File tree

114 files changed

+967
-2024
lines changed

Some content is hidden

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

114 files changed

+967
-2024
lines changed

.eslintignore

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

4-
packages/integrations/**/*
5-
packages/node/**/*
6-
packages/react/**/*
7-
packages/tracing/**/*
84
packages/typescript/**/*

.eslintrc.js

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ module.exports = {
44
node: true,
55
},
66
extends: ['prettier', 'eslint:recommended', 'plugin:import/errors', 'plugin:import/warnings'],
7-
plugins: ['sentry-sdk', 'simple-import-sort'],
8-
ignorePatterns: ['eslint-plugin-sentry-sdk'],
7+
plugins: ['sentry-sdks', 'simple-import-sort'],
8+
ignorePatterns: ['eslint-plugin-sentry-sdks'],
99
overrides: [
1010
{
1111
// Configuration for JavaScript files
@@ -43,7 +43,7 @@ module.exports = {
4343
// Enforce type annotations to maintain consistency. This is especially important as
4444
// we have a public API, so we want changes to be very explicit.
4545
'@typescript-eslint/typedef': ['error', { arrowParameter: false }],
46-
'@typescript-eslint/explicit-function-return-type': 'error',
46+
'@typescript-eslint/explicit-function-return-type': ['error', { allowExpressions: true }],
4747

4848
// Consistent ordering of fields, methods and constructors for classes should be enforced
4949
'@typescript-eslint/member-ordering': 'error',
@@ -87,21 +87,35 @@ module.exports = {
8787
'simple-import-sort/sort': 'error',
8888
'sort-imports': 'off',
8989
'import/order': 'off',
90+
91+
// Disallow delete operator. We should make this operation opt in (by disabling this rule).
92+
'@typescript-eslint/no-dynamic-delete': 'error',
93+
94+
// We should prevent against overloads unless necessary.
95+
'@typescript-eslint/unified-signatures': 'error',
96+
97+
// Disallow unsafe any usage. We should enforce that types be used as possible, or unknown be used
98+
// instead of any. This is especially important for methods that expose a public API, as users
99+
// should know exactly what they have to provide to use those methods. Turned off in tests.
100+
'@typescript-eslint/no-unsafe-member-access': 'error',
90101
},
91102
},
92103
{
93104
// Configuration for files under src
94105
files: ['src/**/*'],
95106
rules: {
96107
// We want to prevent async await usage in our files to prevent uncessary bundle size.
97-
'sentry-sdk/no-async-await': 'error',
108+
'sentry-sdks/no-async-await': 'error',
98109

99110
// JSDOC comments are required for classes and methods. As we have a public facing codebase, documentation,
100111
// even if it may seems excessive at times, is important to emphasize. Turned off in tests.
101112
'jsdoc/require-jsdoc': [
102113
'error',
103114
{ require: { ClassDeclaration: true, MethodDefinition: true }, checkConstructors: false },
104115
],
116+
117+
// All imports should be accounted for
118+
'import/no-extraneous-dependencies': 'error',
105119
},
106120
},
107121
{
@@ -116,6 +130,7 @@ module.exports = {
116130
'@typescript-eslint/explicit-function-return-type': 'off',
117131
'no-unused-expressions': 'off',
118132
'@typescript-eslint/no-unused-expressions': 'off',
133+
'@typescript-eslint/no-unsafe-member-access': 'off',
119134
},
120135
},
121136
{
@@ -164,5 +179,8 @@ module.exports = {
164179

165180
// imports should be ordered.
166181
'import/order': ['error', { 'newlines-between': 'always' }],
182+
183+
// Make sure for in loops check for properties
184+
'guard-for-in': 'error',
167185
},
168186
};

.vscode/extensions.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
// See http://go.microsoft.com/fwlink/?LinkId=827846
33
// for the documentation about the extensions.json format
4-
"recommendations": ["esbenp.prettier-vscode", "ms-vscode.vscode-typescript-tslint-plugin", "dbaeumer.vscode-eslint"]
4+
"recommendations": ["esbenp.prettier-vscode", "dbaeumer.vscode-eslint"]
55
}

.vscode/settings.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
"**/dist/": true
1414
},
1515
"typescript.tsdk": "./node_modules/typescript/lib",
16-
"tslint.autoFixOnSave": true,
1716
"[json]": {
1817
"editor.formatOnType": false,
1918
"editor.formatOnPaste": false,

dangerfile.ts

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
import { exec } from 'child_process';
22
import { danger, fail, message, schedule, warn } from 'danger';
3-
import tslint from 'danger-plugin-tslint';
4-
import { prettyResults } from 'danger-plugin-tslint/dist/prettyResults';
53
import { CLIEngine } from 'eslint';
6-
import { resolve } from 'path';
74
import { promisify } from 'util';
85

9-
const PACKAGES = ['integrations', 'node'];
106
const EXTENSIONS = ['.js', '.jsx', '.ts', '.tsx'];
117

128
/**
@@ -48,35 +44,6 @@ export default async (): Promise<void> => {
4844
return;
4945
}
5046

51-
schedule(async () => {
52-
const tsLintResult = (
53-
await Promise.all(
54-
PACKAGES.map(packageName => {
55-
return new Promise<string>(res => {
56-
tslint({
57-
lintResultsJsonPath: resolve(__dirname, 'packages', packageName, 'lint-results.json'),
58-
handleResults: results => {
59-
if (results.length > 0) {
60-
const formattedResults = prettyResults(results);
61-
res(`TSLint failed: **@sentry/${packageName}**\n\n${formattedResults}`);
62-
} else {
63-
res('');
64-
}
65-
},
66-
});
67-
});
68-
}),
69-
)
70-
).filter(str => str.length);
71-
if (tsLintResult.length) {
72-
tsLintResult.forEach(tsLintFail => {
73-
fail(`${tsLintFail}`);
74-
});
75-
} else {
76-
message('✅ TSLint passed');
77-
}
78-
});
79-
8047
await eslint();
8148

8249
const hasChangelog = danger.git.modified_files.indexOf('CHANGELOG.md') !== -1;

eslint-plugin-sentry-sdk/package.json renamed to eslint-plugin-sentry-sdks/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "eslint-plugin-sentry-sdk",
2+
"name": "eslint-plugin-sentry-sdks",
33
"version": "0.0.1",
44
"main": "index.js",
55
"devDependencies": {

package.json

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
"fix": "lerna run --stream --concurrency 1 fix",
1010
"link:yarn": "lerna run --stream --concurrency 1 link:yarn",
1111
"lint": "lerna run --stream --concurrency 1 lint",
12-
"lint:json": "lerna run --stream --concurrency 1 lint:tslint:json",
1312
"test": "lerna run --stream --concurrency 1 --sort test",
1413
"codecov": "codecov",
1514
"postpublish": "make publish-docs"
@@ -44,19 +43,17 @@
4443
"@types/mocha": "^5.2.0",
4544
"@types/node": "^11.13.7",
4645
"@types/sinon": "^7.0.11",
47-
"@typescript-eslint/eslint-plugin": "^3.7.1",
48-
"@typescript-eslint/parser": "^3.7.1",
46+
"@typescript-eslint/eslint-plugin": "^3.9.0",
47+
"@typescript-eslint/parser": "^3.9.0",
4948
"chai": "^4.1.2",
5049
"codecov": "^3.6.5",
5150
"danger": "^7.1.3",
52-
"danger-plugin-eslint": "^0.1.0",
53-
"danger-plugin-tslint": "^2.0.0",
5451
"eslint": "^7.5.0",
5552
"eslint-config-prettier": "^6.11.0",
5653
"eslint-plugin-deprecation": "^1.1.0",
5754
"eslint-plugin-import": "^2.22.0",
5855
"eslint-plugin-jsdoc": "^30.0.3",
59-
"eslint-plugin-sentry-sdk": "file:./eslint-plugin-sentry-sdk",
56+
"eslint-plugin-sentry-sdks": "file:./eslint-plugin-sentry-sdks",
6057
"eslint-plugin-simple-import-sort": "^5.0.3",
6158
"jest": "^24.7.1",
6259
"karma-browserstack-launcher": "^1.5.1",
@@ -71,10 +68,8 @@
7168
"sinon": "^7.3.2",
7269
"size-limit": "^4.5.5",
7370
"ts-jest": "^24.0.2",
74-
"tslint": "5.16.0",
7571
"typedoc": "^0.14.2",
76-
"typescript": "3.4.5",
77-
"typescript-tslint-plugin": "^0.3.1"
72+
"typescript": "3.4.5"
7873
},
7974
"resolutions": {
8075
"**/agent-base": "5"

packages/angular/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
"prettier": "^1.17.0",
3131
"prettier-check": "^2.0.0",
3232
"rimraf": "^2.6.3",
33-
"tslint": "^5.16.0",
3433
"typescript": "^3.5.1"
3534
},
3635
"scripts": {

packages/angular/src/errorhandler.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ class SentryErrorHandler implements AngularErrorHandler {
7878
// Allow custom overrides of extracting function
7979
if (this._options.extractor) {
8080
const defaultExtractor = this._defaultExtractor.bind(this);
81-
// tslint:disable-next-line:no-unsafe-any
8281
return this._options.extractor(error, defaultExtractor);
8382
}
8483

0 commit comments

Comments
 (0)