Avoid electrical fires by taking these steps
No Electrical Box
Add a junction box and re-install the light. Junction boxes protect the connections from accidental damage and contain sparks and heat from loose connections and short circuits.
Cutting Wires too Short
Putting strain on wires can be very dangerous. They can cause poor connections, which is dangerous. Leave the wires long enough to protrude 3 inches from the box. Add small plastic connectors if the wire wasn't made long enough.
Leaving Cables Unprotected
Unprotected cable gets easily damaged. That's why you won't pass inspection by leaving it unprotected when running over/under wall or ceiling framing. Add a 1.5-inch-thick board alongside the cable
Installing a Three-slot Receptacle without a Ground
A very common mistake people make for convenience. Use a tester to see if the outlet is grounded. If it isn't, put the two-slot outlet back in.
Recessing Boxes Behind Wall Surface
Boxes behind combustible materials can be a fire hazard. To fix this problem, add a plastic box extension to go past the outer wall