I did it a few times. Not code but simply because the switch was in the same box as the GFI recep. Since it was a dedicated circuit, it was easier to do it this way then run a separate light feed and it made no sense to have the option there and not use it. Never had any nuisence tripping.