@odg/eslint-config 3.0.3 → 3.1.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@odg/eslint-config",
3
- "version": "3.0.3",
3
+ "version": "3.1.0",
4
4
  "description": "Linter for JavaScript And Typescript project",
5
5
  "type": "module",
6
6
  "main": "index.mjs",
@@ -29,10 +29,6 @@
29
29
  "@types/node": ">=24",
30
30
  "typescript": "*"
31
31
  },
32
- "peerDependencies": {
33
- "@typescript-eslint/parser": "*",
34
- "eslint": "^9"
35
- },
36
32
  "dependencies": {
37
33
  "@babel/core": "*",
38
34
  "@odg/eslint-plugin": "*",
@@ -6,9 +6,11 @@ export default {
6
6
  {
7
7
  code: 120,
8
8
  ignoreUrls: true,
9
- ignoreStrings: true,
9
+ ignoreStrings: false,
10
10
  ignoreTemplateLiterals: true,
11
11
  ignoreRegExpLiterals: true,
12
+ ignoreComments: false,
13
+ ignoreTrailingComments: false,
12
14
  },
13
15
  ], // Caracteres máximo por linhas
14
16
  },
@@ -1,6 +1,15 @@
1
1
  const indentSize = 4;
2
2
  const complexity = 15;
3
3
  const alwaysMultiline = "always-multiline";
4
+ const multiLineBlock = "multiline-block-like";
5
+
6
+ // 1. DEFINIÇÕES (Para deixar a regra limpa)
7
+ const VARIABLES = [ "const", "let", "var" ];
8
+ const EXPORTS = [ "export", "cjs-export" ];
9
+ const IMPORTS = [ "import", "cjs-import" ];
10
+ const TYPES = [ "interface", "type", "enum", "class" ];
11
+ const FLOW_CONTROL = [ "if", "switch", "try", "for", "do", "while" ];
12
+ const BLOCK_LIKE = [ "block-like", multiLineBlock ];
4
13
 
