Several states have laws that purport to restrict or punish faithless electors for their electoral votes. See Wikipedia's Faithless elector: Legal position. Michigan and Minnesota even claim the authority to replace the votes of faithless electors after the fact:
If an elector fails to cast a ballot for the presidential or vice presidential candidate of the party under whose name the elector was chosen, the elector's vote or abstention is invalidated and an alternate presidential elector, chosen by lot from among the alternates, shall cast a ballot in the name of the elector for the presidential and vice presidential candidate of the party under whose name the elector was chosen.
If the status of elector is viewed literally, such laws constitute interference with the elector's free franchise. This obviously seems legally suspect.
While faithless-elector laws have never been enforced, and thus have not been tested in court, are they legally valid?
(This is separate of the issue of whether states or parties can require electors to pledge to vote for their party's candidate—which they can.)