Skip to content

Commit a64aa8d

Browse files
committed
remove errors tab
1 parent 350f958 commit a64aa8d

File tree

9 files changed

+4
-463
lines changed

9 files changed

+4
-463
lines changed

packages/react-router-devtools/src/client/context/rdtReducer.ts

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,6 @@ export type ServerInfo = {
4747
}
4848
}
4949

50-
type HTMLErrorPrimitive = {
51-
file?: string
52-
tag: string
53-
}
54-
55-
export type HTMLError = {
56-
child: HTMLErrorPrimitive
57-
parent: HTMLErrorPrimitive
58-
}
59-
6050
export type ReactRouterDevtoolsState = {
6151
timeline: TimelineEvent[]
6252
settings: {
@@ -88,7 +78,6 @@ export type ReactRouterDevtoolsState = {
8878
*/
8979
showRouteBoundariesOn: "hover" | "click"
9080
}
91-
htmlErrors: HTMLError[]
9281
server?: ServerInfo
9382
persistOpen: boolean
9483
}
@@ -108,7 +97,6 @@ export const initialState: ReactRouterDevtoolsState = {
10897
routeViewMode: "tree",
10998
withServerDevTools: true,
11099
},
111-
htmlErrors: [],
112100
persistOpen: false,
113101
}
114102

@@ -149,11 +137,6 @@ type SetServerInfo = {
149137
payload: ServerInfo
150138
}
151139

152-
type SetHtmlErrors = {
153-
type: "SET_HTML_ERRORS"
154-
payload: HTMLError[]
155-
}
156-
157140
/** Aggregate of all action types */
158141
export type ReactRouterDevtoolsActions =
159142
| SetTimelineEvent
@@ -162,19 +145,13 @@ export type ReactRouterDevtoolsActions =
162145
| SetWholeState
163146
| SetIsSubmittedAction
164147
| SetServerInfo
165-
| SetHtmlErrors
166148
| SetPersistOpenAction
167149

