Merged in fix/3697-prettier-configs (pull request #3396)

fix(SW-3691): Setup one prettier config for whole repo

* Setup prettierrc in root and remove other configs


Approved-by: Joakim Jäderberg
Approved-by: Linus Flood
This commit is contained in:
Rasmus Langvad
2026-01-07 12:45:50 +00:00
parent 932413412b
commit d0546926a9
500 changed files with 18367 additions and 18419 deletions

View File

@@ -1,33 +1,33 @@
import { cx } from 'class-variance-authority'
import { cx } from "class-variance-authority"
import { Divider } from '../Divider'
import { MaterialIcon } from '../Icons/MaterialIcon'
import Image from '../Image'
import ImageContainer from '../ImageContainer'
import Table from '../Table'
import { Typography } from '../Typography'
import { Divider } from "../Divider"
import { MaterialIcon } from "../Icons/MaterialIcon"
import Image from "../Image"
import ImageContainer from "../ImageContainer"
import Table from "../Table"
import { Typography } from "../Typography"
import {
extractAvailableListClassNames,
hasAvailableParagraphFormat,
} from './utils'
} from "./utils"
import styles from './jsontohtml.module.css'
import styles from "./jsontohtml.module.css"
import {
DeprecatedImageVaultAssetResponse,
ImageVaultAssetResponse,
mapImageVaultAssetResponseToImageVaultAsset,
mapInsertResponseToImageVaultAsset,
} from '@scandic-hotels/common/utils/imageVault'
import { TextLink } from '../TextLink'
import type { EmbedByUid } from './JsonToHtml'
import type { Attributes } from './types/rte/attrs'
} from "@scandic-hotels/common/utils/imageVault"
import { TextLink } from "../TextLink"
import type { EmbedByUid } from "./JsonToHtml"
import type { Attributes } from "./types/rte/attrs"
import {
AvailableParagraphFormatEnum,
RTEItemTypeEnum,
RTETypeEnum,
} from './types/rte/enums'
} from "./types/rte/enums"
import {
type RTEDefaultNode,
type RTEImageNode,
@@ -36,11 +36,11 @@ import {
type RTENode,
type RTERegularNode,
type RTETextNode,
} from './types/rte/node'
import type { RenderOptions } from './types/rte/option'
} from "./types/rte/node"
import type { RenderOptions } from "./types/rte/option"
function noNestedLinksOrReferences(node: RTENode) {
if ('type' in node) {
if ("type" in node) {
if (node.type === RTETypeEnum.reference) {
return node.children
} else if (node.type === RTETypeEnum.a) {
@@ -60,17 +60,17 @@ function extractPossibleAttributes(attrs: Attributes | undefined) {
props.id = attrs.id
}
if (attrs.class && typeof attrs.class === 'string') {
if (attrs.class && typeof attrs.class === "string") {
props.className = attrs.class
} else if (attrs['class-name']) {
props.className = attrs['class-name']
} else if (attrs.classname && typeof attrs.classname === 'string') {
} else if (attrs["class-name"]) {
props.className = attrs["class-name"]
} else if (attrs.classname && typeof attrs.classname === "string") {
props.className = attrs.classname
}
if (attrs.style?.['text-align']) {
if (attrs.style?.["text-align"]) {
props.style = {
textAlign: attrs.style['text-align'] as React.CSSProperties['textAlign'],
textAlign: attrs.style["text-align"] as React.CSSProperties["textAlign"],
}
}
@@ -94,9 +94,9 @@ export const renderOptions: RenderOptions = {
key={node.uid}
className={className}
{...props}
href={typeof node.attrs.url === 'string' ? node.attrs.url : ''}
href={typeof node.attrs.url === "string" ? node.attrs.url : ""}
target={
typeof node.attrs.target === 'string' ? node.attrs.target : '_blank'
typeof node.attrs.target === "string" ? node.attrs.target : "_blank"
}
isInline
>
@@ -310,9 +310,9 @@ export const renderOptions: RenderOptions = {
// Determine whether to use a div or p based on children.
// Some children use div or sections as wrappers and these are
// not allowed inside p tags.
const Elem = node.children.some((child) => 'children' in child)
? 'div'
: 'p'
const Elem = node.children.some((child) => "children" in child)
? "div"
: "p"
return (
<Typography key={node.uid} variant="Body/Paragraph/mdRegular">
@@ -374,17 +374,17 @@ export const renderOptions: RenderOptions = {
next: RTENext,
fullRenderOptions: RenderOptions
) => {
if (!('attrs' in node)) {
if (!("attrs" in node)) {
return null
}
const type = node.attrs.type
if (type === RTEItemTypeEnum.asset) {
const imageTypeRegex = /^image\//
const isImage = imageTypeRegex.test(node.attrs['asset-type'] as string)
const isImage = imageTypeRegex.test(node.attrs["asset-type"] as string)
if (isImage) {
const image = embeds?.[node?.attrs?.['asset-uid'] as string]
if (image?.node.__typename === 'SysAsset') {
const image = embeds?.[node?.attrs?.["asset-uid"] as string]
if (image?.node.__typename === "SysAsset") {
if (image.node.url) {
const alt = image?.node?.title ?? node.attrs.alt
const { className, ...props } = extractPossibleAttributes(
@@ -404,7 +404,7 @@ export const renderOptions: RenderOptions = {
)
}
}
} else if (node.attrs['display-type'] === 'link' && node.attrs.href) {
} else if (node.attrs["display-type"] === "link" && node.attrs.href) {
const { className, ...props } = extractPossibleAttributes(node.attrs)
return (
<TextLink
@@ -429,9 +429,9 @@ export const renderOptions: RenderOptions = {
}
if (type === RTEItemTypeEnum.entry) {
const entry = embeds?.[node?.attrs?.['entry-uid'] as string]
const entry = embeds?.[node?.attrs?.["entry-uid"] as string]
if (entry?.node.__typename === 'ImageContainer') {
if (entry?.node.__typename === "ImageContainer") {
if (entry.node.image_left && entry.node.image_right) {
return (
<ImageContainer
@@ -443,17 +443,17 @@ export const renderOptions: RenderOptions = {
}
return null
} else if (
entry?.node.__typename === 'AccountPage' ||
entry?.node.__typename === 'CampaignOverviewPage' ||
entry?.node.__typename === 'CampaignPage' ||
entry?.node.__typename === 'CollectionPage' ||
entry?.node.__typename === 'ContentPage' ||
entry?.node.__typename === 'DestinationCityPage' ||
entry?.node.__typename === 'DestinationCountryPage' ||
entry?.node.__typename === 'DestinationOverviewPage' ||
entry?.node.__typename === 'HotelPage' ||
entry?.node.__typename === 'LoyaltyPage' ||
entry?.node.__typename === 'StartPage'
entry?.node.__typename === "AccountPage" ||
entry?.node.__typename === "CampaignOverviewPage" ||
entry?.node.__typename === "CampaignPage" ||
entry?.node.__typename === "CollectionPage" ||
entry?.node.__typename === "ContentPage" ||
entry?.node.__typename === "DestinationCityPage" ||
entry?.node.__typename === "DestinationCountryPage" ||
entry?.node.__typename === "DestinationOverviewPage" ||
entry?.node.__typename === "HotelPage" ||
entry?.node.__typename === "LoyaltyPage" ||
entry?.node.__typename === "StartPage"
) {
// If entry is not an ImageContainer, it is a page and we return it as a link
const { className, ...props } = extractPossibleAttributes(node.attrs)
@@ -490,18 +490,18 @@ export const renderOptions: RenderOptions = {
[RTETypeEnum.ImageVault]: (node: RTEImageNode) => {
const type = node.type
if (!('attrs' in node) || type !== RTETypeEnum.ImageVault) {
if (!("attrs" in node) || type !== RTETypeEnum.ImageVault) {
return null
}
let image = undefined
if ('imageVaultId' in node.attrs && 'fileName' in node.attrs) {
if ("imageVaultId" in node.attrs && "fileName" in node.attrs) {
image = mapImageVaultAssetResponseToImageVaultAsset(
node.attrs as unknown as ImageVaultAssetResponse
)
}
if ('Name' in node.attrs && 'Id' in node.attrs) {
if ("Name" in node.attrs && "Id" in node.attrs) {
image = mapInsertResponseToImageVaultAsset(
node.attrs as unknown as DeprecatedImageVaultAssetResponse
)
@@ -765,7 +765,7 @@ export const renderOptions: RenderOptions = {
)
}
if (className === AvailableParagraphFormatEnum['script-1']) {
if (className === AvailableParagraphFormatEnum["script-1"]) {
return (
<Typography key={id} variant="Title/Decorative/lg">
<p className={cx(styles.p, propsClassName)} {...props}>
@@ -775,7 +775,7 @@ export const renderOptions: RenderOptions = {
)
}
if (className === AvailableParagraphFormatEnum['script-2']) {
if (className === AvailableParagraphFormatEnum["script-2"]) {
return (
<Typography key={id} variant="Title/Decorative/md">
<p className={cx(styles.p, propsClassName)} {...props}>
@@ -785,7 +785,7 @@ export const renderOptions: RenderOptions = {
)
}
if (className === AvailableParagraphFormatEnum['subtitle-1']) {
if (className === AvailableParagraphFormatEnum["subtitle-1"]) {
return (
<Typography key={id} variant="Title/Subtitle/lg">
<p className={cx(styles.p, propsClassName)} {...props}>
@@ -794,7 +794,7 @@ export const renderOptions: RenderOptions = {
</Typography>
)
}
if (className === AvailableParagraphFormatEnum['subtitle-2']) {
if (className === AvailableParagraphFormatEnum["subtitle-2"]) {
return (
<Typography key={id} variant="Title/Subtitle/md">
<p className={cx(styles.p, propsClassName)} {...props}>