@hailstails/hone 1.4.0 → 2.0.0-pre.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.
- package/ADOPTING.md +239 -168
- package/CHANGELOG.md +141 -0
- package/MIGRATING.md +145 -45
- package/README.md +148 -182
- package/chunks/chunk-5HRMJ4O2.js +608 -0
- package/chunks/chunk-5U4JMWNV.js +9 -0
- package/chunks/{chunk-FEWCJU7H.js → chunk-ASUN4AVC.js} +31 -12
- package/chunks/chunk-DGOLOS5A.js +9 -0
- package/chunks/{chunk-HJA4CX7C.js → chunk-FBZBSDED.js} +1 -1
- package/chunks/{chunk-Y2KPZDDV.js → chunk-GNOMK7CR.js} +201 -98
- package/chunks/chunk-IX2VZTBO.js +887 -0
- package/chunks/{chunk-QWA6OVLC.js → chunk-K2W3D3NB.js} +8 -2
- package/chunks/chunk-L7BGRC6D.js +22 -0
- package/chunks/chunk-M6SOGWT7.js +82 -0
- package/chunks/chunk-MWLBA4B3.js +849 -0
- package/chunks/chunk-NRIQD3PI.js +38 -0
- package/chunks/chunk-OKLYWD2Z.js +823 -0
- package/chunks/{chunk-3HFJHJDO.js → chunk-QP5TLOBY.js} +17 -8
- package/chunks/chunk-R75QELTA.js +481 -0
- package/chunks/chunk-RANAKCTW.js +31 -0
- package/chunks/{chunk-NA5L6PUE.js → chunk-RANIXNWY.js} +1 -2
- package/chunks/chunk-RFR3ITBS.js +9 -0
- package/chunks/{chunk-Z4UBS7WI.js → chunk-RGSHTPLA.js} +26 -7
- package/chunks/{chunk-T32FOWZA.js → chunk-TNY2PASL.js} +14 -18
- package/chunks/{chunk-Y4SMWOD2.js → chunk-UJONWHA4.js} +2 -2
- package/chunks/{chunk-WF3PPYRR.js → chunk-VYBO2Q65.js} +4 -2
- package/chunks/chunk-Z6JHBNDS.js +15 -0
- package/chunks/eslint-10-boundary-A4JIQ734.js +14 -0
- package/chunks/eslint-9-boundary-CL5DDBHX.js +34 -0
- package/docs/adding-a-discipline-or-mechanism.md +23 -19
- package/docs/extending.md +6 -5
- package/docs/output-contract.md +713 -16
- package/docs/why-chain-contract.md +6 -6
- package/methods/README.md +2 -2
- package/methods/assessment-template.md +3 -3
- package/methods/lenses/clean-architecture.md +26 -62
- package/methods/lenses/decomposition.md +7 -7
- package/methods/lenses/defended-on-intent.md +6 -6
- package/methods/lenses/di-discipline.md +18 -21
- package/methods/lenses/errors-as-data.md +6 -6
- package/methods/lenses/function-first.md +25 -27
- package/methods/lenses/naming.md +6 -6
- package/methods/lenses/test-discipline.md +8 -8
- package/methods/lenses/type-soundness.md +6 -6
- package/methods/lenses/zod-boundary.md +9 -9
- package/package.json +30 -28
- package/rules/README.md +335 -54
- package/rules/SPIRIT.md +4 -4
- package/rules/cases/a-value-is-one-of-several-kinds-or-states.md +20 -0
- package/rules/cases/an-adopter-is-not-handed-our-risk.md +17 -0
- package/rules/cases/an-operation-can-fail.md +20 -0
- package/rules/cases/builds-the-real-implementations.md +25 -0
- package/rules/cases/causes-an-effect.md +26 -0
- package/rules/cases/checks-a-value-that-may-be-one-of-several-outcomes.md +20 -0
- package/rules/cases/checks-conditions-before-its-work.md +20 -0
- package/rules/cases/coordinates-other-units.md +20 -0
- package/rules/cases/does-one-job.md +23 -0
- package/rules/cases/explains-something-in-prose.md +20 -0
- package/rules/cases/gives-a-value-its-type.md +26 -0
- package/rules/cases/gives-each-unit-its-test.md +20 -0
- package/rules/cases/keeps-state-or-settings-across-calls.md +20 -0
- package/rules/cases/makes-a-new-value-from-what-it-has.md +17 -0
- package/rules/cases/names-something.md +20 -0
- package/rules/cases/needs-the-current-time-a-random-value-a-new-id-or-an-outside-ordering.md +26 -0
- package/rules/cases/puts-code-in-a-file-or-folder.md +20 -0
- package/rules/cases/reads-data-from-outside.md +23 -0
- package/rules/cases/reuses-behaviour-from-another-unit-or-type.md +20 -0
- package/rules/cases/sends-data-out-of-the-program.md +20 -0
- package/rules/cases/sets-how-strictly-the-checker-works.md +14 -0
- package/rules/cases/ships-code-for-others.md +17 -0
- package/rules/cases/states-what-the-unit-gives-back-for-one-case-or-several.md +20 -0
- package/rules/cases/takes-an-outside-dependency.md +38 -0
- package/rules/cases/tests-across-units-or-against-a-real-system.md +20 -0
- package/rules/cases/uses-a-system-or-service-outside-the-program.md +29 -0
- package/rules/cases/uses-what-a-collaborator-gives-back.md +20 -0
- package/rules/cases/writes-basic-logic.md +17 -0
- package/rules/cases.md +71 -0
- package/rules/numbers.md +155 -0
- package/rules/principles/external-behaviour-sits-at-a-boundary.md +12 -0
- package/rules/principles/no-hidden-effects.md +17 -0
- package/rules/principles/no-leak-across-a-boundary.md +19 -0
- package/rules/principles/one-place-decides.md +12 -0
- package/rules/principles/our-code-reads-in-the-common-language.md +12 -0
- package/rules/principles/outside-risk-is-carried-on-purpose.md +13 -0
- package/rules/principles/tests-are-ours.md +12 -0
- package/rules/principles/the-type-checker-proves-it.md +12 -0
- package/rules/principles.md +93 -0
- package/rules/record-kinds/authorised-location.md +26 -0
- package/rules/record-kinds/boundary-record.md +9 -0
- package/rules/record-kinds/debt.md +23 -0
- package/rules/record-kinds/dependency-record.md +9 -0
- package/rules/record-kinds/deviation.md +9 -0
- package/rules/records.md +137 -0
- package/rules/rules/declared-not-asserted.md +16 -0
- package/rules/rules/doer-or-orchestrator.md +16 -0
- package/rules/rules/failures-are-values.md +15 -0
- package/rules/rules/fixed-versions.md +11 -0
- package/rules/rules/guard-first.md +14 -0
- package/rules/rules/handed-what-it-uses.md +16 -0
- package/rules/rules/kinds-are-named.md +16 -0
- package/rules/rules/one-reason-per-module.md +18 -0
- package/rules/rules/one-word-everywhere.md +19 -0
- package/rules/rules/outside-dependencies-justified.md +14 -0
- package/rules/rules/outside-dependencies-stay-at-boundaries.md +18 -0
- package/rules/rules/ports-declared-inside.md +22 -0
- package/rules/rules/shipped-risk-declared.md +11 -0
- package/rules/rules/straight-through-tests.md +15 -0
- package/rules/rules/tested-where-its-owned.md +20 -0
- package/rules/rules/tools-live-in-the-repo.md +11 -0
- package/rules/rules/upstream-stays-untouched.md +11 -0
- package/rules/rules/written-out-answers.md +17 -0
- package/rules/rules.md +185 -0
- package/rules/sources.md +142 -0
- package/rules/typescript/checks.md +1685 -0
- package/rules/typescript/recipes/adapter-per-outside-party.md +18 -0
- package/rules/typescript/recipes/assert-to-narrow.md +18 -0
- package/rules/typescript/recipes/bounded-context-generic.md +19 -0
- package/rules/typescript/recipes/closure-factory.md +20 -0
- package/rules/typescript/recipes/companion-test-file.md +18 -0
- package/rules/typescript/recipes/composed-orchestrator.md +18 -0
- package/rules/typescript/recipes/composition-root.md +18 -0
- package/rules/typescript/recipes/copy-never-write-in.md +18 -0
- package/rules/typescript/recipes/declared-not-bundled.md +17 -0
- package/rules/typescript/recipes/dependency-record.md +20 -0
- package/rules/typescript/recipes/domain-vocabulary-list.md +18 -0
- package/rules/typescript/recipes/entity-module.md +20 -0
- package/rules/typescript/recipes/exact-pins-and-a-lock-file.md +18 -0
- package/rules/typescript/recipes/extension-outside-the-vendored-code.md +18 -0
- package/rules/typescript/recipes/failure-asserted-as-a-value.md +18 -0
- package/rules/typescript/recipes/failure-mapping-at-the-adapter.md +20 -0
- package/rules/typescript/recipes/fix-the-declaration-not-the-value.md +18 -0
- package/rules/typescript/recipes/functional-iteration.md +18 -0
- package/rules/typescript/recipes/guard-clauses.md +18 -0
- package/rules/typescript/recipes/integration-test-owns-its-scratch.md +18 -0
- package/rules/typescript/recipes/integration-test-suffix.md +18 -0
- package/rules/typescript/recipes/iteach-over-typed-rows.md +18 -0
- package/rules/typescript/recipes/map-out-at-the-adapter.md +18 -0
- package/rules/typescript/recipes/meaning-in-names-not-comments.md +22 -0
- package/rules/typescript/recipes/named-exported-type.md +18 -0
- package/rules/typescript/recipes/narrow-ports.md +18 -0
- package/rules/typescript/recipes/one-argument-object.md +19 -0
- package/rules/typescript/recipes/port-in-the-domain.md +19 -0
- package/rules/typescript/recipes/ports-in-the-argument.md +18 -0
- package/rules/typescript/recipes/repo-scripts-only.md +18 -0
- package/rules/typescript/recipes/result-union.md +22 -0
- package/rules/typescript/recipes/screaming-folders.md +20 -0
- package/rules/typescript/recipes/shared-strict-base-config.md +20 -0
- package/rules/typescript/recipes/stub-with-vifn.md +20 -0
- package/rules/typescript/recipes/tagged-union-and-exhaustive-switch.md +18 -0
- package/rules/typescript/recipes/whole-words.md +18 -0
- package/rules/typescript/recipes/whole-written-out-expectation.md +18 -0
- package/rules/typescript/recipes/world-values-through-a-port.md +18 -0
- package/rules/typescript/recipes/zod-at-the-producers-adapter.md +19 -0
- package/rules/typescript/recipes.md +390 -0
- package/rules/typescript/symptoms/absence-standing-for-a-state.md +36 -0
- package/rules/typescript/symptoms/adapter-built-outside-the-root.md +30 -0
- package/rules/typescript/symptoms/ambient-randomness.md +36 -0
- package/rules/typescript/symptoms/answer-set-in-a-hook.md +45 -0
- package/rules/typescript/symptoms/authored-class-or-this/class-keyword.md +30 -0
- package/rules/typescript/symptoms/authored-class-or-this/static-members-only.md +18 -0
- package/rules/typescript/symptoms/authored-class-or-this.md +49 -0
- package/rules/typescript/symptoms/behaviour-tested-away-from-its-owner.md +44 -0
- package/rules/typescript/symptoms/boolean-in-a-signature/boolean-annotation.md +30 -0
- package/rules/typescript/symptoms/boolean-in-a-signature.md +43 -0
- package/rules/typescript/symptoms/branch-in-a-test/test-body.md +213 -0
- package/rules/typescript/symptoms/branch-in-a-test.md +48 -0
- package/rules/typescript/symptoms/bundled-dependency.md +28 -0
- package/rules/typescript/symptoms/catch-all-failure-kind.md +37 -0
- package/rules/typescript/symptoms/change-spread-across-modules.md +27 -0
- package/rules/typescript/symptoms/claimed-type/cast-to-any.md +29 -0
- package/rules/typescript/symptoms/claimed-type/non-null-assertions.md +34 -0
- package/rules/typescript/symptoms/claimed-type/unlisted-cast-site.md +34 -0
- package/rules/typescript/symptoms/claimed-type.md +56 -0
- package/rules/typescript/symptoms/computed-value-in-a-test/test-body.md +144 -0
- package/rules/typescript/symptoms/computed-value-in-a-test.md +36 -0
- package/rules/typescript/symptoms/coverage-gate.md +27 -0
- package/rules/typescript/symptoms/date-used-directly/clock-sources.md +31 -0
- package/rules/typescript/symptoms/date-used-directly.md +46 -0
- package/rules/typescript/symptoms/default-for-a-required-value.md +45 -0
- package/rules/typescript/symptoms/default-on-a-closed-union/default-arm.md +32 -0
- package/rules/typescript/symptoms/default-on-a-closed-union.md +32 -0
- package/rules/typescript/symptoms/dependency-without-a-record.md +33 -0
- package/rules/typescript/symptoms/doer-calling-our-own-unit.md +36 -0
- package/rules/typescript/symptoms/double-with-a-body/logic-in-a-passed-function.md +32 -0
- package/rules/typescript/symptoms/double-with-a-body/stub-implementation.md +31 -0
- package/rules/typescript/symptoms/double-with-a-body.md +55 -0
- package/rules/typescript/symptoms/drawer-path/drawer-names.md +28 -0
- package/rules/typescript/symptoms/drawer-path.md +32 -0
- package/rules/typescript/symptoms/duplicate-decision.md +36 -0
- package/rules/typescript/symptoms/edit-inside-vendored-code.md +33 -0
- package/rules/typescript/symptoms/failure-shaped-as-success.md +28 -0
- package/rules/typescript/symptoms/floating-version.md +27 -0
- package/rules/typescript/symptoms/inherited-environment-in-a-subprocess/git-spawn-environment.md +30 -0
- package/rules/typescript/symptoms/inherited-environment-in-a-subprocess.md +33 -0
- package/rules/typescript/symptoms/inner-layer-imports-outer.md +33 -0
- package/rules/typescript/symptoms/integration-heavy-suite.md +29 -0
- package/rules/typescript/symptoms/large-input-for-a-few-fields.md +37 -0
- package/rules/typescript/symptoms/library-class-built-in-place.md +42 -0
- package/rules/typescript/symptoms/long-function/function-length.md +47 -0
- package/rules/typescript/symptoms/long-function.md +75 -0
- package/rules/typescript/symptoms/loop-keyword/loop-statement.md +34 -0
- package/rules/typescript/symptoms/loop-keyword.md +49 -0
- package/rules/typescript/symptoms/machine-touched-in-a-unit-test.md +40 -0
- package/rules/typescript/symptoms/many-spellings-of-one-concept.md +29 -0
- package/rules/typescript/symptoms/module-level-state.md +30 -0
- package/rules/typescript/symptoms/module-or-global-patched/module-mock-call.md +29 -0
- package/rules/typescript/symptoms/module-or-global-patched.md +38 -0
- package/rules/typescript/symptoms/name-off-its-casing/filename-case.md +16 -0
- package/rules/typescript/symptoms/name-off-its-casing/naming-convention.md +20 -0
- package/rules/typescript/symptoms/name-off-its-casing.md +31 -0
- package/rules/typescript/symptoms/no-lock-file.md +27 -0
- package/rules/typescript/symptoms/orchestrator-that-computes.md +27 -0
- package/rules/typescript/symptoms/outside-dependency-vocabulary-for-basic-logic.md +33 -0
- package/rules/typescript/symptoms/outside-import-past-a-boundary/import-or-require.md +44 -0
- package/rules/typescript/symptoms/outside-import-past-a-boundary.md +45 -0
- package/rules/typescript/symptoms/outside-type-in-a-signature.md +37 -0
- package/rules/typescript/symptoms/own-type-guard.md +36 -0
- package/rules/typescript/symptoms/port-named-for-a-mechanism.md +34 -0
- package/rules/typescript/symptoms/port-outside-the-domain.md +28 -0
- package/rules/typescript/symptoms/positional-parameters/parameter-count.md +30 -0
- package/rules/typescript/symptoms/positional-parameters.md +43 -0
- package/rules/typescript/symptoms/process-global-used-in-place.md +53 -0
- package/rules/typescript/symptoms/prose-in-code.md +27 -0
- package/rules/typescript/symptoms/rebinding/parameter-reassignment.md +18 -0
- package/rules/typescript/symptoms/rebinding/test-body.md +32 -0
- package/rules/typescript/symptoms/rebinding.md +36 -0
- package/rules/typescript/symptoms/schema-past-its-adapter.md +41 -0
- package/rules/typescript/symptoms/shorthand-name/identifier-names.md +29 -0
- package/rules/typescript/symptoms/shorthand-name.md +32 -0
- package/rules/typescript/symptoms/strictness-weakened/exact-optional-property-types.md +51 -0
- package/rules/typescript/symptoms/strictness-weakened/no-fallthrough-cases-in-switch.md +51 -0
- package/rules/typescript/symptoms/strictness-weakened/no-implicit-override.md +51 -0
- package/rules/typescript/symptoms/strictness-weakened/no-property-access-from-index-signature.md +51 -0
- package/rules/{CD-3/CHECKS.md → typescript/symptoms/strictness-weakened/no-unchecked-indexed-access.md} +23 -38
- package/rules/typescript/symptoms/strictness-weakened/strict.md +51 -0
- package/rules/typescript/symptoms/strictness-weakened/use-unknown-in-catch-variables.md +51 -0
- package/rules/typescript/symptoms/strictness-weakened.md +32 -0
- package/rules/typescript/symptoms/tangled-function/cognitive-complexity.md +42 -0
- package/rules/typescript/symptoms/tangled-function.md +75 -0
- package/rules/typescript/symptoms/test-of-the-type-checker.md +24 -0
- package/rules/typescript/symptoms/test-switched-off/focused-tests.md +15 -0
- package/rules/typescript/symptoms/test-switched-off/skipped-tests.md +15 -0
- package/rules/typescript/symptoms/test-switched-off.md +25 -0
- package/rules/typescript/symptoms/text-past-its-reader/test-body.md +30 -0
- package/rules/typescript/symptoms/text-past-its-reader.md +71 -0
- package/rules/typescript/symptoms/throw-between-our-units.md +46 -0
- package/rules/typescript/symptoms/throw-or-catch-in-a-test/throw-statement.md +32 -0
- package/rules/typescript/symptoms/throw-or-catch-in-a-test/try-block.md +39 -0
- package/rules/typescript/symptoms/throw-or-catch-in-a-test.md +35 -0
- package/rules/typescript/symptoms/thrown-non-error/throw-only-error.md +15 -0
- package/rules/typescript/symptoms/thrown-non-error.md +27 -0
- package/rules/typescript/symptoms/tool-fetched-at-run-time.md +27 -0
- package/rules/typescript/symptoms/tuple-as-data.md +29 -0
- package/rules/typescript/symptoms/type-derived-from-code/factory-return-types.md +29 -0
- package/rules/typescript/symptoms/type-derived-from-code.md +41 -0
- package/rules/typescript/symptoms/types-only-file.md +36 -0
- package/rules/typescript/symptoms/unasserted-call.md +29 -0
- package/rules/typescript/symptoms/unit-without-a-running-test/companion-test-file.md +28 -0
- package/rules/typescript/symptoms/unit-without-a-running-test.md +28 -0
- package/rules/{CD-5/CHECKS.md → typescript/symptoms/untracked-escape/directive-pointers.md} +12 -23
- package/rules/typescript/symptoms/untracked-escape.md +32 -0
- package/rules/typescript/symptoms/untyped-value/explicit-any.md +14 -0
- package/rules/typescript/symptoms/untyped-value/implicit-any-let.md +14 -0
- package/rules/typescript/symptoms/untyped-value.md +36 -0
- package/rules/typescript/symptoms/wide-input.md +37 -0
- package/rules/typescript/symptoms/wide-port.md +32 -0
- package/rules/typescript/symptoms/work-inside-a-condition/else-after-an-exit.md +40 -0
- package/rules/typescript/symptoms/work-inside-a-condition.md +41 -0
- package/rules/typescript/symptoms/write-into-a-parameter/parameter-mutation.md +33 -0
- package/rules/typescript/symptoms/write-into-a-parameter.md +34 -0
- package/rules/typescript/symptoms.md +821 -0
- package/{core → src/application}/conformance/conformance-testing-types.d.ts +16 -6
- package/src/audit.d.ts +20 -0
- package/{api → src}/audit.js +6 -5
- package/{core/rule-set-reader → src/domain/rule-set}/authored-rule-set-types.d.ts +2 -2
- package/{core/values → src/domain/rule-set}/edition-types.d.ts +3 -3
- package/{core/values → src/domain/rule-set}/identifier-types.d.ts +2 -2
- package/{core/conformance → src/domain/runner}/conformance-types.d.ts +1 -1
- package/{core/mechanism-port → src/domain/runner}/piece-failure-types.d.ts +1 -1
- package/{core/mechanism-port → src/domain/runner}/runner-module-types.d.ts +4 -4
- package/src/domain/runner/runner-result-types.d.ts +88 -0
- package/src/eslint-plugin.d.ts +16 -0
- package/src/eslint-plugin.js +72 -0
- package/src/hone.js +13385 -0
- package/src/infrastructure/disciplines-file/version-one-names.json +634 -0
- package/src/infrastructure/engines/eslint/authored-class-or-this/class-keyword/class-keyword.examples.json +84 -0
- package/{mechanisms/eslint/CD-14/cd14/cd14.eslint-plugin.js → src/infrastructure/engines/eslint/authored-class-or-this/class-keyword/eslint-plugin.js} +9 -10
- package/src/infrastructure/engines/eslint/authored-class-or-this/class-keyword/piece.json +12 -0
- package/src/infrastructure/engines/eslint/authored-class-or-this/static-members-only/piece.json +24 -0
- package/src/infrastructure/engines/eslint/authored-class-or-this/static-members-only/static-members-only.examples.json +36 -0
- package/src/infrastructure/engines/eslint/claimed-type/non-null-assertions/eslint-plugin.js +16 -0
- package/src/infrastructure/engines/eslint/claimed-type/non-null-assertions/non-null-assertions.examples.json +48 -0
- package/src/infrastructure/engines/eslint/claimed-type/non-null-assertions/piece.json +22 -0
- package/src/infrastructure/engines/eslint/long-function/function-length/function-length.examples.json +42 -0
- package/src/infrastructure/engines/eslint/long-function/function-length/piece.json +16 -0
- package/{mechanisms/eslint/CD-7/cd7/cd7.eslint-plugin.js → src/infrastructure/engines/eslint/name-off-its-casing/filename-case/eslint-plugin.js} +5 -4
- package/src/infrastructure/engines/eslint/name-off-its-casing/filename-case/filename-case.examples.json +60 -0
- package/src/infrastructure/engines/eslint/name-off-its-casing/filename-case/piece.json +11 -0
- package/src/infrastructure/engines/eslint/name-off-its-casing/naming-convention/eslint-plugin.js +16 -0
- package/src/infrastructure/engines/eslint/name-off-its-casing/naming-convention/naming-convention.examples.json +78 -0
- package/src/infrastructure/engines/eslint/name-off-its-casing/naming-convention/piece.json +214 -0
- package/src/infrastructure/engines/eslint/positional-parameters/parameter-count/eslint-plugin.js +16 -0
- package/src/infrastructure/engines/eslint/positional-parameters/parameter-count/parameter-count.examples.json +30 -0
- package/src/infrastructure/engines/eslint/positional-parameters/parameter-count/piece.json +18 -0
- package/src/infrastructure/engines/eslint/rebinding/parameter-reassignment/eslint-plugin.js +16 -0
- package/src/infrastructure/engines/eslint/rebinding/parameter-reassignment/parameter-reassignment.examples.json +30 -0
- package/src/infrastructure/engines/eslint/rebinding/parameter-reassignment/piece.json +17 -0
- package/{mechanisms → src/infrastructure/engines}/eslint/runner/README.md +5 -5
- package/{mechanisms/eslint/runner → src/infrastructure/engines/eslint/runner/pieces}/eslint-piece-settings-types.d.ts +1 -1
- package/{mechanisms → src/infrastructure/engines}/eslint/runner/runner.js +2189 -1371
- package/{mechanisms/eslint/CD-41 → src/infrastructure/engines/eslint/tangled-function/cognitive-complexity}/README.md +1 -1
- package/src/infrastructure/engines/eslint/tangled-function/cognitive-complexity/cognitive-complexity.examples.json +48 -0
- package/{mechanisms/eslint/CD-41/cd41/cd41.eslint-plugin.js → src/infrastructure/engines/eslint/tangled-function/cognitive-complexity/eslint-plugin.js} +58 -14
- package/src/infrastructure/engines/eslint/tangled-function/cognitive-complexity/piece.json +12 -0
- package/{mechanisms/eslint/CD-27/cd27/cd27.eslint-plugin.js → src/infrastructure/engines/eslint/test-switched-off/focused-tests/eslint-plugin.js} +5 -4
- package/src/infrastructure/engines/eslint/test-switched-off/focused-tests/focused-tests.examples.json +60 -0
- package/src/infrastructure/engines/eslint/test-switched-off/focused-tests/piece.json +12 -0
- package/src/infrastructure/engines/eslint/test-switched-off/skipped-tests/piece.json +16 -0
- package/src/infrastructure/engines/eslint/test-switched-off/skipped-tests/skipped-tests.examples.json +54 -0
- package/{mechanisms/eslint/CD-10/cd10/cd10.eslint-plugin.js → src/infrastructure/engines/eslint/thrown-non-error/throw-only-error/eslint-plugin.js} +5 -4
- package/src/infrastructure/engines/eslint/thrown-non-error/throw-only-error/piece.json +12 -0
- package/src/infrastructure/engines/eslint/thrown-non-error/throw-only-error/throw-only-error.examples.json +54 -0
- package/{mechanisms/eslint/CD-1/cd1/cd1.eslint-plugin.js → src/infrastructure/engines/eslint/untyped-value/explicit-any/eslint-plugin.js} +14 -9
- package/src/infrastructure/engines/eslint/untyped-value/explicit-any/explicit-any.examples.json +36 -0
- package/src/infrastructure/engines/eslint/untyped-value/explicit-any/piece.json +12 -0
- package/src/infrastructure/engines/eslint/untyped-value/implicit-any-let/implicit-any-let.examples.json +48 -0
- package/src/infrastructure/engines/eslint/untyped-value/implicit-any-let/piece.json +16 -0
- package/src/infrastructure/engines/eslint/work-inside-a-condition/else-after-an-exit/else-after-an-exit.examples.json +36 -0
- package/{mechanisms/eslint/CD-42/cd42/cd42.eslint-plugin.js → src/infrastructure/engines/eslint/work-inside-a-condition/else-after-an-exit/eslint-plugin.js} +29 -13
- package/src/infrastructure/engines/eslint/work-inside-a-condition/else-after-an-exit/piece.json +12 -0
- package/src/infrastructure/engines/walker/authored-class-or-this/class-keyword/class-keyword.examples.json +84 -0
- package/{mechanisms/audit/CD-14 → src/infrastructure/engines/walker/authored-class-or-this/class-keyword}/class-syntax.js +6 -3
- package/src/infrastructure/engines/walker/authored-class-or-this/class-keyword/piece.json +10 -0
- package/src/infrastructure/engines/walker/boolean-in-a-signature/boolean-annotation/boolean-annotation.examples.json +42 -0
- package/{mechanisms/audit/CD-43 → src/infrastructure/engines/walker/boolean-in-a-signature/boolean-annotation}/boolean-signatures.js +14 -6
- package/src/infrastructure/engines/walker/boolean-in-a-signature/boolean-annotation/piece.json +9 -0
- package/src/infrastructure/engines/walker/branch-in-a-test/test-body/piece.json +95 -0
- package/{mechanisms/audit/CD-27 → src/infrastructure/engines/walker/branch-in-a-test/test-body}/test-body-logic.js +188 -56
- package/src/infrastructure/engines/walker/branch-in-a-test/test-body/test-body.examples.json +280 -0
- package/{mechanisms/audit/CD-1 → src/infrastructure/engines/walker/claimed-type/cast-to-any}/any-cast.js +7 -4
- package/src/infrastructure/engines/walker/claimed-type/cast-to-any/cast-to-any.examples.json +48 -0
- package/src/infrastructure/engines/walker/claimed-type/cast-to-any/piece.json +9 -0
- package/{mechanisms/audit/CD-2 → src/infrastructure/engines/walker/claimed-type/unlisted-cast-site}/cast-expressions.js +13 -6
- package/src/infrastructure/engines/walker/claimed-type/unlisted-cast-site/piece.json +14 -0
- package/src/infrastructure/engines/walker/claimed-type/unlisted-cast-site/unlisted-cast-site.examples.json +54 -0
- package/src/infrastructure/engines/walker/computed-value-in-a-test/test-body/piece.json +18 -0
- package/src/infrastructure/engines/walker/date-used-directly/clock-sources/clock-sources.examples.json +30 -0
- package/src/infrastructure/engines/walker/date-used-directly/clock-sources/clock-sources.js +36 -0
- package/src/infrastructure/engines/walker/date-used-directly/clock-sources/piece.json +9 -0
- package/src/infrastructure/engines/walker/default-on-a-closed-union/default-arm/default-arm.examples.json +36 -0
- package/src/infrastructure/engines/walker/default-on-a-closed-union/default-arm/piece.json +9 -0
- package/src/infrastructure/engines/walker/default-on-a-closed-union/default-arm/switch-defaults.js +54 -0
- package/src/infrastructure/engines/walker/double-with-a-body/logic-in-a-passed-function/piece.json +18 -0
- package/{mechanisms/audit/CD-25 → src/infrastructure/engines/walker/double-with-a-body/stub-implementation}/dependency-isolation.js +8 -4
- package/src/infrastructure/engines/walker/double-with-a-body/stub-implementation/piece.json +9 -0
- package/src/infrastructure/engines/walker/double-with-a-body/stub-implementation/stub-implementation.examples.json +36 -0
- package/{mechanisms/audit/CD-7 → src/infrastructure/engines/walker/drawer-path/drawer-names}/categorical-paths.js +23 -8
- package/src/infrastructure/engines/walker/drawer-path/drawer-names/drawer-names.examples.json +42 -0
- package/src/infrastructure/engines/walker/drawer-path/drawer-names/piece.json +9 -0
- package/src/infrastructure/engines/walker/inherited-environment-in-a-subprocess/git-spawn-environment/git-spawn-environment.examples.json +36 -0
- package/{mechanisms/audit/CD-47 → src/infrastructure/engines/walker/inherited-environment-in-a-subprocess/git-spawn-environment}/hermetic-git-spawns.js +13 -4
- package/src/infrastructure/engines/walker/inherited-environment-in-a-subprocess/git-spawn-environment/piece.json +9 -0
- package/src/infrastructure/engines/walker/loop-keyword/loop-statement/loop-statement.examples.json +48 -0
- package/{mechanisms/audit/CD-15 → src/infrastructure/engines/walker/loop-keyword/loop-statement}/loops.js +12 -4
- package/src/infrastructure/engines/walker/loop-keyword/loop-statement/piece.json +9 -0
- package/src/infrastructure/engines/walker/module-or-global-patched/module-mock-call/module-mock-call.examples.json +36 -0
- package/{mechanisms/audit/CD-26 → src/infrastructure/engines/walker/module-or-global-patched/module-mock-call}/module-mocking.js +8 -4
- package/src/infrastructure/engines/walker/module-or-global-patched/module-mock-call/piece.json +9 -0
- package/src/infrastructure/engines/walker/outside-import-past-a-boundary/import-or-require/import-boundaries.js +133 -0
- package/src/infrastructure/engines/walker/outside-import-past-a-boundary/import-or-require/import-or-require.examples.json +42 -0
- package/src/infrastructure/engines/walker/outside-import-past-a-boundary/import-or-require/piece.json +14 -0
- package/src/infrastructure/engines/walker/rebinding/test-body/piece.json +18 -0
- package/{mechanisms/audit/runner → src/infrastructure/engines/walker/runner/pieces}/walker-piece.d.ts +8 -14
- package/{mechanisms/audit → src/infrastructure/engines/walker}/runner/runner.js +194 -121
- package/{mechanisms/audit/runner → src/infrastructure/engines/walker/runner/toolchain}/typescript-parse.d.ts +1 -0
- package/src/infrastructure/engines/walker/shorthand-name/identifier-names/identifier-names.examples.json +42 -0
- package/{mechanisms/audit/CD-6 → src/infrastructure/engines/walker/shorthand-name/identifier-names}/identifier-names.js +32 -15
- package/src/infrastructure/engines/walker/shorthand-name/identifier-names/piece.json +9 -0
- package/src/infrastructure/engines/walker/strictness-weakened/exact-optional-property-types/exact-optional-property-types.examples.json +71 -0
- package/src/infrastructure/engines/walker/strictness-weakened/exact-optional-property-types/piece.json +17 -0
- package/src/infrastructure/engines/walker/strictness-weakened/no-fallthrough-cases-in-switch/no-fallthrough-cases-in-switch.examples.json +71 -0
- package/src/infrastructure/engines/walker/strictness-weakened/no-fallthrough-cases-in-switch/piece.json +17 -0
- package/src/infrastructure/engines/walker/strictness-weakened/no-implicit-override/no-implicit-override.examples.json +71 -0
- package/src/infrastructure/engines/walker/strictness-weakened/no-implicit-override/piece.json +17 -0
- package/src/infrastructure/engines/walker/strictness-weakened/no-property-access-from-index-signature/no-property-access-from-index-signature.examples.json +71 -0
- package/src/infrastructure/engines/walker/strictness-weakened/no-property-access-from-index-signature/piece.json +17 -0
- package/src/infrastructure/engines/walker/strictness-weakened/no-unchecked-indexed-access/no-unchecked-indexed-access.examples.json +71 -0
- package/src/infrastructure/engines/walker/strictness-weakened/no-unchecked-indexed-access/piece.json +17 -0
- package/{mechanisms/audit/CD-3 → src/infrastructure/engines/walker/strictness-weakened/strict}/compiler-overrides.js +102 -38
- package/src/infrastructure/engines/walker/strictness-weakened/strict/piece.json +13 -0
- package/src/infrastructure/engines/walker/strictness-weakened/strict/strict.examples.json +64 -0
- package/src/infrastructure/engines/walker/strictness-weakened/use-unknown-in-catch-variables/piece.json +17 -0
- package/src/infrastructure/engines/walker/strictness-weakened/use-unknown-in-catch-variables/use-unknown-in-catch-variables.examples.json +71 -0
- package/src/infrastructure/engines/walker/text-past-its-reader/test-body/piece.json +18 -0
- package/src/infrastructure/engines/walker/throw-or-catch-in-a-test/throw-statement/piece.json +9 -0
- package/src/infrastructure/engines/walker/throw-or-catch-in-a-test/throw-statement/throw-statement.examples.json +36 -0
- package/{mechanisms/audit/CD-10 → src/infrastructure/engines/walker/throw-or-catch-in-a-test/throw-statement}/throws-in-tests.js +6 -3
- package/src/infrastructure/engines/walker/throw-or-catch-in-a-test/try-block/piece.json +18 -0
- package/src/infrastructure/engines/walker/type-derived-from-code/factory-return-types/factory-return-types.examples.json +36 -0
- package/{mechanisms/audit/CD-7a → src/infrastructure/engines/walker/type-derived-from-code/factory-return-types}/factory-return-types.js +5 -3
- package/src/infrastructure/engines/walker/type-derived-from-code/factory-return-types/piece.json +9 -0
- package/src/infrastructure/engines/walker/unit-without-a-running-test/companion-test-file/companion-test-file.examples.json +36 -0
- package/{mechanisms/audit/CD-23 → src/infrastructure/engines/walker/unit-without-a-running-test/companion-test-file}/export-test-sibling.js +7 -4
- package/src/infrastructure/engines/walker/unit-without-a-running-test/companion-test-file/piece.json +9 -0
- package/{mechanisms/audit/CD-5 → src/infrastructure/engines/walker/untracked-escape/directive-pointers}/comments-directives.js +40 -19
- package/src/infrastructure/engines/walker/untracked-escape/directive-pointers/directive-pointers.examples.json +96 -0
- package/src/infrastructure/engines/walker/untracked-escape/directive-pointers/piece.json +16 -0
- package/src/infrastructure/engines/walker/write-into-a-parameter/parameter-mutation/parameter-mutation.examples.json +42 -0
- package/{mechanisms/audit/CD-44 → src/infrastructure/engines/walker/write-into-a-parameter/parameter-mutation}/parameter-mutation.js +22 -7
- package/src/infrastructure/engines/walker/write-into-a-parameter/parameter-mutation/piece.json +9 -0
- package/src/rule-set.d.ts +4 -0
- package/src/testing.d.ts +7 -0
- package/src/testing.js +524 -0
- package/api/audit.d.ts +0 -20
- package/api/rule-set.d.ts +0 -4
- package/api/testing.d.ts +0 -5
- package/api/testing.js +0 -238
- package/chunks/chunk-335ITLPO.js +0 -7
- package/chunks/chunk-6SM3HKWO.js +0 -1912
- package/chunks/chunk-E6VR3VRV.js +0 -268
- package/chunks/chunk-FR4FASVM.js +0 -108
- package/chunks/chunk-LDQUT742.js +0 -15
- package/chunks/chunk-MXSIQPCV.js +0 -13
- package/chunks/chunk-RWQ4UNKY.js +0 -24
- package/core/check/tool-command.js +0 -2586
- package/core/mechanism-port/runner-result-types.d.ts +0 -15
- package/mechanisms/audit/CD-1/piece.json +0 -13
- package/mechanisms/audit/CD-10/piece.json +0 -13
- package/mechanisms/audit/CD-14/piece.json +0 -13
- package/mechanisms/audit/CD-15/piece.json +0 -13
- package/mechanisms/audit/CD-17/clock-sources.js +0 -28
- package/mechanisms/audit/CD-17/piece.json +0 -13
- package/mechanisms/audit/CD-19/import-boundaries.js +0 -99
- package/mechanisms/audit/CD-19/piece.json +0 -18
- package/mechanisms/audit/CD-2/piece.json +0 -18
- package/mechanisms/audit/CD-23/piece.json +0 -13
- package/mechanisms/audit/CD-25/piece.json +0 -13
- package/mechanisms/audit/CD-26/piece.json +0 -13
- package/mechanisms/audit/CD-27/piece.json +0 -17
- package/mechanisms/audit/CD-3/piece.json +0 -77
- package/mechanisms/audit/CD-43/piece.json +0 -13
- package/mechanisms/audit/CD-44/piece.json +0 -13
- package/mechanisms/audit/CD-47/piece.json +0 -13
- package/mechanisms/audit/CD-5/piece.json +0 -20
- package/mechanisms/audit/CD-6/piece.json +0 -13
- package/mechanisms/audit/CD-7/piece.json +0 -13
- package/mechanisms/audit/CD-7a/piece.json +0 -13
- package/mechanisms/audit/CD-8/piece.json +0 -13
- package/mechanisms/audit/CD-8/switch-defaults.js +0 -42
- package/mechanisms/eslint/CD-1/piece.json +0 -23
- package/mechanisms/eslint/CD-10/piece.json +0 -15
- package/mechanisms/eslint/CD-14/piece.json +0 -31
- package/mechanisms/eslint/CD-2/cd2/cd2.eslint-plugin.js +0 -15
- package/mechanisms/eslint/CD-2/piece.json +0 -25
- package/mechanisms/eslint/CD-27/piece.json +0 -23
- package/mechanisms/eslint/CD-40/cd40/cd40.eslint-plugin.js +0 -15
- package/mechanisms/eslint/CD-40/piece.json +0 -21
- package/mechanisms/eslint/CD-41/piece.json +0 -23
- package/mechanisms/eslint/CD-42/piece.json +0 -15
- package/mechanisms/eslint/CD-44/cd44/cd44.eslint-plugin.js +0 -15
- package/mechanisms/eslint/CD-44/piece.json +0 -20
- package/mechanisms/eslint/CD-6/cd6/cd6.eslint-plugin.js +0 -15
- package/mechanisms/eslint/CD-6/piece.json +0 -217
- package/mechanisms/eslint/CD-7/piece.json +0 -15
- package/rules/CD-1/CHECKS.md +0 -39
- package/rules/CD-1/README.md +0 -28
- package/rules/CD-1/discipline.json +0 -195
- package/rules/CD-10/CHECKS.md +0 -49
- package/rules/CD-10/README.md +0 -27
- package/rules/CD-10/discipline.json +0 -133
- package/rules/CD-11/CHECKS.md +0 -13
- package/rules/CD-11/README.md +0 -25
- package/rules/CD-11/discipline.json +0 -12
- package/rules/CD-12/CHECKS.md +0 -13
- package/rules/CD-12/README.md +0 -25
- package/rules/CD-12/discipline.json +0 -12
- package/rules/CD-13/CHECKS.md +0 -13
- package/rules/CD-13/README.md +0 -25
- package/rules/CD-13/discipline.json +0 -12
- package/rules/CD-14/CHECKS.md +0 -49
- package/rules/CD-14/README.md +0 -28
- package/rules/CD-14/discipline.json +0 -173
- package/rules/CD-15/CHECKS.md +0 -42
- package/rules/CD-15/README.md +0 -30
- package/rules/CD-15/discipline.json +0 -73
- package/rules/CD-16/CHECKS.md +0 -7
- package/rules/CD-16/README.md +0 -15
- package/rules/CD-17/CHECKS.md +0 -37
- package/rules/CD-17/README.md +0 -28
- package/rules/CD-17/discipline.json +0 -51
- package/rules/CD-18/CHECKS.md +0 -13
- package/rules/CD-18/README.md +0 -25
- package/rules/CD-18/discipline.json +0 -12
- package/rules/CD-19/CHECKS.md +0 -49
- package/rules/CD-19/README.md +0 -29
- package/rules/CD-19/discipline.json +0 -63
- package/rules/CD-2/CHECKS.md +0 -58
- package/rules/CD-2/README.md +0 -30
- package/rules/CD-2/discipline.json +0 -151
- package/rules/CD-20/CHECKS.md +0 -7
- package/rules/CD-20/README.md +0 -15
- package/rules/CD-21/CHECKS.md +0 -13
- package/rules/CD-21/README.md +0 -24
- package/rules/CD-21/discipline.json +0 -12
- package/rules/CD-22/CHECKS.md +0 -13
- package/rules/CD-22/README.md +0 -24
- package/rules/CD-22/discipline.json +0 -12
- package/rules/CD-23/CHECKS.md +0 -35
- package/rules/CD-23/README.md +0 -26
- package/rules/CD-23/discipline.json +0 -57
- package/rules/CD-24/CHECKS.md +0 -7
- package/rules/CD-24/README.md +0 -15
- package/rules/CD-25/CHECKS.md +0 -38
- package/rules/CD-25/README.md +0 -31
- package/rules/CD-25/discipline.json +0 -57
- package/rules/CD-26/CHECKS.md +0 -36
- package/rules/CD-26/README.md +0 -29
- package/rules/CD-26/discipline.json +0 -57
- package/rules/CD-27/CHECKS.md +0 -451
- package/rules/CD-27/README.md +0 -29
- package/rules/CD-27/discipline.json +0 -437
- package/rules/CD-28/CHECKS.md +0 -13
- package/rules/CD-28/README.md +0 -25
- package/rules/CD-28/discipline.json +0 -12
- package/rules/CD-29/CHECKS.md +0 -13
- package/rules/CD-29/README.md +0 -23
- package/rules/CD-29/discipline.json +0 -12
- package/rules/CD-3/README.md +0 -26
- package/rules/CD-3/discipline.json +0 -641
- package/rules/CD-30/CHECKS.md +0 -13
- package/rules/CD-30/README.md +0 -24
- package/rules/CD-30/discipline.json +0 -12
- package/rules/CD-31/CHECKS.md +0 -13
- package/rules/CD-31/README.md +0 -23
- package/rules/CD-31/discipline.json +0 -12
- package/rules/CD-32/CHECKS.md +0 -13
- package/rules/CD-32/README.md +0 -24
- package/rules/CD-32/discipline.json +0 -12
- package/rules/CD-33/CHECKS.md +0 -13
- package/rules/CD-33/README.md +0 -24
- package/rules/CD-33/discipline.json +0 -12
- package/rules/CD-34/CHECKS.md +0 -13
- package/rules/CD-34/README.md +0 -23
- package/rules/CD-34/discipline.json +0 -12
- package/rules/CD-39/CHECKS.md +0 -13
- package/rules/CD-39/README.md +0 -24
- package/rules/CD-39/discipline.json +0 -12
- package/rules/CD-4/CHECKS.md +0 -13
- package/rules/CD-4/README.md +0 -26
- package/rules/CD-4/discipline.json +0 -12
- package/rules/CD-40/CHECKS.md +0 -39
- package/rules/CD-40/README.md +0 -29
- package/rules/CD-40/discipline.json +0 -58
- package/rules/CD-41/CHECKS.md +0 -64
- package/rules/CD-41/README.md +0 -31
- package/rules/CD-41/discipline.json +0 -138
- package/rules/CD-42/CHECKS.md +0 -47
- package/rules/CD-42/README.md +0 -25
- package/rules/CD-42/discipline.json +0 -61
- package/rules/CD-43/CHECKS.md +0 -37
- package/rules/CD-43/README.md +0 -27
- package/rules/CD-43/discipline.json +0 -65
- package/rules/CD-44/CHECKS.md +0 -48
- package/rules/CD-44/README.md +0 -26
- package/rules/CD-44/discipline.json +0 -111
- package/rules/CD-45/CHECKS.md +0 -13
- package/rules/CD-45/README.md +0 -25
- package/rules/CD-45/discipline.json +0 -12
- package/rules/CD-46/CHECKS.md +0 -7
- package/rules/CD-46/README.md +0 -25
- package/rules/CD-47/CHECKS.md +0 -37
- package/rules/CD-47/README.md +0 -31
- package/rules/CD-47/discipline.json +0 -57
- package/rules/CD-5/README.md +0 -28
- package/rules/CD-5/discipline.json +0 -131
- package/rules/CD-6/CHECKS.md +0 -51
- package/rules/CD-6/README.md +0 -28
- package/rules/CD-6/discipline.json +0 -165
- package/rules/CD-7/CHECKS.md +0 -46
- package/rules/CD-7/README.md +0 -29
- package/rules/CD-7/discipline.json +0 -142
- package/rules/CD-7a/CHECKS.md +0 -38
- package/rules/CD-7a/README.md +0 -26
- package/rules/CD-7a/discipline.json +0 -57
- package/rules/CD-8/CHECKS.md +0 -42
- package/rules/CD-8/README.md +0 -26
- package/rules/CD-8/discipline.json +0 -57
- package/rules/CD-9/CHECKS.md +0 -13
- package/rules/CD-9/README.md +0 -26
- package/rules/CD-9/discipline.json +0 -12
- /package/{core/values → src/domain/finding}/anchor.d.ts +0 -0
- /package/{core/values → src/domain/repository}/branded.d.ts +0 -0
- /package/{core/values → src/domain/repository}/repo-path-types.d.ts +0 -0
- /package/{core/values → src/domain}/result.d.ts +0 -0
- /package/{core/values → src/domain/rule-set}/clause-address-types.d.ts +0 -0
- /package/{core/values → src/domain/settings/json-values}/json-value.d.ts +0 -0
- /package/{mechanisms/eslint/CD-14 → src/infrastructure/engines/eslint/authored-class-or-this/class-keyword}/README.md +0 -0
- /package/{mechanisms/eslint/CD-2 → src/infrastructure/engines/eslint/claimed-type/non-null-assertions}/README.md +0 -0
- /package/{mechanisms/eslint/CD-7 → src/infrastructure/engines/eslint/name-off-its-casing/filename-case}/README.md +0 -0
- /package/{mechanisms/eslint/CD-6 → src/infrastructure/engines/eslint/name-off-its-casing/naming-convention}/README.md +0 -0
- /package/{mechanisms/eslint/CD-40 → src/infrastructure/engines/eslint/positional-parameters/parameter-count}/README.md +0 -0
- /package/{mechanisms/eslint/CD-44 → src/infrastructure/engines/eslint/rebinding/parameter-reassignment}/README.md +0 -0
- /package/{mechanisms/eslint/CD-27 → src/infrastructure/engines/eslint/test-switched-off/focused-tests}/README.md +0 -0
- /package/{mechanisms/eslint/CD-10 → src/infrastructure/engines/eslint/thrown-non-error/throw-only-error}/README.md +0 -0
- /package/{mechanisms/eslint/CD-1 → src/infrastructure/engines/eslint/untyped-value/explicit-any}/README.md +0 -0
- /package/{mechanisms/eslint/CD-42 → src/infrastructure/engines/eslint/work-inside-a-condition/else-after-an-exit}/README.md +0 -0
- /package/{mechanisms/audit → src/infrastructure/engines/walker}/runner/README.md +0 -0
- /package/{api → src}/rule-set.js +0 -0
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 1,
|
|
3
|
-
"id": "CD-26",
|
|
4
|
-
"clauses": [
|
|
5
|
-
{
|
|
6
|
-
"kind": "mechanical",
|
|
7
|
-
"id": "module-mocking",
|
|
8
|
-
"summary": "No module-mocking — module-mock means DI is wrong",
|
|
9
|
-
"mechanisms": [
|
|
10
|
-
"audit"
|
|
11
|
-
],
|
|
12
|
-
"anchor": {
|
|
13
|
-
"kind": "file"
|
|
14
|
-
},
|
|
15
|
-
"cases": {
|
|
16
|
-
"flag": [
|
|
17
|
-
{
|
|
18
|
-
"name": "vi.mock of a module",
|
|
19
|
-
"fileName": "store.test.ts",
|
|
20
|
-
"source": "vi.mock(\"./store.ts\");\n",
|
|
21
|
-
"expectedLines": [
|
|
22
|
-
1
|
|
23
|
-
]
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
"name": "vi.mock in a tsx test",
|
|
27
|
-
"fileName": "view.test.tsx",
|
|
28
|
-
"source": "import { vi } from \"vitest\";\nvi.mock(\"module\");\n",
|
|
29
|
-
"expectedLines": [
|
|
30
|
-
2
|
|
31
|
-
]
|
|
32
|
-
}
|
|
33
|
-
],
|
|
34
|
-
"allow": [
|
|
35
|
-
{
|
|
36
|
-
"name": "injected fake port",
|
|
37
|
-
"fileName": "port.test.ts",
|
|
38
|
-
"source": "const port = vi.fn();\nconst other = { mock: vi.fn() };\n",
|
|
39
|
-
"expectedLines": []
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
"name": "vi.mock outside a test file",
|
|
43
|
-
"fileName": "helper.ts",
|
|
44
|
-
"source": "vi.mock(\"module\");\n",
|
|
45
|
-
"expectedLines": []
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
"name": "bracket access is not detected",
|
|
49
|
-
"fileName": "bracket.test.ts",
|
|
50
|
-
"source": "vi[\"mock\"](\"module\");\n",
|
|
51
|
-
"expectedLines": []
|
|
52
|
-
}
|
|
53
|
-
]
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
]
|
|
57
|
-
}
|
package/rules/CD-27/CHECKS.md
DELETED
|
@@ -1,451 +0,0 @@
|
|
|
1
|
-
# CD-27 checks
|
|
2
|
-
|
|
3
|
-
Read [the rule and its spirit](README.md) first. This page is the mechanics: what each check flags and misses, how to fix a flagged site, and how to record an exception.
|
|
4
|
-
|
|
5
|
-
## Clauses
|
|
6
|
-
|
|
7
|
-
| Clause | Mechanism | Checks |
|
|
8
|
-
| --- | --- | --- |
|
|
9
|
-
| `CD-27#test-body-logic` | audit | branching, `let`, and computing methods in a test file; edition 2 adds short-circuits, optional chaining, `switch` and computing namespace calls |
|
|
10
|
-
| `CD-27#focused-tests` | eslint | `.only` on a test or suite, or `fdescribe`, `fit`, `ftest`, `fsuite` |
|
|
11
|
-
| `CD-27#skipped-tests` | eslint | `.skip` or `.fixme` on a test or suite, or `xdescribe`, `xit`, `xtest`, `xsuite` |
|
|
12
|
-
|
|
13
|
-
## What the check flags
|
|
14
|
-
`CD-27#test-body-logic` has two editions. Edition 1 runs by default. Edition 2 adds the constructs below and becomes the default in the next major release; see [Settings](#settings) to run it now.
|
|
15
|
-
|
|
16
|
-
Edition 1:
|
|
17
|
-
- Test files only: `*.test.ts` and `*.test.tsx`. Generated folders such as `node_modules`, `dist`, `build` and `coverage` are skipped.
|
|
18
|
-
- `if` statements, `try` statements, ternary expressions and `let` declarations.
|
|
19
|
-
- A method call with a computing or mutating name, wherever it could be the string or array method of that name: `map`, `filter`, `reduce`, `find`, `forEach`, `join`, `slice`, `split`, `replace`, `includes`, `sort`, `trim`, `keys`, `values`, `push`, `pop`, `splice`, `fill` and similar string and array methods.
|
|
20
|
-
- Not flagged: a call with one of those names whose arguments no string or array method of that name accepts, which makes it the unit's own API. Either it passes an object literal where none of them takes an object, such as `paths.join({ segments: ["a", "b"] })`, or it passes more arguments than any of them takes, such as `screen.keys("x", true, true)`.
|
|
21
|
-
- Still flagged, though they look like that:
|
|
22
|
-
- a call whose receiver traces back to a built-in namespace such as `Object` or `Math`, a package or `node:` module (imported, required or loaded with `import()`), or a string or array literal. The trace follows variables declared in the test file, including names destructured from a traced module or namespace, such as `posix` after `const { posix } = path`, and a property read directly off an object literal declared there, such as `deps.path` after `const deps = { path }`;
|
|
23
|
-
- a call that spreads its arguments;
|
|
24
|
-
- an object at a position where a string or array method takes one, such as `rows.includes({ id: "a" })`, `rows.push({ id: "a" })`, `rows.reduce(sum, { total: 0 })`, `rows.find(isA, {})` or `text.split({ [Symbol.split]: splitter })`.
|
|
25
|
-
- What this check cannot know: it reads names and syntax, not types, so it cannot tell what a receiver is.
|
|
26
|
-
- It flags the unit's own method given a variable, such as `repository.find(query)`.
|
|
27
|
-
- It misses a string or array method taken off its receiver before the call.
|
|
28
|
-
- It does not trace a receiver that is a function parameter, an `it.each` row, a value from another module (even a relative module that re-exports a package), a name destructured from an object literal, or a property nested deeper in one, such as `deps.nested.path`; it reads these as the unit's own.
|
|
29
|
-
- It releases a method of another built-in or library type that shares a name, such as a stream's `values` or `reduce`, when that call passes an object or more arguments than the string or array method takes.
|
|
30
|
-
|
|
31
|
-
Only a check that reads types knows a receiver's identity, and Hone does not have one yet.
|
|
32
|
-
- Loops are not flagged here; CD-15 covers them. `throw` is CD-10.
|
|
33
|
-
|
|
34
|
-
Edition 2 also flags:
|
|
35
|
-
- `??`, `||` and `&&`, and their assignment forms `??=`, `||=` and `&&=`.
|
|
36
|
-
- Optional chaining: `a?.b`, `a?.[key]` and `f?.()`.
|
|
37
|
-
- `switch` statements.
|
|
38
|
-
- Computing calls on a built-in namespace: `JSON.stringify`, `JSON.parse`, `Object.assign`, `Object.fromEntries`, `Array.from` and any `Math` method. A finding on `JSON.stringify` or `JSON.parse` points at [CD-19](../CD-19/README.md); see [Serialising or parsing JSON](#serialising-or-parsing-json).
|
|
39
|
-
|
|
40
|
-
Neither edition flags element access such as `calls[0]`, calls to free functions, a method called through a computed key, such as `rows["map"]`, or text built with a template literal. Helper files that tests import are not checked; only the test files themselves are.
|
|
41
|
-
|
|
42
|
-
## What the ESLint check flags
|
|
43
|
-
Needs ESLint adopted through the projection; see [the ESLint piece](../../mechanisms/eslint/CD-27/README.md).
|
|
44
|
-
- `hone-cd27/focused-tests` flags `.only` on a `describe`, `it`, `test` or `suite` chain, including `.only.each` and `test.describe.only`, and the bare names `fdescribe`, `fit`, `ftest` and `fsuite`. It reports at the `only` token.
|
|
45
|
-
- `hone-cd27/skipped-tests` flags `.skip` and `.fixme` on those chains, and the bare names `xdescribe`, `xit`, `xtest` and `xsuite`.
|
|
46
|
-
- Not flagged: `.todo`, `.concurrent` and `.each`.
|
|
47
|
-
|
|
48
|
-
## Settings
|
|
49
|
-
- `edition`: the edition this clause runs, `"1"` or `"2"`. Without it, the clause runs edition 1, or the latest edition when `checkEditions` in `disciplines.json` is `"latest"`.
|
|
50
|
-
|
|
51
|
-
```json
|
|
52
|
-
"clauseSettings": {
|
|
53
|
-
"CD-27#test-body-logic": { "edition": "2" }
|
|
54
|
-
}
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
## Example violation
|
|
58
|
-
```ts
|
|
59
|
-
const expected = rows.map((row) => row.id);
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
## How to fix
|
|
63
|
-
```ts
|
|
64
|
-
expect(ids).toEqual(["a1", "b2"]);
|
|
65
|
-
```
|
|
66
|
-
Write the expected value out. A method call in the act step is flagged too, so move such logic into the unit under test.
|
|
67
|
-
|
|
68
|
-
Each finding ends with `fix:` and the page and section for what it flagged, such as `(node_modules/@hailstails/hone/rules/CD-27/CHECKS.md#an-optional-chain-after-an-index)`.
|
|
69
|
-
|
|
70
|
-
## Allowed forms in a test
|
|
71
|
-
Each section shows a flagged form first, then the forms to write instead, or the rule the finding points at. Every form to write instead passes every audit and ESLint clause Hone ships, at each edition its check declares, and compiles under the compiler options CD-3 requires. A test reads this page and holds every block on it to that. `assert`, `expect`, `it` and `vi` come from `vitest`, and a `declare const` line stands for the unit under test.
|
|
72
|
-
|
|
73
|
-
### Branching with if
|
|
74
|
-
```ts
|
|
75
|
-
declare const parse: (text: string) => { readonly outcome: "ok"; readonly value: string } | { readonly outcome: "failed" };
|
|
76
|
-
const parsed = parse("a");
|
|
77
|
-
if (parsed.outcome === "ok") {
|
|
78
|
-
expect(parsed.value).toBe("a");
|
|
79
|
-
}
|
|
80
|
-
```
|
|
81
|
-
Compare the whole result:
|
|
82
|
-
|
|
83
|
-
```ts
|
|
84
|
-
declare const parse: (text: string) => { readonly outcome: "ok"; readonly value: string } | { readonly outcome: "failed" };
|
|
85
|
-
expect(parse("a")).toEqual({ outcome: "ok", value: "a" });
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
Or write one test per case, or one table:
|
|
89
|
-
|
|
90
|
-
```ts
|
|
91
|
-
declare const parse: (text: string) => { readonly outcome: "ok"; readonly value: string } | { readonly outcome: "failed" };
|
|
92
|
-
it.each([
|
|
93
|
-
{ text: "a", expected: { outcome: "ok", value: "a" } },
|
|
94
|
-
{ text: "", expected: { outcome: "failed" } },
|
|
95
|
-
])("parses $text", ({ text, expected }) => {
|
|
96
|
-
expect(parse(text)).toEqual(expected);
|
|
97
|
-
});
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
### A try block
|
|
101
|
-
```ts
|
|
102
|
-
declare const load: (path: string) => string;
|
|
103
|
-
try {
|
|
104
|
-
load("missing.json");
|
|
105
|
-
} catch (error) {
|
|
106
|
-
expect(error).toBeInstanceOf(Error);
|
|
107
|
-
}
|
|
108
|
-
```
|
|
109
|
-
Assert the throw:
|
|
110
|
-
|
|
111
|
-
```ts
|
|
112
|
-
declare const load: (path: string) => string;
|
|
113
|
-
expect(() => load("missing.json")).toThrow(Error);
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
```ts
|
|
117
|
-
declare const loadLater: (path: string) => Promise<string>;
|
|
118
|
-
it("refuses a missing file", async () => {
|
|
119
|
-
await expect(loadLater("missing.json")).rejects.toThrow(Error);
|
|
120
|
-
});
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
### A ternary
|
|
124
|
-
```ts
|
|
125
|
-
declare const discountFor: (customer: { readonly tier: "premium" | "standard" }) => number;
|
|
126
|
-
const tier = "premium";
|
|
127
|
-
expect(discountFor({ tier })).toBe(tier === "premium" ? 10 : 0);
|
|
128
|
-
```
|
|
129
|
-
Write the value out, with one table row per case:
|
|
130
|
-
|
|
131
|
-
```ts
|
|
132
|
-
declare const discountFor: (customer: { readonly tier: "premium" | "standard" }) => number;
|
|
133
|
-
it.each([
|
|
134
|
-
{ tier: "premium", expected: 10 },
|
|
135
|
-
{ tier: "standard", expected: 0 },
|
|
136
|
-
] as const)("gives $expected off to a $tier customer", ({ tier, expected }) => {
|
|
137
|
-
expect(discountFor({ tier })).toBe(expected);
|
|
138
|
-
});
|
|
139
|
-
```
|
|
140
|
-
|
|
141
|
-
### A let
|
|
142
|
-
```ts
|
|
143
|
-
declare const record: (store: { readonly save: (text: string) => void }) => void;
|
|
144
|
-
let saved = "";
|
|
145
|
-
record({ save: (text) => { saved = text; } });
|
|
146
|
-
expect(saved).toBe("a");
|
|
147
|
-
```
|
|
148
|
-
Record the calls with `vi.fn` and assert them:
|
|
149
|
-
|
|
150
|
-
```ts
|
|
151
|
-
declare const record: (store: { readonly save: (text: string) => void }) => void;
|
|
152
|
-
const save = vi.fn<(text: string) => void>();
|
|
153
|
-
record({ save });
|
|
154
|
-
expect(save).toHaveBeenCalledWith("a");
|
|
155
|
-
```
|
|
156
|
-
|
|
157
|
-
### A method that picks or tests an element
|
|
158
|
-
```ts
|
|
159
|
-
declare const listTasks: () => readonly { readonly id: string; readonly status: "open" | "done" }[];
|
|
160
|
-
expect(listTasks().find((task) => task.id === "a")).toEqual({ id: "a", status: "open" });
|
|
161
|
-
```
|
|
162
|
-
Assert on the whole array:
|
|
163
|
-
|
|
164
|
-
```ts
|
|
165
|
-
declare const listTasks: () => readonly { readonly id: string; readonly status: "open" | "done" }[];
|
|
166
|
-
expect(listTasks()).toContainEqual({ id: "a", status: "open" });
|
|
167
|
-
```
|
|
168
|
-
|
|
169
|
-
```ts
|
|
170
|
-
declare const listTasks: () => readonly { readonly id: string; readonly status: "open" | "done" }[];
|
|
171
|
-
expect(listTasks()).toEqual(expect.arrayContaining([expect.objectContaining({ id: "a" })]));
|
|
172
|
-
```
|
|
173
|
-
|
|
174
|
-
The check cannot tell the unit's own method with one of these names from an array method when it is given a variable, such as `repository.find(query)`. That is a limit of the check, described under [What the check flags](#what-the-check-flags).
|
|
175
|
-
|
|
176
|
-
### A method that computes a value
|
|
177
|
-
```ts
|
|
178
|
-
declare const idsOf: (rows: readonly { readonly id: string }[]) => readonly string[];
|
|
179
|
-
const rows = [{ id: "a1" }, { id: "b2" }];
|
|
180
|
-
expect(idsOf(rows)).toEqual(rows.map((row) => row.id));
|
|
181
|
-
```
|
|
182
|
-
Write the expected value out:
|
|
183
|
-
|
|
184
|
-
```ts
|
|
185
|
-
declare const idsOf: (rows: readonly { readonly id: string }[]) => readonly string[];
|
|
186
|
-
expect(idsOf([{ id: "a1" }, { id: "b2" }])).toEqual(["a1", "b2"]);
|
|
187
|
-
```
|
|
188
|
-
|
|
189
|
-
Or match the part that matters:
|
|
190
|
-
|
|
191
|
-
```ts
|
|
192
|
-
declare const receiptOf: (order: { readonly total: number }) => { readonly total: number; readonly label: string };
|
|
193
|
-
expect(receiptOf({ total: 30 })).toMatchObject({ label: expect.stringContaining("30") });
|
|
194
|
-
```
|
|
195
|
-
|
|
196
|
-
### A method that mutates
|
|
197
|
-
```ts
|
|
198
|
-
declare const namesOf: (team: string) => readonly string[];
|
|
199
|
-
const expected = ["Ada"];
|
|
200
|
-
expected.push("Grace");
|
|
201
|
-
expect(namesOf("core")).toEqual(expected);
|
|
202
|
-
```
|
|
203
|
-
Write the finished array out:
|
|
204
|
-
|
|
205
|
-
```ts
|
|
206
|
-
declare const namesOf: (team: string) => readonly string[];
|
|
207
|
-
expect(namesOf("core")).toEqual(["Ada", "Grace"]);
|
|
208
|
-
```
|
|
209
|
-
|
|
210
|
-
### A short-circuit
|
|
211
|
-
```ts
|
|
212
|
-
declare const lookup: (id: string) => { readonly name: string } | undefined;
|
|
213
|
-
const found = lookup("a");
|
|
214
|
-
expect(found !== undefined && found.name === "Ada").toBe(true);
|
|
215
|
-
```
|
|
216
|
-
Write the value a fallback gives. To narrow a value that may be missing, assert it is defined, then read it:
|
|
217
|
-
|
|
218
|
-
```ts
|
|
219
|
-
declare const lookup: (id: string) => { readonly name: string } | undefined;
|
|
220
|
-
const found = lookup("a");
|
|
221
|
-
assert.isDefined(found);
|
|
222
|
-
expect(found.name).toBe("Ada");
|
|
223
|
-
```
|
|
224
|
-
|
|
225
|
-
### An optional chain after an index
|
|
226
|
-
```ts
|
|
227
|
-
declare const listTasks: () => readonly { readonly id: string; readonly status: "open" | "done" }[];
|
|
228
|
-
expect(listTasks()[0]?.id).toBe("a");
|
|
229
|
-
```
|
|
230
|
-
Compare the whole element:
|
|
231
|
-
|
|
232
|
-
```ts
|
|
233
|
-
declare const listTasks: () => readonly { readonly id: string; readonly status: "open" | "done" }[];
|
|
234
|
-
expect(listTasks()[0]).toMatchObject({ id: "a" });
|
|
235
|
-
```
|
|
236
|
-
|
|
237
|
-
Or destructure it and assert it is defined before reading it:
|
|
238
|
-
|
|
239
|
-
```ts
|
|
240
|
-
declare const listTasks: () => readonly { readonly id: string; readonly status: "open" | "done" }[];
|
|
241
|
-
const [first] = listTasks();
|
|
242
|
-
assert.isDefined(first);
|
|
243
|
-
expect(first.id).toBe("a");
|
|
244
|
-
```
|
|
245
|
-
|
|
246
|
-
### An optional chain on a mock call
|
|
247
|
-
```ts
|
|
248
|
-
declare const start: (run: (task: { readonly id: string }) => void) => void;
|
|
249
|
-
const run = vi.fn<(task: { readonly id: string }) => void>();
|
|
250
|
-
start(run);
|
|
251
|
-
expect(run.mock.calls[0]?.[0].id).toBe("a");
|
|
252
|
-
```
|
|
253
|
-
Assert that call by its position:
|
|
254
|
-
|
|
255
|
-
```ts
|
|
256
|
-
declare const start: (run: (task: { readonly id: string }) => void) => void;
|
|
257
|
-
const run = vi.fn<(task: { readonly id: string }) => void>();
|
|
258
|
-
start(run);
|
|
259
|
-
expect(run).toHaveBeenNthCalledWith(1, expect.objectContaining({ id: "a" }));
|
|
260
|
-
```
|
|
261
|
-
|
|
262
|
-
Reading `run.mock.lastCall?.[0]` names this section too. Assert the last call:
|
|
263
|
-
|
|
264
|
-
```ts
|
|
265
|
-
declare const start: (run: (task: { readonly id: string }) => void) => void;
|
|
266
|
-
const run = vi.fn<(task: { readonly id: string }) => void>();
|
|
267
|
-
start(run);
|
|
268
|
-
expect(run).toHaveBeenLastCalledWith({ id: "a" });
|
|
269
|
-
```
|
|
270
|
-
|
|
271
|
-
### An optional chain on a mock result
|
|
272
|
-
```ts
|
|
273
|
-
declare const pricing: { readonly priceOf: (amount: number) => number };
|
|
274
|
-
declare const settle: (prices: { readonly priceOf: (amount: number) => number }) => void;
|
|
275
|
-
const priceOf = vi.spyOn(pricing, "priceOf");
|
|
276
|
-
settle(pricing);
|
|
277
|
-
expect(priceOf.mock.results[0]?.value).toBe(4);
|
|
278
|
-
```
|
|
279
|
-
Assert what that call returned, by its position:
|
|
280
|
-
|
|
281
|
-
```ts
|
|
282
|
-
declare const pricing: { readonly priceOf: (amount: number) => number };
|
|
283
|
-
declare const settle: (prices: { readonly priceOf: (amount: number) => number }) => void;
|
|
284
|
-
const priceOf = vi.spyOn(pricing, "priceOf");
|
|
285
|
-
settle(pricing);
|
|
286
|
-
expect(priceOf).toHaveNthReturnedWith(1, 4);
|
|
287
|
-
```
|
|
288
|
-
|
|
289
|
-
`toHaveLastReturnedWith` asserts what the last call returned.
|
|
290
|
-
|
|
291
|
-
An optional chain on `mock.instances` or `mock.contexts` names [An optional chain after an index](#an-optional-chain-after-an-index).
|
|
292
|
-
|
|
293
|
-
### An optional chain on a property
|
|
294
|
-
```ts
|
|
295
|
-
declare const findUser: (id: string) => { readonly name: string } | undefined;
|
|
296
|
-
expect(findUser("a")?.name).toBe("Ada");
|
|
297
|
-
```
|
|
298
|
-
Compare the whole value:
|
|
299
|
-
|
|
300
|
-
```ts
|
|
301
|
-
declare const findUser: (id: string) => { readonly name: string } | undefined;
|
|
302
|
-
expect(findUser("a")).toMatchObject({ name: "Ada" });
|
|
303
|
-
```
|
|
304
|
-
|
|
305
|
-
Or assert it is defined before reading it:
|
|
306
|
-
|
|
307
|
-
```ts
|
|
308
|
-
declare const findUser: (id: string) => { readonly name: string } | undefined;
|
|
309
|
-
const user = findUser("a");
|
|
310
|
-
assert.isDefined(user);
|
|
311
|
-
expect(user.name).toBe("Ada");
|
|
312
|
-
```
|
|
313
|
-
|
|
314
|
-
### An optional call
|
|
315
|
-
```ts
|
|
316
|
-
declare const observers: { readonly enter?: (node: string) => void };
|
|
317
|
-
observers.enter?.("a");
|
|
318
|
-
```
|
|
319
|
-
Destructure the function, assert it is defined, then call it:
|
|
320
|
-
|
|
321
|
-
```ts
|
|
322
|
-
declare const observers: { readonly enter?: (node: string) => void };
|
|
323
|
-
const { enter } = observers;
|
|
324
|
-
assert.isDefined(enter);
|
|
325
|
-
enter("a");
|
|
326
|
-
```
|
|
327
|
-
|
|
328
|
-
A method that reads `this` loses it once taken off its object, so assert it is defined where it is and call it there:
|
|
329
|
-
|
|
330
|
-
```ts
|
|
331
|
-
declare const tracker: { readonly entered: readonly string[]; enter?(node: string): void };
|
|
332
|
-
assert.isDefined(tracker.enter);
|
|
333
|
-
tracker.enter("a");
|
|
334
|
-
```
|
|
335
|
-
|
|
336
|
-
### A switch
|
|
337
|
-
```ts
|
|
338
|
-
declare const areaOf: (shape: { readonly kind: "square"; readonly side: number } | { readonly kind: "circle"; readonly radius: number }) => number;
|
|
339
|
-
const shape = { kind: "square", side: 2 } as const;
|
|
340
|
-
switch (shape.kind) {
|
|
341
|
-
case "square":
|
|
342
|
-
expect(areaOf(shape)).toBe(4);
|
|
343
|
-
}
|
|
344
|
-
```
|
|
345
|
-
Write one test per case, or one table:
|
|
346
|
-
|
|
347
|
-
```ts
|
|
348
|
-
declare const areaOf: (shape: { readonly kind: "square"; readonly side: number } | { readonly kind: "circle"; readonly radius: number }) => number;
|
|
349
|
-
it.each([
|
|
350
|
-
{ shape: { kind: "square", side: 2 } as const, expected: 4 },
|
|
351
|
-
{ shape: { kind: "circle", radius: 0 } as const, expected: 0 },
|
|
352
|
-
])("measures a $shape.kind", ({ shape, expected }) => {
|
|
353
|
-
expect(areaOf(shape)).toBe(expected);
|
|
354
|
-
});
|
|
355
|
-
```
|
|
356
|
-
|
|
357
|
-
### Serialising or parsing JSON
|
|
358
|
-
```ts
|
|
359
|
-
declare const render: (row: { readonly id: string }) => string;
|
|
360
|
-
expect(JSON.parse(render({ id: "a" }))).toEqual({ id: "a" });
|
|
361
|
-
```
|
|
362
|
-
A finding on `JSON.stringify` or `JSON.parse` names this section. [CD-19](../CD-19/README.md) is the rule for the runtime's standard library.
|
|
363
|
-
|
|
364
|
-
### Merging objects
|
|
365
|
-
```ts
|
|
366
|
-
const base = { method: "POST", path: "/tasks" } as const;
|
|
367
|
-
const request = Object.assign({}, base, { body: "a" });
|
|
368
|
-
expect(request.body).toBe("a");
|
|
369
|
-
```
|
|
370
|
-
Write the object out, spreading what it copies:
|
|
371
|
-
|
|
372
|
-
```ts
|
|
373
|
-
const base = { method: "POST", path: "/tasks" } as const;
|
|
374
|
-
const request = { ...base, body: "a" };
|
|
375
|
-
expect(request.body).toBe("a");
|
|
376
|
-
```
|
|
377
|
-
|
|
378
|
-
A spread copies an `Error`'s own properties into a plain object, which is not an `Error`. To give an `Error` a property, assign it:
|
|
379
|
-
|
|
380
|
-
```ts
|
|
381
|
-
declare const reasonOf: (error: Error & { readonly code?: string }) => string;
|
|
382
|
-
const missing: Error & { code?: string } = new Error("ENOENT");
|
|
383
|
-
missing.code = "ENOENT";
|
|
384
|
-
expect(reasonOf(missing)).toBe("missing");
|
|
385
|
-
```
|
|
386
|
-
|
|
387
|
-
### Building an object from entries
|
|
388
|
-
```ts
|
|
389
|
-
declare const countsOf: (words: readonly string[]) => Readonly<Record<string, number>>;
|
|
390
|
-
expect(countsOf(["a"])).toEqual(Object.fromEntries([["a", 1]]));
|
|
391
|
-
```
|
|
392
|
-
Write the object out:
|
|
393
|
-
|
|
394
|
-
```ts
|
|
395
|
-
declare const countsOf: (words: readonly string[]) => Readonly<Record<string, number>>;
|
|
396
|
-
expect(countsOf(["a"])).toEqual({ a: 1 });
|
|
397
|
-
```
|
|
398
|
-
|
|
399
|
-
### Building an array from a length
|
|
400
|
-
```ts
|
|
401
|
-
declare const pageOf: (rows: readonly { readonly id: number }[]) => readonly { readonly id: number }[];
|
|
402
|
-
expect(pageOf(Array.from({ length: 3 }, (_, index) => ({ id: index })))).toHaveLength(3);
|
|
403
|
-
```
|
|
404
|
-
Write a short array out:
|
|
405
|
-
|
|
406
|
-
```ts
|
|
407
|
-
declare const pageOf: (rows: readonly { readonly id: number }[]) => readonly { readonly id: number }[];
|
|
408
|
-
expect(pageOf([{ id: 0 }, { id: 1 }, { id: 2 }])).toHaveLength(3);
|
|
409
|
-
```
|
|
410
|
-
|
|
411
|
-
An array too long to read written out, such as one row past a page size of 1,000, has no form on this page.
|
|
412
|
-
|
|
413
|
-
### A Math call
|
|
414
|
-
```ts
|
|
415
|
-
declare const roundedOf: (amount: number) => number;
|
|
416
|
-
expect(roundedOf(2.5)).toBe(Math.round(2.5));
|
|
417
|
-
```
|
|
418
|
-
Write the number out:
|
|
419
|
-
|
|
420
|
-
```ts
|
|
421
|
-
declare const roundedOf: (amount: number) => number;
|
|
422
|
-
expect(roundedOf(2.5)).toBe(3);
|
|
423
|
-
```
|
|
424
|
-
|
|
425
|
-
### Logic inside a function the test passes on
|
|
426
|
-
```ts
|
|
427
|
-
declare const isInstalled: (fileKind: { readonly kindOf: (path: string) => "file" | "missing" }) => "installed" | "missing";
|
|
428
|
-
const installedFiles = ["bin/hone.js"];
|
|
429
|
-
expect(isInstalled({ kindOf: (path) => (installedFiles.includes(path) ? "file" : "missing") })).toBe("installed");
|
|
430
|
-
```
|
|
431
|
-
A function a test writes as a property or method of an object literal, or gives to `vi.fn` or `mockImplementation`, is passed on: to the unit, to a table row, or to a double. Any flagged construct inside it names this section. Make it a `vi.fn` spy with a written-out return, and write out what it was asked:
|
|
432
|
-
|
|
433
|
-
```ts
|
|
434
|
-
declare const isInstalled: (fileKind: { readonly kindOf: (path: string) => "file" | "missing" }) => "installed" | "missing";
|
|
435
|
-
const kindOf = vi.fn<(path: string) => "file" | "missing">().mockReturnValue("file");
|
|
436
|
-
expect(isInstalled({ kindOf })).toBe("installed");
|
|
437
|
-
expect(kindOf).toHaveBeenCalledExactlyOnceWith("bin/hone.js");
|
|
438
|
-
```
|
|
439
|
-
|
|
440
|
-
[CD-25](../CD-25/README.md) is the rule for test doubles.
|
|
441
|
-
|
|
442
|
-
## Exceptions
|
|
443
|
-
Add an entry to `discipline-exceptions.json` at the repository root. Use `authorised-location` when a test file legitimately needs logic. Use `file-carve-out` for debt in one file: it is forfeited once the file is touched, and needs no `whyChain`. See [discipline-exceptions.json](../../README.md#discipline-exceptionsjson).
|
|
444
|
-
|
|
445
|
-
```json
|
|
446
|
-
{ "version": 1, "exceptions": [
|
|
447
|
-
{ "kind": "authorised-location", "clause": "CD-27#test-body-logic", "file": "src/legacy/report.test.ts", "reason": "..." }
|
|
448
|
-
] }
|
|
449
|
-
```
|
|
450
|
-
|
|
451
|
-
An `authorised-location` or `clause-wide-carve-out` also needs a `whyChain` that follows the [why-chain contract](../../docs/why-chain-contract.md): five whys chained cause to cause, a `rootCause`, its `rootCheck`, a `readback` and an `owner`. A record imported from an earlier system carries `provenance` instead. A `file-carve-out` is debt and needs only its `kind`, `clause` and `file`; its `reason` is an optional note, and a `whyChain` or `provenance` it gives anyway is still judged. With `"fileExceptionWhyChains": "optional"` in `disciplines.json`, an `authorised-location` may give only its `reason`, which will be refused in the next major release. [The exceptions format](../../README.md#discipline-exceptionsjson) gives each shape.
|
package/rules/CD-27/README.md
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
# CD-27: Tests are zero-everything — zero logic, zero branches, zero unpredictability
|
|
2
|
-
|
|
3
|
-
## Rule
|
|
4
|
-
|
|
5
|
-
Test bodies are zero-logic straight lines: no branching, no loops, no try, no ternary, no computed expectations — just arrange, act, assert against hardcoded values. Logic in a test is untested code testing code; variability is supplied by a stub and pinned, never accommodated with a conditional.
|
|
6
|
-
|
|
7
|
-
Review lens: [test-discipline](../../methods/lenses/test-discipline.md). The lens reviews the whole rule, including what no check flags. What each check flags, how to fix a flagged site, and how to record an exception: [CHECKS.md](CHECKS.md). The thinking behind every rule: [the spirit of the rules](../SPIRIT.md).
|
|
8
|
-
|
|
9
|
-
## Spirit
|
|
10
|
-
|
|
11
|
-
**What the friction is for.** A test is the unit's specification, and it is read when it fails. Logic in a test is code with no test of its own. The friction makes a straight line with written-out expectations the easy test, so a failure can be trusted and read in one pass.
|
|
12
|
-
|
|
13
|
-
**What a finding points at.** Match the sites against these causes.
|
|
14
|
-
- *Output that is hard to predict.* Expectations are computed because the result varies with time, randomness or ordering. Inject the source of variation and pin it with a stub.
|
|
15
|
-
- *Several cases in one test.* A branch or a conditional picks between cases. Write one test per case, or one parameterised test over a table of rows.
|
|
16
|
-
- *The unit's logic repeated in the test.* The test derives the answer the way the unit does. Write the answer out. If that is hard, the unit returns too much for one case or does too much.
|
|
17
|
-
- *Failures caught to inspect them.* A try in a test means the unit throws where it could return its failure as data. Assert on the returned result.
|
|
18
|
-
- *Tests switched off or focused.* A skip or an only hides a failing, slow or flaky case. Fix it or delete it.
|
|
19
|
-
|
|
20
|
-
**Where to go.** Every test is arrange, act, assert, against literal values. Variation comes from injected stubs. N cases are N tests or one table.
|
|
21
|
-
|
|
22
|
-
**Reactions to distrust.**
|
|
23
|
-
- "It's just a helper in the test." A helper with logic is untested code deciding whether other code passes.
|
|
24
|
-
- "Written-out values are brittle." They break when behaviour changes. That is their job.
|
|
25
|
-
- "The expected value is too big to write." Then the test asserts more than the unit's own responsibility, or the unit does too much.
|
|
26
|
-
|
|
27
|
-
**Principles behind it.**
|
|
28
|
-
- *Conditional Test Logic* (a test smell in Gerard Meszaros, *xUnit Test Patterns*). A test with branches can pass without checking what it claims to check.
|
|
29
|
-
- *Arrange, act, assert.* One setup, one action, one check: the shape that makes a test a readable specification.
|