Skip to content

Commit 075c2bb

Browse files
committed
fix: fix lint error
1 parent 9cfef37 commit 075c2bb

File tree

3 files changed

+9
-14
lines changed

3 files changed

+9
-14
lines changed

packages/core/src/client/findSourceMap.ts

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const fetchContent = (url: string) => fetch(url).then((r) => r.text());
66
const findSourceMap = async (fileSource: string, filename: string) => {
77
try {
88
// Prefer to get it via filename + '.map'.
9-
const mapUrl = filename + '.map';
9+
const mapUrl = `${filename}.map`;
1010
return await fetchContent(mapUrl);
1111
} catch (e) {
1212
const mapUrl = fileSource.match(/\/\/# sourceMappingURL=(.*)$/)?.[1];
@@ -33,7 +33,7 @@ const escapeHTML = (str: string) =>
3333
const formatSourceCode = (sourceCode: string, pos: any) => {
3434
// Note that the line starts at 1, not 0.
3535
const { line: crtLine, column, name } = pos;
36-
let lines = sourceCode.split('\n');
36+
const lines = sourceCode.split('\n');
3737

3838
// Display up to 6 lines of source code
3939
const lineCount = Math.min(lines.length, 6);
@@ -51,12 +51,7 @@ const formatSourceCode = (sourceCode: string, pos: any) => {
5151

5252
// When the sourcemap information includes specific column details, add an error hint below the error line.
5353
if (line === crtLine && column > 0) {
54-
const errorLine =
55-
' '.repeat(prefix.length + column) +
56-
'<span style="color: #fc5e5e;">' +
57-
'^'.repeat(name?.length || 1) +
58-
'</span>';
59-
54+
const errorLine = `${' '.repeat(prefix.length + column)}<span style="color: #fc5e5e;">${'^'.repeat(name?.length || 1)}</span>`;
6055
result.push(errorLine);
6156
}
6257
}
@@ -78,8 +73,8 @@ export const findSourceCode = async (sourceInfo: any) => {
7873

7974
// Use sourcemap to find the source code location
8075
const pos = consumer.originalPositionFor({
81-
line: parseInt(line, 10),
82-
column: parseInt(column, 10),
76+
line: Number.parseInt(line, 10),
77+
column: Number.parseInt(column, 10),
8378
});
8479

8580
const url = `${pos.source}:${pos.line}:${pos.column}`;

packages/core/src/client/format.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { StatsCompilation, StatsError } from '@rspack/core';
2-
import { type OverlayError } from '../types';
2+
import type { OverlayError } from '../types';
33
import { findSourceCode } from './findSourceMap';
44

55
function resolveFileName(stats: StatsError) {
@@ -82,13 +82,13 @@ export async function formatRuntimeErrors(
8282
event: PromiseRejectionEvent | ErrorEvent,
8383
isRejection: boolean,
8484
): Promise<OverlayError | undefined> {
85-
let error = isRejectionEvent(isRejection, event)
85+
const error = isRejectionEvent(isRejection, event)
8686
? event.reason
8787
: event?.error;
8888

8989
if (!error) return;
9090
const errorName = isRejection
91-
? 'Unhandled Rejection (' + error.name + ')'
91+
? `Unhandled Rejection (${error.name})`
9292
: error.name;
9393

9494
const stack = parseRuntimeStack(error.stack);

packages/core/src/client/overlay.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { type OverlayError } from '../types';
1+
import type { OverlayError } from '../types';
22
import { formatRuntimeErrors } from './format';
33
import { registerOverlay } from './hmr';
44

0 commit comments

Comments
 (0)