File tree 2 files changed +9
-5
lines changed
packages/react-error-overlay/src
2 files changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ type Props = {|
27
27
class CompileErrorContainer extends PureComponent < Props , void > {
28
28
render ( ) {
29
29
const { error, openInEditor } = this . props ;
30
- const errLoc = parseCompileError ( error ) ;
30
+ const errLoc : ? ErrorLocation = parseCompileError ( error ) ;
31
31
return (
32
32
< ErrorOverlay >
33
33
< Header headerText = "Failed to compile" />
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ export type ErrorLocation = {|
6
6
lineNumber : number ,
7
7
| } ;
8
8
9
- const filePathRegex = / ^ \. ( \/ [ ^ \ /\n ] + ) + \. [ ^ \ /\n ] + $ / ;
9
+ const filePathRegex = / ^ \. ( \/ [ ^ / \n ] + ) + \. [ ^ / \n ] + $ / ;
10
10
11
11
const lineNumberRegexes = [
12
12
// Babel syntax errors
@@ -28,7 +28,9 @@ function parseCompileError(message: string): ?ErrorLocation {
28
28
29
29
for (let i = 0; i < lines . length ; i ++ ) {
30
30
const line : string = Anser . ansiToText ( lines [ i ] ) . trim ( ) ;
31
- if ( ! line ) continue ;
31
+ if ( ! line ) {
32
+ continue ;
33
+ }
32
34
33
35
if ( ! fileName && line . match ( filePathRegex ) ) {
34
36
fileName = line ;
@@ -38,13 +40,15 @@ function parseCompileError(message: string): ?ErrorLocation {
38
40
while ( k < lineNumberRegexes . length ) {
39
41
const match : ?Array < string > = line.match(lineNumberRegexes[k]);
40
42
if (match) {
41
- lineNumber = parseInt ( match [ 1 ] ) ;
43
+ lineNumber = parseInt ( match [ 1 ] , 10 ) ;
42
44
break ;
43
45
}
44
46
k++;
45
47
}
46
48
47
- if ( fileName && lineNumber ) break ;
49
+ if ( fileName && lineNumber ) {
50
+ break ;
51
+ }
48
52
}
49
53
50
54
return fileName && lineNumber ? { fileName , lineNumber } : null;
You can’t perform that action at this time.
0 commit comments