How Do I Fix This
We have a lighted medicine cabinet with three little low-voltage halogen lamps that looks a lot like this one:
The lights are switched by one of those combo switch/GFCI receptacle devices that's on the wall next to the cabinet. She's always complained that with a single receptacle that she plugging and unplugging to use her haircare appliances. So I figure I'll put in a bigger box and add another receptacle.
The transformer sits above the lights and the "cord" goes into the wall and enters the box with the receptacle, not through a knock out but through the mounting holes in the side of the box.
At this point I'm suspecting that this thing was never meant to be hardwired and the original installer just cut the plug off the cord and ran into the box. Although a length of lamp cord running down the wall to the receptacle seems a bit odd, not to mention ugly.
The only "proper" fix that comes to mind is to put a switched receptacle directly above the cabinet. That wouldn't look so great either.