The following are two classic quotes from Puritans Thomas Watson and Joseph Alleine on those who trust in their own righteousness:
[Some people being very moral have] "nothing to do with the business of repentance. They are so good, that they scorn God's offer of mercy. Indeed these are often in the worst condition: these are they who think they need no repentance (Luke 15:7). Their morality undoes them. They make a "savior" of it, and so on this rock they suffer shipwreck. Morality shoots short of heaven. It is only nature refined. A moral man is but old Adam dressed in fine clothes. The king's image counterfeited and stamped upon brass will not go current. The moral person seems to have the image of God—but he is only brass metal, which will never pass for current. Morality is insufficient for salvation. Though the life is moralized, the lust may be unmortified. The heart may be full of pride and atheism. Under the fair leaves of a tree, there may be a worm. I am not saying, repent that you are moral—but that you are no more than moral. Satan entered into the house that had just been swept and garnished (Luke 11:26). This is the emblem of a moral man, who is swept by civility and garnished with common gifts—but is not washed by true repentance. The unclean spirit enters into such a one. If morality were sufficient to salvation, Christ need not have died. The moral man has a fair lamp—but it lacks the oil of grace."
From Thomas Watson, The Doctrine of Repentance
[Some people end up] "Trusting in their own righteousness. This is a soul-ruining mischief. When men trust in their own righteousness they do indeed reject Christ's. Beloved, you had need be watchful on every hand, for not only your sins—but your duties may undo you. It may be you never thought of this; but so it is, that a man may as certainly perish by his seeming righteousness and supposed graces—as by gross sins; and that is, when a man trusts to these as his righteousness before God, for satisfying His justice, appeasing His wrath, procuring His favor, and obtaining His pardon. This is to put Christ out of office, and make a Savior of our own duties and graces. Beware of this, O professing Christians; you are much in duties—but this one fly will spoil all the ointment. When you have done most and best, be sure to go out of yourselves—to Christ; reckon your own righteousness as filthy rags (Phil 3:9; Isa 64:6)."
Joseph Alleine, A Sure Guide to Heaven
Comment: Both Christians and non-Christians are to repent of trusting in their good works. We can neither attain nor maintain our justification by them. Jesus would have us look to no other Savior but Himself. Yet true grace will always set a person to aspire after holiness (Phil 3:13; Prov 4:18).