Skip to content

Commit 5a1085c

Browse files
committed
chore: update linting commands and configuration
- Renamed `format-and-lint` scripts to `lint` for clarity and consistency. - Adjusted Biome configuration to disable automatic import organization. - Updated AGENTS.md and package.json to reflect these changes. - Enhanced type definitions in various components for better type safety.
1 parent 0bd9cd3 commit 5a1085c

26 files changed

+156
-114
lines changed

AGENTS.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
- `yarn build`: Build all packages/apps.
1313
- `yarn serve`: Serve built Storybook (`apps/docs`).
1414
- `yarn test`: Run workspace tests (Storybook test-runner in `apps/docs`).
15-
- `yarn format-and-lint` | `:fix`: Check/auto-fix with Biome.
15+
- `yarn lint` | `:fix`: Check/auto-fix with Biome.
1616
- Per workspace (examples):
1717
- `yarn workspace @lambdacurry/forms build`
1818
- `yarn workspace @lambdacurry/forms-docs dev`
@@ -34,7 +34,7 @@
3434
- Commits: short imperative subject, optional scope, concise body explaining rationale.
3535
- Example: `Fix: remove deprecated dropdown select`.
3636
- PRs: clear description, linked issues, screenshots or Storybook links, notes on testing.
37-
- Required checks: `yarn format-and-lint` passes; build succeeds; tests updated/added.
37+
- Required checks: `yarn lint` passes; build succeeds; tests updated/added.
3838
- Versioning: when changing published package(s), add a Changeset (`yarn changeset`) before merge.
3939

4040
## Security & Configuration

apps/docs/src/remix-hook-form/data-table/data-table-router-form.stories.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,8 +302,7 @@ export default meta;
302302
type Story = StoryObj<typeof meta>;
303303

