chore: add eslint, prettier, husky and commitlint tooling

This commit is contained in:
Arthur Bassi 2026-06-12 11:40:01 -03:00
parent 1632f1e656
commit 2121b86a8e
7 changed files with 145 additions and 0 deletions

View file

@ -0,0 +1,52 @@
---
description: SeaHaven Admin — arquitetura IrisLoan, convenções de rebuild seletivo
alwaysApply: true
---
# SeaHaven Admin — convenções IrisLoan
## Stack
- Vite SPA + React Router 7, TypeScript strict, Tailwind v4 + MUI
- HTTP: Ky com `credentials: "include"` (cookies httpOnly)
- Server state: TanStack Query; forms: React Hook Form + Zod
- **Não usar** em código novo: Next.js, Redux, axios, `apiUtil.js`, `tokenUtility.js`
## Estrutura alvo (`src/`)
```
api/ domain/<feature>/ app/ infra/query-key/ lib/ hooks/
components/ui|common|layout/ config/menu.ts providers/ main.tsx
```
- Alias `@/` para imports; arquivos novos em **kebab-case** (`use-debounce.ts`, `query-key.ts`)
- `pages/` é **somente referência** de endpoints e regras de negócio — deletar após entrega em `domain/` + `app/`
## HTTP e auth
- Centralizar paths em `api/api-paths.ts` e respostas em `api/handle-api-response.ts`
- Auth via AuthProvider + cookies; não criar slices Redux para sessão
## Estado e dados
- Cache e mutations: React Query + `infra/query-key/query-key.ts`
- Defaults do client em `lib/query/query-client.ts`
## Forms e UI
- Schemas Zod em `domain/<feature>/schemas/`; views finas em `app/`
- Tailwind utilitário + componentes MUI; **não** importar `site.css` em código novo
## Fluxo ao implementar feature
1. Consultar legado em `pages/<feature>/` (endpoints, campos, regras)
2. Criar `domain/<feature>/` (schemas, hooks, use-cases)
3. View fina em `app/` + rota em `app/routes.tsx`
4. Deletar `pages/<feature>/` quando a feature nova estiver pronta
## Tooling
- ESLint strict só em `.ts/.tsx` da arquitetura nova; legado em `pages/` ignorado
- Commits: Conventional Commits (`feat(scope): subject`)
Referência: `docs/ARCHITECTURE_PLAN.md`

1
.husky/commit-msg Normal file
View file

@ -0,0 +1 @@
npx commitlint --edit $1

1
.husky/pre-commit Normal file
View file

@ -0,0 +1 @@
npx lint-staged

13
.prettierignore Normal file
View file

@ -0,0 +1,13 @@
dist
build
node_modules
coverage
package-lock.json
*.tsbuildinfo
# Legacy — format incrementally when touched (lint-staged)
src/pages/**
src/**/*.js
src/**/*.jsx
src/**/*.css
!src/styles/globals.css

15
.prettierrc Normal file
View file

@ -0,0 +1,15 @@
{
"semi": true,
"singleQuote": false,
"trailingComma": "all",
"printWidth": 100,
"tabWidth": 2,
"overrides": [
{
"files": "*.mdc",
"options": {
"parser": "markdown"
}
}
]
}

1
commitlint.config.js Normal file
View file

@ -0,0 +1 @@
export default { extends: ["@commitlint/config-conventional"] };

62
eslint.config.js Normal file
View file

@ -0,0 +1,62 @@
import js from "@eslint/js";
import eslintConfigPrettier from "eslint-config-prettier";
import pluginReactHooks from "eslint-plugin-react-hooks";
import pluginReactRefresh from "eslint-plugin-react-refresh";
import globals from "globals";
import tseslint from "typescript-eslint";
const legacyIgnores = [
"src/pages/**",
"src/app/store.js",
"src/app/slices/**",
"src/lib/queryClient.js",
"src/hooks/**",
"src/components/**",
"src/constants/**",
"src/layouts/**",
"src/**/*.js",
"src/**/*.jsx",
];
export default tseslint.config(
{
ignores: ["dist/**", "build/**", "node_modules/**", "coverage/**", ...legacyIgnores],
},
js.configs.recommended,
...tseslint.configs.recommended,
eslintConfigPrettier,
{
files: [
"src/{api,domain,app,lib,providers,infra,config,hooks,components/auth}/**/*.{ts,tsx}",
"src/**/*.{ts,tsx}",
"vite.config.ts",
],
languageOptions: {
ecmaVersion: "latest",
sourceType: "module",
globals: globals.browser,
parserOptions: {
projectService: true,
tsconfigRootDir: import.meta.dirname,
},
},
plugins: {
"react-hooks": pluginReactHooks,
"react-refresh": pluginReactRefresh,
},
rules: {
...pluginReactHooks.configs.recommended.rules,
"react-hooks/set-state-in-effect": "off",
"react-hooks/exhaustive-deps": "warn",
"react-refresh/only-export-components": ["warn", { allowConstantExport: true }],
"@typescript-eslint/no-unused-vars": ["error", { argsIgnorePattern: "^_" }],
"@typescript-eslint/no-explicit-any": "warn",
},
},
{
files: ["vite.config.ts", "scripts/**/*.{js,mjs}"],
languageOptions: {
globals: globals.node,
},
},
);