From 9f71f648ed85341befc6dd3c63c33c7931fbe5a2 Mon Sep 17 00:00:00 2001 From: "Malin J." Date: Wed, 11 Sep 2024 09:53:26 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=97=91=EF=B8=8F=20Fix=20sanity=20lint=20w?= =?UTF-8?q?arnings=20and=20clean=20up=20#2344=20(#2439)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .eslintignore | 1 + .../components/DeleteTranslationDialog/index.tsx | 3 +-- sanityv3/schemas/editors/blockContentType.tsx | 4 ---- .../objects/background/backgroundOptions.tsx | 6 +++--- .../objects/background/imageBackground.tsx | 2 +- sanityv3/schemas/objects/campaignBanner/index.tsx | 15 ++------------- sanityv3/schemas/objects/card.tsx | 2 +- .../schemas/objects/grid/cellTypes/gridTeaser.tsx | 4 ++-- .../objects/grid/cellTypes/gridTextBlock.tsx | 11 +++++------ sanityv3/schemas/objects/grid/index.tsx | 1 - .../schemas/objects/grid/rowTypes/span2and1.tsx | 1 - sanityv3/schemas/objects/iframe.tsx | 4 ++-- sanityv3/schemas/objects/textBlock.tsx | 6 ++---- web/lib/queries/routes.ts | 1 - web/pageComponents/pageTemplates/NewsRoomPage.tsx | 1 - web/pageComponents/shared/image/Caption.tsx | 1 - .../shared/search/simplePagination/Pagination.tsx | 1 - web/pageComponents/topicPages/Form/Form.tsx | 2 +- 18 files changed, 21 insertions(+), 45 deletions(-) diff --git a/.eslintignore b/.eslintignore index e02e175dc..27363ce0a 100644 --- a/.eslintignore +++ b/.eslintignore @@ -5,3 +5,4 @@ legacy/js/dist legacy/css web/public/legacy/legacy.minified.js legacy +dist \ No newline at end of file diff --git a/sanityv3/actions/customDelete/components/DeleteTranslationDialog/index.tsx b/sanityv3/actions/customDelete/components/DeleteTranslationDialog/index.tsx index 25208cee0..64b1d0563 100644 --- a/sanityv3/actions/customDelete/components/DeleteTranslationDialog/index.tsx +++ b/sanityv3/actions/customDelete/components/DeleteTranslationDialog/index.tsx @@ -1,7 +1,6 @@ import { Card, Flex, Spinner, Stack, Text } from '@sanity/ui' import { useEffect, useMemo, useState } from 'react' -import { SanityDocument } from 'sanity' -import { useClient } from 'sanity' +import { SanityDocument , useClient } from 'sanity' import { separateReferences } from './seperateReferences' import { apiVersion } from '../../../../sanity.client' import { defaultLanguage } from '../../../../languages' diff --git a/sanityv3/schemas/editors/blockContentType.tsx b/sanityv3/schemas/editors/blockContentType.tsx index 9bad24f08..27f0aba9b 100644 --- a/sanityv3/schemas/editors/blockContentType.tsx +++ b/sanityv3/schemas/editors/blockContentType.tsx @@ -71,9 +71,7 @@ const Level3BaseStyle = (props: any) => { export const configureBlockContent = (options: BlockContentProps = {}): BlockDefinition => { const { h2 = true, - useH2BaseStyle = false, h3 = true, - useH3BaseStyle = false, h4 = false, internalLink = true, externalLink = true, @@ -165,9 +163,7 @@ export const configureBlockContent = (options: BlockContentProps = {}): BlockDef } const h2DefaultConfig = { title: 'Heading 2', value: 'h2' } - const h2BaseConfig = { title: 'Heading 2', value: 'h2', component: Level2BaseStyle } const h3DefaultConfig = { title: 'Heading 3', value: 'h3' } - const h3BaseConfig = { title: 'Heading 3', value: 'h3', component: Level3BaseStyle } const h4Config = { title: 'Heading 4', value: 'h4' } const smallTextConfig = { title: 'Small text', diff --git a/sanityv3/schemas/objects/background/backgroundOptions.tsx b/sanityv3/schemas/objects/background/backgroundOptions.tsx index 400b22d91..819862c5b 100644 --- a/sanityv3/schemas/objects/background/backgroundOptions.tsx +++ b/sanityv3/schemas/objects/background/backgroundOptions.tsx @@ -1,4 +1,4 @@ -import { defineType, defineField, Rule } from 'sanity' +import { defineType, defineField } from 'sanity' export default defineType({ type: 'object', @@ -21,10 +21,10 @@ export default defineType({ ].filter((e) => e), options: { sortable: false }, validation: (Rule) => [ - Rule.custom((background, context) => { + Rule.custom((background) => { return background?.length > 1 ? 'Only 1 background item' : true }), - Rule.custom((background, context) => { + Rule.custom((background) => { if (background?.[0]._type === 'backgroundImage') { return background[0]?.image?.asset ? true : 'Image required' } diff --git a/sanityv3/schemas/objects/background/imageBackground.tsx b/sanityv3/schemas/objects/background/imageBackground.tsx index dc55b60cd..0bcf5b060 100644 --- a/sanityv3/schemas/objects/background/imageBackground.tsx +++ b/sanityv3/schemas/objects/background/imageBackground.tsx @@ -1,4 +1,4 @@ -import { defineType, defineField, Image } from 'sanity' +import { defineType, defineField } from 'sanity' import { RadioIconSelector } from '../../components' import { ContentRightImage, ContentLeftImage, ContentCenterImage } from '../../../icons' import { capitalizeFirstLetter } from '../../../helpers/formatters' diff --git a/sanityv3/schemas/objects/campaignBanner/index.tsx b/sanityv3/schemas/objects/campaignBanner/index.tsx index 69f960962..e3db74d0d 100644 --- a/sanityv3/schemas/objects/campaignBanner/index.tsx +++ b/sanityv3/schemas/objects/campaignBanner/index.tsx @@ -3,7 +3,7 @@ import blocksToText from '../../../helpers/blocksToText' import { configureBlockContent } from '../../editors' import { validateCharCounterEditor } from '../../validations/validateCharCounterEditor' -import type { Image, PortableTextBlock, Reference, Rule, ValidationContext } from 'sanity' +import type { Image, PortableTextBlock, Reference, Rule } from 'sanity' import type { ColorSelectorValue } from '../../components/ColorSelector' const blockConfigTitle = { @@ -18,19 +18,8 @@ const blockConfigTitle = { largeText: true, extraLargeText: true, } -const blockConfigContent = { - h2: false, - h3: false, - h4: false, - internalLink: false, - externalLink: false, - attachment: false, - lists: false, - smallText: true, -} const blockTitleType = configureBlockContent({ ...blockConfigTitle }) -const blockContentType = configureBlockContent({ ...blockConfigContent }) export type CampaignBanner = { _type: 'campaignBanner' @@ -66,7 +55,7 @@ export default { type: 'array', of: [blockTitleType], validation: (Rule: Rule) => - Rule.custom((value: PortableTextBlock[], ctx: ValidationContext) => { + Rule.custom((value: PortableTextBlock[]) => { return validateCharCounterEditor(value, 600) }).warning(), }, diff --git a/sanityv3/schemas/objects/card.tsx b/sanityv3/schemas/objects/card.tsx index e36a2fe04..d9a53d602 100644 --- a/sanityv3/schemas/objects/card.tsx +++ b/sanityv3/schemas/objects/card.tsx @@ -5,7 +5,7 @@ import type { PortableTextBlock } from 'sanity' import { Stack, Text, Card } from '@sanity/ui' import blocksToText from '../../helpers/blocksToText' -const CardField = forwardRef((props: any, ref) => { +const CardField = forwardRef((props: any) => { return ( diff --git a/sanityv3/schemas/objects/grid/cellTypes/gridTeaser.tsx b/sanityv3/schemas/objects/grid/cellTypes/gridTeaser.tsx index 5b778a20c..6468cdbe6 100644 --- a/sanityv3/schemas/objects/grid/cellTypes/gridTeaser.tsx +++ b/sanityv3/schemas/objects/grid/cellTypes/gridTeaser.tsx @@ -81,7 +81,7 @@ export default { of: [blockContentType], hidden: ({ parent }: GridTeaserDocument) => parent.useExtendedThemes, validation: (Rule: Rule) => - Rule.custom((value: PortableTextBlock[], ctx: ValidationContext) => { + Rule.custom((value: PortableTextBlock[]) => { return validateCharCounterEditor(value, 600) }).warning(), }, @@ -92,7 +92,7 @@ export default { of: [themedTitleContentType], hidden: ({ parent }: GridTeaserDocument) => !parent.useExtendedThemes, validation: (Rule: Rule) => - Rule.custom((value: PortableTextBlock[], ctx: ValidationContext) => { + Rule.custom((value: PortableTextBlock[]) => { return validateCharCounterEditor(value, 600) }).warning(), }, diff --git a/sanityv3/schemas/objects/grid/cellTypes/gridTextBlock.tsx b/sanityv3/schemas/objects/grid/cellTypes/gridTextBlock.tsx index ee9b469d2..9efb69796 100644 --- a/sanityv3/schemas/objects/grid/cellTypes/gridTextBlock.tsx +++ b/sanityv3/schemas/objects/grid/cellTypes/gridTextBlock.tsx @@ -4,18 +4,17 @@ import type { PortableTextBlock, Reference, Rule } from 'sanity' import type { ColorSelectorValue } from '../../../components/ColorSelector' import CompactBlockEditor from '../../../components/CompactBlockEditor' import blocksToText from '../../../../helpers/blocksToText' -import { EdsIcon } from '../../../../icons' -import { configureBlockContent } from '../../../editors' -import { configureThemedTitleBlockContent } from '../../../editors/themedTitleEditorContentType' -import { fromLargerTextThemeColors, fromNormalTextThemeColors } from '../../../components/ThemeSelector' -import { capitalizeFirstLetter } from '../../../../helpers/formatters' -import { +import { EdsIcon , ContentRightImage, ContentLeftImage, ContentCenterImage, ContentBottomLeftImage, ContentBottomCenterImage, } from '../../../../icons' +import { configureBlockContent } from '../../../editors' +import { configureThemedTitleBlockContent } from '../../../editors/themedTitleEditorContentType' +import { fromLargerTextThemeColors, fromNormalTextThemeColors } from '../../../components/ThemeSelector' +import { capitalizeFirstLetter } from '../../../../helpers/formatters' import { RadioIconSelector } from '../../../components' const blockContentType = configureBlockContent({ diff --git a/sanityv3/schemas/objects/grid/index.tsx b/sanityv3/schemas/objects/grid/index.tsx index 9fe2bc528..34a32bd06 100644 --- a/sanityv3/schemas/objects/grid/index.tsx +++ b/sanityv3/schemas/objects/grid/index.tsx @@ -1,4 +1,3 @@ -import { configureBlockContent } from '../../editors' import { PortableTextBlock } from 'sanity' import { EdsIcon } from '../../../icons' import { table_chart } from '@equinor/eds-icons' diff --git a/sanityv3/schemas/objects/grid/rowTypes/span2and1.tsx b/sanityv3/schemas/objects/grid/rowTypes/span2and1.tsx index 791e9357c..4cca3e492 100644 --- a/sanityv3/schemas/objects/grid/rowTypes/span2and1.tsx +++ b/sanityv3/schemas/objects/grid/rowTypes/span2and1.tsx @@ -1,5 +1,4 @@ import blocksToText from '../../../../helpers/blocksToText' -import { configureBlockContent } from '../../../editors' import { PortableTextBlock, Rule } from 'sanity' import { EdsIcon } from '../../../../icons' diff --git a/sanityv3/schemas/objects/iframe.tsx b/sanityv3/schemas/objects/iframe.tsx index 1c30381f6..aeb61b2bf 100644 --- a/sanityv3/schemas/objects/iframe.tsx +++ b/sanityv3/schemas/objects/iframe.tsx @@ -2,11 +2,11 @@ // It features description, ingress and c2a in addition to the basic iframe fields import { code } from '@equinor/eds-icons' -import type { PortableTextBlock, Rule } from 'sanity' +import type { PortableTextBlock } from 'sanity' import type { ColorSelectorValue } from '../components/ColorSelector' import blocksToText from '../../helpers/blocksToText' import { EdsIcon } from '../../icons' -import { configureBlockContent, configureTitleBlockContent } from '../editors' +import { configureBlockContent } from '../editors' import { title, frameTitle, diff --git a/sanityv3/schemas/objects/textBlock.tsx b/sanityv3/schemas/objects/textBlock.tsx index 30dd20485..49bb92988 100644 --- a/sanityv3/schemas/objects/textBlock.tsx +++ b/sanityv3/schemas/objects/textBlock.tsx @@ -1,6 +1,6 @@ /* eslint-disable @typescript-eslint/ban-ts-comment */ import { text_field } from '@equinor/eds-icons' -import type { PortableTextBlock, Reference, Rule, SanityDocument, ValidationContext } from 'sanity' +import type { PortableTextBlock, Reference, Rule, ValidationContext } from 'sanity' import type { ColorSelectorValue } from '../components/ColorSelector' import blocksToText from '../../helpers/blocksToText' import { EdsIcon } from '../../icons' @@ -127,9 +127,7 @@ export default { }, of: [titleContentType], validation: (Rule: Rule) => - Rule.custom((value: PortableTextBlock[], ctx: ValidationContext) => - !value ? 'A title is recommended' : true, - ).warning(), + Rule.custom((value: PortableTextBlock[]) => (!value ? 'A title is recommended' : true)).warning(), }, { title: 'Use brand theme for title', diff --git a/web/lib/queries/routes.ts b/web/lib/queries/routes.ts index 6aa7aae53..a91c0e1d1 100644 --- a/web/lib/queries/routes.ts +++ b/web/lib/queries/routes.ts @@ -1,4 +1,3 @@ -import { noDrafts } from './common/langAndDrafts' import pageContentFields from './common/pageContentFields' import { landingPageContentFields } from './common/landingPageContentFields' import { eventContentFields } from './common/eventContentFields' diff --git a/web/pageComponents/pageTemplates/NewsRoomPage.tsx b/web/pageComponents/pageTemplates/NewsRoomPage.tsx index 4ab36129c..67eda8889 100644 --- a/web/pageComponents/pageTemplates/NewsRoomPage.tsx +++ b/web/pageComponents/pageTemplates/NewsRoomPage.tsx @@ -79,7 +79,6 @@ const NewsRoomPage = ({ isServerRendered, locale, pageData, slug, url }: NewsRoo const isoCode = getIsoFromLocale(locale) const indexName = `${envPrefix}_NEWS_${isoCode}` const resultsRef = useRef(null) - let eventHandler: any // eslint-disable-next-line // @ts-ignore: @TODO: The types are not correct const createURL = ({ qsModule, routeState, location }) => { diff --git a/web/pageComponents/shared/image/Caption.tsx b/web/pageComponents/shared/image/Caption.tsx index 258ade84e..9af4423df 100644 --- a/web/pageComponents/shared/image/Caption.tsx +++ b/web/pageComponents/shared/image/Caption.tsx @@ -1,7 +1,6 @@ import type { CaptionData } from 'types/types' import { FigureCaption } from '@components' import { HTMLAttributes } from 'react' -import { twMerge } from 'tailwind-merge' export const Caption = ({ caption, attribution, className }: CaptionData & HTMLAttributes) => { return caption || attribution ? ( diff --git a/web/pageComponents/shared/search/simplePagination/Pagination.tsx b/web/pageComponents/shared/search/simplePagination/Pagination.tsx index f65e3a1e7..1a0230dd8 100644 --- a/web/pageComponents/shared/search/simplePagination/Pagination.tsx +++ b/web/pageComponents/shared/search/simplePagination/Pagination.tsx @@ -1,7 +1,6 @@ import { Icon } from '@equinor/eds-core-react' import { chevron_left, chevron_right, first_page, last_page } from '@equinor/eds-icons' import { useContext, useEffect, useRef, useState } from 'react' -import styled from 'styled-components' import { usePrefersReducedMotion } from '../../../../common/hooks/usePrefersReducedMotion' import { PaginationContext } from './PaginationContext' import { PaginationItem } from './PaginationItem' diff --git a/web/pageComponents/topicPages/Form/Form.tsx b/web/pageComponents/topicPages/Form/Form.tsx index 8f503d41f..0a83018b7 100644 --- a/web/pageComponents/topicPages/Form/Form.tsx +++ b/web/pageComponents/topicPages/Form/Form.tsx @@ -6,7 +6,7 @@ import SubscribeForm from './SubscribeForm' import CareerFairForm from './CareerFairForm' import OrderReportsForm from './OrderReportsForm' import CareersContactForm from './careersContactForm/CareersContactForm' -import type { LinkData, FormData } from '../../../types/types' +import type { FormData } from '../../../types/types' import { twMerge } from 'tailwind-merge' import CallToActions from '@sections/CallToActions'