hard-lint 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +225 -0
- package/dist/config.d.ts +37 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +62 -0
- package/dist/config.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +27 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +5 -0
- package/dist/types.js.map +1 -0
- package/eslint.config.mjs +83 -0
- package/package.json +65 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 naylsonferreira
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
# hard-lint
|
|
2
|
+
|
|
3
|
+
⚙️ Configuração **rigorosa** de ESLint para projetos TypeScript.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/hard-lint)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
7
|
+
[](https://github.com/naylsonferreira/hard-lint/actions/workflows/ci.yml)
|
|
8
|
+
|
|
9
|
+
## O que é?
|
|
10
|
+
|
|
11
|
+
`hard-lint` é uma biblioteca de configuração ESLint que implementa regras **rigorosas** para garantir:
|
|
12
|
+
|
|
13
|
+
- ✅ **Tipagem forte** - Proibição de `any`, tipos explícitos
|
|
14
|
+
- ✅ **Code quality** - Proibição de console, comentários
|
|
15
|
+
- ✅ **Acessibilidade** - Seletores semânticos em testes
|
|
16
|
+
- ✅ **Manutenibilidade** - Limites de complexidade, sintaxe consistente
|
|
17
|
+
- ✅ **Segurança** - Evita eval, scripts dinâmicos
|
|
18
|
+
|
|
19
|
+
## Instalação
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npm install --save-dev hard-lint eslint typescript
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Requisitos
|
|
26
|
+
|
|
27
|
+
- **Node.js** >= 18.0.0
|
|
28
|
+
- **npm** >= 9.0.0
|
|
29
|
+
- **ESLint** >= 9.0.0
|
|
30
|
+
- **TypeScript** >= 5.0.0
|
|
31
|
+
|
|
32
|
+
## O que Está Incluído
|
|
33
|
+
|
|
34
|
+
- ✅ **eslint.config.mjs** - Configuração ESLint 9 flat config
|
|
35
|
+
- ✅ **20+ regras rigorosas** - TypeScript, console, comentários, segurança
|
|
36
|
+
- ✅ **Pre-commit hooks** - Husky + lint-staged para validação automática
|
|
37
|
+
- ✅ **Commit validation** - Commitlint com Conventional Commits
|
|
38
|
+
- ✅ **Tipos TypeScript** - Para customizações
|
|
39
|
+
- ✅ **Documentação completa** - README, guias de contribuição
|
|
40
|
+
|
|
41
|
+
## Uso Rápido
|
|
42
|
+
|
|
43
|
+
### Em `eslint.config.mjs`:
|
|
44
|
+
|
|
45
|
+
```javascript
|
|
46
|
+
import hardlint from 'hard-lint';
|
|
47
|
+
|
|
48
|
+
export default [...hardlint];
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Regras Implementadas
|
|
52
|
+
|
|
53
|
+
### 📋 TypeScript
|
|
54
|
+
|
|
55
|
+
| Regra | Severidade | Config |
|
|
56
|
+
|-------|-----------|--------|
|
|
57
|
+
| `@typescript-eslint/no-explicit-any` | ❌ Error | Proíbe tipo `any` |
|
|
58
|
+
| `@typescript-eslint/no-unused-vars` | ❌ Error | Detecta variáveis não usadas (permite `_var`) |
|
|
59
|
+
|
|
60
|
+
### 🚫 Console & Comentários
|
|
61
|
+
|
|
62
|
+
| Regra | Severidade | Config |
|
|
63
|
+
|-------|-----------|--------|
|
|
64
|
+
| `no-console` | ❌ Error | Proíbe console.log, debug, warn, info |
|
|
65
|
+
| `no-inline-comments` | ❌ Error | Proíbe comentários na mesma linha |
|
|
66
|
+
| `no-warning-comments` | ❌ Error | Proíbe `todo`, `fixme`, `hack`, `xxx`, `note`, `debug`, `review` |
|
|
67
|
+
|
|
68
|
+
### 🎨 Code Style
|
|
69
|
+
|
|
70
|
+
| Regra | Severidade | Config |
|
|
71
|
+
|-------|-----------|--------|
|
|
72
|
+
| `no-var` | ❌ Error | Use `const`/`let` obrigatoriamente |
|
|
73
|
+
| `prefer-const` | ❌ Error | Use `const` sempre que possível |
|
|
74
|
+
| `prefer-arrow-callback` | ❌ Error | Prefira arrow functions em callbacks |
|
|
75
|
+
| `no-nested-ternary` | ❌ Error | Proíbe ternários aninhados |
|
|
76
|
+
| `sort-imports` | ❌ Error | Imports devem estar ordenados |
|
|
77
|
+
| `complexity` | ❌ Error | Máximo 10 de complexidade ciclomática |
|
|
78
|
+
| `max-depth` | ❌ Error | Máximo 3 níveis de aninhamento |
|
|
79
|
+
| `max-nested-callbacks` | ❌ Error | Máximo 3 callbacks aninhados |
|
|
80
|
+
|
|
81
|
+
### 🔒 Segurança
|
|
82
|
+
|
|
83
|
+
| Regra | Severidade | Config |
|
|
84
|
+
|-------|-----------|--------|
|
|
85
|
+
| `no-eval` | ❌ Error | Proíbe `eval()` |
|
|
86
|
+
| `no-implied-eval` | ❌ Error | Proíbe eval implícito (setTimeout com string) |
|
|
87
|
+
| `no-new-func` | ❌ Error | Proíbe `new Function()` |
|
|
88
|
+
| `no-script-url` | ❌ Error | Proíbe `javascript:` URLs |
|
|
89
|
+
|
|
90
|
+
### 🎭 Seletores Semânticos (E2E)
|
|
91
|
+
|
|
92
|
+
Validators customizados para garantir testes E2E que se comportam como usuários reais:
|
|
93
|
+
|
|
94
|
+
| Padrão | Mensagem |
|
|
95
|
+
|--------|----------|
|
|
96
|
+
| `.locator('button').nth()` | Use `getByRole('button')` para seletores semânticos |
|
|
97
|
+
| `.locator('button').filter()` | Use `getByRole('button', { name: /texto/i })` |
|
|
98
|
+
| `.locator('h1\|h2\|h3...')` | Use `getByRole('heading', { name: /texto/i })` |
|
|
99
|
+
| `.locator('button').first()` | Use `getByRole()` ou `getByLabel()` |
|
|
100
|
+
|
|
101
|
+
**Rodar manualmente:**
|
|
102
|
+
```bash
|
|
103
|
+
npm run validate-e2e [arquivos...]
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
**Automático no pre-commit:** Valida todos os `.e2e.ts` e `.test.ts` antes de commitar.
|
|
107
|
+
|
|
108
|
+
**Objetivo:** Testes que clicam em **palavras**, não em divs. Seletores que representam o que o usuário vê e interage.
|
|
109
|
+
|
|
110
|
+
## Exemplos
|
|
111
|
+
|
|
112
|
+
### ❌ PROIBIDO
|
|
113
|
+
|
|
114
|
+
```typescript
|
|
115
|
+
const data: any = fetch('/api');
|
|
116
|
+
|
|
117
|
+
console.log('Debug:', value);
|
|
118
|
+
console.debug('Debug info');
|
|
119
|
+
console.warn('warning');
|
|
120
|
+
|
|
121
|
+
const count = 0; // contador
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### ✅ CORRETO
|
|
125
|
+
|
|
126
|
+
```typescript
|
|
127
|
+
const data: Promise<Response> = fetch('/api');
|
|
128
|
+
|
|
129
|
+
const count = 0;
|
|
130
|
+
|
|
131
|
+
const initializeUserCount = 0;
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
## Scripts
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
npm run build # Build da biblioteca
|
|
138
|
+
npm run dev # Watch mode
|
|
139
|
+
npm run lint # Lint este projeto
|
|
140
|
+
npm run type-check # Type check
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
## Git Hooks (Husky + Commitlint)
|
|
144
|
+
|
|
145
|
+
Este projeto usa **Husky** + **lint-staged** + **commitlint** para validar código e commits:
|
|
146
|
+
|
|
147
|
+
### Pre-Commit Hook
|
|
148
|
+
|
|
149
|
+
Executado **automaticamente** antes de cada commit:
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
git add .
|
|
153
|
+
git commit -m "feat: adiciona nova feature"
|
|
154
|
+
# ↓ Valida automaticamente
|
|
155
|
+
# - Roda ESLint (proíbe comentários, console, etc)
|
|
156
|
+
# - Detecta e bloqueia violations
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
**Se houver erro:**
|
|
160
|
+
- ❌ Commit é bloqueado
|
|
161
|
+
- 📋 Erro é exibido
|
|
162
|
+
- 🔧 Corrija o código antes de committar
|
|
163
|
+
|
|
164
|
+
### Commit-Msg Hook
|
|
165
|
+
|
|
166
|
+
Valida o **formato da mensagem**:
|
|
167
|
+
|
|
168
|
+
```bash
|
|
169
|
+
# ✅ Formato correto (max 100 chars)
|
|
170
|
+
git commit -m "feat: add new validation rule"
|
|
171
|
+
|
|
172
|
+
# ❌ Formato inválido
|
|
173
|
+
git commit -m "blablabla"
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
**Tipos permitidos:**
|
|
177
|
+
- `feat` - Nova feature
|
|
178
|
+
- `fix` - Bug fix
|
|
179
|
+
- `docs` - Documentação
|
|
180
|
+
- `style` - Formatação
|
|
181
|
+
- `refactor` - Refatoração
|
|
182
|
+
- `perf` - Performance
|
|
183
|
+
- `test` - Testes
|
|
184
|
+
- `chore` - Manutenção
|
|
185
|
+
- `revert` - Revert
|
|
186
|
+
- `ci` - CI/CD
|
|
187
|
+
|
|
188
|
+
Veja [PRE_COMMIT.md](./PRE_COMMIT.md) para documentação completa.
|
|
189
|
+
|
|
190
|
+
## Configuração Avançada
|
|
191
|
+
|
|
192
|
+
Para customizar ou estender a config:
|
|
193
|
+
|
|
194
|
+
```javascript
|
|
195
|
+
import hardlint from 'hard-lint';
|
|
196
|
+
|
|
197
|
+
export default [
|
|
198
|
+
...hardlint,
|
|
199
|
+
{
|
|
200
|
+
files: ['src/**/*.ts'],
|
|
201
|
+
rules: {
|
|
202
|
+
'no-console': 'warn'
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
];
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
## Contribuindo
|
|
209
|
+
|
|
210
|
+
1. Fork o repositório (https://github.com/naylsonferreira/hard-lint)
|
|
211
|
+
2. Crie uma branch (`git checkout -b feature/improvement`)
|
|
212
|
+
3. Commit suas mudanças (`git commit -m 'Add: melhoria'`)
|
|
213
|
+
4. Push para a branch (`git push origin feature/improvement`)
|
|
214
|
+
5. Abra um Pull Request
|
|
215
|
+
|
|
216
|
+
## Publicação no NPM
|
|
217
|
+
|
|
218
|
+
1. Faça login: `npm login`
|
|
219
|
+
2. Incremente versão: `npm version patch|minor|major`
|
|
220
|
+
3. Build: `npm run build`
|
|
221
|
+
4. Publique: `npm publish --access public`
|
|
222
|
+
|
|
223
|
+
## Licença
|
|
224
|
+
|
|
225
|
+
MIT © 2026 naylsonferreira
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Funções para criar configurações hard-lint customizadas
|
|
3
|
+
*/
|
|
4
|
+
import type { HardLintConfig, ESLintConfig } from './types';
|
|
5
|
+
/**
|
|
6
|
+
* Cria uma configuração hard-lint customizada
|
|
7
|
+
*
|
|
8
|
+
* @param options - Opções de configuração
|
|
9
|
+
* @returns Array de configurações ESLint
|
|
10
|
+
*/
|
|
11
|
+
export declare function createHardLintConfig(): ESLintConfig[];
|
|
12
|
+
/**
|
|
13
|
+
* Tipos de severidade recomendados
|
|
14
|
+
*/
|
|
15
|
+
export declare const SEVERITY: {
|
|
16
|
+
ERROR: "error";
|
|
17
|
+
WARN: "warn";
|
|
18
|
+
OFF: "off";
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Predefinições de configuração
|
|
22
|
+
*/
|
|
23
|
+
export declare const PRESETS: {
|
|
24
|
+
/**
|
|
25
|
+
* Máxima rigorosidade - todas as regras ativadas
|
|
26
|
+
*/
|
|
27
|
+
strict: () => HardLintConfig;
|
|
28
|
+
/**
|
|
29
|
+
* Moderado - algumas regras como warn
|
|
30
|
+
*/
|
|
31
|
+
moderate: () => HardLintConfig;
|
|
32
|
+
/**
|
|
33
|
+
* Apenas regras críticas
|
|
34
|
+
*/
|
|
35
|
+
minimal: () => HardLintConfig;
|
|
36
|
+
};
|
|
37
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5D;;;;;GAKG;AACH,wBAAgB,oBAAoB,IAAI,YAAY,EAAE,CAkBrD;AAED;;GAEG;AACH,eAAO,MAAM,QAAQ;;;;CAIpB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,OAAO;IAClB;;OAEG;kBACS,cAAc;IAM1B;;OAEG;oBACW,cAAc;IAM5B;;OAEG;mBACU,cAAc;CAK5B,CAAC"}
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Funções para criar configurações hard-lint customizadas
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Cria uma configuração hard-lint customizada
|
|
6
|
+
*
|
|
7
|
+
* @param options - Opções de configuração
|
|
8
|
+
* @returns Array de configurações ESLint
|
|
9
|
+
*/
|
|
10
|
+
export function createHardLintConfig() {
|
|
11
|
+
const configs = [];
|
|
12
|
+
// Configurações base (importadas dinamicamente do eslint.config.mjs)
|
|
13
|
+
// Esta função é um helper que permite customizar a configuração
|
|
14
|
+
/**
|
|
15
|
+
* Exemplo de uso:
|
|
16
|
+
* const config = createHardLintConfig({
|
|
17
|
+
* nextRules: false,
|
|
18
|
+
* overrides: {
|
|
19
|
+
* 'no-console': 'warn'
|
|
20
|
+
* }
|
|
21
|
+
* });
|
|
22
|
+
*/
|
|
23
|
+
return configs;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Tipos de severidade recomendados
|
|
27
|
+
*/
|
|
28
|
+
export const SEVERITY = {
|
|
29
|
+
ERROR: 'error',
|
|
30
|
+
WARN: 'warn',
|
|
31
|
+
OFF: 'off'
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Predefinições de configuração
|
|
35
|
+
*/
|
|
36
|
+
export const PRESETS = {
|
|
37
|
+
/**
|
|
38
|
+
* Máxima rigorosidade - todas as regras ativadas
|
|
39
|
+
*/
|
|
40
|
+
strict: () => ({
|
|
41
|
+
e2eRules: true,
|
|
42
|
+
nextRules: true,
|
|
43
|
+
defaultSeverity: 'error'
|
|
44
|
+
}),
|
|
45
|
+
/**
|
|
46
|
+
* Moderado - algumas regras como warn
|
|
47
|
+
*/
|
|
48
|
+
moderate: () => ({
|
|
49
|
+
e2eRules: true,
|
|
50
|
+
nextRules: true,
|
|
51
|
+
defaultSeverity: 'warn'
|
|
52
|
+
}),
|
|
53
|
+
/**
|
|
54
|
+
* Apenas regras críticas
|
|
55
|
+
*/
|
|
56
|
+
minimal: () => ({
|
|
57
|
+
e2eRules: false,
|
|
58
|
+
nextRules: false,
|
|
59
|
+
defaultSeverity: 'warn'
|
|
60
|
+
})
|
|
61
|
+
};
|
|
62
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB;IAElC,MAAM,OAAO,GAAmB,EAAE,CAAC;IAEnC,qEAAqE;IACrE,gEAAgE;IAEhE;;;;;;;;OAQG;IAEH,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,KAAK,EAAE,OAAgB;IACvB,IAAI,EAAE,MAAe;IACrB,GAAG,EAAE,KAAc;CACpB,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB;;OAEG;IACH,MAAM,EAAE,GAAmB,EAAE,CAAC,CAAC;QAC7B,QAAQ,EAAE,IAAI;QACd,SAAS,EAAE,IAAI;QACf,eAAe,EAAE,OAAO;KACzB,CAAC;IAEF;;OAEG;IACH,QAAQ,EAAE,GAAmB,EAAE,CAAC,CAAC;QAC/B,QAAQ,EAAE,IAAI;QACd,SAAS,EAAE,IAAI;QACf,eAAe,EAAE,MAAM;KACxB,CAAC;IAEF;;OAEG;IACH,OAAO,EAAE,GAAmB,EAAE,CAAC,CAAC;QAC9B,QAAQ,EAAE,KAAK;QACf,SAAS,EAAE,KAAK;QAChB,eAAe,EAAE,MAAM;KACxB,CAAC;CACH,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,YAAY,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAC9C,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tipos para a configuração hard-lint
|
|
3
|
+
*/
|
|
4
|
+
import type { Linter } from 'eslint';
|
|
5
|
+
export interface HardLintConfig {
|
|
6
|
+
/**
|
|
7
|
+
* Habilita regras rigorosas para testes E2E
|
|
8
|
+
* @default true
|
|
9
|
+
*/
|
|
10
|
+
e2eRules?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Habilita regras do Next.js
|
|
13
|
+
* @default true
|
|
14
|
+
*/
|
|
15
|
+
nextRules?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Sobrescreve regras específicas
|
|
18
|
+
*/
|
|
19
|
+
overrides?: Record<string, 'error' | 'warn' | 'off'>;
|
|
20
|
+
/**
|
|
21
|
+
* Severidade padrão para regras personalizadas
|
|
22
|
+
* @default 'error'
|
|
23
|
+
*/
|
|
24
|
+
defaultSeverity?: 'error' | 'warn' | 'off';
|
|
25
|
+
}
|
|
26
|
+
export type ESLintConfig = Linter.Config;
|
|
27
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAErC,MAAM,WAAW,cAAc;IAC7B;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,GAAG,KAAK,CAAC,CAAC;IAErD;;;OAGG;IACH,eAAe,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,KAAK,CAAC;CAC5C;AAED,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import js from '@eslint/js';
|
|
2
|
+
import tseslint from '@typescript-eslint/eslint-plugin';
|
|
3
|
+
import tsparser from '@typescript-eslint/parser';
|
|
4
|
+
|
|
5
|
+
export default [
|
|
6
|
+
// Configuração global
|
|
7
|
+
{
|
|
8
|
+
ignores: ['node_modules/', 'dist/', '.next/', 'coverage/', 'examples/', 'scripts/']
|
|
9
|
+
},
|
|
10
|
+
|
|
11
|
+
// Base: JavaScript/TypeScript
|
|
12
|
+
js.configs.recommended,
|
|
13
|
+
|
|
14
|
+
// Configuração para todos os arquivos
|
|
15
|
+
{
|
|
16
|
+
files: ['**/*.{ts,tsx,js,jsx}'],
|
|
17
|
+
plugins: {
|
|
18
|
+
'@typescript-eslint': tseslint
|
|
19
|
+
},
|
|
20
|
+
languageOptions: {
|
|
21
|
+
parser: tsparser,
|
|
22
|
+
globals: {
|
|
23
|
+
module: 'readonly',
|
|
24
|
+
require: 'readonly'
|
|
25
|
+
},
|
|
26
|
+
parserOptions: {
|
|
27
|
+
ecmaVersion: 'latest',
|
|
28
|
+
sourceType: 'module',
|
|
29
|
+
ecmaFeatures: {
|
|
30
|
+
jsx: true
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
rules: {
|
|
35
|
+
// Regras TypeScript rigorosas
|
|
36
|
+
'@typescript-eslint/no-explicit-any': 'error',
|
|
37
|
+
'@typescript-eslint/no-unused-vars': [
|
|
38
|
+
'error',
|
|
39
|
+
{
|
|
40
|
+
argsIgnorePattern: '^_',
|
|
41
|
+
varsIgnorePattern: '^_'
|
|
42
|
+
}
|
|
43
|
+
],
|
|
44
|
+
|
|
45
|
+
// Regras de console
|
|
46
|
+
'no-console': 'error',
|
|
47
|
+
|
|
48
|
+
// Regras de comentários
|
|
49
|
+
'no-inline-comments': 'error',
|
|
50
|
+
'no-warning-comments': [
|
|
51
|
+
'error',
|
|
52
|
+
{
|
|
53
|
+
terms: ['todo', 'fixme', 'hack', 'xxx', 'note', 'debug', 'review'],
|
|
54
|
+
location: 'anywhere'
|
|
55
|
+
}
|
|
56
|
+
],
|
|
57
|
+
|
|
58
|
+
// Regras de code style
|
|
59
|
+
'no-var': 'error',
|
|
60
|
+
'prefer-const': 'error',
|
|
61
|
+
'prefer-arrow-callback': 'error',
|
|
62
|
+
'no-nested-ternary': 'error',
|
|
63
|
+
'complexity': ['error', 10],
|
|
64
|
+
'max-depth': ['error', 3],
|
|
65
|
+
'max-nested-callbacks': ['error', 3],
|
|
66
|
+
|
|
67
|
+
// Regras de segurança
|
|
68
|
+
'no-eval': 'error',
|
|
69
|
+
'no-implied-eval': 'error',
|
|
70
|
+
'no-new-func': 'error',
|
|
71
|
+
'no-script-url': 'error',
|
|
72
|
+
|
|
73
|
+
// Regras de imports
|
|
74
|
+
'sort-imports': [
|
|
75
|
+
'error',
|
|
76
|
+
{
|
|
77
|
+
ignoreCase: true,
|
|
78
|
+
ignoreMemberSort: true
|
|
79
|
+
}
|
|
80
|
+
]
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
];
|
package/package.json
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "hard-lint",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Configuração rigorosa de ESLint para projetos TypeScript",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist",
|
|
9
|
+
"eslint.config.mjs"
|
|
10
|
+
],
|
|
11
|
+
"scripts": {
|
|
12
|
+
"build": "tsc",
|
|
13
|
+
"dev": "tsc --watch",
|
|
14
|
+
"lint": "eslint .",
|
|
15
|
+
"type-check": "tsc --noEmit",
|
|
16
|
+
"validate-e2e": "node scripts/validate-e2e-selectors.js",
|
|
17
|
+
"prepare": "npm run build && husky install"
|
|
18
|
+
},
|
|
19
|
+
"keywords": [
|
|
20
|
+
"eslint",
|
|
21
|
+
"config",
|
|
22
|
+
"typescript",
|
|
23
|
+
"linting",
|
|
24
|
+
"code-quality"
|
|
25
|
+
],
|
|
26
|
+
"author": "naylsonferreira",
|
|
27
|
+
"license": "MIT",
|
|
28
|
+
"peerDependencies": {
|
|
29
|
+
"eslint": ">=8.56.0",
|
|
30
|
+
"typescript": ">=5.0.0"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@commitlint/cli": "^20.4.1",
|
|
34
|
+
"@commitlint/config-conventional": "^20.4.1",
|
|
35
|
+
"@eslint/js": "^9.0.0",
|
|
36
|
+
"@types/eslint": "^8.56.0",
|
|
37
|
+
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
|
38
|
+
"@typescript-eslint/parser": "^8.0.0",
|
|
39
|
+
"eslint": "^8.56.0",
|
|
40
|
+
"husky": "^9.1.7",
|
|
41
|
+
"lint-staged": "^16.2.7",
|
|
42
|
+
"typescript": "^5.3.0"
|
|
43
|
+
},
|
|
44
|
+
"engines": {
|
|
45
|
+
"node": ">=18.0.0",
|
|
46
|
+
"npm": ">=9.0.0"
|
|
47
|
+
},
|
|
48
|
+
"repository": {
|
|
49
|
+
"type": "git",
|
|
50
|
+
"url": "git+https://github.com/naylsonferreira/hard-lint.git"
|
|
51
|
+
},
|
|
52
|
+
"bugs": {
|
|
53
|
+
"url": "https://github.com/naylsonferreira/hard-lint/issues"
|
|
54
|
+
},
|
|
55
|
+
"homepage": "https://github.com/naylsonferreira/hard-lint#readme",
|
|
56
|
+
"lint-staged": {
|
|
57
|
+
"**/*.{ts,tsx,js,jsx}": [
|
|
58
|
+
"eslint --fix",
|
|
59
|
+
"eslint"
|
|
60
|
+
],
|
|
61
|
+
"**/*.{e2e,test}.{ts,tsx,js,jsx}": [
|
|
62
|
+
"node scripts/validate-e2e-selectors.js"
|
|
63
|
+
]
|
|
64
|
+
}
|
|
65
|
+
}
|