Skip to content

Commit

Permalink
biome rule update
Browse files Browse the repository at this point in the history
  • Loading branch information
mohammadualam authored and BolajiOlajide committed Jul 31, 2024
1 parent 4a9641c commit 265c5ec
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 33 deletions.
3 changes: 3 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
"noNonNullAssertion": "off",
"noParameterAssign": "off",
"useTemplate": "off"
},
"security": {
"noDangerouslySetInnerHtml": "off"
}
},
"ignore": ["client/browser/src/types/webextension-polyfill/index.d.ts"]
Expand Down
61 changes: 29 additions & 32 deletions lib/ui-react/src/chip/Chip.tsx
Original file line number Diff line number Diff line change
@@ -1,37 +1,34 @@
import type { Annotation } from "@openctx/schema";
import { renderHoverToHTML } from "@openctx/ui-common";
import DOMPurify from "dompurify";
import type { FunctionComponent } from "react";
import { BaseChip } from "./BaseChip.js";
import type { Annotation } from '@openctx/schema'
import { renderHoverToHTML } from '@openctx/ui-common'
import DOMPurify from 'dompurify'
import type { FunctionComponent } from 'react'
import { BaseChip } from './BaseChip.js'
/**
* A single OpenCtx annotation, displayed as a "chip".
*/
export const Chip: FunctionComponent<{
annotation: Annotation;
className?: string;
popoverClassName?: string;
annotation: Annotation
className?: string
popoverClassName?: string
}> = ({ annotation: { item }, className, popoverClassName }) => {
const renderedHover = renderHoverToHTML(item.ui?.hover);
return (
<BaseChip
title={item.title}
url={item.url}
className={className}
popover={
renderedHover ? (
renderedHover.format === "text" ? (
<div>{renderedHover.value}</div>
) : (
/* biome-ignore lint/security/noDangerouslySetInnerHtml: input is sanitized by renderHoverToHTML */
<div
dangerouslySetInnerHTML={{
__html: DOMPurify.sanitize(renderedHover.value),
}}
/>
)
) : null
}
popoverClassName={popoverClassName}
/>
);
};
const renderedHover = renderHoverToHTML(item.ui?.hover)
return (
<BaseChip
title={item.title}
url={item.url}
className={className}
popover={
renderedHover ? (
renderedHover.format === 'text' ? (
<div>{renderedHover.value}</div>
) : (
<div
dangerouslySetInnerHTML={{ __html: DOMPurify.sanitize(renderedHover.value) }}
/>
)
) : null
}
popoverClassName={popoverClassName}
/>
)
}
1 change: 0 additions & 1 deletion web/src/content/ContentPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ export const ContentPage: FunctionComponent<{ content: ContentPages }> = ({ cont
<ContentPageComponent />
</div>
) : pageContext.contentPageHtml ? (
// biome-ignore lint/security/noDangerouslySetInnerHtml: The input value does not come from the user.
<div
dangerouslySetInnerHTML={{
__html: DOMPurify.sanitize(pageContext.contentPageHtml.toString()),
Expand Down

0 comments on commit 265c5ec

Please sign in to comment.