Skip to content

Commit

Permalink
refactor: linting warnings related to the react-compiler
Browse files Browse the repository at this point in the history
  • Loading branch information
SeanCassiere committed Sep 7, 2024
1 parent bbdacea commit 0b322d9
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 40 deletions.
72 changes: 38 additions & 34 deletions src/components/ui/input-datetime.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ interface InputDatetimeProps extends React.HTMLAttributes<HTMLDivElement> {

function InputDatetime(props: InputDatetimeProps) {
const elementId = React.useRef(generateShortId());
// eslint-disable-next-line react-compiler/react-compiler
const id = props.id ?? elementId.current;

const [date, setDate] = React.useState<Date | undefined>(
Expand Down Expand Up @@ -62,42 +63,45 @@ function InputDatetime(props: InputDatetimeProps) {
className="flex h-10 items-center justify-start gap-0.5 rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background duration-100 focus-within:border-input focus-within:outline-none focus-within:ring-2 focus-within:ring-ring focus-within:ring-offset-2 focus-within:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50"
{...getRootProps()}
>
{segments.map((segment, idx) => {
if (segment.type === "separator") {
{
// eslint-disable-next-line react-compiler/react-compiler
segments.map((segment, idx) => {
if (segment.type === "separator") {
return (
<span
key={`${id}-separator-${idx}`}
className="separator m-0 font-mono text-[60%] text-muted-foreground"
>
{segment.value}
</span>
);
}

const inputId = idx === 0 ? id : `${id}-${segment.type}`;
const placeholder =
segment.type !== "am/pm" ? segment.value : undefined;

return (
<span
key={`${id}-separator-${idx}`}
className="separator m-0 font-mono text-[60%] text-muted-foreground"
>
{segment.value}
</span>
<input
key={`${id}-${segment.type}-${idx}`}
id={inputId}
placeholder={placeholder}
disabled={props.disabled}
readOnly={props.readOnly}
onFocus={props.onDateFocus}
onBlur={props.onDateBlur}
className="inline-block h-full flex-grow-0 rounded-sm border-none bg-transparent px-0.5 font-sans text-sm tabular-nums text-foreground caret-transparent outline-none ring-0 selection:bg-foreground selection:text-background placeholder:font-mono focus:bg-foreground focus:text-background focus:ring-0"
style={
{
"--char-length": `${segment.type === "years" ? 4 : segment.type === "am/pm" ? 2.5 : 2}ch`,
minWidth: "calc(var(--char-length) + 0.25rem)",
} as React.CSSProperties
}
{...getInputProps(segment.type)}
/>
);
}

const inputId = idx === 0 ? id : `${id}-${segment.type}`;
const placeholder =
segment.type !== "am/pm" ? segment.value : undefined;

return (
<input
key={`${id}-${segment.type}-${idx}`}
id={inputId}
placeholder={placeholder}
disabled={props.disabled}
readOnly={props.readOnly}
onFocus={props.onDateFocus}
onBlur={props.onDateBlur}
className="inline-block h-full flex-grow-0 rounded-sm border-none bg-transparent px-0.5 font-sans text-sm tabular-nums text-foreground caret-transparent outline-none ring-0 selection:bg-foreground selection:text-background placeholder:font-mono focus:bg-foreground focus:text-background focus:ring-0"
style={
{
"--char-length": `${segment.type === "years" ? 4 : segment.type === "am/pm" ? 2.5 : 2}ch`,
minWidth: "calc(var(--char-length) + 0.25rem)",
} as React.CSSProperties
}
{...getInputProps(segment.type)}
/>
);
})}
})
}
</div>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ function ReportTableContent<TData, TValue>(
}
return colSizes;
// eslint-disable-next-line react-compiler/react-compiler
// eslint-disable-next-line react-hooks/exhaustive-deps, react-compiler/react-compiler
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [table.getState().columnSizingInfo, table.getFlatHeaders()]);

const visibleColumns = React.useMemo(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const ViewColumns: ReportTablePlugin = (props) => {
const allLeafColumns = React.useMemo(
() => table.getAllLeafColumns(),
// eslint-disable-next-line react-compiler/react-compiler
// eslint-disable-next-line react-hooks/exhaustive-deps, react-compiler/react-compiler
// eslint-disable-next-line react-hooks/exhaustive-deps
[table.getAllLeafColumns()]
);

Expand Down
2 changes: 1 addition & 1 deletion src/routes/_auth/-modules/table-list/column-visibility.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function TableListColumnVisibilityDropdown() {
const columns = React.useMemo(
() => table.getAllColumns(),
// eslint-disable-next-line react-compiler/react-compiler
// eslint-disable-next-line react-hooks/exhaustive-deps, react-compiler/react-compiler
// eslint-disable-next-line react-hooks/exhaustive-deps
[table.getAllColumns()]
);

Expand Down
2 changes: 1 addition & 1 deletion src/routes/_auth/-modules/table-list/content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function TableListContent(props: TableListContentProps) {
const rowModel = React.useMemo(
() => table.getRowModel(),
// eslint-disable-next-line react-compiler/react-compiler
// eslint-disable-next-line react-hooks/exhaustive-deps, react-compiler/react-compiler
// eslint-disable-next-line react-hooks/exhaustive-deps
[table.getRowModel()]
);

Expand Down
4 changes: 2 additions & 2 deletions src/routes/_auth/-modules/table-list/toolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ function TableListToolbarActions({
const tableFilters = React.useMemo(
() => table.getState().columnFilters,
// eslint-disable-next-line react-compiler/react-compiler
// eslint-disable-next-line react-hooks/exhaustive-deps, react-compiler/react-compiler
// eslint-disable-next-line react-hooks/exhaustive-deps
[table.getState().columnFilters]
);

Expand Down Expand Up @@ -280,7 +280,7 @@ function ToolbarFilter({
const baseState = React.useMemo(
() => table.getState().columnFilters.find((item) => item.id === id),
// eslint-disable-next-line react-compiler/react-compiler
// eslint-disable-next-line react-hooks/exhaustive-deps, react-compiler/react-compiler
// eslint-disable-next-line react-hooks/exhaustive-deps
[id, table.getState().columnFilters]
);

Expand Down

0 comments on commit 0b322d9

Please sign in to comment.