Skip to content

Commit 7ae2bf7

Browse files
alexeyr-ci2alexeyr
andauthored
Upgrade typescript-eslint (#528)
Upgrade to the current version of `typescript-eslint`. Part 1 of #489. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Chores** - Updated developer dependencies and linting configurations to improve code quality. - **Refactor** - Streamlined asynchronous operations by eliminating redundant promise wrapping for clearer execution. - **Style** - Refined inline guidance and error-handling patterns for consistent development practices. - **Tests** - Adjusted test directives to align with updated standards. These internal improvements enhance maintainability and performance without altering visible features for end-users. <!-- end of auto-generated comment: release notes by coderabbit.ai --> Co-authored-by: Alexey Romanov <[email protected]>
1 parent 97048f0 commit 7ae2bf7

File tree

10 files changed

+99
-90
lines changed

10 files changed

+99
-90
lines changed

.eslintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ overrides:
6868
"@typescript-eslint/restrict-template-expressions": off
6969
"@typescript-eslint/no-unused-vars":
7070
- error
71-
- { argsIgnorePattern: "^_" }
71+
- { argsIgnorePattern: "^_", caughtErrorsIgnorePattern: "^_" }
7272
"@typescript-eslint/no-floating-promises":
7373
- error
7474
- allowForKnownSafePromises:

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
"sentry-testkit": "^5.0.6",
8686
"touch": "^3.1.0",
8787
"typescript": "^5.4.3",
88-
"typescript-eslint": "^7.4.0",
88+
"typescript-eslint": "^8.29.1",
8989
"yalc": "^1.0.0-pre.53"
9090
},
9191
"peerDependencies": {

packages/node-renderer/src/ReactOnRailsProNodeRenderer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ and for "@fastify/..." dependencies in your package.json. Consider removing them
2626
);
2727
}
2828

29-
/* eslint-disable global-require,@typescript-eslint/no-var-requires --
29+
/* eslint-disable global-require,@typescript-eslint/no-require-imports --
3030
* Using normal `import` fails before the check above.
3131
*/
3232
if (cluster.isPrimary) {
3333
(require('./master') as typeof import('./master'))(config);
3434
} else {
3535
await (require('./worker') as typeof import('./worker')).default(config).ready();
3636
}
37-
/* eslint-enable global-require,@typescript-eslint/no-var-requires */
37+
/* eslint-enable global-require,@typescript-eslint/no-require-imports */
3838
}

packages/node-renderer/src/integrations/sentry6.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable @typescript-eslint/no-deprecated */
12
import { captureException, captureMessage, startTransaction } from '@sentry/node';
23
import { CaptureContext, TransactionContext } from '@sentry/types';
34
import { addErrorNotifier, addMessageNotifier, message, setupTracing } from './api';
@@ -23,9 +24,9 @@ export function init({ tracing = false } = {}) {
2324

2425
if (tracing) {
2526
try {
26-
// eslint-disable-next-line global-require,import/no-unresolved -- Intentionally absent in our devDependencies
27+
// eslint-disable-next-line global-require,import/no-unresolved,@typescript-eslint/no-require-imports -- Intentionally absent in our devDependencies
2728
require('@sentry/tracing');
28-
} catch (e) {
29+
} catch (_e) {
2930
message("Failed to load '@sentry/tracing'. Tracing is disabled.");
3031
return;
3132
}

packages/node-renderer/src/shared/log.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ let pretty = false;
55

66
if (process.env.NODE_ENV === 'development' || process.env.NODE_ENV === 'test') {
77
try {
8-
// eslint-disable-next-line global-require
8+
// eslint-disable-next-line global-require,@typescript-eslint/no-require-imports
99
require('pino-pretty');
1010
pretty = true;
11-
} catch (e) {
11+
} catch (_e) {
1212
console.log('pino-pretty not found in development, using the default pino log settings');
1313
}
1414
}

packages/node-renderer/src/shared/tracing.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { message } from './errorReporter';
22

3+
/* eslint-disable @typescript-eslint/no-empty-object-type -- empty interfaces are used as targets for augmentation */
34
/**
45
* This contains the options necessary to start a unit of work (transaction/span/etc.).
56
* Integrations should augment it using their name as the property.
@@ -21,6 +22,7 @@ export interface UnitOfWorkOptions {}
2122
* {@link import('@sentry/types').CaptureContext} parameter, and so it adds `{ sentry6: CaptureContext }`.
2223
*/
2324
export interface TracingContext {}
25+
/* eslint-enable @typescript-eslint/no-empty-object-type */
2426

2527
let setupRun = false;
2628

packages/node-renderer/src/worker/handleRenderRequest.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -42,29 +42,29 @@ async function prepareResult(
4242
}
4343

4444
if (exceptionMessage) {
45-
return Promise.resolve(errorResponseResult(exceptionMessage));
45+
return errorResponseResult(exceptionMessage);
4646
}
4747

4848
if (isReadableStream(result)) {
4949
const newStreamAfterHandlingError = handleStreamError(result, (error) => {
5050
const msg = formatExceptionMessage(renderingRequest, error, 'Error in a rendering stream');
5151
errorReporter.message(msg);
5252
});
53-
return Promise.resolve({
53+
return {
5454
headers: { 'Cache-Control': 'public, max-age=31536000' },
5555
status: 200,
5656
stream: newStreamAfterHandlingError,
57-
});
57+
};
5858
}
5959

60-
return Promise.resolve({
60+
return {
6161
headers: { 'Cache-Control': 'public, max-age=31536000' },
6262
status: 200,
6363
data: result,
64-
});
64+
};
6565
} catch (err) {
6666
const exceptionMessage = formatExceptionMessage(renderingRequest, err, 'Unknown error calling runInVM');
67-
return Promise.resolve(errorResponseResult(exceptionMessage));
67+
return errorResponseResult(exceptionMessage);
6868
}
6969
}
7070

