Skip to content

Commit

Permalink
🗑️ Fix sanity lint warnings and clean up #2344 (#2439)
Browse files Browse the repository at this point in the history
  • Loading branch information
millianapia authored Sep 11, 2024
1 parent d26faf5 commit 9f71f64
Show file tree
Hide file tree
Showing 18 changed files with 21 additions and 45 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ legacy/js/dist
legacy/css
web/public/legacy/legacy.minified.js
legacy
dist
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
4 changes: 0 additions & 4 deletions sanityv3/schemas/editors/blockContentType.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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',
Expand Down
6 changes: 3 additions & 3 deletions sanityv3/schemas/objects/background/backgroundOptions.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { defineType, defineField, Rule } from 'sanity'
import { defineType, defineField } from 'sanity'

export default defineType({
type: 'object',
Expand All @@ -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'
}
Expand Down
2 changes: 1 addition & 1 deletion sanityv3/schemas/objects/background/imageBackground.tsx
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
15 changes: 2 additions & 13 deletions sanityv3/schemas/objects/campaignBanner/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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'
Expand Down Expand Up @@ -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(),
},
Expand Down
2 changes: 1 addition & 1 deletion sanityv3/schemas/objects/card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<Stack>
<Card padding={3} borderLeft>
Expand Down
4 changes: 2 additions & 2 deletions sanityv3/schemas/objects/grid/cellTypes/gridTeaser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
},
Expand All @@ -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(),
},
Expand Down
11 changes: 5 additions & 6 deletions sanityv3/schemas/objects/grid/cellTypes/gridTextBlock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
1 change: 0 additions & 1 deletion sanityv3/schemas/objects/grid/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { configureBlockContent } from '../../editors'
import { PortableTextBlock } from 'sanity'
import { EdsIcon } from '../../../icons'
import { table_chart } from '@equinor/eds-icons'
Expand Down
1 change: 0 additions & 1 deletion sanityv3/schemas/objects/grid/rowTypes/span2and1.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import blocksToText from '../../../../helpers/blocksToText'
import { configureBlockContent } from '../../../editors'

import { PortableTextBlock, Rule } from 'sanity'
import { EdsIcon } from '../../../../icons'
Expand Down
4 changes: 2 additions & 2 deletions sanityv3/schemas/objects/iframe.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 2 additions & 4 deletions sanityv3/schemas/objects/textBlock.tsx
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -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',
Expand Down
1 change: 0 additions & 1 deletion web/lib/queries/routes.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { noDrafts } from './common/langAndDrafts'
import pageContentFields from './common/pageContentFields'
import { landingPageContentFields } from './common/landingPageContentFields'
import { eventContentFields } from './common/eventContentFields'
Expand Down
1 change: 0 additions & 1 deletion web/pageComponents/pageTemplates/NewsRoomPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ const NewsRoomPage = ({ isServerRendered, locale, pageData, slug, url }: NewsRoo
const isoCode = getIsoFromLocale(locale)
const indexName = `${envPrefix}_NEWS_${isoCode}`
const resultsRef = useRef<HTMLDivElement>(null)
let eventHandler: any
// eslint-disable-next-line
// @ts-ignore: @TODO: The types are not correct
const createURL = ({ qsModule, routeState, location }) => {
Expand Down
1 change: 0 additions & 1 deletion web/pageComponents/shared/image/Caption.tsx
Original file line number Diff line number Diff line change
@@ -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<HTMLElement>) => {
return caption || attribution ? (
Expand Down
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
2 changes: 1 addition & 1 deletion web/pageComponents/topicPages/Form/Form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down

0 comments on commit 9f71f64

Please sign in to comment.