304304
export const Default: Story = {
305-
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
306-
args: {} as any, // Args for DataTableRouterForm if needed, handled by Example component
305+
args: {} satisfies Record<string, unknown>, // Args for DataTableRouterForm if needed, handled by Example component
307306
render: () => <DataTableRouterFormExample />,
308307
parameters: {
309308
docs: {

apps/docs/src/remix-hook-form/form-error-custom.stories.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,14 @@ type FormData = z.infer<typeof formSchema>;
1919
// Custom error message component with icon
2020
const AlertErrorMessage = (props: React.ComponentProps<typeof FormMessage>) => (
2121
<div className="flex items-center p-4 bg-red-50 border-l-4 border-red-400 rounded-md">
22-
<svg className="h-5 w-5 text-red-400 mr-3" viewBox="0 0 20 20" fill="currentColor">
22+
<svg
23+
className="h-5 w-5 text-red-400 mr-3"
24+
viewBox="0 0 20 20"
25+
fill="currentColor"
26+
role="img"
27+
aria-labelledby="alert-icon-title"
28+
>
29+
<title id="alert-icon-title">Error</title>
2330
<path
2431
fillRule="evenodd"
2532
d="M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z"

apps/docs/src/remix-hook-form/form-error.test.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { render, screen } from '@testing-library/react';
55
import { useFetcher } from 'react-router';
66
import { RemixFormProvider, useRemixForm } from 'remix-hook-form';
77
import { z } from 'zod';
8+
import type { ElementType, PropsWithChildren } from 'react';
89

910
// Mock useFetcher
1011
jest.mock('react-router', () => ({
@@ -30,14 +31,14 @@ const TestFormWithError = ({
3031
}: {
3132
initialErrors?: Record<string, { message: string }>;
3233
formErrorName?: string;
33-
customComponents?: any;
34+
customComponents?: { FormMessage?: React.ComponentType<PropsWithChildren<Record<string, unknown>>> };
3435
className?: string;
3536
}) => {
3637
const mockFetcher = {
3738
data: { errors: initialErrors },
3839
state: 'idle' as const,
3940
submit: jest.fn(),
40-
Form: 'form' as any,
41+
Form: 'form' as ElementType,
4142
};
4243

4344
mockUseFetcher.mockReturnValue(mockFetcher);
@@ -142,7 +143,7 @@ describe('FormError Component', () => {
142143

143144
describe('Component Customization', () => {
144145
it('uses custom FormMessage component when provided', () => {
145-
const CustomFormMessage = ({ children, ...props }: any) => (
146+
const CustomFormMessage = ({ children, ...props }: PropsWithChildren<Record<string, unknown>>) => (
146147
<div data-testid="custom-form-message" className="custom-message" {...props}>
147148
Custom: {children}
148149
</div>
@@ -216,7 +217,7 @@ describe('FormError Component', () => {
216217
},
217218
state: 'idle' as const,
218219
submit: jest.fn(),
219-
Form: 'form' as any,
220+
Form: 'form' as ElementType,
220221
};
221222

222223
mockUseFetcher.mockReturnValue(mockFetcher);
@@ -314,7 +315,7 @@ describe('FormError Component', () => {
314315
it('does not re-render unnecessarily when unrelated form state changes', () => {
315316
const renderSpy = jest.fn();
316317

317-
const CustomFormMessage = ({ children, ...props }: any) => {
318+
const CustomFormMessage = ({ children, ...props }: PropsWithChildren<Record<string, unknown>>) => {
318319
renderSpy();
319320
return <div {...props}>{children}</div>;
320321
};
@@ -344,7 +345,7 @@ describe('FormError Integration Tests', () => {
344345
data: null,
345346
state: 'idle' as const,
346347
submit: jest.fn(),
347-
Form: 'form' as any,
348+
Form: 'form' as ElementType,
348349
};
349350

350351
mockUseFetcher.mockReturnValue(mockFetcher);

apps/docs/src/remix-hook-form/phone-input.test.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import userEvent from '@testing-library/user-event';
66
import { useFetcher } from 'react-router';
77
import { RemixFormProvider, useRemixForm } from 'remix-hook-form';
88
import { z } from 'zod';
9+
import type { ElementType, PropsWithChildren } from 'react';
910

1011
// Mock useFetcher
1112
jest.mock('react-router', () => ({
@@ -28,13 +29,13 @@ const TestPhoneInputForm = ({
2829
customComponents = {},
2930
}: {
3031
initialErrors?: Record<string, { message: string }>;
31-
customComponents?: any;
32+
customComponents?: { FormMessage?: React.ComponentType<PropsWithChildren<Record<string, unknown>>> };
3233
}) => {
3334
const mockFetcher = {
3435
data: { errors: initialErrors },
3536
state: 'idle' as const,
3637
submit: jest.fn(),
37-
Form: 'form' as any,
38+
Form: 'form' as ElementType,
3839
};
3940

4041
mockUseFetcher.mockReturnValue(mockFetcher);
@@ -151,7 +152,7 @@ describe('PhoneInput Component', () => {
151152

152153
describe('Component Customization', () => {
153154
it('uses custom FormMessage component when provided', () => {
154-
const CustomFormMessage = ({ children, ...props }: any) => (
155+
const CustomFormMessage = ({ children, ...props }: PropsWithChildren<Record<string, unknown>>) => (
155156
<div data-testid="custom-form-message" className="custom-message" {...props}>
156157
Custom: {children}
157158
</div>

biome.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"ignoreUnknown": false,
1010
"includes": ["**", "!**/.turbo", "!**/yarn.lock", "!**/dist", "!**/node_modules", "!**/storybook-static"]
1111
},
12-
"assist": { "actions": { "source": { "organizeImports": "on" } } },
12+
"assist": { "actions": { "source": { "organizeImports": "off" } } },
1313
"formatter": {
1414
"enabled": true,
1515
"formatWithErrors": false,
@@ -45,12 +45,15 @@
4545
},
4646
"suspicious": {
4747
"noConsole": "off",
48-
"noReactSpecificProps": "off"
48+
"noReactSpecificProps": "off",
49+
"noUnknownAtRules": "off"
4950
},
5051
"correctness": {
5152
"noNodejsModules": "off",
5253
"noUndeclaredDependencies": "off",
53-
"useImportExtensions": "off"
54+
"useImportExtensions": "off",
55+
"noUnusedVariables": "off",
56+
"useUniqueElementIds": "off"
5457
}
5558
}
5659
}

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
"serve": "turbo run serve",
1414
"test": "turbo run test",
1515
"clean": "find . -name '.turbo' -type d -prune -exec rm -rf {} + && find . -name 'node_modules' -type d -prune -exec rm -rf {} + && find . -name 'yarn.lock' -type f -delete",
16-
"format-and-lint": "biome check .",
17-
"format-and-lint:fix": "biome check . --write",
16+
"lint": "biome check .",
17+
"lint:fix": "biome check . --write",
1818
"prerelease": "turbo run build",
1919
"release": "changeset publish",
2020
"build-storybook": "turbo run build-storybook"

packages/components/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@
2626
"import": "./dist/ui/*.js"
2727
}
2828
},
29-
"files": ["dist"],
29+
"files": [
30+
"dist"
31+
],
3032
"scripts": {
3133
"prepublishOnly": "yarn run build",
3234
"build": "vite build",

packages/components/src/remix-hook-form/data-table-router-form.tsx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ export interface DataTableRouterFormProps<TData, TValue> {
3636
pageCount?: number;
3737
defaultStateValues?: Partial<DataTableRouterState>;
3838
// New prop for Bazza UI filter configurations
39-
// This should be typed according to bazza/ui's ColumnConfig type (e.g., from createColumnConfigHelper(...).build())
40-
filterColumnConfigs: any[]; // Placeholder type for Bazza UI ColumnConfig[]
39+
// Shape is intentionally loose to allow passing configs from various sources without tight coupling
40+
filterColumnConfigs: unknown[];
4141
// Props for server-fetched options/faceted data for bazza/ui, if needed for server strategy
42-
dtfOptions?: Record<string, any[]>;
43-
dtfFacetedData?: Record<string, any>;
42+
dtfOptions?: unknown;
43+
dtfFacetedData?: unknown;
4444
}
4545

4646
export function DataTableRouterForm<TData, TValue>({
@@ -69,9 +69,10 @@ export function DataTableRouterForm<TData, TValue>({
6969
} = useDataTableFilters({
7070
strategy: 'server',
7171
data: data,
72-
columnsConfig: filterColumnConfigs,
73-
options: dtfOptions,
74-
faceted: dtfFacetedData,
72+
// Cast to the exact parameter type to preserve strong typing without using `any`
73+
columnsConfig: filterColumnConfigs as Parameters<typeof useDataTableFilters>[0]['columnsConfig'],
74+
options: dtfOptions as Parameters<typeof useDataTableFilters>[0]['options'],
75+
faceted: dtfFacetedData as Parameters<typeof useDataTableFilters>[0]['faceted'],
7576
filters: urlState.filters, // Use URL filters as the source of truth
7677
onFiltersChange: (newFilters) => {
7778
// Update URL state when filters change

packages/components/src/remix-hook-form/data-table-router-toolbar.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { type ChangeEvent, useCallback } from 'react';
55
import { Button } from '../ui/button';
66
import { DataTableViewOptions } from '../ui/data-table/data-table-view-options';
77
import { DataTableFilter } from '../ui/data-table-filter';
8+
import type { Column, DataTableFilterActions, FilterStrategy } from '../ui/data-table-filter/core/types';
89
import type { BazzaFiltersState } from './data-table-router-parsers';
910
import { TextField } from './text-field';
1011

@@ -15,10 +16,10 @@ export interface DataTableRouterToolbarProps<TData> {
1516
onResetFiltersAndSearch: () => void;
1617
hasActiveFiltersOrSearch: boolean;
1718

18-
dtfColumns: any[];
19+
dtfColumns: Column<TData>[];
1920
dtfFilters: BazzaFiltersState;
20-
dtfActions: any;
21-
dtfStrategy: 'client' | 'server';
21+
dtfActions: DataTableFilterActions;
22+
dtfStrategy: FilterStrategy;
2223
}
2324

2425
export function DataTableRouterToolbar<TData>({

0 commit comments

Comments
 (0)