|
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 | + |
2 | 8 | module.exports = {
|
3 | 9 | 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__/**', |
10 | 31 | ],
|
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'], |
30 | 37 | },
|
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 | + }, |
55 | 70 | ],
|
| 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', |
56 | 79 | },
|
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 | + // ---------------- |
60 | 106 | {
|
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 | + }, |
62 | 119 | rules: {
|
63 |
| - '@typescript-eslint/no-var-requires': ['off'], |
| 120 | + 'no-console': 'off', |
64 | 121 | },
|
65 | 122 | },
|
66 | 123 | ],
|
|
0 commit comments