unguard 0.14.0 → 0.15.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/README.md CHANGED
@@ -97,13 +97,13 @@ unguard src --fail-on=error
97
97
 
98
98
  ```txt
99
99
  src/lib/probe.ts
100
- 37:4 error Empty catch blocks hide failures... no-empty-catch
100
+ 37:4 warning Catch swallows the error... no-swallowed-catch
101
101
  ```
102
102
 
103
103
  **Flat** (`--format=flat`) -- one line per diagnostic, grepable:
104
104
 
105
105
  ```txt
106
- src/lib/probe.ts:37:4 error [no-empty-catch] Empty catch blocks hide failures...
106
+ src/lib/probe.ts:37:4 warning [no-swallowed-catch] Catch swallows the error...
107
107
  ```
108
108
 
109
109
  ## Current Rules
@@ -128,8 +128,10 @@ These rules use the TypeScript type checker. Non-nullable types suppress the dia
128
128
  | `no-optional-element-access` | warning | `obj?.[key]` on a non-nullable type |
129
129
  | `no-optional-call` | warning | `fn?.()` on a non-nullable type |
130
130
  | `no-nullish-coalescing` | warning | `x ?? fallback` on a non-nullable type |
131
- | `no-logical-or-fallback` | warning | `map.get(k) \|\| fallback` -- data-structure lookups where `??` is correct; `\|\|` on numeric types that swallow `0` |
131
+ | `no-logical-or-fallback` | warning | `map.get(k) \|\| fallback`, `count \|\| 1` -- `\|\|` swallows `0` and `""`; use `??` |
132
132
  | `no-null-ternary-normalization` | warning | `x == null ? fallback : x` |
133
+ | `no-coalesce-then-guard` | warning | `const x = a ?? null; if (x == null)` -- guard re-checks the same partition the `??` just created |
134
+ | `no-await-coalesce` | warning | `await fn() ?? fallback` -- fuses the call's failure mode into the fallback (skips `Map.get`, `Array.find`, and structural optionals) |
133
135
  | `no-non-null-assertion` | warning | `x!` on a nullable type without a local narrowing guard |
134
136
  | `no-double-negation-coercion` | info | `!!value` |
135
137
  | `no-redundant-existence-guard` | warning | `obj && obj.prop` on a non-nullable type |
@@ -138,8 +140,7 @@ These rules use the TypeScript type checker. Non-nullable types suppress the dia
138
140
 
139
141
  | Rule | Severity | What it catches |
140
142
  | ---- | -------- | --------------- |
141
- | `no-empty-catch` | error | `catch {}` with no body and no comment |
142
- | `no-catch-return` | warning | `catch { return fallback }` with no logging or rethrow |
143
+ | `no-swallowed-catch` | warning | `catch (e) {}`, `catch (e) { log(e); return fallback }`, `.catch(() => fallback)` -- error neither rethrown nor surfaced in the return value |
143
144
  | `no-error-rewrap` | error | `throw new Error(e.message)` without `{ cause: e }` |
144
145
 
145
146
  ### Interface design
@@ -149,8 +150,9 @@ These rules use the TypeScript type checker. Non-nullable types suppress the dia
149
150
  | `no-inline-param-type` | warning | `(params: { id: string; ... })` — inline object type on parameter |
150
151
  | `prefer-default-param-value` | info | Optional param reassigned with `??` in the body |
151
152
  | `prefer-required-param-with-guard` | info | `arg?: T` followed by `if (!arg) throw` |
152
- | `repeated-literal-property` | warning | Same literal value (`as const`: 3+, plain: 5+) repeated in object properties within a file |
153
- | `repeated-return-shape` | warning | 3+ functions return object literals with the same property name set |
153
+ | `no-defaulted-required-port-arg` | warning | `class C implements I { method(arg = x) }` where `I.method(arg)` is required -- the default widens the interface contract |
154
+ | `repeated-literal-property` | warning | Same literal value repeated across object properties -- likely a missed constant |
155
+ | `repeated-return-shape` | warning | Multiple functions return object literals with the same property names -- extract a shared return type |
154
156
 
155
157
  ### State management
156
158
 
@@ -164,13 +166,13 @@ These rules use the TypeScript type checker. Non-nullable types suppress the dia
164
166
  | ---- | -------- | --------------- |
165
167
  | `duplicate-type-declaration` | warning | Same type shape in multiple files |
166
168
  | `duplicate-type-name` | warning | Same exported type name, different shapes |
167
- | `duplicate-function-declaration` | warning | Same function body in multiple files (2+ statements) |
169
+ | `duplicate-function-declaration` | warning | Same function body in multiple files |
168
170
  | `duplicate-function-name` | warning | Same exported function name, different bodies |
169
171
  | `duplicate-constant-declaration` | warning | Same constant value in multiple files |
170
- | `duplicate-inline-type-in-params` | warning | Same inline `{ ... }` param type shape repeated 2+ times |
172
+ | `duplicate-inline-type-in-params` | warning | Same inline `{ ... }` param type repeated across signatures |
171
173
  | `duplicate-file` | warning | File with identical content to another file |
172
- | `near-duplicate-function` | warning | Function bodies identical after normalizing params, strings, numbers, `this` |
173
- | `duplicate-statement-sequence` | info | Repeated contiguous statement blocks (3+ statements) |
174
+ | `near-duplicate-function` | warning | Function bodies that match after renaming params and literals -- likely a copy-paste |
175
+ | `duplicate-statement-sequence` | info | Repeated block of statements across functions or files |
174
176
  | `trivial-wrapper` | info | Function that delegates to another without transformation |
175
177
  | `unused-export` | info | Exported function with no usages in the project |
176
178
  | `optional-arg-always-used` | warning | Optional param provided at every call site |