Skip to content

Commit 9424b9e

Browse files
authored
refactor: eslint fixes (#147)
1 parent 78a936c commit 9424b9e

File tree

85 files changed

+3877
-770
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+3877
-770
lines changed

.continue/rules/mcp-app-demo-standards.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ const users = await fetchUsers() // Let TypeScript infer User[]
4545
// ✅ Good: Generic constraints for reusable utilities
4646
function createApiResponse<T extends Record<string, unknown>>(
4747
data: T,
48-
status: 'success' | 'error' = 'success'
48+
status: 'success' | 'error' = 'success',
4949
): ApiResponse<T> {
5050
return { data, status, timestamp: Date.now() }
5151
}
@@ -86,14 +86,14 @@ interface ButtonProps {
8686
disabled?: boolean
8787
}
8888

89-
export default function Button({
90-
children,
91-
onClick,
89+
export default function Button({
90+
children,
91+
onClick,
9292
variant = 'primary',
93-
disabled = false
93+
disabled = false
9494
}: ButtonProps) {
9595
return (
96-
<button
96+
<button
9797
onClick={onClick}
9898
disabled={disabled}
9999
className={cn(buttonVariants({ variant }), disabled && 'opacity-50')}

.continue/rules/state-management.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,15 @@ export const Route = createFileRoute('/dashboard')({
4545

4646
function Dashboard() {
4747
const initialData = Route.useLoaderData()
48-
48+
4949
// Use React Query only for data that needs frequent updates
5050
const { data: liveMetrics } = useQuery({
5151
queryKey: ['live-metrics'],
5252
queryFn: fetchLiveMetrics,
5353
initialData: initialData.metrics,
5454
refetchInterval: 30000, // Update every 30 seconds
5555
})
56-
56+
5757
return <DashboardView user={initialData.user} metrics={liveMetrics} />
5858
}
5959

.continue/rules/styling-ui-guidelines.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,13 @@ You are an expert in Tailwind CSS and Shadcn/ui component development.
113113
// ✅ Good: Accessible modal with focus management
114114
function AccessibleModal({ isOpen, onClose, children }) {
115115
const modalRef = useRef<HTMLDivElement>(null)
116-
116+
117117
useEffect(() => {
118118
if (isOpen && modalRef.current) {
119119
modalRef.current.focus()
120120
}
121121
}, [isOpen])
122-
122+
123123
return (
124124
<Dialog open={isOpen} onOpenChange={onClose}>
125125
<DialogContent

.continue/rules/testing-guidelines.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,16 @@ describe('Button Component', () => {
3232
it('should call onClick when clicked', () => {
3333
const handleClick = vi.fn()
3434
render(<Button onClick={handleClick}>Click me</Button>)
35-
35+
3636
const button = screen.getByRole('button', { name: /click me/i })
3737
fireEvent.click(button)
38-
38+
3939
expect(handleClick).toHaveBeenCalledOnce()
4040
})
41-
41+
4242
it('should be disabled when disabled prop is true', () => {
4343
render(<Button disabled onClick={vi.fn()}>Click me</Button>)
44-
44+
4545
const button = screen.getByRole('button', { name: /click me/i })
4646
expect(button).toBeDisabled()
4747
})
@@ -62,13 +62,13 @@ import { renderWithRouter } from '@/test-utils'
6262
describe('UserDetail Route', () => {
6363
it('should display user information', () => {
6464
const mockUser = { id: '1', name: 'John Doe', email: '[email protected]' }
65-
65+
6666
renderWithRouter({
6767
component: UserDetail,
6868
loaderData: mockUser,
69-
path: '/users/1'
69+
path: '/users/1',
7070
})
71-
71+
7272
expect(screen.getByText('John Doe')).toBeInTheDocument()
7373
expect(screen.getByText('[email protected]')).toBeInTheDocument()
7474
})
@@ -89,13 +89,13 @@ import { useToggle } from '@/hooks/useToggle'
8989
describe('useToggle Hook', () => {
9090
it('should toggle value when called', () => {
9191
const { result } = renderHook(() => useToggle(false))
92-
92+
9393
expect(result.current[0]).toBe(false)
94-
94+
9595
act(() => {
9696
result.current[1]()
9797
})
98-
98+
9999
expect(result.current[0]).toBe(true)
100100
})
101101
})
@@ -108,7 +108,7 @@ describe('validateUser', () => {
108108
it('should validate correct user data', () => {
109109
const validUser = { id: '1', name: 'John', email: '[email protected]' }
110110
const result = validateUser(validUser)
111-
111+
112112
expect(result.success).toBe(true)
113113
expect(userSchema.safeParse(result.data).success).toBe(true)
114114
})
@@ -132,7 +132,7 @@ export function renderWithProviders(ui: React.ReactElement) {
132132
const queryClient = new QueryClient({
133133
defaultOptions: { queries: { retry: false } }
134134
})
135-
135+
136136
return render(
137137
<QueryClientProvider client={queryClient}>
138138
{ui}
@@ -147,4 +147,4 @@ export function renderWithProviders(ui: React.ReactElement) {
147147
• Use proper cleanup to prevent test pollution
148148
• Mock external dependencies at the appropriate level
149149
• Write tests that fail for the right reasons
150-
• Maintain test coverage for critical user flows and edge cases
150+
• Maintain test coverage for critical user flows and edge cases

.continue/rules/validation-zod.md

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -82,35 +82,38 @@ export const Route = createServerFileRoute('/api/users').methods({
8282
async POST({ request }) {
8383
const body = await request.json()
8484
const result = createUserSchema.safeParse(body)
85-
85+
8686
if (!result.success) {
87-
return new Response(JSON.stringify({
88-
error: 'Validation failed',
89-
details: result.error.flatten()
90-
}), {
91-
status: 400,
92-
headers: { 'Content-Type': 'application/json' }
93-
})
87+
return new Response(
88+
JSON.stringify({
89+
error: 'Validation failed',
90+
details: result.error.flatten(),
91+
}),
92+
{
93+
status: 400,
94+
headers: { 'Content-Type': 'application/json' },
95+
},
96+
)
9497
}
95-
98+
9699
const user = await createUser(result.data)
97100
return new Response(JSON.stringify(user), {
98-
headers: { 'Content-Type': 'application/json' }
101+
headers: { 'Content-Type': 'application/json' },
99102
})
100-
}
103+
},
101104
})
102105

103106
// ✅ Good: External API validation
104107
async function fetchUserFromAPI(id: string): Promise<User> {
105108
const response = await fetch(`/api/users/${id}`)
106109
const data = await response.json()
107-
110+
108111
// Always validate external API responses
109112
const result = userSchema.safeParse(data)
110113
if (!result.success) {
111114
throw new Error(`Invalid user data from API: ${result.error.message}`)
112115
}
113-
116+
114117
return result.data
115118
}
116119
```

.github/workflows/test.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ jobs:
2424
- name: Install dependencies
2525
run: npm ci
2626

27+
- name: Check for formatting errors
28+
run: npm run format:check
29+
2730
- name: Run tests
2831
run: npm run test:ci
2932
# This can be removed one we deploy to Netlify and Storybook deploying is a check for PRs. See https://github.com/pomerium/mcp-app-demo/issues/123

.storybook/preview.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
import React from 'react'
21
import type { Preview } from '@storybook/react-vite'
32
import '../src/styles.css'
4-
import { useEffect } from 'react'
53

64
const preview: Preview = {
75
parameters: {

.storybook/vitest.setup.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import * as a11yAddonAnnotations from "@storybook/addon-a11y/preview";
2-
import { setProjectAnnotations } from '@storybook/react-vite';
3-
import * as projectAnnotations from './preview';
1+
import * as a11yAddonAnnotations from '@storybook/addon-a11y/preview'
2+
import { setProjectAnnotations } from '@storybook/react-vite'
3+
import * as projectAnnotations from './preview'
44

55
// This is an important step to apply the right configuration when testing your stories.
66
// More info at: https://storybook.js.org/docs/api/portable-stories/portable-stories-vitest#setprojectannotations
7-
setProjectAnnotations([a11yAddonAnnotations, projectAnnotations]);
7+
setProjectAnnotations([a11yAddonAnnotations, projectAnnotations])

components.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@
1818
"hooks": "@/hooks"
1919
},
2020
"iconLibrary": "lucide"
21-
}
21+
}

eslint.config.js

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,34 @@
11
// For more info, see https://github.com/storybookjs/eslint-plugin-storybook#configuration-flat-config-format
2-
import storybook from "eslint-plugin-storybook";
2+
import storybook from 'eslint-plugin-storybook'
33

44
// @ts-check
55

6-
import { tanstackConfig } from "@tanstack/eslint-config";
6+
import { tanstackConfig } from '@tanstack/eslint-config'
77

8-
export default [...tanstackConfig, ...storybook.configs["flat/recommended"]];
8+
export default [
9+
{
10+
ignores: [
11+
'.nitro/**',
12+
'.output/**',
13+
'.netlify/**',
14+
'storybook-static/**',
15+
'eslint.config.js',
16+
'prettier.config.js',
17+
],
18+
},
19+
{
20+
rules: {
21+
// TypeScript unused variables (includes imports)
22+
'@typescript-eslint/no-unused-vars': [
23+
'error',
24+
{
25+
argsIgnorePattern: '^_',
26+
varsIgnorePattern: '^_',
27+
caughtErrorsIgnorePattern: '^_',
28+
},
29+
],
30+
},
31+
},
32+
...tanstackConfig,
33+
...storybook.configs['flat/recommended'],
34+
]

0 commit comments

Comments
 (0)