Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: turn on noUncheckedIndexedAccess to remove class of bugs #445

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const ArticlePageHeader = ({
<p className="text-sm text-gray-800">{date}</p>

<div className="text-xl tracking-tight text-gray-500 md:text-2xl">
{summary.length === 1 ? (
{summary.length === 1 && summary[0] ? (
<BaseParagraph content={summary[0]} />
) : (
<ul className="list-disc ps-7">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@ const Breadcrumb = ({ links, LinkComponent = "a" }: BreadcrumbProps) => {
return (
<nav aria-label="Breadcrumb">
<ol role="list" className={compoundStyles.nav()}>
<li className={compoundStyles.container()}>
<LinkComponent href={root.url} className={compoundStyles.link()}>
{root.title}
</LinkComponent>
</li>
{root && (
<li className={compoundStyles.container()}>
<LinkComponent href={root.url} className={compoundStyles.link()}>
{root.title}
</LinkComponent>
</li>
)}
{rest.map((link, index) => {
return (
<li key={index} className={compoundStyles.container()}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,19 @@ const getStickyRowIndexes = (tableRows: TableProps["content"]) => {

tableRows
.map((row) => row.content[0])
.forEach(({ attrs }, index) => {
if (!stickyRowIndexes.includes(index)) {
// Index has already been removed by an earlier rowSpan
return
}

if (attrs?.rowspan) {
// Exclude the next few rows that are covered by the rowSpan
stickyRowIndexes = stickyRowIndexes.filter(
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
(value) => value <= index || value >= index + attrs.rowspan!,
)
.forEach((row, index) => {
if (row?.attrs) {
if (!stickyRowIndexes.includes(index)) {
// Index has already been removed by an earlier rowSpan
return
}
const rowspan = row.attrs.rowspan
if (rowspan !== undefined) {
// Exclude the next few rows that are covered by the rowSpan
stickyRowIndexes = stickyRowIndexes.filter(
(value) => value <= index || value >= index + rowspan,
)
}
}
})

Expand Down Expand Up @@ -78,7 +79,7 @@ const Table = ({ attrs: { caption }, content }: TableProps) => {
<tbody>
{content.map((row, index) => {
const TableCellTag =
row.content[0].type === "tableHeader" ? "th" : "td"
row.content[0]?.type === "tableHeader" ? "th" : "td"

return (
<tr
Expand Down
1 change: 1 addition & 0 deletions packages/components/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"resolveJsonModule": true /* Include modules imported with .json extension. */,
"strictBindCallApply": true /* Enable strict 'bind', 'call', and 'apply' methods on functions. */,
"strict": true /* Enable all strict type-checking options. */,
"noUncheckedIndexedAccess": true,
"skipLibCheck": true,
/* Strict Type-Checking Options */
// "noImplicitAny": true,
Expand Down
Loading