While at one time it was acceptable to have these lights in closets as long as the bulb was at least 18 inches away from the closet shelf, exposed incandescent lights are no longer allowed in closets, period.
Here’s what the 2017 National Electric Code (NEC) says about closet lights:
410.16 Luminaires in Clothes Closets.
(A) Luminaire Types Permitted. Only luminaires of the following types shall be permitted in a closet:
(1) Surface-mounted or recessed incandescent or LED luminaires with completely enclosed light sources
(2) Surface-mounted or recessed flourescent luminaires
(3) Surface-mounted fluorescent or LED luminaires identified as suitable for installation within the closet storage space Also, here’s the definition of a luminaire: Luminaire. A complete lighting unit consisting of a light source such as a lamp or lamps, together with the parts designed to position the light source and connect it to the power supply. It may also include parts to protect the light source or the ballast or to distribute the light. A lampholder itself is not a luminaire.