`
+- **Atributos em multiline** quando há mais de 2 props
+
+### TSX (componentes em `.tsx`)
+
+```tsx
+// Componente funcional Vue em TSX
+import { defineComponent, ref } from "vue"
+
+export const MeuComponente = defineComponent({
+ props: {
+ titulo: { type: String, required: true },
+ },
+ setup(props) {
+ const contador = ref(0)
+ return () => (
+
+
{props.titulo}
+
+
+ )
+ },
+})
+```
+
+---
+
+## 🔧 Biome — Regras de Lint Importantes
+
+### Erros (bloqueiam o build)
+
+| Regra | Descrição |
+|-------|-----------|
+| `noUnusedVariables` | Variáveis definidas e não usadas |
+| `noUnusedImports` | Imports não utilizados |
+| `noVoidTypeReturn` | Função `void` retornando valor |
+| `noVueDataObjectDeclaration` | Vue 2 `data: {}` — usar função |
+| `noVueDuplicateKeys` | Chaves duplicadas em objetos Vue |
+| `noVueSetupPropsReactivityLoss` | Desestruturar `props` em `setup()` |
+| `noVueVIfWithVFor` | `v-if` + `v-for` no mesmo elemento |
+| `useVueVForKey` | `v-for` sem `:key` |
+| `useVueValidTemplateRoot` | Template sem raiz única (Vue 2) |
+
+### Warnings (code smells — corrija quando possível)
+
+| Regra | Descrição |
+|-------|-----------|
+| `useArrowFunction` | Prefira arrow functions |
+| `noNonNullAssertion` | Evite `!` — trate o null |
+| `noDelete` | `delete obj.prop` é lento |
+| `noEmptyBlockStatements` | Blocos `{}` vazios |
+| `noArrayIndexKey` | `:key` com índice do array |
+| `noDangerouslySetInnerHtml` | `innerHTML` perigoso |
+| `noExcessiveCognitiveComplexity` | Função muito complexa (max: 20) |
+
+---
+
+## 📦 Como Outros Projetos Consomem Este Pacote
+
+```json
+// biome.json do subprojeto (ex: PILAO-FRONT)
+{
+ "$schema": "./node_modules/@biomejs/biome/configuration_schema.json",
+ "extends": ["./node_modules/p-comuns/Documentos/biome.json"],
+ "files": {
+ "includes": ["src/**/*.{js,ts,jsx,tsx,vue}"]
+ }
+}
+```
+
+```json
+// .vscode/settings.json do subprojeto
+{
+ "editor.defaultFormatter": "biomejs.biome",
+ "editor.formatOnSave": true,
+ "editor.codeActionsOnSave": {
+ "source.organizeImports.biome": "always",
+ "source.fixAll.biome": "always"
+ },
+ "[vue]": { "editor.defaultFormatter": "biomejs.biome" },
+ "[typescript]": { "editor.defaultFormatter": "biomejs.biome" },
+ "[typescriptreact]": { "editor.defaultFormatter": "biomejs.biome" },
+ "editor.rulers": [100],
+ "files.eol": "\n"
+}
+```
+
+---
+
+## 🚀 Scripts
+
+```bash
+pnpm biome # Formata + lint com auto-fix
+pnpm check # biome + tsc --noEmit (sem emitir arquivos)
+pnpm build # Bump de versão + biome + tsup + pack
+pnpm teste # Vitest (testes unitários)
+```
+
+---
+
+## ⚠️ O que NÃO fazer
+
+- ❌ Não use `eslint` — o projeto usa Biome
+- ❌ Não use `prettier` — o projeto usa Biome
+- ❌ Não use `var` — sempre `const` ou `let`
+- ❌ Não use Vue Options API — sempre Composition API
+- ❌ Não desestrure `props` diretamente (quebra reatividade)
+- ❌ Não use `any` — use `unknown` + type narrowing
+- ❌ Não use índice como `:key` no `v-for`
+- ❌ Não quebre linhas com mais de 100 caracteres
+- ❌ Não use ponto-e-vírgula no final (Biome removerá)
+
+---
+
+## 📚 Referências
+
+- [Biome 2.x Docs](https://biomejs.dev)
+- [Vue 3 Composition API](https://vuejs.org/guide/composition-api)
+- [Zod v4](https://zod.dev)
+- [tsup](https://tsup.egoist.dev)
diff --git a/Documentos/biome.json b/Documentos/biome.json
index c27b1f0..44f089e 100755
--- a/Documentos/biome.json
+++ b/Documentos/biome.json
@@ -6,12 +6,20 @@
"enabled": true,
"rules": {
"recommended": true,
+
"correctness": {
"noUnusedVariables": "error",
"noUnusedImports": "error",
"noEmptyPattern": "off",
- "useExhaustiveDependencies": "off"
+ "useExhaustiveDependencies": "off",
+ "noVoidTypeReturn": "error",
+ "noVueDataObjectDeclaration": "error",
+ "noVueDuplicateKeys": "error",
+ "noVueReservedKeys": "error",
+ "noVueReservedProps": "error",
+ "noVueSetupPropsReactivityLoss": "warn"
},
+
"style": {
"noParameterAssign": "error",
"useAsConstAssertion": "error",
@@ -21,44 +29,127 @@
"useSingleVarDeclarator": "error",
"noUnusedTemplateLiteral": "error",
"useNumberNamespace": "error",
- "noInferrableTypes": "error"
+ "noInferrableTypes": "error",
+ "useArrayLiterals": "error",
+ "useConsistentArrayType": {
+ "level": "error",
+ "options": { "syntax": "shorthand" }
+ },
+ "useShorthandAssign": "error",
+ "noNonNullAssertion": "warn"
},
+
"suspicious": {
"noDebugger": "off",
"noDoubleEquals": "off",
"noExplicitAny": "off",
"noApproximativeNumericConstant": "off",
- "noAsyncPromiseExecutor": "off"
+ "noAsyncPromiseExecutor": "off",
+ "noEmptyBlockStatements": "warn",
+ "noConsole": "off",
+ "noArrayIndexKey": "warn"
},
+
"complexity": {
"noUselessConstructor": "off",
"noBannedTypes": "off",
"useLiteralKeys": "off",
"useArrowFunction": "warn",
"useDateNow": "off",
- "noUselessFragments": "off"
+ "noUselessFragments": "off",
+ "noExcessiveCognitiveComplexity": {
+ "level": "warn",
+ "options": { "maxAllowedComplexity": 20 }
+ }
},
+
"performance": {
- "noAccumulatingSpread": "off"
+ "noAccumulatingSpread": "off",
+ "noDelete": "warn"
},
+
"a11y": {
- "useSemanticElements": "off"
+ "useSemanticElements": "off",
+ "useAltText": "warn",
+ "useButtonType": "warn"
+ },
+
+ "security": {
+ "noDangerouslySetInnerHtml": "warn"
+ },
+
+ "nursery": {
+ "noVueArrowFuncInWatch": "warn",
+ "noVueVIfWithVFor": "error",
+ "useVueConsistentDefinePropsDeclaration": "warn",
+ "useVueConsistentVBindStyle": "warn",
+ "useVueConsistentVOnStyle": "warn",
+ "useVueDefineMacrosOrder": "warn",
+ "useVueVForKey": "error",
+ "useVueValidTemplateRoot": "error",
+ "useVueValidVBind": "error",
+ "useVueValidVIf": "error",
+ "useVueValidVElse": "error",
+ "useVueValidVElseIf": "error",
+ "useVueValidVOn": "warn",
+ "useVueValidVHtml": "warn"
}
}
},
+
"formatter": {
"enabled": true,
"indentStyle": "space",
- "indentWidth": 2
+ "indentWidth": 2,
+ "lineWidth": 100,
+ "lineEnding": "lf"
},
+
"javascript": {
+ "globals": [
+ "defineProps",
+ "defineEmits",
+ "defineExpose",
+ "withDefaults",
+ "defineModel",
+ "defineOptions",
+ "defineSlots"
+ ],
+ "parser": {
+ "unsafeParameterDecoratorsEnabled": true
+ },
"formatter": {
"enabled": true,
"semicolons": "asNeeded",
"arrowParentheses": "always",
"bracketSameLine": false,
"trailingCommas": "all",
- "attributePosition": "multiline"
+ "attributePosition": "multiline",
+ "quoteStyle": "double",
+ "jsxQuoteStyle": "double",
+ "bracketSpacing": true
+ }
+ },
+
+ "css": {
+ "formatter": {
+ "enabled": true,
+ "indentStyle": "space",
+ "indentWidth": 2,
+ "lineWidth": 100,
+ "quoteStyle": "double"
+ },
+ "linter": {
+ "enabled": true
+ }
+ },
+
+ "html": {
+ "formatter": {
+ "enabled": true,
+ "indentStyle": "space",
+ "indentWidth": 2,
+ "lineWidth": 100
}
}
}
diff --git a/README.md b/README.md
index 566b352..2c5cc88 100755
--- a/README.md
+++ b/README.md
@@ -1,93 +1,120 @@
-## ✅ Uso do BiomeJS para Autoformatação
+# `p-comuns` — Pacote Compartilhado e-licencie
-Este guia mostra como configurar o [BiomeJS](https://biomejs.dev) para formatar e analisar código JavaScript/TypeScript no seu projeto.
+Pacote de tipos, utilitários e configurações compartilhadas entre todos os subprojetos da plataforma **e-licencie** (back-end Node.js, front-end Vue 3 / TSX).
---
-### 1. Incluir o pacote de configuração comum
+## ✅ Configuração do BiomeJS nos Subprojetos
-Certifique-se de que o pacote `p-comuns` (ou outro com a configuração compartilhada) esteja disponível no seu projeto. Ele deve conter o arquivo `Documentos/biome.json`.
+Este guia mostra como usar a configuração base do Biome disponível neste pacote (`Documentos/biome.json`). Todos os subprojetos herdam essas regras via `extends`.
-pnpm up p-comuns
-
----
-
-### 2. Instalar o Biome com `pnpm`
+### 1. Adicionar o `p-comuns` como dependência
```bash
-pnpm add --save-dev --save-exact @biomejs/biome@2.1.4
+pnpm add --save-dev p-comuns
+# ou atualizar se já existir:
+pnpm up p-comuns
+```
+
+---
+
+### 2. Instalar o Biome
+
+```bash
+pnpm add --save-dev --save-exact @biomejs/biome@2.4.0
```
> 🎯 Use `--save-exact` para garantir consistência de versões entre ambientes.
---
-### 3. Criar o arquivo de configuração na raiz do projeto
-
-Crie um arquivo chamado `biome.json` com o seguinte conteúdo:
+### 3. Criar `biome.json` na raiz do subprojeto
```json
{
- "$schema": "./node_modules/@biomejs/biome/configuration_schema.json",
- "extends": ["./node_modules/p-comuns/Documentos/biome.json"],
+ "$schema": "node_modules/@biomejs/biome/configuration_schema.json",
+ "extends": ["node_modules/p-comuns/Documentos/biome.json"],
+ "vcs": {
+ "enabled": true,
+ "clientKind": "git",
+ "useIgnoreFile": true
+ },
"files": {
- "includes": ["src/**/*.{js,ts,jsx,tsx}"]
+ "includes": ["**/*.{ts,tsx,vue}"]
}
}
```
-> ⚠️ Verifique o caminho correto do `extends` relativo à raiz do seu projeto. Use `./` sempre que possível para evitar erros de resolução.
+> `vcs.useIgnoreFile: true` faz o Biome respeitar o `.gitignore` automaticamente — arquivos como `dist/`, `node_modules/` etc. são ignorados sem configuração adicional.
---
-### 4. Adicionar script no `package.json`
-
-Inclua o comando abaixo em `"scripts"`:
+### 4. Adicionar scripts no `package.json`
```json
{
"scripts": {
"biome": "pnpm exec biome check --write",
+ "check": "pnpm run biome && npx tsc --noEmit"
}
}
```
-Isso permite executar:
-
-```bash
-pnpm biome
-```
-
-> O comando irá **formatar e aplicar as regras de lint** nos arquivos do diretório `src/`.
-
---
-### ✅ Dica extra: formatar todos os arquivos
-
-Se quiser aplicar o Biome a todo o projeto (não só `src/`), altere o include:
+### 5. Configurar o VS Code (`.vscode/settings.json`)
```json
-"includes": ["**/*.{js,ts,jsx,tsx}"]
-```
-
-
-
-adicionar em .vscode/settings.json
-
{
"editor.defaultFormatter": "biomejs.biome",
+ "editor.formatOnSave": true,
+ "editor.codeActionsOnSave": {
+ "source.organizeImports.biome": "always",
+ "source.fixAll.biome": "always"
+ },
"[javascript]": { "editor.defaultFormatter": "biomejs.biome" },
"[javascriptreact]": { "editor.defaultFormatter": "biomejs.biome" },
"[typescript]": { "editor.defaultFormatter": "biomejs.biome" },
"[typescriptreact]": { "editor.defaultFormatter": "biomejs.biome" },
+ "[vue]": { "editor.defaultFormatter": "biomejs.biome" },
+ "[css]": { "editor.defaultFormatter": "biomejs.biome" },
"[json]": { "editor.defaultFormatter": "biomejs.biome" },
"[jsonc]": { "editor.defaultFormatter": "biomejs.biome" },
- "[vue]": {"editor.defaultFormatter": "octref.vetur"},
- "editor.codeActionsOnSave": {
- "source.organizeImports.biome": "always",
- "source.fixAll.biome": "always"
- }
+ "editor.rulers": [100],
+ "files.eol": "\n",
+ "files.trimTrailingWhitespace": true,
+ "files.insertFinalNewline": true
}
+```
+
+> 💡 **Biome formata Vue `.vue` nativamente desde a v2.3** — não precisa do Prettier ou Vetur para formatação!
+
+---
+
+## 🔑 Regras da configuração base (Documentos/biome.json)
+
+### O que está ativado:
+
+| Categoria | Regras notáveis |
+|-----------|----------------|
+| **Correctness** | `noUnusedVariables`, `noUnusedImports`, `noVueSetupPropsReactivityLoss` |
+| **Vue 3 específico** | `noVueVIfWithVFor`, `useVueVForKey`, `noVueDuplicateKeys`, `noVueReservedKeys` |
+| **Style** | `useAsConstAssertion`, `useSelfClosingElements`, `useConsistentArrayType` (shorthand `T[]`) |
+| **Nursery Vue** | `noVueArrowFuncInWatch`, `useVueDefineMacrosOrder`, `useVueConsistentVBindStyle` |
+| **Security** | `noDangerouslySetInnerHtml` (warn) |
+
+### Globals do Vue (sem necessidade de importar):
+
+`defineProps`, `defineEmits`, `defineExpose`, `withDefaults`, `defineModel`, `defineOptions`, `defineSlots`
+
+### Formatação:
+
+- Indentação: **2 espaços**
+- Linha máxima: **100 caracteres**
+- Aspas: **duplas**
+- Ponto-e-vírgula: **apenas quando necessário**
+- Trailing comma: **sempre**
+- Line ending: **LF (`\n`)**
---
@@ -96,29 +123,21 @@ adicionar em .vscode/settings.json
O sistema `tipoFiltro26` foi projetado para gerar automaticamente a tipagem de filtros compatíveis com operadores padrão do PostgreSQL, a partir de um tipo base `T`.
**Principais características:**
-- Tipagem forte e segura (Typescript)
+- Tipagem forte e segura (TypeScript)
- Suporte a aninhamento de objetos
- Operadores lógicos `E` (AND) e `OU` (OR)
- Validação de operadores permitidos por tipo de dado (string, number, boolean)
### Estrutura do Filtro
-O filtro segue uma estrutura onde chaves representam campos (simples ou aninhados) e valores representam condições com operadores específicos.
-
#### 1. Campos Simples
```typescript
-{
- idade: { ">=": 18 }
-}
+{ idade: { ">=": 18 } }
```
#### 2. Campos Aninhados
```typescript
-{
- carro: {
- ano: { "=": 2020 }
- }
-}
+{ carro: { ano: { "=": 2020 } } }
```
#### 3. Operadores Lógicos
@@ -143,7 +162,7 @@ O filtro segue uma estrutura onde chaves representam campos (simples ou aninhado
}
```
-#### 4. Exemplo Complexo Complet
+#### 4. Exemplo Complexo Completo
```typescript
{
idade: { ">=": 18 },
@@ -161,21 +180,23 @@ O filtro segue uma estrutura onde chaves representam campos (simples ou aninhado
### Operadores Suportados (`operadores26`)
-Os operadores são fornecidos pelo enum `operadores26` e são restritos pelo tipo do campo:
-
-* **Number**: `=`, `!=`, `>`, `>=`, `<`, `<=`, `in`
-* **String**: `=`, `!=`, `like`, `in`
-* **Boolean**: `=`, `!=`, `in`
-
-> **Nota:** Atualmente não há suporte automático para `null`, `date`, `jsonb` ou `arrays` como tipos de campo raiz (exceto arrays dentro do operador `in`).
+- **Number**: `=`, `!=`, `>`, `>=`, `<`, `<=`, `in`
+- **String**: `=`, `!=`, `like`, `in`
+- **Boolean**: `=`, `!=`, `in`
### Validação em Tempo de Execução (Zod)
-O sistema inclui um validador Zod `zFiltro26` para validação estrutural dos objetos de filtro recebidos (ex: via API).
-
```typescript
-import { zFiltro26 } from './tipoFiltro.26';
+import { zFiltro26 } from "p-comuns"
// Valida a estrutura (não checa existência de colunas no DB)
-zFiltro26.parse(objetoFiltro);
+zFiltro26.parse(objetoFiltro)
```
+
+---
+
+## 📚 Veja também
+
+- [`AGENTS.md`](./AGENTS.md) — Guia para assistentes de IA (padrões, convenções, arquitetura)
+- [Biome 2.x Docs](https://biomejs.dev)
+- [Vue 3 Composition API](https://vuejs.org/guide/composition-api)
diff --git a/biome.json b/biome.json
index 92399f4..40d361a 100755
--- a/biome.json
+++ b/biome.json
@@ -2,6 +2,6 @@
"$schema": "node_modules/@biomejs/biome/configuration_schema.json",
"extends": ["Documentos/biome.json"],
"files": {
- "includes": ["src/**/*.{js,ts,jsx,tsx}"]
+ "includes": ["src/**/*.{js,ts,jsx,tsx,vue}"]
}
}