5
14
  export default {
6
15
  rules: {
@@ -86,6 +95,48 @@ export default {
86
95
  // "regexp/prefer-regexp-exec": [ "error" ], // Prefira exec em regex // Match retorna 1 resultado apenas
87
96
 
88
97
  "unicorn/no-empty-file": [ "error" ], // Não crie arquivo vazio
98
+ "unicorn/filename-case": [
99
+ "error",
100
+ {
101
+ "cases": {
102
+ "kebabCase": true,
103
+ "pascalCase": true,
104
+ },
105
+ "ignore": [ "\.md$" ],
106
+ },
107
+ ],
108
+ "no-restricted-syntax": [
109
+ "error",
110
+ {
111
+ "selector": "NewExpression[callee.name='Error']",
112
+ "message": "Do not use 'new Error()'. Use the exception classes from the @odg/exception"
113
+ + " package to maintain logging standardization.",
114
+ },
115
+ {
116
+ "selector": "CallExpression[callee.property.name='log']",
117
+ "message": "Do not use console.log. Use the @odg/log injected in the container to ensure traceability.",
118
+ },
119
+ {
120
+ "selector": "CallExpression[callee.property.name='forEach'][arguments.0.async=true]",
121
+ "message": "Do not use `.forEach` with async functions. `.forEach` does not wait for Promises."
122
+ + " Use `for...of` or`Promise.all()` instead.",
123
+ },
124
+ {
125
+ "selector": "CallExpression[callee.property.name='waitForTimeout']",
126
+ "message": "The use of 'waitForTimeout' is prohibited because it's intimidating."
127
+ + " Use 'waitForSelector', 'waitForResponse', or 'waitForFunction' instead.",
128
+ },
129
+ {
130
+ "selector": String.raw`CallExpression[callee.property.name=/^(click|waitForSelector|\$|\$\$|eval|type)$/][arguments.0.type='Literal'][arguments.0.value=/^[.#].*/]`,
131
+ "message": "Do not use hardcoded selectors."
132
+ + " Move a string to a file in the 'Selectors' folder to ensure decoupling.",
133
+ },
134
+ {
135
+ "selector": "BinaryExpression[operator='instanceof'][right.name='Error']",
136
+ "message": "Avoid 'error instances'. Use the specific specifications of your @odg/exception "
137
+ + "or structural type checking for greater security between packets.",
138
+ },
139
+ ],
89
140
  "no-magic-numbers": [
90
141
  "warn",
91
142
  {
@@ -205,9 +256,11 @@ export default {
205
256
  {
206
257
  code: 120,
207
258
  ignoreUrls: true,
208
- ignoreStrings: true,
259
+ ignoreStrings: false,
209
260
  ignoreTemplateLiterals: true,
210
261
  ignoreRegExpLiterals: true,
262
+ ignoreComments: false,
263
+ ignoreTrailingComments: false,
211
264
  },
212
265
  ], // Caracteres máximo por linhas
213
266
  "@stylistic/max-statements-per-line": [ "error", { max: 1 } ], // Máximo operação em 1 linha
@@ -323,16 +376,85 @@ export default {
323
376
  ], // Força não usar blocos com espaços
324
377
  "@stylistic/padding-line-between-statements": [
325
378
  "error",
326
- { "blankLine": "always", "prev": "*", "next": "export" }, // Uma linha em branco antes do export
327
- { "blankLine": "always", "prev": "export", "next": "*" }, // Uma linha em branco apos o export
328
- { "blankLine": "always", "prev": "*", "next": "class" }, // Uma linha em branco antes da classe
329
- { "blankLine": "always", "prev": "class", "next": "*" }, // Uma linha em branco apos a classe
330
- { "blankLine": "always", "prev": "*", "next": "interface" }, // Uma linha em branco antes da interface
331
- { "blankLine": "always", "prev": "interface", "next": "*" }, // Uma linha em branco apos a interface
332
- { "blankLine": "always", "prev": "*", "next": "type" }, // Uma linha em branco antes do type
333
- { "blankLine": "always", "prev": "type", "next": "*" }, // Uma linha em branco apos o type
334
- { "blankLine": "always", "prev": "multiline-block-like", "next": "*" },
335
- { "blankLine": "always", "prev": "*", "next": [ "enum", "interface", "type" ] },
379
+
380
+ /*
381
+ * ------------------------------------------------------
382
+ * 1. DIRETIVAS (ex: "use strict")
383
+ * ------------------------------------------------------
384
+ * Separa diretivas do resto do código
385
+ */
386
+ { "blankLine": "always", "prev": "directive", "next": "*" },
387
+ { "blankLine": "any", "prev": "directive", "next": "directive" },
388
+
389
+ /*
390
+ * ------------------------------------------------------
391
+ * 2. IMPORTS
392
+ * ------------------------------------------------------
393
+ * Imports sempre separados do código que vem depois
394
+ */
395
+ { "blankLine": "always", "prev": IMPORTS, "next": "*" },
396
+
397
+ // Entre imports, não força espaço (deixa agrupar)
398
+ { "blankLine": "any", "prev": IMPORTS, "next": IMPORTS },
399
+
400
+ /*
401
+ * ------------------------------------------------------
402
+ * 3. VARIÁVEIS
403
+ * ------------------------------------------------------
404
+ * A. REGRA GERAL: Variável seguida de *Qualquer coisa* = Espaço
405
+ */
406
+ { "blankLine": "always", "prev": VARIABLES, "next": "*" },
407
+
408
+ // B. EXCEÇÃO 1: Variável seguida de Variável = Pode colar
409
+ { "blankLine": "any", "prev": VARIABLES, "next": VARIABLES },
410
+
411
+ // C. EXCEÇÃO 2: Variável seguida de IF = Pode colar (Guard Clauses)
412
+ { "blankLine": "any", "prev": VARIABLES, "next": "if" },
413
+
414
+ /*
415
+ * ------------------------------------------------------
416
+ * 4. ESTRUTURAS DE TIPO (Types, Interfaces, Enums, Classes)
417
+ * ------------------------------------------------------
418
+ * Sempre dá espaço antes de declarar um tipo/classe
419
+ */
420
+ { "blankLine": "always", "prev": "*", "next": TYPES },
421
+
422
+ // Sempre dá espaço depois de declarar um tipo/classe
423
+ { "blankLine": "always", "prev": TYPES, "next": "*" },
424
+
425
+ /*
426
+ * ------------------------------------------------------
427
+ * 5. FLUXO E LÓGICA (If, For, While, Return)
428
+ * ------------------------------------------------------
429
+ * Espaço antes de comandos de saída (return, throw, break)
430
+ */
431
+ { "blankLine": "always", "prev": "*", "next": [ "return", "throw", "break", "continue" ] },
432
+
433
+ // Espaço ao redor de blocos de controle (if, for, while)
434
+ { "blankLine": "always", "prev": "*", "next": [ ...BLOCK_LIKE, ...FLOW_CONTROL ] },
435
+ { "blankLine": "always", "prev": [ ...BLOCK_LIKE, ...FLOW_CONTROL ], "next": "*" },
436
+
437
+ // EXCEÇÃO: IF seguido de IF (if-inline vai funcionar)
438
+ { "blankLine": "any", "prev": "if", "next": "if" },
439
+
440
+ /*
441
+ * ------------------------------------------------------
442
+ * 6. EXPORTS
443
+ * ------------------------------------------------------
444
+ * Export sempre isolado (antes e depois)
445
+ */
446
+ { "blankLine": "always", "prev": "*", "next": EXPORTS },
447
+ { "blankLine": "any", "prev": EXPORTS, "next": EXPORTS },
448
+
449
+ /*
450
+ * ------------------------------------------------------
451
+ * 7. O MARTELO (Regras de Segurança para Blocos Grandes)
452
+ * ------------------------------------------------------
453
+ * Se qualquer coisa for seguida por um bloco multilinha, OBRIGA espaço.
454
+ * Isso garante que se o seu 'if' colado crescer e virar um bloco, ele ganha espaço.
455
+ */
456
+ { "blankLine": "always", "prev": "*", "next": multiLineBlock },
457
+ { "blankLine": "always", "prev": multiLineBlock, "next": "*" },
336
458
  ],
337
459
  "@stylistic/quote-props": [ "error", "consistent" ], // Objeto com aspas ou sem consistent
338
460
  "@stylistic/quotes": [ "error", "double" ], // Força aspas dupla
@@ -358,7 +480,6 @@ export default {
358
480
  words: true, // Espaço apos Await e palavras chaves
359
481
  nonwords: false, // Força nao ter espaço antes de operadores unários !, -, +
360
482
  overrides: {
361
- "new": false,
362
483
  "++": false, // Nao permite espaço no ++
363
484
  },
364
485
  },
@@ -6,9 +6,11 @@ export default {
6
6
  {
7
7
  code: 120,
8
8
  ignoreUrls: true,
9
- ignoreStrings: true,
9
+ ignoreStrings: false,
10
10
  ignoreTemplateLiterals: true,
11
11
  ignoreRegExpLiterals: true,
12
+ ignoreComments: false,
13
+ ignoreTrailingComments: false,
12
14
  },
13
15
  ], // Caracteres máximo por linhas
14
16
  "toml/indent": [ "error" ], // Indent
@@ -19,9 +19,11 @@ export default {
19
19
  {
20
20
  code: 120,
21
21
  ignoreUrls: true,
22
- ignoreStrings: true,
22
+ ignoreStrings: false,
23
23
  ignoreTemplateLiterals: true,
24
24
  ignoreRegExpLiterals: true,
25
+ ignoreComments: false,
26
+ ignoreTrailingComments: false,
25
27
  },
26
28
  ], // Caracteres máximo por linhas
27
29
  "jsonc/no-irregular-whitespace": [ "error" ], // Não faça espaço irregular
@@ -61,6 +61,7 @@ export default {
61
61
  ], // Não Crie tipos vazios
62
62
  "@typescript-eslint/no-import-type-side-effects": [ "error" ], // Coloque type fora para n importar no build
63
63
  "@typescript-eslint/explicit-function-return-type": [ "error" ], // Força tipo de retorno
64
+ "@typescript-eslint/explicit-module-boundary-types": [ "error" ], // Força tipo de retorno
64
65
  "no-unused-vars": [ "off" ], // Não permite variáveis não utilizadas
65
66
  "@typescript-eslint/no-unused-vars": [
66
67
  "error",
@@ -104,7 +105,7 @@ export default {
104
105
  "error",
105
106
  "method",
106
107
  ], // Use arrow function em method signature interface
107
- "@typescript-eslint/no-unnecessary-type-assertion": [ "error" ], // Não permite declaração que não altera expressão
108
+ "@typescript-eslint/no-unnecessary-type-assertion": [ "error" ], // Não As declaração que não altera expressão
108
109
  "@typescript-eslint/no-unsafe-call": [ "error" ], // Não permite chamadas de funções em tipo any
109
110
  "space-infix-ops": [ "off" ], // Espaço na separação operadores
110
111
  "no-underscore-dangle": [ "error" ], // Não permite _ no nome
@@ -26,9 +26,11 @@ export default {
26
26
  {
27
27
  code: 120,
28
28
  ignoreUrls: true,
29
- ignoreStrings: true,
29
+ ignoreStrings: false,
30
30
  ignoreTemplateLiterals: true,
31
31
  ignoreRegExpLiterals: true,
32
+ ignoreComments: false,
33
+ ignoreTrailingComments: false,
32
34
  },
33
35
  ], // Caracteres máximo por linhas
34
36
  },