This section does not differentiate between one type of clothes closet or another.
Electrical panel box in closet.
If it is on the long wall of the closet all you need is a free 36 of space in front of it 30 in chicago no clothes in the closet for both scenarios.
These codes cover the installation and placement of residential circuit breaker boxes including main service panels and subpanels.
Rooms circuit breaker boxes may not be installed in bathrooms powder rooms clothes closets or in any room where there is insufficient space for a worker to access and work on the box.
Nema 3r if exposed to weather.
If clearance was kept i don t see a major issue as pictured.
In summary electrical panels can be located anywhere other than in bathrooms clothes closets above steps of a stairway or in fire rated partitions or area separation walls as long as the proper working clearances are provided per nec 110 26 and the enclosure type is suitable for the application i e.
According to the national code with relation to electrical panels in closets.
With the electrical panel installed on the narrow side wall there might not be required 30 space unless you have a deep clothes closet.
Panels are located in utility closets and approved all the time with proper clearances.
Nec 240 24d overcurrent devices shall not be located in the vicinity of easily ignitable materials such as a clothes closet.
The wording is vague as it does not absolutely prohibit a panel in a closet more like just around easily ignited materials.
However there are a few issues to consider a bout the language of this code and how it applies to your specific situation.