@cbrl/eslint-config 0.1.0 → 0.1.1

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.
@@ -40,7 +40,7 @@ export const layering = [
40
40
  {
41
41
  group: ['react', 'react-dom', 'next', 'next/*'],
42
42
  message:
43
- 'core/ é o functional core: sem React/Next. Estado, efeito ou render vivem em ui/ ou adapters/.',
43
+ 'core/ is the functional core: no React/Next. State, effects and rendering live in ui/ or adapters/.',
44
44
  },
45
45
  {
46
46
  group: [
@@ -53,17 +53,17 @@ export const layering = [
53
53
  'server-only',
54
54
  ],
55
55
  message:
56
- 'core/ é puro: sem Firestore/admin/server-only. Acesso a dado mora em adapters/ (ex.: *.repo.ts).',
56
+ 'core/ is pure: no Firestore/admin/server-only. Data access lives in adapters/ (e.g. *.repo.ts).',
57
57
  },
58
58
  {
59
59
  group: ['**/adapters/*', '**/ui/*', '@/features/*/adapters/*', '@/features/*/ui/*'],
60
60
  message:
61
- 'Dependência só desce (ui→adapters→core). core/ não pode importar adapters/ nem ui/.',
61
+ 'Dependencies only point down (ui→adapters→core): core/ must not import adapters/ or ui/.',
62
62
  },
63
63
  {
64
64
  group: ['@/app/*', '@/app/**'],
65
65
  message:
66
- 'features/ não importa app/ — app é a casca externa de roteamento (inversão).',
66
+ 'features/ must not import app/: app is the outer routing shell (inversion).',
67
67
  },
68
68
  ],
69
69
  },
@@ -83,7 +83,7 @@ export const layering = [
83
83
  patterns: [
84
84
  {
85
85
  group: ['react', 'react-dom', 'next', 'next/*'],
86
- message: 'domain/ é o kernel puro: sem React/Next.',
86
+ message: 'domain/ is the pure kernel: no React/Next.',
87
87
  },
88
88
  {
89
89
  group: [
@@ -95,11 +95,12 @@ export const layering = [
95
95
  '@/shared/db/*',
96
96
  'server-only',
97
97
  ],
98
- message: 'domain/ é puro: sem Firestore/admin/server-only.',
98
+ message: 'domain/ is pure: no Firestore/admin/server-only.',
99
99
  },
100
100
  {
101
101
  group: ['@/shared/*', '@/features/*', '@/app/*'],
102
- message: 'domain/ é o anel mais interno — não importa shared/, features/ nem app/.',
102
+ message:
103
+ 'domain/ is the innermost ring: it must not import shared/, features/ or app/.',
103
104
  },
104
105
  ],
105
106
  },
@@ -123,7 +124,7 @@ export const layering = [
123
124
  {
124
125
  group: ['@/app/*', '@/app/**'],
125
126
  message:
126
- 'features/ não importa app/ — app é a casca externa de roteamento (inversão).',
127
+ 'features/ must not import app/: app is the outer routing shell (inversion).',
127
128
  },
128
129
  ],
129
130
  },
@@ -140,7 +141,7 @@ export const layering = [
140
141
  {
141
142
  group: ['@/features/*', '@/features/**', '@/app/*', '@/app/**'],
142
143
  message:
143
- 'shared/ é infra abaixo de features/ — não importa features/ nem app/ (inversão de camada).',
144
+ 'shared/ is infrastructure below features/: it must not import features/ or app/ (layer inversion).',
144
145
  },
145
146
  ],
146
147
  },
@@ -156,8 +157,7 @@ export const layering = [
156
157
  patterns: [
157
158
  {
158
159
  group: ['@/app/*', '@/app/**'],
159
- message:
160
- 'components/ é visual compartilhado — não importa app/ (inversão de camada).',
160
+ message: 'components/ is shared UI: it must not import app/ (layer inversion).',
161
161
  },
162
162
  ],
163
163
  },
