Skip to content

Commit 289eff5

Browse files
antonisclaude
andcommitted
chore(deps): bump eslint from 8.x to 9.x
Upgrade ESLint from v8 to v9 across all workspaces. ESLint 9 uses flat config by default, but we keep using legacy .eslintrc.js format via ESLINT_USE_FLAT_CONFIG=false since upstream @sentry-internal/eslint-config-sdk hasn't migrated yet. Key changes: - Bump eslint to ^9.0.0 in all packages - Bump @typescript-eslint/* to ^8.0.0 (supports ESLint 9) - Bump @react-native/eslint-config to 0.84.1 (ESLint 9 compatible deps) - Replace deprecated @typescript-eslint/ban-types with new v8 rules - Replace @typescript-eslint/no-var-requires with no-require-imports - Set caughtErrors: 'none' for no-unused-vars (v8 changed default) - Set no-explicit-any to 'warn' (was 'warn' in v5, 'error' in v8) - Add ESLINT_USE_FLAT_CONFIG=false to lint/fix scripts - Auto-fix prefer-optional-chain violations - Force eslint-plugin-ft-flow to ^3.0.0 via resolution (ESLint 9 compat) Fixes #5600 Ref: #5594 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 45df559 commit 289eff5

25 files changed

Lines changed: 324 additions & 621 deletions

File tree

package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,7 @@
7070
"detox@npm:20.46.0/ajv": "^8.18.0",
7171
"@eslint/eslintrc@npm:2.1.4/ajv": "^6.14.0",
7272
"@eslint/eslintrc@npm:3.3.3/ajv": "^6.14.0",
73-
"eslint@npm:8.57.0/ajv": "^6.14.0",
74-
"eslint@npm:8.57.1/ajv": "^6.14.0",
75-
"eslint@npm:9.39.2/ajv": "^6.14.0",
73+
"eslint@npm:9.39.4/ajv": "^6.14.0",
7674
"express@npm:4.19.2/path-to-regexp": "0.1.12",
7775
"@eslint/config-array@npm:0.21.1/minimatch": "^3.1.3",
7876
"@eslint/eslintrc@npm:2.1.4/minimatch": "^3.1.3",
@@ -86,9 +84,7 @@
8684
"eslint-plugin-node@npm:11.1.0/minimatch": "^3.1.3",
8785
"eslint-plugin-react@npm:7.35.0/minimatch": "^3.1.3",
8886
"eslint-plugin-react@npm:7.37.5/minimatch": "^3.1.3",
89-
"eslint@npm:8.57.0/minimatch": "^3.1.3",
90-
"eslint@npm:8.57.1/minimatch": "^3.1.3",
91-
"eslint@npm:9.39.2/minimatch": "^3.1.3",
87+
"eslint@npm:9.39.4/minimatch": "^3.1.3",
9288
"glob@npm:6.0.4/minimatch": "^3.1.3",
9389
"glob@npm:7.1.6/minimatch": "^3.1.3",
9490
"glob@npm:7.2.3/minimatch": "^3.1.3",
@@ -110,9 +106,10 @@
110106
"@sentry/node@npm:10.31.0/minimatch": "^9.0.7",
111107
"@tufjs/models@npm:2.0.1/minimatch": "^9.0.7",
112108
"@typescript-eslint/typescript-estree@npm:6.21.0/minimatch": "^9.0.7",
113-
"@typescript-eslint/typescript-estree@npm:7.18.0/minimatch": "^9.0.7",
114109
"@typescript-eslint/typescript-estree@npm:8.50.0/minimatch": "^9.0.7",
115110
"@typescript-eslint/typescript-estree@npm:8.54.0/minimatch": "^9.0.7",
111+
"@typescript-eslint/typescript-estree@npm:8.56.1/minimatch": "^9.0.7",
112+
"@typescript-eslint/typescript-estree@npm:8.57.0/minimatch": "^9.0.7",
116113
"editorconfig@npm:1.0.4/minimatch": "^9.0.7",
117114
"glob@npm:10.4.1/minimatch": "^9.0.7",
118115
"glob@npm:10.4.5/minimatch": "^9.0.7",
@@ -121,6 +118,9 @@
121118
"nx@npm:19.6.4/minimatch": "^9.0.7",
122119
"webdriverio@npm:8.40.5/minimatch": "^9.0.7",
123120
"glob@npm:13.0.0/minimatch": "^10.2.3",
121+
"@sentry-internal/eslint-config-sdk@npm:10.43.0/@typescript-eslint/eslint-plugin": "^8.0.0",
122+
"@sentry-internal/eslint-config-sdk@npm:10.43.0/@typescript-eslint/parser": "^8.0.0",
123+
"eslint-plugin-ft-flow": "^3.0.0",
124124
"axios": "^1.13.5",
125125
"fast-xml-parser": "^5.3.6",
126126
"form-data": "4.0.5",

