@@ -92,6 +92,22 @@ export const Linter = ({ rows }: LinterProps) => {
92
92
const failingCheck = row . result . checks . find (
93
93
( check ) => check . passed === false ,
94
94
) ! ;
95
+ const metadata : React . ReactNode [ ] = [ ] ;
96
+ for ( const check of row . result . checks ) {
97
+ if (
98
+ check . type === 'fetch_attempt' &&
99
+ check . metadata . fetchStatusCode
100
+ ) {
101
+ metadata . push ( < > HTTP { check . metadata . fetchStatusCode } </ > ) ;
102
+ }
103
+ }
104
+ metadata . push (
105
+ < CodePreviewLineLink
106
+ line = { row . result . codeLocation . line }
107
+ column = { row . result . codeLocation . column }
108
+ type = "html"
109
+ /> ,
110
+ ) ;
95
111
return (
96
112
< Result status = { row . result . status } key = { i } >
97
113
< Result . Name > { sanitize ( failingCheck . type ) } </ Result . Name >
@@ -102,20 +118,14 @@ export const Linter = ({ rows }: LinterProps) => {
102
118
{ failingCheck . type === 'fetch_attempt' &&
103
119
failingCheck . metadata . fetchStatusCode &&
104
120
failingCheck . metadata . fetchStatusCode >= 300 &&
105
- failingCheck . metadata . fetchStatusCode < 400 ? (
106
- < >
107
- < strong > { failingCheck . metadata . fetchStatusCode } </ strong > :
108
- There was a redirect, the content may have been moved
109
- </ >
110
- ) : null }
121
+ failingCheck . metadata . fetchStatusCode < 400
122
+ ? 'There was a redirect, the content may have been moved'
123
+ : null }
111
124
{ failingCheck . type === 'fetch_attempt' &&
112
125
failingCheck . metadata . fetchStatusCode &&
113
- failingCheck . metadata . fetchStatusCode >= 400 ? (
114
- < >
115
- < strong > { failingCheck . metadata . fetchStatusCode } </ strong > :
116
- The link is broken
117
- </ >
118
- ) : null }
126
+ failingCheck . metadata . fetchStatusCode >= 400
127
+ ? 'The link is broken'
128
+ : null }
119
129
{ failingCheck . type === 'syntax'
120
130
? 'The link is broken due to invalid syntax'
121
131
: null }
@@ -124,15 +134,7 @@ export const Linter = ({ rows }: LinterProps) => {
124
134
{ row . result . link }
125
135
</ span >
126
136
</ Result . Description >
127
- < Result . Metadata >
128
- { [
129
- < CodePreviewLineLink
130
- line = { row . result . codeLocation . line }
131
- column = { row . result . codeLocation . column }
132
- type = "html"
133
- /> ,
134
- ] }
135
- </ Result . Metadata >
137
+ < Result . Metadata > { metadata } </ Result . Metadata >
136
138
</ Result >
137
139
) ;
138
140
}
@@ -146,6 +148,12 @@ export const Linter = ({ rows }: LinterProps) => {
146
148
if ( check . type === 'image_size' && check . metadata . byteCount ) {
147
149
metadata . push ( prettyBytes ( check . metadata . byteCount ) ) ;
148
150
}
151
+ if (
152
+ check . type === 'fetch_attempt' &&
153
+ check . metadata . fetchStatusCode
154
+ ) {
155
+ metadata . push ( < > HTTP { check . metadata . fetchStatusCode } </ > ) ;
156
+ }
149
157
}
150
158
metadata . push (
151
159
< CodePreviewLineLink
@@ -164,20 +172,14 @@ export const Linter = ({ rows }: LinterProps) => {
164
172
{ failingCheck . type === 'fetch_attempt' &&
165
173
failingCheck . metadata . fetchStatusCode &&
166
174
failingCheck . metadata . fetchStatusCode >= 300 &&
167
- failingCheck . metadata . fetchStatusCode < 400 ? (
168
- < >
169
- < strong > { failingCheck . metadata . fetchStatusCode } </ strong > :
170
- There was a redirect, the image may have been moved
171
- </ >
172
- ) : null }
175
+ failingCheck . metadata . fetchStatusCode < 400
176
+ ? 'There was a redirect, the image may have been moved'
177
+ : null }
173
178
{ failingCheck . type === 'fetch_attempt' &&
174
179
failingCheck . metadata . fetchStatusCode &&
175
- failingCheck . metadata . fetchStatusCode >= 400 ? (
176
- < >
177
- < strong > { failingCheck . metadata . fetchStatusCode } </ strong > :
178
- The image is broken
179
- </ >
180
- ) : null }
180
+ failingCheck . metadata . fetchStatusCode >= 400
181
+ ? 'The image is broken'
182
+ : null }
181
183
{ failingCheck . type === 'syntax'
182
184
? 'The image is broken due to an invalid source'
183
185
: null }
0 commit comments