Commit e245b77
authored
[be] Add deadlinks script (#7879)
While rewriting the compiler docs I happened to notice some deadlinks. This PR adds a new `yarn deadlinks` script to identify all deadlinks.
I decided to make this a script for now for simplicity but in the future could be ported to an ESlint rule.
The script handles:
- [x] checks images correctly (images are stored in /public but links can omit the /public)
- [x] looks up React error codes for dynamic error pages
- [x] lints links to contributors and uses URL from acknowledgements page if the member is no longer active on the core team
- [x] special injected anchor tags like #recap and #challenges
Example:
```
yarn run v1.22.22
$ node scripts/deadLinkChecker.js
Checking 177 markdown files...
Fetched 552 React error codes
src/content/learn/add-react-to-an-existing-project.md:23:58
Link text: React-based frameworks
URL: /learn/start-a-new-react-project
✗ Target file not found for: /learn/start-a-new-react-project
src/content/learn/add-react-to-an-existing-project.md:27:45
Link text: benefit from the best practices
URL: /learn/start-a-new-react-project#can-i-use-react-without-a-framework
✗ Target file not found for: /learn/start-a-new-react-project
src/content/learn/add-react-to-an-existing-project.md:152:269
Link text: a React framework
URL: /learn/start-a-new-react-project
✗ Target file not found for: /learn/start-a-new-react-project
src/content/learn/synchronizing-with-effects.md:735:18
Link text: framework
URL: /learn/start-a-new-react-project#production-grade-react-frameworks
✗ Target file not found for: /learn/start-a-new-react-project
src/content/learn/typescript.md:16:3
Link text: Common types from `@types/react`
URL: /learn/typescript/#useful-types
✗ Target file not found for: /learn/typescript/
src/content/learn/typescript.md:17:3
Link text: Further learning locations
URL: /learn/typescript/#further-learning
✗ Target file not found for: /learn/typescript/
src/content/learn/typescript.md:23:5
Link text: production-grade React frameworks
URL: /learn/start-a-new-react-project#production-grade-react-frameworks
✗ Target file not found for: /learn/start-a-new-react-project
src/content/learn/you-might-not-need-an-effect.md:29:399
Link text: frameworks
URL: /learn/start-a-new-react-project#production-grade-react-frameworks
✗ Target file not found for: /learn/start-a-new-react-project
src/content/learn/you-might-not-need-an-effect.md:754:106
Link text: frameworks
URL: /learn/start-a-new-react-project#production-grade-react-frameworks
✗ Target file not found for: /learn/start-a-new-react-project
src/content/learn/your-first-component.md:218:1
Link text: React-based frameworks
URL: /learn/start-a-new-react-project
✗ Target file not found for: /learn/start-a-new-react-project
src/content/reference/react/ViewTransition.md:146:248
Link text: reveal content
URL: /link-to-suspense-below
✗ Target file not found for: /link-to-suspense-below
src/content/reference/react/captureOwnerStack.md:60:94
Link text: `errorInfo.componentStack` in `onUncaughtError`
URL: /reference/react-dom/client/hydrateRoot#show-a-dialog-for-uncaught-errors
✗ Anchor #show-a-dialog-for-uncaught-errors not found in reference/react-dom/client/hydrateRoot.md
src/content/reference/react/forwardRef.md:9:65
Link text: here
URL: /blog/2024/04/25/react-19#ref-as-a-prop
✗ Target file not found for: /blog/2024/04/25/react-19
src/content/reference/react/use.md:315:24
Link text: Server Component
URL: /reference/react/components#server-components
✗ Anchor #server-components not found in reference/react/components.md
src/content/reference/react/useEffect.md:899:67
Link text: if you use a framework,
URL: /learn/start-a-new-react-project#production-grade-react-frameworks
✗ Target file not found for: /learn/start-a-new-react-project
src/content/reference/react/useEffect.md:1051:18
Link text: framework
URL: /learn/start-a-new-react-project#production-grade-react-frameworks
✗ Target file not found for: /learn/start-a-new-react-project
src/content/reference/react/useEffect.md:1736:92
Link text: framework
URL: /learn/start-a-new-react-project#production-grade-react-frameworks
✗ Target file not found for: /learn/start-a-new-react-project
src/content/reference/react/useInsertionEffect.md:136:65
Link text: non-blocking update,
URL: /reference/react/useTransition#marking-a-state-update-as-a-non-blocking-transition
✗ Anchor #marking-a-state-update-as-a-non-blocking-transition not found in reference/react/useTransition.md
src/content/reference/react-dom/createPortal.md:53:76
Link text: key.
URL: /learn/rendering-lists/#keeping-list-items-in-order-with-key
✗ Target file not found for: /learn/rendering-lists/
src/content/reference/react-dom/index.md:24:1
Link text: React-based frameworks
URL: /learn/start-a-new-react-project
✗ Target file not found for: /learn/start-a-new-react-project
src/content/reference/react-dom/index.md:51:3
Link text: `unmountComponentAtNode`
URL: /reference/react-dom/unmountComponentAtNode
✗ Target file not found for: /reference/react-dom/unmountComponentAtNode
src/content/reference/react-dom/preinit.md:7:1
Link text: React-based frameworks
URL: /learn/start-a-new-react-project
✗ Target file not found for: /learn/start-a-new-react-project
src/content/reference/react-dom/preinitModule.md:7:1
Link text: React-based frameworks
URL: /learn/start-a-new-react-project
✗ Target file not found for: /learn/start-a-new-react-project
src/content/reference/react-dom/preload.md:7:1
Link text: React-based frameworks
URL: /learn/start-a-new-react-project
✗ Target file not found for: /learn/start-a-new-react-project
src/content/reference/react-dom/preloadModule.md:7:1
Link text: React-based frameworks
URL: /learn/start-a-new-react-project
✗ Target file not found for: /learn/start-a-new-react-project
src/content/reference/rsc/directives.md:13:36
Link text: bundlers compatible with React Server Components
URL: /learn/start-a-new-react-project#full-stack-frameworks
✗ Target file not found for: /learn/start-a-new-react-project
src/content/reference/rsc/server-components.md:7:34
Link text: React Server Components
URL: /learn/start-a-new-react-project#full-stack-frameworks
✗ Target file not found for: /learn/start-a-new-react-project
src/content/reference/rsc/server-functions.md:198:28
Link text: `useActionState`
URL: /reference/react-dom/hooks/useFormState
✗ Target file not found for: /reference/react-dom/hooks/useFormState
src/content/reference/rsc/server-functions.md:222:28
Link text: `useActionState`
URL: /reference/react-dom/hooks/useFormState
✗ Target file not found for: /reference/react-dom/hooks/useFormState
src/content/reference/rsc/use-client.md:44:77
Link text: compatible bundlers
URL: /learn/start-a-new-react-project#full-stack-frameworks
✗ Target file not found for: /learn/start-a-new-react-project
src/content/reference/rsc/use-server.md:98:54
Link text: serializable props
URL: /reference/rsc/use-client#passing-props-from-server-to-client-components
✗ Anchor #passing-props-from-server-to-client-components not found in reference/rsc/use-client.md
src/content/reference/react-dom/client/createRoot.md:212:278
Link text: using a framework
URL: /learn/start-a-new-react-project#production-grade-react-frameworks
✗ Target file not found for: /learn/start-a-new-react-project
src/content/reference/react-dom/client/index.md:7:185
Link text: framework
URL: /learn/start-a-new-react-project#production-grade-react-frameworks
✗ Target file not found for: /learn/start-a-new-react-project
src/content/reference/react-dom/components/common.md:919:89
Link text: check out more examples.
URL: /reference/react/useRef#examples-dom
✗ Anchor #examples-dom not found in reference/react/useRef.md
src/content/reference/react-dom/components/form.md:39:23
Link text: common element props.
URL: /reference/react-dom/components/common#props
✗ Anchor #props not found in reference/react-dom/components/common.md
src/content/reference/react-dom/components/form.md:233:63
Link text: reference documentation
URL: /reference/react/hooks/useOptimistic
✗ Target file not found for: /reference/react/hooks/useOptimistic
src/content/reference/react-dom/components/input.md:33:24
Link text: common element props.
URL: /reference/react-dom/components/common#props
✗ Anchor #props not found in reference/react-dom/components/common.md
src/content/reference/react-dom/components/link.md:33:23
Link text: common element props.
URL: /reference/react-dom/components/common#props
✗ Anchor #props not found in reference/react-dom/components/common.md
src/content/reference/react-dom/components/meta.md:33:23
Link text: common element props.
URL: /reference/react-dom/components/common#props
✗ Anchor #props not found in reference/react-dom/components/common.md
src/content/reference/react-dom/components/option.md:39:25
Link text: common element props.
URL: /reference/react-dom/components/common#props
✗ Anchor #props not found in reference/react-dom/components/common.md
src/content/reference/react-dom/components/progress.md:33:27
Link text: common element props.
URL: /reference/react-dom/components/common#props
✗ Anchor #props not found in reference/react-dom/components/common.md
src/content/reference/react-dom/components/script.md:34:25
Link text: common element props.
URL: /reference/react-dom/components/common#props
✗ Anchor #props not found in reference/react-dom/components/common.md
src/content/reference/react-dom/components/select.md:39:25
Link text: common element props.
URL: /reference/react-dom/components/common#props
✗ Anchor #props not found in reference/react-dom/components/common.md
src/content/reference/react-dom/components/style.md:33:24
Link text: common element props.
URL: /reference/react-dom/components/common#props
✗ Anchor #props not found in reference/react-dom/components/common.md
src/content/reference/react-dom/components/textarea.md:33:27
Link text: common element props.
URL: /reference/react-dom/components/common#props
✗ Anchor #props not found in reference/react-dom/components/common.md
src/content/reference/react-dom/components/title.md:33:24
Link text: common element props.
URL: /reference/react-dom/components/common#props
✗ Anchor #props not found in reference/react-dom/components/common.md
src/content/reference/react-dom/server/index.md:7:182
Link text: framework
URL: /learn/start-a-new-react-project#production-grade-react-frameworks
✗ Target file not found for: /learn/start-a-new-react-project
src/content/reference/react-dom/static/index.md:7:146
Link text: framework
URL: /learn/start-a-new-react-project#production-grade-react-frameworks
✗ Target file not found for: /learn/start-a-new-react-project
src/content/blog/2023/03/16/introducing-react-dev.md:45:5
Link text: API Reference
URL: /reference
✗ Target file not found for: /reference
src/content/blog/2023/03/16/introducing-react-dev.md:610:117
Link text: Alternatives
URL: /reference/react-dom/findDOMNode#alternatives
✗ Target file not found for: /reference/react-dom/findDOMNode
src/content/blog/2023/03/22/react-labs-what-we-have-been-working-on-march-2023.md:34:40
Link text: Next.js App Router
URL: /learn/start-a-new-react-project#nextjs-app-router
✗ Target file not found for: /learn/start-a-new-react-project
src/content/blog/2023/03/22/react-labs-what-we-have-been-working-on-march-2023.md:95:605
Link text: Next.js App Router
URL: /learn/start-a-new-react-project#nextjs-app-router
✗ Target file not found for: /learn/start-a-new-react-project
src/content/blog/2024/02/15/react-labs-what-we-have-been-working-on-february-2024.md:110:3
Link text: Sathya Gunasekaran
URL: /community/team#sathya-gunasekaran
✗ Contributor link should be updated to: https://github.com/gsathya
src/content/blog/2024/04/25/react-19-upgrade-guide.md:132:20
Link text: improved how errors are handled
URL: /blog/2024/04/25/react-19#error-handling
✗ Target file not found for: /blog/2024/04/25/react-19
src/content/blog/2024/04/25/react-19-upgrade-guide.md:502:19
Link text: `ref` as a prop
URL: /blog/2024/04/25/react-19#ref-as-a-prop
✗ Target file not found for: /blog/2024/04/25/react-19
src/content/blog/2024/12/05/react-19.md:358:391
Link text: Full-stack React Architecture
URL: /learn/start-a-new-react-project#which-features-make-up-the-react-teams-full-stack-architecture-vision
✗ Target file not found for: /learn/start-a-new-react-project
src/content/blog/2024/12/05/react-19.md:392:28
Link text: React Server Actions
URL: /reference/rsc/server-actions
✗ Target file not found for: /reference/rsc/server-actions
src/content/blog/2025/04/23/react-labs-view-transitions-activity-and-more.md:2498:37
Link text: view transition classes
URL: /reference/react/ViewTransition#view-transition-classes
✗ Anchor #view-transition-classes not found in reference/react/ViewTransition.md
Found 58 dead links out of 1555 total links
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
```1 parent 84a5696 commit e245b77
3 files changed
+354
-10
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
| 18 | + | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
| 23 | + | |
| 24 | + | |
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
| |||
61 | 62 | | |
62 | 63 | | |
63 | 64 | | |
| 65 | + | |
64 | 66 | | |
65 | 67 | | |
66 | 68 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2443 | 2443 | | |
2444 | 2444 | | |
2445 | 2445 | | |
| 2446 | + | |
| 2447 | + | |
| 2448 | + | |
| 2449 | + | |
| 2450 | + | |
| 2451 | + | |
| 2452 | + | |
| 2453 | + | |
2446 | 2454 | | |
2447 | 2455 | | |
2448 | 2456 | | |
| |||
2452 | 2460 | | |
2453 | 2461 | | |
2454 | 2462 | | |
2455 | | - | |
2456 | | - | |
2457 | | - | |
2458 | | - | |
2459 | | - | |
2460 | | - | |
2461 | | - | |
2462 | | - | |
2463 | 2463 | | |
2464 | 2464 | | |
2465 | 2465 | | |
| |||
0 commit comments