@sarj/eslint-plugin 2.12.2 → 2.14.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
@@ -12,10 +12,54 @@ import sarj from "@sarj/eslint-plugin";
12
12
  export default [...sarj.configs.recommended];
13
13
  ```
14
14
 
15
- 41 rules. Each rule's source under `src/rules/` carries its own `@fileoverview` rationale plus `meta.docs.description` + `meta.messages` — read the file for the full reasoning, including the false positives it deliberately does not fire on.
15
+ 45 rules. Each rule's source under `src/rules/` carries its own `@fileoverview` rationale plus `meta.docs.description` + `meta.messages` — read the file for the full reasoning, including the false positives it deliberately does not fire on.
16
16
 
17
17
  Presets: `recommended` (warn-first), `strict` (every rule at error), `style-guide` (formatting/naming subset).
18
18
 
19
+ ## New in 2.14.0 — `no-tautological-expect`
20
+
21
+ The TS half of SARJ057. An `expect(...)` whose operands are all literals has
22
+ already decided its outcome before the test runs — `expect(true).toBe(true)`
23
+ passes if you delete the module under test.
24
+
25
+ Python has caught the assertion-*free* test since 0.15.0 (`SARJ043
26
+ zero-assertion-test`) and had no TypeScript counterpart, which is exactly how
27
+ `expect(true).toBe(true); // placeholder` survived in an internal suite named for
28
+ the behaviour it was supposed to check: the file *has* an assertion, so nothing
29
+ was looking at it.
30
+
31
+ | Rule | What it catches | Preset |
32
+ |---|---|---|
33
+ | `no-tautological-expect` | `expect(<literal>).toBe/toEqual/toStrictEqual(<textually identical literal>)`, and `expect(<literal>).toBeDefined()/toBeTruthy()/toBeNull()/…` — a zero-argument matcher on a literal receiver. | warn / error |
34
+
35
+ **The narrowness is the rule.** The obvious generalisation — "flag a comparison
36
+ of a thing with itself" — measures ~95% false positives:
37
+ `expect(hash([o])).toEqual(hash([o]))` is a *determinism* test,
38
+ `expect(memo(x)).toBe(memo(x))` a *memoization* test, `expect(a).toEqual(a)` on a
39
+ value with custom equality a *reflexivity* test. All three can genuinely fail. So
40
+ an identifier, member-expression or call operand is never enough: both sides must
41
+ be literals, and textually identical ones. A modified chain (`.not`, `.resolves`,
42
+ `.rejects`), a spread, an interpolated template literal, and two *different*
43
+ literals are all left alone.
44
+
45
+ Measured before shipping: **3 hits across 5,819 `.ts`/`.tsx` files** (1,003 of
46
+ them test files, where the rule is active) — six internal repos plus `got`,
47
+ `hono`, `swr` and `trpc`. 3 true positives, **0 false positives**; every hit is
48
+ an abandoned placeholder.
49
+
50
+ ## New in 2.13.0 — the anti-comment-verbosity family
51
+
52
+ From a 37,918-comment, nine-repo measurement study. All three are
53
+ deletion-class, so each was validated against zod / swr / zustand / TanStack
54
+ Query as well as the maintained repos. Read the `@fileoverview` in each rule for
55
+ the hit counts and the false-positive class every guard was built from.
56
+
57
+ | Rule | What it catches | Preset |
58
+ |---|---|---|
59
+ | `no-restated-comment` | A single-line comment whose every content word already appears on the statement below it. Defers to `no-comment-cruft` for the verb-led shape, so a comment is never reported twice. | warn / error |
60
+ | `jsdoc-restates-signature` | A JSDoc block whose description and `@param`/`@returns` only re-spell the signature. Offers a delete SUGGESTION, never an auto-`--fix`. | warn / error |
61
+ | `trailing-value-narration` | `staleTime: 5 * 60 * 1000, // 5 minutes` — the unit belongs in the name, where it cannot drift. | warn / error |
62
+
19
63
  ## New in 2.9.0
20
64
 
21
65
  Both distilled from two years of PR-review comments across ~1,065 PRs.