diff --git a/site/.eslintrc.yaml b/site/.eslintrc.yaml index bbdd563aacb9b..b7aa5bd97dc15 100644 --- a/site/.eslintrc.yaml +++ b/site/.eslintrc.yaml @@ -78,6 +78,7 @@ rules: - info - debug no-dupe-class-members: "off" + no-implicit-coercion: "error" no-restricted-imports: - error - paths: diff --git a/site/src/AppRouter.tsx b/site/src/AppRouter.tsx index 5f2955eb3a6fa..1b9eb9a67aa21 100644 --- a/site/src/AppRouter.tsx +++ b/site/src/AppRouter.tsx @@ -145,7 +145,7 @@ export const AppRouter: FC = () => { diff --git a/site/src/components/ErrorSummary/ErrorSummary.tsx b/site/src/components/ErrorSummary/ErrorSummary.tsx index 6e8352a8e9544..5ac024e8d9077 100644 --- a/site/src/components/ErrorSummary/ErrorSummary.tsx +++ b/site/src/components/ErrorSummary/ErrorSummary.tsx @@ -49,7 +49,7 @@ export const ErrorSummary: FC> = ({ {message} - {!!detail && } + {Boolean(detail) && } {dismissible && ( diff --git a/site/src/components/LoadingButton/LoadingButton.tsx b/site/src/components/LoadingButton/LoadingButton.tsx index f667ecbe0b307..4e9fe0f57bab1 100644 --- a/site/src/components/LoadingButton/LoadingButton.tsx +++ b/site/src/components/LoadingButton/LoadingButton.tsx @@ -23,7 +23,7 @@ export const LoadingButton: FC> = ({ children, ...rest }) => { - const styles = useStyles({ hasLoadingLabel: !!loadingLabel }) + const styles = useStyles({ hasLoadingLabel: Boolean(loadingLabel) }) const hidden = loading ? { opacity: 0 } : undefined return ( @@ -34,7 +34,7 @@ export const LoadingButton: FC> = ({ )} - {!!loadingLabel && loadingLabel} + {Boolean(loadingLabel) && loadingLabel} ) } diff --git a/site/src/components/Navbar/Navbar.tsx b/site/src/components/Navbar/Navbar.tsx index 608e8697e4f91..09690c876e333 100644 --- a/site/src/components/Navbar/Navbar.tsx +++ b/site/src/components/Navbar/Navbar.tsx @@ -14,7 +14,8 @@ export const Navbar: React.FC = () => { selectFeatureVisibility, shallowEqual, ) - const canViewAuditLog = featureVisibility[FeatureNames.AuditLog] && !!permissions?.viewAuditLog + const canViewAuditLog = + featureVisibility[FeatureNames.AuditLog] && Boolean(permissions?.viewAuditLog) const onSignOut = () => authSend("SIGN_OUT") return diff --git a/site/src/components/SearchBarWithFilter/SearchBarWithFilter.tsx b/site/src/components/SearchBarWithFilter/SearchBarWithFilter.tsx index b4caf55f69509..927eb495c8002 100644 --- a/site/src/components/SearchBarWithFilter/SearchBarWithFilter.tsx +++ b/site/src/components/SearchBarWithFilter/SearchBarWithFilter.tsx @@ -42,7 +42,7 @@ export const SearchBarWithFilter: React.FC { - const styles = useStyles({ error: !!error }) + const styles = useStyles({ error: Boolean(error) }) const form = useFormik({ enableReinitialize: true, @@ -108,7 +108,7 @@ export const SearchBarWithFilter: React.FC> = }) => { const styles = useStyles({ size }) const anchorRef = useRef(null) - const [isOpen, setIsOpen] = useState(!!open) + const [isOpen, setIsOpen] = useState(Boolean(open)) const id = isOpen ? "help-popover" : undefined const onClose = () => { diff --git a/site/src/components/UserDropdown/UsersDropdown.tsx b/site/src/components/UserDropdown/UsersDropdown.tsx index fd63ba015d542..a391951196cda 100644 --- a/site/src/components/UserDropdown/UsersDropdown.tsx +++ b/site/src/components/UserDropdown/UsersDropdown.tsx @@ -51,7 +51,7 @@ export const UserDropdown: React.FC> > = ({ - {!!resources && !!resources.length && ( + {typeof resources !== "undefined" && resources.length > 0 && ( { return ( ) } diff --git a/site/src/components/WorkspaceScheduleForm/WorkspaceScheduleForm.tsx b/site/src/components/WorkspaceScheduleForm/WorkspaceScheduleForm.tsx index aad9ff2f92432..ee439cbefec75 100644 --- a/site/src/components/WorkspaceScheduleForm/WorkspaceScheduleForm.tsx +++ b/site/src/components/WorkspaceScheduleForm/WorkspaceScheduleForm.tsx @@ -164,7 +164,7 @@ export const validationSchema = Yup.object({ .test("positive-if-auto-stop", Language.errorNoStop, function (value) { const parent = this.parent as WorkspaceScheduleFormValues if (parent.autoStopEnabled) { - return !!value + return Boolean(value) } else { return true } diff --git a/site/src/pages/TemplateSettingsPage/TemplateSettingsPageView.tsx b/site/src/pages/TemplateSettingsPage/TemplateSettingsPageView.tsx index 4a37119881134..a4c2515f2714a 100644 --- a/site/src/pages/TemplateSettingsPage/TemplateSettingsPageView.tsx +++ b/site/src/pages/TemplateSettingsPage/TemplateSettingsPageView.tsx @@ -33,7 +33,7 @@ export const TemplateSettingsPageView: FC = ({ return ( - {!!errors.getTemplateError && } + {Boolean(errors.getTemplateError) && } {isLoading && } {template && ( { cancellationError, } = workspaceState.context - const canUpdateWorkspace = !!permissions?.updateWorkspace + const canUpdateWorkspace = Boolean(permissions?.updateWorkspace) const [bannerState, bannerSend] = useMachine(workspaceScheduleBannerMachine) const [buildInfoState] = useActor(xServices.buildInfoXService) @@ -66,9 +66,9 @@ export const WorkspacePage: FC = () => { if (workspaceState.matches("error")) { return (
- {!!getWorkspaceError && } - {!!refreshTemplateError && } - {!!checkPermissionsError && } + {Boolean(getWorkspaceError) && } + {Boolean(refreshTemplateError) && } + {Boolean(checkPermissionsError) && }
) } else if (!workspace || !permissions) { diff --git a/site/src/util/events.ts b/site/src/util/events.ts index d8cc5d0c4dcfa..e0d03ecef1d13 100644 --- a/site/src/util/events.ts +++ b/site/src/util/events.ts @@ -45,5 +45,5 @@ export type AnnotatedEventListener = (event: E) => void export const isCustomEvent = ( event: CustomEvent | Event, ): event is CustomEvent => { - return !!(event as CustomEvent).detail + return Boolean((event as CustomEvent).detail) }