Skip to content

Commit 44876ee

Browse files
committed
chore: Use ESLint config from sentry-javascript
1 parent ba647cc commit 44876ee

File tree

4 files changed

+409
-139
lines changed

4 files changed

+409
-139
lines changed

.eslintrc.js

Lines changed: 112 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,123 @@
1-
/* eslint-env node */
1+
// TODO: Remove this file after migration!
2+
// TODO: Remove Sentry ESLint config package from package.json
3+
// Note: All paths are relative to the directory in which eslint is being run, rather than the directory where this file
4+
// lives
5+
6+
// ESLint config docs: https://eslint.org/docs/user-guide/configuring/
7+
28
module.exports = {
39
root: true,
4-
parser: '@typescript-eslint/parser',
5-
plugins: ['@typescript-eslint', 'simple-import-sort'],
6-
extends: [
7-
'eslint:recommended',
8-
'plugin:@typescript-eslint/recommended',
9-
'plugin:prettier/recommended', // Should be last
10+
env: {
11+
es6: true,
12+
},
13+
parserOptions: {
14+
ecmaVersion: 2018,
15+
},
16+
extends: ['@sentry-internal/sdk'],
17+
ignorePatterns: [
18+
'coverage/**',
19+
'build/**',
20+
'dist/**',
21+
'cjs/**',
22+
'esm/**',
23+
'examples/**',
24+
'test/manual/**',
25+
'types/**',
26+
// TODO: Remove these after migration
27+
'scripts/**',
28+
'config/**',
29+
'config/**',
30+
'__mocks__/**',
1031
],
11-
12-
settings: {},
13-
14-
globals: {},
15-
rules: {
16-
// note you must disable the base rule as it can report incorrect errors
17-
'no-unused-vars': 'off',
18-
'@typescript-eslint/no-unused-vars': [
19-
'error',
20-
{ vars: 'all', varsIgnorePattern: '^_', argsIgnorePattern: '^_' },
21-
],
22-
23-
'@typescript-eslint/no-explicit-any': 'off',
24-
25-
// Make sure that all ts-ignore comments are given a description.
26-
'@typescript-eslint/ban-ts-comment': [
27-
'warn',
28-
{
29-
'ts-ignore': 'allow-with-description',
32+
overrides: [
33+
{
34+
files: ['*.ts', '*.tsx', '*.d.ts'],
35+
parserOptions: {
36+
project: ['tsconfig.json'],
3037
},
31-
],
32-
33-
'simple-import-sort/imports': [
34-
'error',
35-
{
36-
groups: [
37-
// Side effect imports.
38-
['^\\u0000'],
39-
40-
// Node.js builtins.
41-
// eslint-disable-next-line @typescript-eslint/no-var-requires
42-
[`^(${require('module').builtinModules.join('|')})(/|$)`],
43-
44-
// Packages.
45-
['^@?\\w'],
46-
47-
// Internal packages.
48-
['^@$', '^(@/)(.*|$)'],
49-
50-
// Parent imports. Put `..` last.
51-
['^\\.\\.(?!/?$)', '^\\.\\./?$'],
52-
53-
// Other relative imports. Put same-folder imports and `.` last.
54-
['^\\./(?=.*/)(?!/?$)', '^\\.(?!/?$)', '^\\./?$'],
38+
},
39+
// TODO: Extract this to package-specific config after mgiration
40+
{
41+
files: ['worker/**/*.ts'],
42+
parserOptions: {
43+
project: ['config/tsconfig.worker.json'],
44+
},
45+
},
46+
{
47+
files: ['*.ts', '*.tsx', '*.d.ts'],
48+
rules: {
49+
// TODO (high-prio): Go through console logs and figure out which ones should be replaced with the SDK logger
50+
'no-console': 'off',
51+
// TODO (high-pio): Re-enable this after migration
52+
'no-restricted-globals': 'off',
53+
// TODO (high-prio): Re-enable this after migration
54+
'@typescript-eslint/explicit-member-accessibility': 'off',
55+
// TODO (high-prio): Remove this exception from naming convention after migration
56+
'@typescript-eslint/naming-convention': [
57+
'error',
58+
{
59+
selector: 'memberLike',
60+
modifiers: ['private'],
61+
format: ['camelCase'],
62+
leadingUnderscore: 'allow',
63+
},
64+
{
65+
selector: 'memberLike',
66+
modifiers: ['protected'],
67+
format: ['camelCase'],
68+
leadingUnderscore: 'allow',
69+
},
5570
],
71+
// TODO (high-prio): Re-enable this after migration
72+
'@sentry-internal/sdk/no-async-await': 'off',
73+
// TODO (high-prio): Re-enable this after migration
74+
'@typescript-eslint/no-floating-promises': 'off',
75+
// TODO (medium-prio): Re-enable this after migration
76+
'jsdoc/require-jsdoc': 'off',
77+
// TODO: Do we even want to turn this on? Why not enable ++?
78+
'no-plusplus': 'off',
5679
},
57-
],
58-
},
59-
overrides: [
80+
},
81+
{
82+
files: ['jest.setup.ts'],
83+
rules: {
84+
'no-console': 'off',
85+
},
86+
},
87+
{
88+
files: ['test/**/*.ts'],
89+
rules: {
90+
// TODO: decide if we want to keep our '@test' import paths
91+
'import/no-unresolved': 'off',
92+
// most of these errors come from `new Promise(process.nextTick)`
93+
'@typescript-eslint/unbound-method': 'off',
94+
// TODO: decide if we want to enable this again after the migration
95+
// We can take the freedom to be a bit more lenient with tests
96+
'@typescript-eslint/no-floating-promises': 'off',
97+
},
98+
},
99+
{
100+
files: ['src/worker/**/*.js'],
101+
parserOptions: {
102+
sourceType: 'module',
103+
},
104+
},
105+
// ----------------
60106
{
61-
files: ['*.spec.ts'],
107+
files: ['*.tsx'],
108+
rules: {
109+
// Turn off jsdoc on tsx files until jsdoc is fixed for tsx files
110+
// See: https://github.com/getsentry/sentry-javascript/issues/3871
111+
'jsdoc/require-jsdoc': 'off',
112+
},
113+
},
114+
{
115+
files: ['scenarios/**', 'rollup/**'],
116+
parserOptions: {
117+
sourceType: 'module',
118+
},
62119
rules: {
63-
'@typescript-eslint/no-var-requires': ['off'],
120+
'no-console': 'off',
64121
},
65122
},
66123
],

demo/yarn.lock

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1522,13 +1522,12 @@
15221522
tslib "^1.9.3"
15231523

15241524
"@sentry/replay@file:..":
1525-
version "0.6.14-3"
1525+
version "0.6.14"
15261526
dependencies:
15271527
"@sentry/core" "^7.7.0"
15281528
"@sentry/types" "^7.7.0"
15291529
"@sentry/utils" "^7.7.0"
15301530
lodash.debounce "^4.0.8"
1531-
pako "^2.0.4"
15321531
rrweb "^1.1.3"
15331532

15341533
"@sentry/tracing@^7.1.1":
@@ -6168,11 +6167,6 @@ p-try@^2.0.0:
61686167
version "2.2.0"
61696168
resolved "https://registry.yarnpkg.com/p-try/-/p-try-2.2.0.tgz#cb2868540e313d61de58fafbe35ce9004d5540e6"
61706169

6171-
pako@^2.0.4:
6172-
version "2.0.4"
6173-
resolved "https://registry.yarnpkg.com/pako/-/pako-2.0.4.tgz#6cebc4bbb0b6c73b0d5b8d7e8476e2b2fbea576d"
6174-
integrity sha512-v8tweI900AUkZN6heMU/4Uy4cXRc2AYNRggVmTR+dEncawDJgCdLMximOVA2p4qO57WMynangsfGRb5WD6L1Bg==
6175-
61766170
param-case@^3.0.4:
61776171
version "3.0.4"
61786172
resolved "https://registry.yarnpkg.com/param-case/-/param-case-3.0.4.tgz#7d17fe4aa12bde34d4a77d91acfb6219caad01c5"

package.json

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"fix:eslint": "eslint . --format stylish --fix",
2525
"fix:prettier": "prettier --write \"{src,test,scripts,worker}/**/*.ts\"",
2626
"lint": "run-s lint:prettier lint:eslint",
27-
"lint:eslint": "eslint . --ext .js,.jsx,.ts,.tsx #TODO: we might want to use eslintcache after migration",
27+
"lint:eslint": "eslint . --format stylish #TODO: we might want to use eslintcache after migration",
2828
"lint:prettier": "prettier --check \"{src,test,scripts,worker}/**/*.ts\"",
2929
"test": "jest",
3030
"test:watch": "jest --watch",
@@ -47,6 +47,7 @@
4747
"@rollup/plugin-node-resolve": "^13.3.0",
4848
"@rollup/plugin-replace": "^4.0.0",
4949
"@rollup/plugin-typescript": "^8.3.1",
50+
"@sentry-internal/eslint-config-sdk": "^7.20.1",
5051
"@sentry/browser": "^7.7.0",
5152
"@size-limit/file": "^8.1.0",
5253
"@size-limit/time": "^8.1.0",
@@ -55,12 +56,7 @@
5556
"@types/lodash.throttle": "^4.1.7",
5657
"@types/node": "^18.11.0",
5758
"@types/pako": "^2.0.0",
58-
"@typescript-eslint/eslint-plugin": "^5.31.0",
59-
"@typescript-eslint/parser": "^5.31.0",
6059
"eslint": "7.32.0",
61-
"eslint-config-prettier": "^8.5.0",
62-
"eslint-plugin-prettier": "^4.0.0",
63-
"eslint-plugin-simple-import-sort": "^7.0.0",
6460
"jest": "27.5.1",
6561
"jest-environment-jsdom": "27.5.1",
6662
"jsdom-worker": "^0.2.1",

0 commit comments

Comments
 (0)