Abdullah bin Masud reported,

Some people asked the Messenger of Allah ﷺ, "Messenger of Allah, will we be held accountable for what we did during the days of ignorance?"He replied, "Whoever among you does well in Islam will not be held accountable for it, but whoever does evil will be held accountable for his deeds both in the days of ignorance and in Islam."

Azami 15149

Sahih

عن عبد الله بن مسعود قال

قال أناس لرسول الله ﷺ: يا رسول الله، أنؤاخذ بما عملنا في الجاهلية؟ قال: أما من أحسن منكم في الإسلام فلا يؤاخذ بها، ومن أساء أخذ بعمله في الجاهلية والإسلام.

الأعظمي 15149صحيح
Contents
Reference
Commentary
Ayat
Collection
Jami al-Kamil
Book
Asceticism and softening of the heart
Chapter
Virtue of asceticism and softening of hearts
Section
Islam demolishes what came before it, except for those who did evil
Numbering
Jami al-Kamil 15149 (2nd edition)
Azami 15149