My new home's disposal was wired solid, with 14-2 NM "Romex" going down through a hole in the bottom of the cabinet. The cable was placed in a piece of Liquid-Tite flexible conduit.
Now, I didn't like that one bit. A metal disposal, attached to a metal sink, and no GFCI? In a fixture whose main purpose is moving water? And, the unit isn't double insulated? In my opinion that's exactly and precisely the reason for a GFCI. I never liked the idea of turning on and off a disposal from a wall switch anyway.
So, shortly after moving in, I relocated the wiring to a proper box mounted on the side wall of the cabinet; installed a GFCI outlet there, wired to the cable that formerly went to the disposal. I added a good pigtail for the disposal, and added an air switch...to me, much safer, and far more convenient. Never liked touching a wall switch with wet hands. (thanks, Mom...)
But wait, there's more. The way the entire under sink area was wired was a bit mystifying to me. Like
@frodo the receptacle must have a wall switch. For some strange reason, they require the same for a hard-wired dishwasher...now if you have a smart dishwasher with Wifi and some visitor is unfamiliar with all the switches on your wall, they run the risk of accidentally shutting off the dishwasher in the middle of a cycle, or, you'll need to reconnect to wifi or reprogram it. Thankfully on my home (but not my neighbors) these two switches are in a separate duplex box. I put on covers so they do not accidentally get shut off. You can stick your finger in the side if need be to get to the switch.
Then to further complicate things, the electrician ran a 14-3 wire from the main panel to another box underneath the kitchen in the crawl space, sharing the neutral on two breakers. (breakers are joined). In the box, it was separated into two wires, one for the disposal and one for the dishwasher. Not the way I would have done it, but it is what it is.