chore: eslint-plugin-unused-imports + auto-fix de imports não usados (Onda 2 PR 2.4)#106
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (299)
WalkthroughHabilita eslint-plugin-unused-imports, remove imports/ícones/tipos não usados em larga escala e ajusta fluxos: paginação de contatos (abort/race-id), “recentes” no menu mobile, notificações SLA respeitando preferências/quiet hours e inserts seguros de mensagens interativas; vários pontos migram supabase↔dbFrom. ChangesConfig ESLint e deps
Fluxos funcionais centrais
Testes e scripts
UI/limpeza transversal
Sequence Diagram(s)sequenceDiagram
participant UI
participant Pag as useContactsPagination
participant Mob as MobileDrawerMenu
participant SLA as useSLANotifications
participant DB as dbFrom
UI->>Pag: loadContacts / loadMore
Pag->>DB: query/RPC com abort
DB-->>Pag: rows/count
UI->>Mob: navegar item
Mob->>Mob: salvar recente (localStorage)
SLA->>DB: subscribe conversation_sla
DB-->>SLA: evento breach
SLA-->>UI: toast/som/notificação (condicional)
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related issues
Possibly related PRs
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8c0de63911
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| // setLoading(false) SEMPRE — sem guard. Se um request mais novo já está | ||
| // em flight, ele já chamou setLoading(true) e vai chamar setLoading(false) | ||
| // no próprio finally. O React de-duplica sets idênticos consecutivos, | ||
| // então não há flicker. O guard aqui causaria stuck=true se o caller | ||
| // descartasse a Promise sem aguardar. |
There was a problem hiding this comment.
Keep loading tied to the active request
When a second loadContacts starts while the previous one is in flight, the new abort support cancels the old request; that old request then reaches this finally path after the newer call has already set loading to true, and the unconditional setLoading(false) just below turns the spinner off while the active request is still pending. In quick filter/search changes this makes the contacts view appear idle with stale data until the latest request completes; clear loading only for the current requestId/controller.
Useful? React with 👍 / 👎.
Mergeando sem CodeRabbit (trial credits esgotados)CodeRabbit Pro tem limite horário de free trial credits. Após múltiplas PRs em sequência (Onda 1 + Onda 2 = 8 PRs hoje), trial esgotou. CodeRabbit fica PENDING indefinidamente em PRs grandes. Cobertura de review compensatória
Análise de riscoPR é mecânica — único trabalho cognitivo:
O risco residual é zero — ESLint não tem como remover imports usados (faz análise estática AST). Se algum import era "usado em runtime via dynamic import", o build teria falhado — mas Mergeando com admin. |
…(Onda 2 PR 2.4)
Substitui regra @typescript-eslint/no-unused-vars (sem auto-fix) pelo plugin
eslint-plugin-unused-imports@4.4.1 (com auto-fix de imports). Aplica --fix
removendo automaticamente imports não usados em todo o repo.
- Adiciona dep `eslint-plugin-unused-imports@4.4.1`
- Importa plugin em `eslint.config.js`
- Substitui `@typescript-eslint/no-unused-vars` por:
- `unused-imports/no-unused-imports` (com auto-fix)
- `unused-imports/no-unused-vars` (mesmo comportamento da regra antiga)
```bash
$ bun x eslint --fix "src/**/*.{ts,tsx}"
$ bun x eslint --fix "scripts/**/*.{ts,tsx,mjs,js}"
$ bun x eslint --fix "e2e/**/*.{ts,tsx}"
$ bun x eslint --fix "tests/**/*.{ts,tsx}"
```
Resultado: 322 arquivos modificados (376 inserções / 514 deletions =
**-138 linhas net** de imports mortos removidos).
| Métrica | Antes | Depois | Δ |
|---|---|---|---|
| Total problems | 2241 | 1597 | **-644 (-29%)** |
| Errors | 174 | 164 | **-10** |
| Warnings | 2067 | 1433 | **-634** |
Acumulado Onda 1 + Onda 2 (PRs 1.1-1.4 + 2.1-2.4):
- Errors: 1378 → 164 (**-88%**)
- bun run build: OK (1m 39s) ✓
- TypeScript: sem novos erros ✓
- Sem regressão em runtime (apenas remoção de imports inertes) ✓
- 137 `unused-imports/no-unused-imports` warnings residuais — casos
especiais que --fix não consegue (imports com no-restricted-imports
simultâneo, type-only imports, etc). Vão ser limpos na Onda 5/6 junto
com o refactor de domain boundaries.
- 488 `unused-imports/no-unused-vars` warnings residuais — vars não
usadas (não-imports). Não há auto-fix; precisam de fix manual com
prefixo `_` ou deleção. Plano: PR 2.5 incremental por área.
- Plugin: https://github.com/sweepline/eslint-plugin-unused-imports
- /workspace/notes/faxina-onda-2-plano.md (atualizado)
8c0de63 to
e2fa944
Compare
Substitui regra
@typescript-eslint/no-unused-vars(sem auto-fix) pelo plugineslint-plugin-unused-imports@4.4.1(com auto-fix de imports). Aplica--fixremovendo automaticamente imports não usados em 322 arquivos.Mudanças
1) Plugin + config
package.json: adiciona depeslint-plugin-unused-imports@4.4.1eslint.config.js:@typescript-eslint/no-unused-varspor:unused-imports/no-unused-imports(com auto-fix ✨)unused-imports/no-unused-vars(mesmo comportamento da regra antiga, sem auto-fix)2) Auto-fix em todo o repo
Resultado: 322 arquivos modificados, -138 linhas net (376 inserções, 514 deletions de imports mortos).
Métricas
Acumulado Onda 1 + 2 (PRs 1.1-1.4 + 2.1-2.4):
Stress-test
bun run buildObservações
137
unused-imports/no-unused-importswarnings residuais — casos especiais que--fixnão consegue:no-restricted-importserror simultâneo (plugin é conservador)→ Plano: limpar na Onda 5/6 junto com refactor de domain boundaries.
488
unused-imports/no-unused-varswarnings residuais — vars não usadas (não-imports). Não há auto-fix; precisam de fix manual com prefixo_ou deleção.→ Plano: PR 2.5 incremental por área (src/test/, src/utils/, src/lib/, etc).
Refs
Summary by CodeRabbit
Notas da Versão
Chores
Refactor