Skip to content

Commit 3bd6b68

Browse files
committed
fix: lint errors
1 parent d765b01 commit 3bd6b68

6 files changed

Lines changed: 25 additions & 12 deletions

File tree

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
"scripts": {
77
"dev": "vite",
88
"build": "tsc -b && vite build",
9-
"lint": "biome check --write src",
9+
"lint": "biome check src",
1010
"lint:fix": "biome check --write src ",
11-
"format": "biome format --write \"src/**/*.{ts,tsx,css,md}\"",
11+
"format": "biome format --write src",
1212
"preview": "vite preview"
1313
},
1414
"dependencies": {

src/api/fcb/query.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import init, {
1+
import {
22
type AsyncFeatureIter,
33
HttpFcbReader,
44
WasmAttrQuery,

src/api/fcb/types.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,11 @@ export interface CjInfo {
2424
};
2525
}
2626

27+
export const validOperators = ["Gt", "Ge", "Eq", "Lt", "Le"] as const;
2728
// Types for attribute conditions
2829
export interface Condition {
2930
attribute: string;
30-
operator: "Gt" | "Ge" | "Eq" | "Lt" | "Le";
31+
operator: (typeof validOperators)[number];
3132
value: string | number;
3233
}
3334

src/components/ui/label.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const Label = React.forwardRef<
55
HTMLLabelElement,
66
React.LabelHTMLAttributes<HTMLLabelElement>
77
>(({ className, ...props }, ref) => (
8+
// biome-ignore lint/a11y/noLabelWithoutControl: <explanation> TODO refactor this components
89
<label
910
ref={ref}
1011
className={cn(

src/feature/attribute/hooks.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
import type { Condition as ConditionType } from "@/api/fcb";
1+
import {
2+
type Condition as ConditionType,
3+
validOperators,
4+
} from "@/api/fcb/types";
25
import { attributeConditionsAtom } from "@/store";
36
import { useAtom } from "jotai";
47

@@ -11,7 +14,6 @@ type Props = {
1114
export const useAttributeConditionForm = ({
1215
handleFetchFcbWithAttributeConditions,
1316
}: Props) => {
14-
// Use Jotai atom instead of local state
1517
const [conditions, setConditions] = useAtom(attributeConditionsAtom);
1618

1719
const updateCondition = (
@@ -27,7 +29,11 @@ export const useAttributeConditionForm = ({
2729
newConditions[index][key] = Number.isNaN(num) ? value : num;
2830
} else if (key === "operator") {
2931
// Ensure the operator is one of the valid types
30-
newConditions[index][key] = value as Condition["operator"];
32+
if (validOperators.includes(value as Condition["operator"])) {
33+
newConditions[index][key] = value as Condition["operator"];
34+
} else {
35+
return prev;
36+
}
3137
} else {
3238
// For attribute field
3339
newConditions[index][key] = value;

src/main.tsx

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,13 @@ import { createRoot } from "react-dom/client";
33
import "./index.css";
44
import App from "./App.tsx";
55

6-
createRoot(document.getElementById("root")!).render(
7-
<StrictMode>
8-
<App />
9-
</StrictMode>,
10-
);
6+
const rootElement = document.getElementById("root");
7+
if (rootElement) {
8+
createRoot(rootElement).render(
9+
<StrictMode>
10+
<App />
11+
</StrictMode>,
12+
);
13+
} else {
14+
console.error("Root element not found");
15+
}

0 commit comments

Comments
 (0)