168150
export const rdtReducer = (
169151
state: ReactRouterDevtoolsState,
170152
{ type, payload }: ReactRouterDevtoolsActions
171153
): ReactRouterDevtoolsState => {
172154
switch (type) {
173-
case "SET_HTML_ERRORS":
174-
return {
175-
...state,
176-
htmlErrors: [...payload],
177-
}
178155
case "SET_SERVER_INFO":
179156
return {
180157
...state,

packages/react-router-devtools/src/client/context/useRDTContext.ts

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,6 @@ const useRDTContext = () => {
2424
}
2525
}
2626

27-
export const useHtmlErrors = () => {
28-
const { state, dispatch } = useRDTContext()
29-
const { htmlErrors } = state
30-
const setHtmlErrors = useCallback(
31-
(htmlErrors: ReactRouterDevtoolsState["htmlErrors"]) => {
32-
dispatch({
33-
type: "SET_HTML_ERRORS",
34-
payload: htmlErrors,
35-
})
36-
},
37-
[dispatch]
38-
)
39-
return { htmlErrors, setHtmlErrors }
40-
}
41-
4227
export const useServerInfo = () => {
4328
const { state, dispatch } = useRDTContext()
4429
const { server } = state

packages/react-router-devtools/src/client/hooks/useOpenElementSource.ts

Lines changed: 0 additions & 38 deletions
This file was deleted.
Lines changed: 2 additions & 140 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,10 @@
11
import { type Fiber, onCommitFiberRoot, traverseFiber } from "bippy"
2-
import { useCallback, useEffect, useRef } from "react"
2+
import { useCallback, useEffect } from "react"
33
import { useNavigation } from "react-router"
4-
import type { HTMLError } from "../context/rdtReducer.js"
5-
import { useHtmlErrors } from "../context/useRDTContext.js"
64

75
export const ROUTE_CLASS = "outlet-route"
86

97
export function useReactTreeListeners() {
10-
const invalidHtmlCollection = useRef<HTMLError[]>([])
11-
const { setHtmlErrors } = useHtmlErrors()
12-
const addToInvalidCollection = (entry: HTMLError) => {
13-
if (invalidHtmlCollection.current.find((item) => JSON.stringify(item) === JSON.stringify(entry))) return
14-
invalidHtmlCollection.current.push(entry)
15-
}
16-
178
const navigation = useNavigation()
189

1910
// biome-ignore lint/suspicious/noExplicitAny: we don't know the type
@@ -26,144 +17,15 @@ export function useReactTreeListeners() {
2617
styleNearestElement(fiberNode?.child)
2718
}, [])
2819

29-
// biome-ignore lint/correctness/useExhaustiveDependencies: we want this to run only once
30-
const findIncorrectHtml = useCallback(
31-
// biome-ignore lint/suspicious/noExplicitAny: we don't know the type
32-
(fiberNode: Fiber<any> | null, originalFiberNode: Fiber<any> | null, originalTag: string) => {
33-
if (!fiberNode) return
34-
35-
const tag = fiberNode.elementType
36-
const addInvalid = () => {
37-
const parentSource = originalFiberNode?._debugOwner?._debugSource ?? originalFiberNode?._debugSource
38-
const source = fiberNode?._debugOwner?._debugSource ?? fiberNode?._debugSource
39-
addToInvalidCollection({
40-
child: {
41-
file: parentSource?.fileName,
42-
tag: tag,
43-
},
44-
parent: {
45-
file: source?.fileName,
46-
tag: originalTag,
47-
},
48-
})
49-
}
50-
51-
if (originalTag === "a") {
52-
const element = fiberNode.stateNode as HTMLElement
53-
switch (tag) {
54-
case "a":
55-
case "button":
56-
case "details":
57-
case "embed":
58-
case "iframe":
59-
case "label":
60-
case "select":
61-
case "textarea": {
62-
addInvalid()
63-
break
64-
}
65-
case "audio": {
66-
if (element.getAttribute("controls") !== null) {
67-
addInvalid()
68-
}
69-
break
70-
}
71-
case "img": {
72-
if (element.getAttribute("usemap") !== null) {
73-
addInvalid()
74-
}
75-
break
76-
}
77-
case "input": {
78-
if (element.getAttribute("type") !== "hidden") {
79-
addInvalid()
80-
}
81-
break
82-
}
83-
case "object": {
84-
if (element.getAttribute("usemap") !== null) {
85-
addInvalid()
86-
}
87-
break
88-
}
89-
case "video": {
90-
if (element.getAttribute("controls") !== null) {
91-
addInvalid()
92-
}
93-
break
94-
}
95-
default: {
96-
break
97-
}
98-
}
99-
}
100-
if (originalTag === "p") {
101-
switch (tag) {
102-
case "div":
103-
case "h1":
104-
case "h2":
105-
case "h3":
106-
case "h4":
107-
case "h5":
108-
case "h6":
109-
case "main":
110-
case "pre":
111-
case "p":
112-
case "section":
113-
case "table":
114-
case "ul":
115-
case "ol":
116-
case "li": {
117-
addInvalid()
118-
break
119-
}
120-
default: {
121-
break
122-
}
123-
}
124-
}
125-
if (originalTag === "form") {
126-
if (tag === "form") {
127-
addInvalid()
128-
}
129-
}
130-
if (["h1", "h2", "h3", "h4", "h5", "h6"].includes(originalTag)) {
131-
if (tag === "h1" || tag === "h2" || tag === "h3" || tag === "h4" || tag === "h5" || tag === "h6") {
132-
addInvalid()
133-
}
134-
}
135-
findIncorrectHtml(fiberNode?.child, originalFiberNode, originalTag)
136-
if (fiberNode?.sibling) {
137-
findIncorrectHtml(fiberNode?.sibling, originalFiberNode, originalTag)
138-
}
139-
},
140-
[]
141-
)
142-
14320
useEffect(() => {
14421
if (navigation.state !== "idle") return
14522

14623
onCommitFiberRoot((root) =>
14724
traverseFiber(root.current, (fiberNode) => {
148-
if (fiberNode?.stateNode && fiberNode?.elementType === "form") {
149-
findIncorrectHtml(fiberNode.child, fiberNode, "form")
150-
}
151-
if (fiberNode?.stateNode && fiberNode?.elementType === "a") {
152-
findIncorrectHtml(fiberNode.child, fiberNode, "a")
153-
}
154-
if (fiberNode?.stateNode && fiberNode?.elementType === "p") {
155-
findIncorrectHtml(fiberNode.child, fiberNode, "p")
156-
}
157-
if (fiberNode?.stateNode && ["h1", "h2", "h3", "h4", "h5", "h6"].includes(fiberNode?.elementType)) {
158-
findIncorrectHtml(fiberNode.child, fiberNode, fiberNode?.elementType)
159-
}
16025
if (fiberNode?.elementType?.name === "default" || fiberNode?.elementType?.name === "RenderedRoute") {
16126
styleNearestElement(fiberNode)
16227
}
16328
})
16429
)
165-
166-
setHtmlErrors(invalidHtmlCollection.current)
167-
invalidHtmlCollection.current = []
168-
}, [navigation.state, styleNearestElement, findIncorrectHtml, setHtmlErrors])
30+
}, [navigation.state, styleNearestElement])
16931
}

