The m'gila says clearly that Ester was "bas dodo", which seems to mean she was the daughter of Mord'chay's uncle, i.e., his first cousin. The targum renders this as "b'ras achvoy". Does that mean "his niece"? If not, then where does the common claim that Ester was Mord'chay's niece come from? Alternatively, if so, then is there a commentary on the m'gila that says explicitly that she was his cousin?
R' Ari Zivotofsky has a nice article on this subject, explaining the possible reasons for this misconception: https://www2.biu.ac.il/JH/Parasha/eng/purim/ziv.html
See the commentary of the Ibn Ezra on Esther 8:1 (page 30 in the linked document) where he says that Mordechai was Esther's uncle.