In general, you should try to avoid charging your phone overnight, and instead unplug your phone when you go to bed, and charge it after you wake up. During the time it takes you to shower and eat breakfast you should reach a comfortable charge percentage.
Definitely also avoid leaving your phone under your pillow while charging it. Besides the real risk of a fire, the lack of airflow can cause a high-temperature state, which will increase the battery degradation.
We’re not saying to only charge your phone in the morning. Realistically with partial charges, you will also charge it during work or in the evening. However, as much as you can, avoid going over 80%.
Although Li-Ion batteries don’t have a charge capacity memory, there is some research that says that you should fully discharge your battery at least once every 30 cycles. Your hardware can form a digital memory which will make the charge gauge inaccurate if the battery is never fully discharged. For most people this will happen naturally at least a few times a month, so we don’t recommend going out of your way to fully discharge your battery.
That said, if your phone dies randomly even though the battery gauge says you have charge left, it could be caused by miscalibration (or a faulty battery). If calibrating your battery doesn’t fix the issue, then faulty batteries should be a valid claim if your battery is still under warranty.