Keep it as short as possible, too long motor to ESC can in some cases cause erratic commutation and too long esc to battery can cause overvoltage - both can damage transistors. The rule is, that if you have battery voltage close to max voltage of ESC, you cannot lengthen battery leads, and in that case you must do it on motor wires. If you have low battery voltage, it is better on battery side. However proper way is to lengthen battery lead and add capacitors. They should be installed in case that wire length is over 10 inches. But it depends on battery volatage (difference between battery voltage and max ESC voltage)