@@ -186,13 +186,13 @@ export const layering = [
186
186
  from: ['feat-core'],
187
187
  disallow: ['feat-adapters', 'feat-ui'],
188
188
  message:
189
- 'core ({{from}}) não importa {{target}} — dependência só desce (ui→adapters→core).',
189
+ 'core ({{from}}) must not import {{target}}: dependencies only point down (ui→adapters→core).',
190
190
  },
191
191
  {
192
192
  from: ['feat-adapters'],
193
193
  disallow: ['feat-ui'],
194
194
  message:
195
- 'adapters ({{from}}) não importa ui — o fluxo é ui→adapters, nunca o contrário.',
195
+ 'adapters ({{from}}) must not import ui: the flow is ui→adapters, never the reverse.',
196
196
  },
197
197
  ],
198
198
  },
@@ -1,5 +1,4 @@
1
- // Layer: test-quality & ownership gates (paved road). See CONTRIBUTING.md
2
- // §"Princípios de engenharia". Prefer the canonical community plugin over a
1
+ // Layer: test-quality & ownership gates (paved road). Prefer the canonical community plugin over a
3
2
  // custom rule; a built-in `no-restricted-*` is used ONLY where no plugin rule
4
3
  // exists (the data-testid and raw-primitive bans). Existing violations are
5
4
  // grandfathered via the native bulk-suppressions file and pruned over time —
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cbrl/eslint-config",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Strict ESLint flat config for TypeScript, React and Next.js apps, with custom fail-fast rules (no eslint-disable, no env fallbacks).",
5
5
  "license": "MIT",
6
6
  "author": "Kayron Cabral",
@@ -1,8 +1,6 @@
1
- // Custom rule: proíbe spread condicional aninhado em outro spread condicional.
1
+ // Custom rule: bans a conditional spread nested inside another conditional spread.
2
2
  //
3
- // Codifica decisão canônica do PR #971 (commit `abec9de7`) + recidiva no
4
- // PR #972 (commit `285e0f1c`). Memória de projeto não previne recidiva
5
- // cross-instância de Claude; análise sintática previne.
3
+ // A recurring review finding turned into a syntactic check, so it cannot regress.
6
4
  //
7
5
  // Anti-pattern:
8
6
  //
@@ -10,19 +8,19 @@
10
8
  // base: 1,
11
9
  // ...(c1
12
10
  // ? { foo: mapValue({
13
- // ...(c2 ? { a: x } : {}), // ← spread aninhado dentro
14
- // ...(c3 ? { b: y } : {}), // de outro spread cond
11
+ // ...(c2 ? { a: x } : {}), // ← spread nested inside
12
+ // ...(c3 ? { b: y } : {}), // another conditional spread
15
13
  // }) }
16
14
  // : {}),
17
15
  // }
18
16
  //
19
- // Por quê é ruim:
20
- // - Legibilidade ruim (nesting profundo, ternário + spread misturados)
21
- // - TypeScript infer fica frágil (vira `Partial<X>` / `Record<string,unknown>`)
22
- // - Repetição da expressão de teste (`c1.x` 3-6× no mesmo bloco)
23
- // - Esconde forma final do objeto — leitor expande mentalmente
17
+ // Why it hurts:
18
+ // - Poor readability (deep nesting, ternaries mixed with spreads)
19
+ // - Fragile TypeScript inference (degrades to `Partial<X>` / `Record<string, unknown>`)
20
+ // - The test expression repeats (`c1.x` 3-6 times in the same block)
21
+ // - Hides the final shape of the object — the reader expands it mentally
24
22
  //
25
- // Padrão correto: record intermediário + `if`s explícitos.
23
+ // Correct pattern: an intermediate record plus explicit `if`s.
26
24
  //
27
25
  // const inner: Record<string, X> = {}
28
26
  // if (c2) inner.a = x
