Skip to content

Commit

Permalink
Biome1.5.1 (#5867)
Browse files Browse the repository at this point in the history
Lots of work here, mostly because I didn't want to turn off the
`noImplicitAnyLet` lint. This PR tries its best to type all the untyped
lets biome complained about (Don't ask me how many hours that took or
how many lints that was >200...), which in the future will force test
authors to actually type their global variables setup in `beforeAll`.

---------

Co-authored-by: Gastón Fournier <gaston@getunleash.io>
  • Loading branch information
Christopher Kolstad and gastonfournier committed Jan 12, 2024
1 parent e27a578 commit 5a3bb1f
Show file tree
Hide file tree
Showing 132 changed files with 839 additions and 537 deletions.
2 changes: 1 addition & 1 deletion biome.json
@@ -1,5 +1,5 @@
{
"$schema": "https://biomejs.dev/schemas/1.4.0/schema.json",
"$schema": "https://biomejs.dev/schemas/1.5.1/schema.json",
"linter": {
"enabled": true,
"rules": {
Expand Down
2 changes: 1 addition & 1 deletion frontend/package.json
Expand Up @@ -32,7 +32,7 @@
"gen:api:sandbox": "NODE_OPTIONS=\"${NODE_OPTIONS} --no-experimental-fetch\" UNLEASH_OPENAPI_URL=https://sandbox.getunleash.io/demo2/docs/openapi.json yarn run gen:api"
},
"devDependencies": {
"@biomejs/biome": "1.4.1",
"@biomejs/biome": "1.5.1",
"@codemirror/lang-json": "6.0.1",
"@emotion/react": "11.11.3",
"@emotion/styled": "11.11.0",
Expand Down
Expand Up @@ -17,8 +17,8 @@ import { PageHeader } from '../../../common/PageHeader/PageHeader';
export const InstanceStats: VFC = () => {
const { stats } = useInstanceStats();

let versionTitle;
let version;
let versionTitle: string;
let version: string | undefined;

if (stats?.versionEnterprise) {
versionTitle = 'Unleash Enterprise version';
Expand Down
Expand Up @@ -56,7 +56,11 @@ export const ApplicationList = () => {
() => [
{
id: 'Icon',
Cell: ({ row: { original: { icon } } }: any) => (
Cell: ({
row: {
original: { icon },
},
}: any) => (
<IconCell
icon={
<Avatar>
Expand All @@ -72,7 +76,9 @@ export const ApplicationList = () => {
accessor: 'appName',
width: '50%',
Cell: ({
row: { original: { appName, description } },
row: {
original: { appName, description },
},
}: any) => (
<LinkCell
title={appName}
Expand Down
Expand Up @@ -93,7 +93,7 @@ export const ChangeRequestTimeline: FC<ISuggestChangeTimelineProps> = ({
scheduledAt,
failureReason,
}) => {
let data;
let data: ChangeRequestState[];
switch (state) {
case 'Rejected':
data = rejectedSteps;
Expand Down
Expand Up @@ -80,7 +80,6 @@ export const MultiActionButton: FC<{
}}
open={open}
anchorEl={anchorRef.current}
role={undefined}
transition
disablePortal
>
Expand Down
Expand Up @@ -137,7 +137,12 @@ export const ChangeRequestsTabs = ({
.includes(feature.name.toLowerCase()),
);
},
Cell: ({ value, row: { original: { title } } }: any) => (
Cell: ({
value,
row: {
original: { title },
},
}: any) => (
<FeaturesCell
project={projectId}
value={value}
Expand Down
Expand Up @@ -24,7 +24,7 @@ export const PermissionHOC: FC<IPermissionHOCProps> = ({
tooltipProps,
}) => {
const { hasAccess } = useContext(AccessContext);
let access;
let access: boolean;

if (projectId && environmentId) {
access = hasAccess(permission, projectId, environmentId);
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/component/common/UserAvatar/UserAvatar.tsx
Expand Up @@ -44,7 +44,7 @@ export const UserAvatar: FC<IUserAvatarProps> = ({
src = user?.imageUrl;
}

let fallback;
let fallback: string | undefined;
if (!children && user) {
fallback = user?.name || user?.email || user?.username;
if (fallback?.includes(' ')) {
Expand Down
Expand Up @@ -71,7 +71,11 @@ const ContextList: VFC = () => {
Header: 'Name',
accessor: 'name',
width: '70%',
Cell: ({ row: { original: { name, description } } }: any) => (
Cell: ({
row: {
original: { name, description },
},
}: any) => (
<LinkCell
title={name}
to={`/context/edit/${name}`}
Expand All @@ -91,7 +95,11 @@ const ContextList: VFC = () => {
Header: 'Actions',
id: 'Actions',
align: 'center',
Cell: ({ row: { original: { name } } }: any) => (
Cell: ({
row: {
original: { name },
},
}: any) => (
<ContextActionsCell
name={name}
onDelete={() => {
Expand Down
21 changes: 9 additions & 12 deletions frontend/src/component/demo/DemoSteps/DemoSteps.tsx
Expand Up @@ -211,18 +211,15 @@ export const DemoSteps = ({
const currentStep = currentTopic.steps[step];
if (!currentStep) return;

setTimeout(
() => {
if (
currentStep.href &&
!location.pathname.endsWith(currentStep.href.split('?')[0])
) {
navigate(currentStep.href);
}
waitForLoad(currentStep);
},
currentStep.delay ?? 0,
);
setTimeout(() => {
if (
currentStep.href &&
!location.pathname.endsWith(currentStep.href.split('?')[0])
) {
navigate(currentStep.href);
}
waitForLoad(currentStep);
}, currentStep.delay ?? 0);
}, [topic, step]);

useEffect(() => {
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/component/events/EventDiff/EventDiff.tsx
@@ -1,7 +1,7 @@
import { diff } from 'deep-diff';
import { IEvent } from 'interfaces/event';
import { useTheme } from '@mui/system';
import { CSSProperties } from 'react';
import { JSX, CSSProperties } from 'react';

const DIFF_PREFIXES: Record<string, string> = {
A: ' ',
Expand Down Expand Up @@ -40,7 +40,7 @@ const EventDiff = ({
: undefined;

const buildItemDiff = (diff: any, key: string) => {
let change;
let change: JSX.Element | undefined;
if (diff.lhs !== undefined) {
change = (
<div style={styles.D}>
Expand All @@ -59,7 +59,7 @@ const EventDiff = ({
};

const buildDiff = (diff: any, index: number): IEventDiffResult => {
let change;
let change: JSX.Element | undefined;
const key = diff.path?.join('.') ?? diff.index;

if (diff.item) {
Expand Down
Expand Up @@ -70,7 +70,11 @@ export const EnvironmentVariantsTable = ({
{
Header: 'Weight',
accessor: 'weight',
Cell: ({ row: { original: { name, weight } } }: any) => {
Cell: ({
row: {
original: { name, weight },
},
}: any) => {
return (
<TextCell data-testid={`VARIANT_WEIGHT_${name}`}>
{calculateVariantWeight(weight)} %
Expand Down
6 changes: 5 additions & 1 deletion frontend/src/component/featureTypes/FeatureTypesList.tsx
Expand Up @@ -54,7 +54,11 @@ export const FeatureTypesList = () => {
Header: 'Name',
accessor: 'name',
width: '90%',
Cell: ({ row: { original: { name, description } } }: any) => {
Cell: ({
row: {
original: { name, description },
},
}: any) => {
return (
<LinkCell
data-loading
Expand Down
Expand Up @@ -5,12 +5,10 @@ import { Typography, styled } from '@mui/material';
import { IntegrationIcon } from '../IntegrationList/IntegrationIcon/IntegrationIcon';
import { Markdown } from 'component/common/Markdown/Markdown';

const StyledHowDoesItWorkSection = styled(StyledRaisedSection)(
({ theme }) => ({
fontSize: theme.fontSizes.smallBody,
gap: theme.spacing(1.5),
}),
);
const StyledHowDoesItWorkSection = styled(StyledRaisedSection)(({ theme }) => ({
fontSize: theme.fontSizes.smallBody,
gap: theme.spacing(1.5),
}));

interface IIntegrationHowToSectionProps {
provider?: Pick<AddonTypeSchema, 'howTo' | 'name'>;
Expand Down
Expand Up @@ -117,7 +117,11 @@ export const VariantInformation: VFC<IVariantInformationProps> = ({
const COLUMNS = [
{
id: 'Icon',
Cell: ({ row: { original: { selected } } }: any) => (
Cell: ({
row: {
original: { selected },
},
}: any) => (
<>
<ConditionallyRender
condition={selected}
Expand All @@ -132,9 +136,11 @@ const COLUMNS = [
Header: 'Name',
accessor: 'name',
searchable: true,
Cell: ({ row: { original: { name } } }: any) => (
<TextCell>{name}</TextCell>
),
Cell: ({
row: {
original: { name },
},
}: any) => <TextCell>{name}</TextCell>,
maxWidth: 175,
width: 175,
},
Expand All @@ -144,8 +150,10 @@ const COLUMNS = [
sortType: 'alphanumeric',
searchable: true,
maxWidth: 75,
Cell: ({ row: { original: { weight } } }: any) => (
<TextCell>{weight}</TextCell>
),
Cell: ({
row: {
original: { weight },
},
}: any) => <TextCell>{weight}</TextCell>,
},
];
Expand Up @@ -57,7 +57,11 @@ export const ProjectDoraMetrics = () => {
Header: 'Name',
accessor: 'name',
width: '40%',
Cell: ({ row: { original: { name } } }: any) => {
Cell: ({
row: {
original: { name },
},
}: any) => {
return (
<Box
data-loading
Expand Down
Expand Up @@ -268,8 +268,7 @@ export const ProjectAccessAssign = ({
option: IAccessOption,
selected: boolean,
) => {
let optionGroup;
let optionUser;
let optionGroup: IGroup | undefined, optionUser: IUser | undefined;
if (option.type === ENTITY_TYPE.GROUP) {
optionGroup = option.entity as IGroup;
} else {
Expand Down
Expand Up @@ -102,7 +102,6 @@ const strategyListItem = (
{`${formatStrategyNameParens(
strategy,
)} — in change request `}

<StyledLink
to={formatChangeRequestPath(strategy.projectId, id)}
target='_blank'
Expand Down
1 change: 0 additions & 1 deletion frontend/src/component/segments/SegmentProjectAlert.tsx
Expand Up @@ -134,7 +134,6 @@ const strategyListItem = (
{`${formatStrategyNameParens(
strategy,
)} — in change request `}

<Link
to={formatChangeRequestPath(strategy.projectId, id)}
target='_blank'
Expand Down
Expand Up @@ -184,7 +184,11 @@ const getColumns = () => [
Header: 'Name',
accessor: 'name',
width: '60%',
Cell: ({ row: { original: { name, description, id } } }: any) => (
Cell: ({
row: {
original: { name, description, id },
},
}: any) => (
<LinkCell
title={name}
to={`/segments/edit/${id}`}
Expand Down
Expand Up @@ -256,7 +256,9 @@ export const StrategiesList = () => {
accessor: (row: any) => formatStrategyName(row.name),
width: '90%',
Cell: ({
row: { original: { name, description, deprecated } },
row: {
original: { name, description, deprecated },
},
}: any) => {
return (
<LinkCell
Expand Down
6 changes: 5 additions & 1 deletion frontend/src/component/tags/TagTypeList/TagTypeList.tsx
Expand Up @@ -77,7 +77,11 @@ export const TagTypeList = () => {
Header: 'Name',
accessor: 'name',
width: '90%',
Cell: ({ row: { original: { name, description } } }: any) => {
Cell: ({
row: {
original: { name, description },
},
}: any) => {
return (
<LinkCell
data-loading
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/component/user/Authentication/Authentication.tsx
Expand Up @@ -15,7 +15,7 @@ import { ConditionallyRender } from 'component/common/ConditionallyRender/Condit
import { Alert } from '@mui/material';
import { useAuthDetails } from 'hooks/api/getters/useAuth/useAuthDetails';
import { AUTH_PAGE_ID } from 'utils/testIds';
import { useEffect } from 'react';
import { ReactElement, useEffect } from 'react';
import { usePlausibleTracker } from 'hooks/usePlausibleTracker';

interface IAuthenticationProps {
Expand Down Expand Up @@ -46,7 +46,7 @@ const Authentication = ({
return null;
}

let content;
let content: ReactElement;
if (authDetails.type === PASSWORD_TYPE) {
content = (
<>
Expand Down
5 changes: 0 additions & 5 deletions frontend/src/themes/themeTypes.ts
Expand Up @@ -122,17 +122,12 @@ declare module '@mui/material/styles' {
variants: string[];
}

// biome-ignore lint/suspicious/noEmptyInterface: <explanation>
interface Theme extends CustomTheme {}
// biome-ignore lint/suspicious/noEmptyInterface: <explanation>
interface ThemeOptions extends CustomTheme {}

// biome-ignore lint/suspicious/noEmptyInterface: <explanation>
interface Palette extends CustomPalette {}
// biome-ignore lint/suspicious/noEmptyInterface: <explanation>
interface PaletteOptions extends CustomPalette {}

// biome-ignore lint/suspicious/noEmptyInterface: <explanation>
interface TypeBackground extends CustomTypeBackground {}

/* Extend the background object from MUI */
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/utils/routePathHelpers.ts
Expand Up @@ -8,7 +8,7 @@ export const getCreateTogglePath = (
) => {
const path = `/projects/${projectId}/create-toggle`;

let queryString;
let queryString: string | undefined;
if (query) {
queryString = Object.keys(query).reduce((acc, curr) => {
return `${acc}${curr}=${query[curr]}`;
Expand Down

0 comments on commit 5a3bb1f

Please sign in to comment.