Skip to content

Commit eeb70e6

Browse files
committed
chore(core): implement senior-grade quality and dx improvements
- feat: add example CI pipeline config (disabled by default) - sec: enable strict 'noExplicitAny' and 'noDangerouslySetInnerHtml' - fix: mount Sonner Toaster in root router for global access - fix: ensure strict type safety on next-themes to sonner props - fix: resolve non-null assertion in main.tsx with runtime check - perf: improve QueryClient defaults with proper gcTime and retries - dev: configure React Query DevTools for runtime debugging - style: rename use-mobile.tsx to .ts as it lacks JSX - chore: configure test script with --passWithNoTests - chore: optimize husky pre-commit to use lint-staged - chore: remove dead interceptor code from api instance - chore: add explicit folders for features, services and store
1 parent ef20feb commit eeb70e6

15 files changed

Lines changed: 152 additions & 28 deletions

File tree

.biomeignore

Lines changed: 0 additions & 2 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# TEMPLATE SENIOR REACT - CI Pipeline Example
2+
# ----------------------------------------------------------------------
3+
# Este arquivo é providenciado apenas como referência e está DESATIVADO.
4+
# Sendo este repositório um "Template/Boilerplate", não rodamos CI
5+
# automáticos nele.
6+
#
7+
# Para ativar o CI na sua própria aplicação que nascer deste template,
8+
# remova os comentários (#) abaixo.
9+
# ----------------------------------------------------------------------
10+
11+
# name: CI Pipeline
12+
#
13+
# on:
14+
# push:
15+
# branches: [main]
16+
# pull_request:
17+
# branches: [main]
18+
#
19+
# jobs:
20+
# build-lint-test:
21+
# runs-on: ubuntu-latest
22+
# steps:
23+
# - name: Checkout Repository
24+
# uses: actions/checkout@v4
25+
#
26+
# - name: Setup Node.js
27+
# uses: actions/setup-node@v4
28+
# with:
29+
# node-version: '20'
30+
#
31+
# - name: Setup pnpm
32+
# uses: pnpm/action-setup@v4
33+
# with:
34+
# version: 10.33.0
35+
#
36+
# - name: Install Dependencies
37+
# run: pnpm install --frozen-lockfile
38+
#
39+
# - name: Typecheck
40+
# run: pnpm run typecheck
41+
#
42+
# - name: Lint (Biome)
43+
# run: pnpm run lint
44+
#
45+
# - name: Test (Vitest)
46+
# run: pnpm run test --passWithNoTests
47+
#
48+
# - name: Build
49+
# run: pnpm run build

.husky/pre-commit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
pnpm typecheck && pnpm lint:fix
1+
pnpm typecheck && pnpm dlx lint-staged

biome.json

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
},
88
"files": {
99
"ignoreUnknown": false,
10-
"includes": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.js", "src/**/*.jsx"]
10+
"includes": ["**/*.ts", "**/*.tsx", "**/*.js", "**/*.jsx", "**/*.json", "**/*.css"]
1111
},
1212
"formatter": {
1313
"enabled": true,
@@ -38,13 +38,13 @@
3838
"useExhaustiveDependencies": "warn"
3939
},
4040
"suspicious": {
41-
"noExplicitAny": "off",
41+
"noExplicitAny": "error",
4242
"noEmptyInterface": "warn",
4343
"noArrayIndexKey": "error",
4444
"noDocumentCookie": "off"
4545
},
4646
"security": {
47-
"noDangerouslySetInnerHtml": "off"
47+
"noDangerouslySetInnerHtml": "warn"
4848
},
4949
"a11y": {
5050
"useFocusableInteractive": "off",
@@ -80,5 +80,17 @@
8080
"organizeImports": "on"
8181
}
8282
}
83-
}
83+
},
84+
"overrides": [
85+
{
86+
"includes": ["src/routeTree.gen.ts"],
87+
"linter": {
88+
"rules": {
89+
"suspicious": {
90+
"noExplicitAny": "off"
91+
}
92+
}
93+
}
94+
}
95+
]
8496
}

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"lint:fix": "biome check --write . || true",
1818
"format": "biome format --write .",
1919
"typecheck": "tsc --noEmit",
20-
"test": "vitest run",
20+
"test": "vitest run --passWithNoTests",
2121
"test:watch": "vitest",
2222
"prepare": "husky"
2323
},
@@ -79,6 +79,7 @@
7979
"@fontsource-variable/geist": "^5.2.8",
8080
"@tailwindcss/typography": "^0.5.19",
8181
"@tailwindcss/vite": "^4.2.2",
82+
"@tanstack/react-query-devtools": "^5.95.2",
8283
"@tanstack/router-cli": "^1.166.18",
8384
"@tanstack/router-plugin": "^1.167.4",
8485
"@testing-library/react": "^16.3.2",

pnpm-lock.yaml

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/providers/query-provider.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
2+
import { ReactQueryDevtools } from '@tanstack/react-query-devtools';
23
import { type ReactNode, useState } from 'react';
34

45
export function AppQueryProvider({ children }: { children: ReactNode }) {
@@ -9,10 +10,20 @@ export function AppQueryProvider({ children }: { children: ReactNode }) {
910
queries: {
1011
refetchOnWindowFocus: false,
1112
staleTime: 5 * 60 * 1000,
13+
gcTime: 10 * 60 * 1000,
14+
retry: 1,
15+
},
16+
mutations: {
17+
retry: 0,
1218
},
1319
},
1420
})
1521
);
1622

17-
return <QueryClientProvider client={queryClient}>{children}</QueryClientProvider>;
23+
return (
24+
<QueryClientProvider client={queryClient}>
25+
{children}
26+
<ReactQueryDevtools initialIsOpen={false} position="bottom" />
27+
</QueryClientProvider>
28+
);
1829
}

src/components/ui/sonner.tsx

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import {
2+
CircleCheckIcon,
3+
InfoIcon,
4+
Loader2Icon,
5+
OctagonXIcon,
6+
TriangleAlertIcon,
7+
} from 'lucide-react';
8+
import { useTheme } from 'next-themes';
9+
import { Toaster as Sonner, type ToasterProps } from 'sonner';
10+
11+
const Toaster = ({ ...props }: ToasterProps) => {
12+
const { theme = 'system' } = useTheme();
13+
14+
return (
15+
<Sonner
16+
theme={theme === 'dark' || theme === 'light' || theme === 'system' ? theme : 'system'}
17+
className="toaster group"
18+
icons={{
19+
success: <CircleCheckIcon className="size-4" />,
20+
info: <InfoIcon className="size-4" />,
21+
warning: <TriangleAlertIcon className="size-4" />,
22+
error: <OctagonXIcon className="size-4" />,
23+
loading: <Loader2Icon className="size-4 animate-spin" />,
24+
}}
25+
style={
26+
{
27+
'--normal-bg': 'var(--popover)',
28+
'--normal-text': 'var(--popover-foreground)',
29+
'--normal-border': 'var(--border)',
30+
'--border-radius': 'var(--radius)',
31+
} as React.CSSProperties
32+
}
33+
toastOptions={{
34+
classNames: {
35+
toast: 'cn-toast',
36+
},
37+
}}
38+
{...props}
39+
/>
40+
);
41+
};
42+
43+
export { Toaster };

src/features/.gitkeep

Whitespace-only changes.

0 commit comments

Comments
 (0)