Illegal maybe depending on your jurisdiction but it’s something that happens more often than you think.
I am not here to convince you to give notice, but only stating the reasons people do give a courtesy notice. As always there are people who don’t see the need to observe certain courtesies, but they are the exception not the norm.