Giovanni Battista (John Baptist) Scaramelli (1687-1752) was a Jesuit spiritual writer. In one of his books, he wrote almost 100 pages concerning scruples (a term for obsessions and compulsions). His advice on how to overcome them sounds a lot like behavior therapy.
[Compulsions.] [S]cruples are not grounded on true reasons.... Consequently, to act in despite of them...is not to act against reason but against a fantastic shadow; hence it cannot be said that such an action is unreasonable, and therefore it cannot possibly be sinful. Nay, more, it is necessary to act in this manner, else we could never get rid of these foolish fears and groundless anxieties.... When a man first goes to sea, he is afraid of the violence of the waves, he fears the rocks and dreads the storms; on his next voyage he is less afraid; and if he continues to go to sea, he loses all fear, as, by acting against his alarms, he has conquered and overcome them.... So, too, the scrupulous man, if he act in contempt of his fears and whimsical notions, rises above them and at length conquers them, and by this means gets rid of the toils wherein his scruples, with their countless nonsensical fancies, had entangled him. But if, withheld by empty fears, he abstain from acting, they will begin to master him, to make him a very slave, and to leave him no longer the least liberty of following the dictates of right reason. [Vol. II, ¶ 452, pp. 358-9]
[Obsessions.] Other temptations there are which are not dangerous, as they are abhorrent.... Such are temptations to blasphemy, certain abominable thoughts and words against God, the saints, and holy images.... Now, with such temptations it is by no means prudent or wise to struggle or to enter on a hand-to-hand fight, saying "I will not consent; I detest, I abhor them": both because, on account of there being no danger of yielding them consent, there is no need to offer resistance and because, by resisting, the person subjects himself to a slavery, by conceiving such an intense abhorrence of them, as most frequently only stirs them to activity and imprints them more deeply on the fancy....
Not a few persons are timorous, and of so delicate a conscience, that they feel great abhorrence of all impurity, and of every action in which a grievous sin may lurk. When an image or a feeling contrary to purity presents itself to such as these, they fall into great fear and feel intense pain; they arm themselves against such thoughts.... And what is the result? The more these thoughts are driven away the more they return to the mind.... [A]s I have already observed, nothing is so apt to awaken such thoughts, or to fix them in the mind, as excessive fear. The reason of which is obvious. Fear excites the fancy and impresses it with the dreaded object. [Vol. II, ¶¶ 409-11, pp. 323-7]
NOTE: For more on Scaramelli, see Osborn, 1998, pp. 214-6.