Answer:
The National Electrical Code (NEC) generally requires the junction box (J-box) to be installed within 6 feet of the luminaire, but local regulations may vary, so it's essential to check your specific local electrical code for any additional requirements.