In the same lain as Music as Code
and CAD as Code
.
Designing electronics as composable modules in code seems like a good idea.
Some tools like that:
tscircuit - Make electronics using Typescript and React
CircuitJS1 - an electronic circuit simulator that runs in the browser
replicad - Design circuits using Javascript/Typescript.