I don't think there's anything inherently wrong or illegal about taking power off an outlet in an adjoining room and running it to a light fixture in your closet. HOW you do it will determine whether it's ok or not.
You can only fit so many wires into an outlet box, the cable needs to be protected in its run from one spot to the other and the new fixture needs to be grounded, etc.
Would the light be a pull chain or would you also install a light switch?
I'm not a professional and others with more experience will chime in but those are my thoughts.
Pictures of the existing outlet with the cover off and of the closet where you intend to put the new fixture might get you better answers.
You can only fit so many wires into an outlet box, the cable needs to be protected in its run from one spot to the other and the new fixture needs to be grounded, etc.
Would the light be a pull chain or would you also install a light switch?
I'm not a professional and others with more experience will chime in but those are my thoughts.
Pictures of the existing outlet with the cover off and of the closet where you intend to put the new fixture might get you better answers.