( binding: Binding, runtime: RuntimeModule, path: readonly string[] = [] )
| 602 | } |
| 603 | |
| 604 | private readBinding( |
| 605 | binding: Binding, |
| 606 | runtime: RuntimeModule, |
| 607 | path: readonly string[] = [] |
| 608 | ): void { |
| 609 | const paths = this.readBindings.get(binding) |
| 610 | const key = path.join(".") |
| 611 | if (paths?.has(key)) return |
| 612 | if (paths) paths.add(key) |
| 613 | else this.readBindings.set(binding, new Set([key])) |
| 614 | const { module } = runtime |
| 615 | const write = |
| 616 | binding.writes[0] ?? |
| 617 | binding.references.find(reference => reference.isWrite)?.id |
| 618 | if (write) { |
| 619 | escape( |
| 620 | `${module.positionOf(write)} assigns ${binding.name}, which holds a validator` |
| 621 | ) |
| 622 | } |
| 623 | if (binding.kind !== "const" && binding.kind !== "import") { |
| 624 | escape( |
| 625 | `${module.positionOf(binding.id)} holds a validator in ${binding.name}, which isn't a const` |
| 626 | ) |
| 627 | } |
| 628 | if (runtime.passed.includes(binding)) { |
| 629 | escape( |
| 630 | `${module.positionOf(binding.id)} passes ${binding.name} to a factory that checks it, which may read any member` |
| 631 | ) |
| 632 | } |
| 633 | for (const reference of binding.references) { |
| 634 | if (isDead(reference.id, runtime)) continue |
| 635 | const [operand, parent] = operatorOf(reference.id) |
| 636 | // read by importers through the export |
| 637 | if ( |
| 638 | parent?.type === "ExportSpecifier" || |
| 639 | parent?.type === "ExportDefaultDeclaration" |
| 640 | ) |
| 641 | continue |
| 642 | this.read(operand, parent, runtime, path) |
| 643 | } |
| 644 | for (const name of binding.exportNames) this.readExport(runtime, name, path) |
| 645 | } |
| 646 | |
| 647 | private readExport( |
| 648 | runtime: RuntimeModule, |
no test coverage detected