Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into remove-e2e-tests-not-…
Browse files Browse the repository at this point in the history
…required-label
  • Loading branch information
agnesgaroux committed Sep 17, 2024
2 parents c57be2a + 7416ffd commit 8df4441
Show file tree
Hide file tree
Showing 219 changed files with 540 additions and 553 deletions.
13 changes: 13 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ const sharedRules = {
],
'react-hooks/rules-of-hooks': 'error',
'prettier/prettier': 'error',
'no-restricted-imports': [
'error',
{ patterns: ['../*'] }, // Should only import relatively from same directory
],
'no-restricted-syntax': [
'error',
"JSXElement.children > [expression.callee.property.name='stringify']",
Expand All @@ -42,6 +46,7 @@ module.exports = {
},
extends: sharedExtends,
rules: sharedRules,
reportUnusedDisableDirectives: true,
parserOptions: {
ecmaFeatures: {
jsx: true,
Expand Down Expand Up @@ -87,5 +92,13 @@ module.exports = {
'react/prop-types': 'off',
},
},
// Some directories don't have an absolute import equivalent so ignoring
// import rules for them.
{
files: ['dash/**'],
rules: {
'no-restricted-imports': 'off',
},
},
],
};
2 changes: 1 addition & 1 deletion cardigan/stories/components/Cards/Cards.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export const guideStopCard = GuideStopCardTemplate.bind({});
guideStopCard.args = {
link: '/stop-1',
totalStops: 3,
duration: 3.5,
duration: '03:30',
number: 1,
title: 'Exhibition guide stop',
type: 'audio',
Expand Down
2 changes: 1 addition & 1 deletion common/data/errors.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { FunctionComponent } from 'react';
import { prismicPageIds } from './hardcoded-ids';
import Space from '../views/components/styled/Space';
import Space from '@weco/common/views/components/styled/Space';
import Layout, { gridSize8 } from '@weco/common/views/components/Layout';

export const errorMessages = {
Expand Down
2 changes: 1 addition & 1 deletion common/data/microcopy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
// able to edit it themselves, using the GitHub web interface.
//

import { createScreenreaderLabel } from '../utils/telephone-numbers';
import { createScreenreaderLabel } from '@weco/common/utils/telephone-numbers';

export const pageDescriptions = {
articles:
Expand Down
4 changes: 2 additions & 2 deletions common/data/organization.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { objToJsonLd } from '../utils/json-ld';
import { Organization } from '../model/organization';
import { objToJsonLd } from '@weco/common/utils/json-ld';
import { Organization } from '@weco/common/model/organization';

export const wellcomeCollectionAddress = {
addressLocality: 'London',
Expand Down
2 changes: 1 addition & 1 deletion common/model/opening-hours.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DayOfWeek } from '../utils/format-date';
import { DayOfWeek } from '@weco/common/utils/format-date';
import { ImageType } from './image';

export type OverrideType =
Expand Down
2 changes: 0 additions & 2 deletions common/model/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export type UserInfo = {
};

// This is the type returned by the Auth0 profile endpoint
/* eslint-disable camelcase */
export type Auth0UserProfile = {
sub: string;
email: string;
Expand All @@ -21,7 +20,6 @@ export type Auth0UserProfile = {
nickname: string;
'https://wellcomecollection.org/patron_barcode': string;
};
/* eslint-enable camelcase */

// Auth0 subject claims (aka user IDs) are prefixed with `auth0|`, plus
// the `p` prefix for Sierra patrons.
Expand Down
24 changes: 12 additions & 12 deletions common/prismicio-types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6405,14 +6405,14 @@ export interface GuideStopSliceDefaultPrimary {
transcript: prismic.RichTextField;

/**
* Audio duration (in minutes) field in *GuideStop → Primary*
* Audio duration (mm:ss) field in *GuideStop → Default → Primary*
*
* - **Field Type**: Number
* - **Placeholder**: approximate time in minutes, e.g. 3.5
* - **API ID Path**: guide_stop.primary.audio_duration
* - **Documentation**: https://prismic.io/docs/field#number
* - **Field Type**: Text
* - **Placeholder**: e.g. 03:30
* - **API ID Path**: guide_stop.default.primary.audio_duration
* - **Documentation**: https://prismic.io/docs/field#key-text
*/
audio_duration: prismic.NumberField;
audio_duration: prismic.KeyTextField;

/**
* BSL video (Youtube) field in *GuideStop → Primary*
Expand All @@ -6435,14 +6435,14 @@ export interface GuideStopSliceDefaultPrimary {
subtitles: prismic.RichTextField;

/**
* Video duration (in minutes) field in *GuideStop → Primary*
* Video duration (mm:ss) field in *GuideStop → Default → Primary*
*
* - **Field Type**: Number
* - **Placeholder**: approximate time in minutes, e.g. 3.5
* - **API ID Path**: guide_stop.primary.video_duration
* - **Documentation**: https://prismic.io/docs/field#number
* - **Field Type**: Text
* - **Placeholder**: e.g. 03:30
* - **API ID Path**: guide_stop.default.primary.video_duration
* - **Documentation**: https://prismic.io/docs/field#key-text
*/
video_duration: prismic.NumberField;
video_duration: prismic.KeyTextField;

/**
* Image field in *GuideStop → Primary*
Expand Down
4 changes: 2 additions & 2 deletions common/server-data/__mocks__/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import {
emptyGlobalAlert,
emptyPopupDialog,
emptyPrismicQuery,
} from '../../services/prismic/documents';
import { ServerData } from '../types';
} from '@weco/common/services/prismic/documents';
import { ServerData } from '@weco/common/server-data/types';
import { CollectionVenueDocument as RawCollectionVenueDocument } from '@weco/common/prismicio-types';

export async function init(): Promise<void> {
Expand Down
2 changes: 1 addition & 1 deletion common/server-data/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { promises as fs } from 'fs';
import { GetServerSidePropsContext } from 'next';
import togglesHandler, { getTogglesFromContext } from './toggles';
import prismicHandler from './prismic';
import { simplifyServerData } from '../services/prismic/transformers/server-data';
import { simplifyServerData } from '@weco/common/services/prismic/transformers/server-data';
import { SimplifiedServerData } from './types';
import { getAllConsentStates } from '@weco/common/services/app/civic-uk';

Expand Down
2 changes: 1 addition & 1 deletion common/server-data/prismic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
} from '@weco/common/prismicio-types';
import { Handler } from './';
import * as prismic from '@prismicio/client';
import { InferDataInterface } from '../services/prismic/types';
import { InferDataInterface } from '@weco/common/services/prismic/types';
import { createClient as createPrismicClient } from '@weco/common/services/prismic/fetch';

export type RawCollectionVenueDocumentLite = {
Expand Down
2 changes: 1 addition & 1 deletion common/server-data/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
defaultValue as prismicDefaultValue,
PrismicData,
SimplifiedPrismicData,
} from '../server-data/prismic';
} from '@weco/common/server-data/prismic';

/**
* The type is stored here rather than with the service because
Expand Down
5 changes: 4 additions & 1 deletion common/services/app/usePrismicPreview.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { useEffect } from 'react';
import { PrismicData, SimplifiedPrismicData } from '../../server-data/prismic';
import {
PrismicData,
SimplifiedPrismicData,
} from '@weco/common/server-data/prismic';

declare global {
interface Window {
Expand Down
6 changes: 3 additions & 3 deletions common/services/prismic/opening-times.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { formatDayName } from '../../utils/format-date';
import { formatDayName } from '@weco/common/utils/format-date';
import {
OverrideType,
ExceptionalPeriod,
Expand All @@ -7,7 +7,7 @@ import {
OpeningHoursDay,
ExceptionalOpeningHoursDay,
HasOverrideDate,
} from '../../model/opening-hours';
} from '@weco/common/model/opening-hours';
import { isNotUndefined } from '@weco/common/utils/type-guards';
import {
addDays,
Expand All @@ -16,7 +16,7 @@ import {
isSameDay,
isSameDayOrBefore,
today,
} from '../../utils/dates';
} from '@weco/common/utils/dates';

const ONE_WEEK = 7;

Expand Down
7 changes: 5 additions & 2 deletions common/services/prismic/transformers/collection-venues.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import {
ResultsLite,
RawCollectionVenueDocumentLite,
} from '../../../server-data/prismic';
} from '@weco/common/server-data/prismic';
import { DayOfWeek, formatTime } from '@weco/common/utils/format-date';
import { Venue, OpeningHoursDay } from '@weco/common/model/opening-hours';
import { DayField, ModifiedDayOpeningTime } from '../documents';
import {
DayField,
ModifiedDayOpeningTime,
} from '@weco/common/services/prismic/documents';
import { isNotUndefined } from '@weco/common/utils/type-guards';
import * as prismic from '@prismicio/client';
import { transformImage } from './images';
Expand Down
3 changes: 1 addition & 2 deletions common/services/prismic/transformers/images.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,8 @@ function transformFilledImage(image: prismic.FilledImageFieldImage): ImageType {
acc[key] = image;
return acc;
}, {});
/* eslint-disable @typescript-eslint/no-non-null-assertion */

const alt = image.alt!;
/* eslint-enable @typescript-eslint/no-non-null-assertion */

const simpleCrops = Object.keys(crops)
.filter(key => {
Expand Down
8 changes: 4 additions & 4 deletions common/services/prismic/transformers/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Tasl } from '../../../model/tasl';
import { licenseTypeArray } from '../../../model/license';
import linkResolver from '../link-resolver';
import { Tasl } from '@weco/common/model/tasl';
import { licenseTypeArray } from '@weco/common/model/license';
import linkResolver from '@weco/common/services/prismic/link-resolver';
import {
isFilledLinkToDocument,
isFilledLinkToMediaField,
isFilledLinkToWebField,
} from '../types';
} from '@weco/common/services/prismic/types';
import * as prismic from '@prismicio/client';

export function transformTaslFromString(pipedString: string | null): Tasl {
Expand Down
2 changes: 1 addition & 1 deletion common/services/prismic/transformers/server-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
ServerData,
SimplifiedServerData,
} from '@weco/common/server-data/types';
import { InferDataInterface } from '../types';
import { InferDataInterface } from '@weco/common/services/prismic/types';
import {
PopupDialogDocument as RawPopupDialogDocument,
GlobalAlertDocument as RawGlobalAlertDocument,
Expand Down
4 changes: 2 additions & 2 deletions common/test/fixtures/identity/user.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { UserInfo, Auth0UserProfile } from '../../../model/user';
import { RequestsList } from '../../../model/requesting';
import { UserInfo, Auth0UserProfile } from '@weco/common/model/user';
import { RequestsList } from '@weco/common/model/requesting';

export const mockUser: UserInfo = {
userId: '7654321',
Expand Down
2 changes: 1 addition & 1 deletion common/test/fixtures/test-helpers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
RenderOptions,
MatcherFunction,
} from '@testing-library/react';
import theme from '../../views/themes/default';
import theme from '@weco/common/views/themes/default';

const ProvidersWrapper: FunctionComponent<PropsWithChildren> = ({
children,
Expand Down
1 change: 0 additions & 1 deletion common/types/styled-components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@ import theme from '@weco/common/views/themes/default';
type ThemeInterface = typeof theme;

declare module 'styled-components' {
// eslint-disable-next-line @typescript-eslint/no-empty-interface
interface DefaultTheme extends ThemeInterface {}
}
2 changes: 1 addition & 1 deletion common/utils/convert-url-to-string.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Url } from '../model/link-props';
import { Url } from '@weco/common/model/link-props';

export default function convertUrlToString(url: Url): string {
const { query = {} } = url;
Expand Down
2 changes: 1 addition & 1 deletion common/utils/dates.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DateRange } from '../model/date-range';
import { DateRange } from '@weco/common/model/date-range';
import { formatDayDate } from './format-date';

/** Returns the current date/time.
Expand Down
13 changes: 0 additions & 13 deletions common/utils/format-time.test.ts

This file was deleted.

11 changes: 0 additions & 11 deletions common/utils/format-time.ts

This file was deleted.

9 changes: 4 additions & 5 deletions common/utils/json-ld.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { convertImageUri } from './convert-image-uri';
import { Organization } from '../model/organization';
import { BreadcrumbItems } from '../model/breadcrumbs';
import { Organization } from '@weco/common/model/organization';
import { BreadcrumbItems } from '@weco/common/model/breadcrumbs';
import { JsonLdObj } from '@weco/common/views/components/JsonLd/JsonLd';
import type {
OpeningHours,
OpeningHoursDay,
SpecialOpeningHours,
} from '../model/opening-hours';
} from '@weco/common/model/opening-hours';
import { formatDate } from './format-date';

type ObjToJsonLdProps = { type: string; root?: boolean };
Expand Down Expand Up @@ -83,9 +83,8 @@ function imageLd(image: Image) {
image &&
objToJsonLd(
{
/* eslint-disable @typescript-eslint/no-non-null-assertion */
url: convertImageUri((image.contentUrl || image.url)!, 1200),
/* eslint-enable @typescript-eslint/no-non-null-assertion */

width: image.width,
height: image.height,
},
Expand Down
2 changes: 1 addition & 1 deletion common/views/components/Buttons/Buttons.Dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import Button, { ButtonTypes } from '@weco/common/views/components/Buttons';
import { AppContext } from '@weco/common/views/components/AppContext/AppContext';
import { chevron, IconSvg } from '@weco/common/icons';
import { themeValues } from '@weco/common/views/themes/config';
import { BorderlessButton } from '../BorderlessClickable';
import { BorderlessButton } from '@weco/common/views/components/BorderlessClickable';

const DropdownWrapper = styled.div`
display: inline-flex;
Expand Down
2 changes: 1 addition & 1 deletion common/views/components/Buttons/Buttons.SolidLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { FunctionComponent, SyntheticEvent } from 'react';
import NextLink, { LinkProps } from 'next/link';
import { classNames } from '@weco/common/utils/classnames';
import Icon from '@weco/common/views/components/Icon/Icon';
import ConditionalWrapper from '../ConditionalWrapper/ConditionalWrapper';
import ConditionalWrapper from '@weco/common/views/components/ConditionalWrapper/ConditionalWrapper';
import {
BaseButtonInner,
ButtonIconWrapper,
Expand Down
12 changes: 7 additions & 5 deletions common/views/components/ErrorPage/ErrorPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ import {
import { headerBackgroundLs } from '@weco/common/utils/backgrounds';
import { underConstruction } from '@weco/common/icons';
import Icon from '@weco/common/views/components/Icon/Icon';
import PageHeader, { headerSpaceSize } from '../PageHeader/PageHeader';
import PageLayout from '../PageLayout/PageLayout';
import SpacingSection from '../styled/SpacingSection';
import SpacingComponent from '../styled/SpacingComponent';
import PageHeader, {
headerSpaceSize,
} from '@weco/common/views/components/PageHeader/PageHeader';
import PageLayout from '@weco/common/views/components/PageLayout/PageLayout';
import SpacingSection from '@weco/common/views/components/styled/SpacingSection';
import SpacingComponent from '@weco/common/views/components/styled/SpacingComponent';
import Space from '@weco/common/views/components/styled/Space';
import { dangerouslyGetEnabledToggles } from '@weco/common/utils/cookies';
import Layout, { gridSize8 } from '../Layout';
import Layout, { gridSize8 } from '@weco/common/views/components/Layout';
import togglesList from '@weco/toggles/toggles';

const MessageBar = styled(Space).attrs({
Expand Down
2 changes: 1 addition & 1 deletion common/views/components/Footer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import styled from 'styled-components';
import Space from '@weco/common/views/components/styled/Space';
import OpeningTimes from '@weco/common/views/components/OpeningTimes/OpeningTimes';
import Divider from '@weco/common/views/components/Divider/Divider';
import FindUs from '../FindUs/FindUs';
import FindUs from '@weco/common/views/components/FindUs/FindUs';
import FooterNav from './Footer.Nav';
import FooterSocial from './Footer.Social';
import FooterWellcomeLogo from './Footer.WellcomeLogo';
Expand Down
Loading

0 comments on commit 8df4441

Please sign in to comment.