@@ -100,7 +100,7 @@ async function handleNewBundleProvided(
100100
errorMessage,
101101
`Failed to acquire lock ${lockfileName}. Worker: ${workerIdLabel()}.`,
102102
);
103-
return Promise.resolve(errorResponseResult(msg));
103+
return errorResponseResult(msg);
104104
}
105105

106106
try {
@@ -123,7 +123,7 @@ async function handleNewBundleProvided(
123123
to ${bundleFilePathPerTimestamp})`,
124124
);
125125
log.error(msg);
126-
return Promise.resolve(errorResponseResult(msg));
126+
return errorResponseResult(msg);
127127
}
128128
log.info(
129129
'File exists when trying to overwrite bundle %s. Assuming bundle written by other thread',
@@ -136,14 +136,14 @@ to ${bundleFilePathPerTimestamp})`,
136136
// file must be fully written
137137
log.info('buildVM, bundleFilePathPerTimestamp', bundleFilePathPerTimestamp);
138138
await buildVM(bundleFilePathPerTimestamp);
139-
return prepareResult(renderingRequest, bundleFilePathPerTimestamp);
139+
return await prepareResult(renderingRequest, bundleFilePathPerTimestamp);
140140
} catch (error) {
141141
const msg = formatExceptionMessage(
142142
renderingRequest,
143143
error,
144144
`Unexpected error when building the VM ${bundleFilePathPerTimestamp}`,
145145
);
146-
return Promise.resolve(errorResponseResult(msg));
146+
return errorResponseResult(msg);
147147
}
148148
} finally {
149149
if (lockAcquired) {
@@ -185,12 +185,12 @@ export = async function handleRenderRequest({
185185

186186
// If the current VM has the correct bundle and is ready
187187
if (hasVMContextForBundle(bundleFilePathPerTimestamp)) {
188-
return prepareResult(renderingRequest, bundleFilePathPerTimestamp);
188+
return await prepareResult(renderingRequest, bundleFilePathPerTimestamp);
189189
}
190190

191191
// If gem has posted updated bundle:
192192
if (providedNewBundle) {
193-
return handleNewBundleProvided(
193+
return await handleNewBundleProvided(
194194
bundleFilePathPerTimestamp,
195195
providedNewBundle,
196196
renderingRequest,
@@ -202,19 +202,19 @@ export = async function handleRenderRequest({
202202
const fileExists = await fileExistsAsync(bundleFilePathPerTimestamp);
203203
if (!fileExists) {
204204
log.info(`No saved bundle ${bundleFilePathPerTimestamp}. Requesting a new bundle.`);
205-
return Promise.resolve({
205+
return {
206206
headers: { 'Cache-Control': 'no-cache, no-store, max-age=0, must-revalidate' },
207207
status: 410,
208208
data: 'No bundle uploaded',
209-
});
209+
};
210210
}
211211

212212
// The bundle exists, but the VM has not yet been created.
213213
// Another worker must have written it or it was saved during deployment.
214214
log.info('Bundle %s exists. Building VM for worker %s.', bundleFilePathPerTimestamp, workerIdLabel());
215215
await buildVM(bundleFilePathPerTimestamp);
216216

217-
return prepareResult(renderingRequest, bundleFilePathPerTimestamp);
217+
return await prepareResult(renderingRequest, bundleFilePathPerTimestamp);
218218
} catch (error) {
219219
const msg = formatExceptionMessage(
220220
renderingRequest,

packages/node-renderer/src/worker/vm.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ ${smartTrim(result)}`);
319319
await writeFileAsync(debugOutputPathResult, result);
320320
}
321321

322-
return Promise.resolve(result);
322+
return result;
323323
} catch (exception) {
324324
const exceptionMessage = formatExceptionMessage(renderingRequest, exception);
325325
log.debug('Caught exception in rendering request', exceptionMessage);

packages/node-renderer/tests/shared/tracing.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ test('should run function and finish span', async () => {
3434
await fn();
3535
}, testTransactionContext);
3636
expect(savedSpan).toBeDefined();
37+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- the suggested replacement doesn't work
3738
expect(savedSpan?.name).toBe(spanName);
3839
expect(Sentry.getActiveSpan()).not.toBe(savedSpan);
3940
expect(fn.mock.calls).toHaveLength(1);

0 commit comments

Comments
 (0)