@@ -30,20 +28,20 @@
30
28
  // const obj: Record<string, Y> = { base: 1 }
31
29
  // if (c1) obj.foo = mapValue(inner)
32
30
  //
33
- // Distinção (NÃO confundir):
34
- // - Spread condicional ÚNICO E RASO (`...(opts.foo ? { foo: ... } : {})`)
35
- // é idiomático — esta rule NÃO dispara nele.
36
- // - Só dispara quando há aninhamento (spread cond dentro de spread cond).
31
+ // Do NOT confuse with:
32
+ // - A SINGLE, SHALLOW conditional spread (`...(opts.foo ? { foo: ... } : {})`)
33
+ // is idiomatic — this rule does NOT fire on it.
34
+ // - It only fires on nesting (a conditional spread inside a conditional spread).
37
35
 
38
36
  function isConditionalSpread(node) {
39
37
  return node?.type === 'SpreadElement' && node.argument?.type === 'ConditionalExpression'
40
38
  }
41
39
 
42
- // Walk recursivo procurando outro spread condicional dentro do nó dado.
43
- // Caminha por ObjectExpression, CallExpression args, ArrayExpression,
44
- // ConditionalExpression branches e Property values — cobre os formatos
45
- // reais do anti-pattern (incluindo o caso `mapValue({...cond...})` onde o
46
- // spread aninhado mora dentro de uma chamada de helper).
40
+ // Recursive walk looking for another conditional spread inside the given node.
41
+ // Visits ObjectExpression, CallExpression args, ArrayExpression,
42
+ // ConditionalExpression branches and Property values — the real shapes of the
43
+ // anti-pattern (including `mapValue({...cond...})`, where the nested spread
44
+ // lives inside a helper call).
47
45
  function containsConditionalSpread(node, depthBudget = 50) {
48
46
  if (!node || depthBudget <= 0) return false
49
47
  if (isConditionalSpread(node)) return true
@@ -1,30 +1,29 @@
1
- // Custom rule: proíbe fallback hardcoded de VALOR em `process.env.<ANY>`.
1
+ // Custom rule: bans a hardcoded VALUE fallback on `process.env.<ANY>`.
2
2
  //
3
- // Codifica princípio canônico do harness: "fail-fast > silent default".
4
- // Vale pra QUALQUER env var (não só secrets): um default literal mascara
5
- // misconfig — o app roda com um valor trivial em vez de quebrar e expor que a
6
- // env não foi setada.
3
+ // Encodes "fail-fast over silent default". It applies to ANY env var, not only
4
+ // secrets: a literal default hides misconfiguration — the app runs with a
5
+ // trivial value instead of failing and revealing the variable was never set.
7
6
  //
8
- // Anti-pattern detectado (right operand é um literal de VALOR):
7
+ // Flagged anti-pattern (the right operand is a VALUE literal):
9
8
  // const url = process.env.APP_URL ?? 'http://localhost:3000'
10
9
  // const x = process.env.X || 'default'
11
10
  // process.env.X ??= 'literal'
12
11
  // process.env.X ||= 'literal'
13
- // const p = process.env.A ?? process.env.B ?? 'literal' // cadeia que termina em literal
12
+ // const p = process.env.A ?? process.env.B ?? 'literal' // chain ending in a literal
14
13
  //
15
- // Padrão correto: leia e falhe alto se ausente.
14
+ // Correct pattern: read it and fail loudly when missing.
16
15
  // const url = process.env.APP_URL
17
16
  // if (!url) throw new Error('APP_URL not set')
18
- // // ou um helper `env('APP_URL')` que faz isso.
17
+ // // or `requireEnv('APP_URL')` from @cbrl/env.
19
18
  //
20
- // NÃO viola (default não é literal de valor — não mascara misconfig):
21
- // - `||` booleano / lógica: `if (process.env.X || process.env.Y)`, `!!a || !!b`
22
- // - cadeia env→env sem literal: `process.env.A ?? process.env.B` (termina em throw downstream)
23
- // - normalização de ausência: `process.env.X ?? null`, `?? undefined`
24
- // - fallback que não é literal: `process.env.XDG_CONFIG_HOME ?? join(homedir(), ...)`
19
+ // NOT a violation (the default is not a value literal, so nothing is masked):
20
+ // - boolean / logical `||`: `if (process.env.X || process.env.Y)`, `!!a || !!b`
21
+ // - env→env chain with no literal: `process.env.A ?? process.env.B` (throws downstream)
22
+ // - absence normalization: `process.env.X ?? null`, `?? undefined`
23
+ // - non-literal fallback: `process.env.XDG_CONFIG_HOME ?? join(homedir(), ...)`
25
24
 
26
- // Literal de VALOR: string/number/boolean/bigint/template. Exclui `null`
27
- // (ESLint: Literal com value === null) — `?? null` é normalização, não default.
25
+ // VALUE literal: string/number/boolean/bigint/template. Excludes `null`
26
+ // (an ESLint Literal with value === null): `?? null` normalizes, it is not a default.
28
27
  function isValueLiteralFallback(node) {
29
28
  if (!node) return false
30
29
  if (node.type === 'TemplateLiteral') return true
@@ -41,8 +40,8 @@ function isProcessEnvAccess(node) {
41
40
  )
42
41
  }
43
42
 
44
- // `left` "vem de process.env" se é um acesso direto OU uma cadeia ??/|| cuja
45
- // raiz à esquerda é process.env — pega `process.env.A ?? process.env.B ?? 'lit'`.
43
+ // `left` "comes from process.env" when it is a direct access OR a ??/|| chain
44
+ // whose leftmost root is process.env — catches `process.env.A ?? process.env.B ?? 'lit'`.
46
45
  function leftRootIsProcessEnv(node) {
47
46
  if (isProcessEnvAccess(node)) return true
48
47
  if (node?.type === 'LogicalExpression' && (node.operator === '??' || node.operator === '||')) {
@@ -51,7 +50,7 @@ function leftRootIsProcessEnv(node) {
51
50
  return false
52
51
  }
53
52
 
54
- // Nome da env mais à esquerda (pra mensagem), descendo a cadeia ??/||.
53
+ // Leftmost env var name (for the message), walking down the ??/|| chain.
55
54
  function leftmostEnvVarName(node) {
56
55
  if (isProcessEnvAccess(node)) return node.property?.name
57
56
  if (node?.type === 'LogicalExpression') return leftmostEnvVarName(node.left)
@@ -1,12 +1,12 @@
1
1
  // Custom rule: bans EVERY `eslint-disable*` directive in code. A wrong rule is
2
2
  // changed in eslint.config.mjs through review, never silenced inline.
3
3
  //
4
- // Por que custom e não só o nativo `linterOptions.noInlineConfig`:
5
- // noInlineConfig neutraliza os directives mas reporta apenas WARNING (não
6
- // configurável pra error) — não barra um lint que roda sem `--max-warnings 0`.
7
- // Esta rule reporta ERROR (hard-fail). O `noInlineConfig` fica ligado em
8
- // paralelo como backstop: torna o disable inerte, então NÃO dá pra silenciar
9
- // esta própria regra com um `// eslint-disable-line cbrl/no-eslint-disable`.
4
+ // Why a custom rule and not just the native `linterOptions.noInlineConfig`:
5
+ // noInlineConfig neutralizes the directives but only reports a WARNING (not
6
+ // configurable as an error), so it does not fail a lint run without
7
+ // `--max-warnings 0`. This rule reports an ERROR (hard fail). `noInlineConfig`
8
+ // stays on alongside it as a backstop: it makes the directive inert, so this
9
+ // rule cannot be silenced with `// eslint-disable-line cbrl/no-eslint-disable`.
10
10
 
11
11
  export const noEslintDisable = {
12
12
  meta: {