packages/core/.eslintrc.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,27 @@ module.exports = {
2828
files: ['*.ts', '*.tsx'],
2929
extends: ['plugin:react/recommended'],
3030
plugins: ['react', 'react-native'],
31+
parserOptions: {
32+
project: './tsconfig.json',
33+
},
3134
rules: {
3235
'@typescript-eslint/typedef': ['error', { arrowParameter: false, variableDeclarationIgnoreFunction: true }],
36+
// @typescript-eslint/ban-types was removed in v8, replaced by more specific rules.
37+
// no-empty-object-type was 'off' under ban-types, keep it off.
38+
'@typescript-eslint/no-empty-object-type': 'off',
39+
// no-explicit-any was 'warn' in v5 recommended, keep it as 'warn' (v8 defaults to 'error')
40+
'@typescript-eslint/no-explicit-any': 'warn',
41+
// Allow require() in React Native code (dynamic requires are a common RN pattern)
42+
'@typescript-eslint/no-require-imports': 'off',
43+
// In @typescript-eslint v8, caughtErrors defaults to 'all' (was 'none' in v5).
44+
// The codebase commonly uses catch(e) {} without using the error variable.
45+
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_', caughtErrors: 'none' }],
3346
},
3447
},
3548
{
3649
// Test Files
3750
files: ['*.test.ts', '*.test.tsx', '*.test.js', '*.test.jsx'],
3851
rules: {
39-
'@typescript-eslint/no-var-requires': 'off',
4052
'@typescript-eslint/no-empty-function': 'off',
4153
'@typescript-eslint/no-explicit-any': 'off',
4254
'@typescript-eslint/unbound-method': 'off',
@@ -51,6 +63,8 @@ module.exports = {
5163
},
5264
rules: {
5365
'no-console': 'off',
66+
// In ESLint 9, no-unused-vars reports catch clause variables by default
67+
'no-unused-vars': ['error', { argsIgnorePattern: '^_', caughtErrors: 'none' }],
5468
},
5569
},
5670
{

packages/core/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@
3838
"test:watch": "npx jest --watch",
3939
"yalc:add:sentry-javascript": "yalc add @sentry/browser @sentry/core @sentry/react @sentry/types",
4040
"fix": "npx run-s fix:eslint fix:prettier",
41-
"fix:eslint": "eslint --config .eslintrc.js --fix .",
41+
"fix:eslint": "ESLINT_USE_FLAT_CONFIG=false eslint --config .eslintrc.js --fix .",
4242
"fix:prettier": "prettier --config ../../.prettierrc.json --ignore-path ../../.prettierignore --write \"{src,test,scripts,plugin/src}/**/**.ts\"",
4343
"lint": "npx run-s lint:eslint lint:prettier",
44-
"lint:eslint": "eslint --config .eslintrc.js .",
44+
"lint:eslint": "ESLINT_USE_FLAT_CONFIG=false eslint --config .eslintrc.js .",
4545
"lint:prettier": "prettier --config ../../.prettierrc.json --ignore-path ../../.prettierignore --check \"{src,test,scripts,plugin/src}/**/**.ts\""
4646
},
4747
"bin": {
@@ -95,13 +95,13 @@
9595
"@types/uglify-js": "^3.17.2",
9696
"@types/uuid": "^9.0.4",
9797
"@types/xmlhttprequest": "^1.8.2",
98-
"@typescript-eslint/eslint-plugin": "^5.48.0",
99-
"@typescript-eslint/parser": "^5.48.0",
98+
"@typescript-eslint/eslint-plugin": "^8.0.0",
99+
"@typescript-eslint/parser": "^8.0.0",
100100
"babel-jest": "^29.6.3",
101101
"babel-plugin-module-resolver": "^5.0.0",
102102
"babel-preset-fbjs": "^3.4.0",
103103
"downlevel-dts": "^0.11.0",
104-
"eslint": "^8.57.0",
104+
"eslint": "^9.0.0",
105105
"eslint-plugin-react": "^7.37.0",
106106
"eslint-plugin-react-native": "^3.8.1",
107107
"expo": "^53.0.0",

packages/core/plugin/src/withSentry.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ const withSentryPlugin: ConfigPlugin<PluginProps | void> = (config, props) => {
4343
warnOnce(`There was a problem with configuring your native Android project: ${e}`);
4444
}
4545
// if `enableAndroidGradlePlugin` is provided configure the Sentry Android Gradle Plugin
46-
if (props?.experimental_android && props?.experimental_android?.enableAndroidGradlePlugin) {
46+
if (props?.experimental_android?.enableAndroidGradlePlugin) {
4747
try {
4848
cfg = withSentryAndroidGradlePlugin(cfg, props.experimental_android);
4949
} catch (e) {

packages/core/src/js/integrations/debugsymbolicator.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ async function symbolicate(rawStack: string, skipFirstFrames: number = 0): Promi
8585
: newStack;
8686

8787
const stackWithoutInternalCallsites = stackWithoutPoppedFrames.filter(
88+
// eslint-disable-next-line @typescript-eslint/prefer-optional-chain -- keep falsy check for empty string file paths
8889
(frame: { file?: string }) => frame.file && frame.file.match(INTERNAL_CALLSITES_REGEX) === null,
8990
);
9091

packages/core/src/js/misc.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export function isHardCrash(payload: EnvelopeItemPayload): boolean {
1212
const values: Exception[] =
1313
typeof payload !== 'string' && 'exception' in payload && payload.exception?.values ? payload.exception.values : [];
1414
for (const exception of values) {
15-
if (exception.mechanism && exception.mechanism.handled === false && exception.mechanism.type === 'onerror') {
15+
if (exception.mechanism?.handled === false && exception.mechanism.type === 'onerror') {
1616
return true;
1717
}
1818
}

packages/core/src/js/tools/utils.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,7 @@ export function prependModule(
139139
module: Module<VirtualJSOutput>,
140140
): Module<MixedOutput>[] {
141141
const modifiedPreModules = [...modules];
142-
if (
143-
modifiedPreModules.length > 0 &&
144-
modifiedPreModules[0] !== undefined &&
145-
modifiedPreModules[0].path === PRELUDE_MODULE_PATH
146-
) {
142+
if (modifiedPreModules.length > 0 && modifiedPreModules[0]?.path === PRELUDE_MODULE_PATH) {
147143
// prelude module must be first as it measures the bundle startup time
148144
modifiedPreModules.unshift(modules[0] as Module<VirtualJSOutput>);
149145
modifiedPreModules[1] = module;

packages/core/src/js/tracing/integrations/nativeFrames.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,7 @@ export const nativeFramesIntegration = (): Integration => {
197197
if (
198198
event.type !== 'transaction' ||
199199
!event.transaction ||
200-
!event.contexts ||
201-
!event.contexts.trace ||
200+
!event.contexts?.trace ||
202201
!event.timestamp ||
203202
!event.contexts.trace.span_id
204203
) {

packages/core/src/js/tracing/integrations/timeToDisplayIntegration.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export const timeToDisplayIntegration = (): Integration => {
2323
enableTimeToInitialDisplayForPreloadedRoutes =
2424
getReactNavigationIntegration(client)?.options.enableTimeToInitialDisplayForPreloadedRoutes ?? false;
2525
},
26+
// eslint-disable-next-line complexity
2627
processEvent: async event => {
2728
if (event.type !== 'transaction') {
2829
// TimeToDisplay data is only relevant for transactions

packages/core/src/js/tracing/reactnativenavigation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ export const reactNativeNavigationIntegration = ({
158158
}
159159

160160
// We ignore actions that pertain to the same screen.
161-
const isSameComponent = prevComponentEvent && event.componentId === prevComponentEvent.componentId;
161+
const isSameComponent = event.componentId === prevComponentEvent?.componentId;
162162
if (isSameComponent) {
163163
discardLatestNavigationSpan();
164164
return;

0 commit comments

Comments
 (0)