packages/react-router-devtools/src/client/layout/Tabs.tsx

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useHtmlErrors, useSettingsContext } from "../context/useRDTContext.js"
1+
import { useSettingsContext } from "../context/useRDTContext.js"
22
import { useHorizontalScroll } from "../hooks/useHorizontalScroll.js"
33
import { useTabs } from "../hooks/useTabs.js"
44
import { cx } from "../styles/use-styles.js"
@@ -50,28 +50,16 @@ const Tab = ({
5050

5151
const Tabs = ({ plugins }: TabsProps) => {
5252
const { settings } = useSettingsContext()
53-
const { htmlErrors } = useHtmlErrors()
5453
const { styles } = useStyles()
5554
const { activeTab } = settings
5655
const { visibleTabs } = useTabs(plugins)
5756
const scrollRef = useHorizontalScroll()
5857

59-
const hasErrors = htmlErrors.length > 0
6058
return (
6159
<div className={styles.layout.tabs.container}>
6260
<div ref={scrollRef} className={cx("react-router-dev-tools-tab", styles.layout.tabs.scrollContainer)}>
6361
{visibleTabs.map((tab) => (
64-
<Tab
65-
key={tab.id}
66-
tab={{
67-
...tab,
68-
name: tab.id === "errors" && hasErrors ? `Errors (${htmlErrors.length})` : tab.name,
69-
}}
70-
activeTab={activeTab}
71-
className={cx(
72-
tab.id === "errors" && activeTab !== "errors" && hasErrors && styles.layout.tabs.tabErrorPulse
73-
)}
74-
/>
62+
<Tab key={tab.id} tab={tab} activeTab={activeTab} />
7563
))}
7664
</div>
7765
</div>

packages/react-router-devtools/src/client/styles/use-styles.ts

Lines changed: 0 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1091,67 +1091,6 @@ const stylesFactory = (theme: "light" | "dark") => {
10911091
`,
10921092
},
10931093

1094-
// Errors Tab
1095-
errorsTab: {
1096-
container: css`
1097-
display: flex;
1098-
flex-direction: column;
1099-
gap: 0.25rem;
1100-
`,
1101-
headerContainer: css`
1102-
margin-bottom: 0.25rem;
1103-
`,
1104-
headerTitle: css`
1105-
font-size: 1.125rem;
1106-
font-weight: 600;
1107-
`,
1108-
divider: css`
1109-
margin-top: 0.5rem;
1110-
border-color: #9ca3af;
1111-
`,
1112-
noErrors: css`
1113-
font-size: 1.5rem;
1114-
`,
1115-
errorCard: css`
1116-
display: flex;
1117-
justify-content: flex-start;
1118-
gap: 0.5rem;
1119-
border-radius: 0.5rem;
1120-
border: 1px solid rgba(220, 38, 38, 0.2);
1121-
padding: 0.5rem;
1122-
`,
1123-
errorIcon: css`
1124-
color: #dc2626;
1125-
`,
1126-
errorContent: css`
1127-
display: flex;
1128-
flex-direction: column;
1129-
gap: 0.5rem;
1130-
@media (min-width: 1024px) {
1131-
gap: 0;
1132-
}
1133-
`,
1134-
errorMessage: css`
1135-
color: #dc2626;
1136-
font-weight: 700;
1137-
`,
1138-
errorFileInfo: css`
1139-
display: flex;
1140-
flex-direction: column;
1141-
align-items: flex-start;
1142-
gap: 0.25rem;
1143-
font-size: 0.875rem;
1144-
color: #6b7280;
1145-
@media (min-width: 1024px) {
1146-
flex-direction: row;
1147-
}
1148-
`,
1149-
errorFile: css`
1150-
cursor: pointer;
1151-
color: #ffffff;
1152-
`,
1153-
},
1154-
11551094
// Settings Tab
11561095
settingsTab: {
11571096
container: css`

0 commit comments

Comments
 (0)