There is no violation; indeed, with today's elaborate closets, receptacles are becomming common.
The NEC does prohibit installing panels in clothes closets these days---the practice was once common---and that may be what the inspector was thinking of.

In any event, it is the inspectors' duty to cite the code. Just don't jump on him if he admits to being a little confused...it happens to us all!