@drkmttr/adhere 0.6.1 → 0.7.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.
Files changed (36) hide show
  1. package/README.md +59 -31
  2. package/package.json +7 -7
  3. package/presets/effect/basics/external-calls-are-resilient.md +6 -2
  4. package/presets/effect/basics/fn-for-named-effects.md +10 -2
  5. package/presets/effect/basics/gen-for-sequencing.md +10 -2
  6. package/presets/effect/basics/instrument-with-pipe.md +9 -2
  7. package/presets/effect/cli/handlers-delegate.md +13 -2
  8. package/presets/effect/config/business-logic-depends-on-config-service.md +9 -2
  9. package/presets/effect/config/secrets-are-redacted.md +6 -2
  10. package/presets/effect/config/tests-provide-values-directly.md +8 -2
  11. package/presets/effect/config/validate-with-schema.md +9 -2
  12. package/presets/effect/data/brand-meaningful-primitives.md +11 -2
  13. package/presets/effect/data/decode-json-with-schema.md +6 -2
  14. package/presets/effect/data/records-are-schema-classes.md +9 -2
  15. package/presets/effect/data/variants-are-tagged-unions.md +9 -2
  16. package/presets/effect/errors/catch-defects-at-boundaries-only.md +6 -2
  17. package/presets/effect/errors/defects-for-bugs.md +13 -2
  18. package/presets/effect/errors/domain-errors-are-tagged.md +6 -2
  19. package/presets/effect/errors/wrap-external-errors.md +7 -2
  20. package/presets/effect/platform/os-access-through-platform-services.md +8 -2
  21. package/presets/effect/services/fresh-layer-per-test.md +9 -2
  22. package/presets/effect/services/memoize-parameterized-layers.md +9 -2
  23. package/presets/effect/services/methods-have-no-requirements.md +9 -2
  24. package/presets/effect/services/no-mutable-state.md +9 -2
  25. package/presets/effect/services/provide-at-entry.md +7 -2
  26. package/presets/effect/services/test-layers-are-in-memory.md +12 -2
  27. package/presets/effect/testing/test-clock-for-time.md +11 -2
  28. package/presets/effect/testing/test-random.md +9 -2
  29. package/skills/adhere/SKILL.md +24 -17
  30. package/src/cli.ts +2 -2
  31. package/src/config.ts +67 -13
  32. package/src/init.ts +10 -8
  33. package/src/markdown.ts +59 -25
  34. package/src/services/Jev.ts +45 -31
  35. package/src/workflows/audit.ts +3 -5
  36. package/src/workflows/format.ts +7 -3
@@ -1,4 +1,4 @@
1
- import type { Rule, RuleId } from "#config.ts";
1
+ import { type Examples, examplesOf, type Rule, type RuleId } from "#config.ts";
2
2
  import type { ScannedFile, WalkUnavailable } from "#models/Audit.ts";
3
3
  import { AdhereConfig } from "#services/AdhereConfig.ts";
4
4
  import { AuditCache, type Judgment, sha256 } from "#services/AuditCache.ts";
@@ -18,8 +18,7 @@ import { type Crypto, Effect, Record } from "effect";
18
18
  export interface Finding {
19
19
  readonly rule: RuleId;
20
20
  readonly description: string;
21
- readonly reference?: string;
22
- readonly avoid?: string;
21
+ readonly examples: Examples;
23
22
  readonly file: string;
24
23
  readonly line: number;
25
24
  readonly snippet: string;
@@ -233,8 +232,7 @@ export const executeAudit = (
233
232
  {
234
233
  rule: id,
235
234
  description: k.rule.description,
236
- reference: k.rule.reference,
237
- avoid: k.rule.avoid,
235
+ examples: examplesOf(k.rule),
238
236
  file: file.path,
239
237
  line: judgment.line,
240
238
  snippet: judgment.snippet ?? "",
@@ -97,16 +97,20 @@ const excerpt = (finding: Finding, root: string | undefined): ReadonlyArray<Line
97
97
  ];
98
98
  };
99
99
 
100
- /** The reference as the hint. A rule without one shows its code to avoid instead, labeled so. */
100
+ /**
101
+ * The code to write as the hint. A rule with only code not to write shows
102
+ * that instead, labeled with its word: `never`, or `should not`.
103
+ */
101
104
  const hint = (finding: Finding): ReadonlyArray<Line> => {
105
+ const { good, bad } = finding.examples;
102
106
  const [label, code] =
103
- finding.reference === undefined ? ["avoid", finding.avoid ?? ""] : ["hint", finding.reference];
107
+ good === undefined ? [bad?.word ?? "hint", bad?.code ?? ""] : ["hint", good.code];
104
108
  return hanging(span(` ${label}: `, "label"), codeLines(code));
105
109
  };
106
110
 
107
111
  /**
108
112
  * One diagnostic, in the frame `vp lint` prints on a terminal: a red header,
109
- * the offending line, a pink underline, and the reference code as the hint.
113
+ * the offending line, a pink underline, and the code to write as the hint.
110
114
  */
111
115
  const frame = (finding: Finding, root: string | undefined): ReadonlyArray<Line> => [
112
116
  header(finding),