California is violating the rights of poor defendants by attaching fees to misdemeanor criminal convictions regardless of their ability to pay, a state appeals court ruled Tuesday.

The ruling by the Second District Court of Appeal in Los Angeles singled out payments imposed by state law to help fund court operations and maintain a statewide restitution fund for crime victims. The fees, totaling $220, were charged to a homeless woman convicted of driving with a license that had been suspended — because of unpaid fees from traffic tickets she had received years earlier as a teenager — and were referred to a collection agency when she couldn’t pay them.

Imposing fines and fees without considering a defendant’s ability to pay “simply punishes her for being poor,” Justice Laurie Zelon said in the 3-0 ruling. She said the assessments can affect a person’s credit rating, employment prospects and overall ability to rehabilitate and re-enter society, because those who can pay such fines in full can seek to get their convictions erased.

The ruling potentially affects thousands of people, said attorney Kathryn Eidmann of the nonprofit Public Counsel, which represented the woman.

“It’s irrational to try to raise funding from the poorest of the poor,” Eidmann said. “Courts are starting to rethink the way the court system operates.”

So is the Legislature, which in 2017 halted the practice of suspending licenses of drivers who could not afford to pay their tickets. But that law was not in effect when Velia Dueñas of Los Angeles had her license suspended for failing to pay $1,088 in fines for tickets she received as a juvenile. She was convicted three times of driving with a suspended license and sentenced to jail, serving 141 days because she was unable to pay the fines, the court said.,

In the latest case, Dueñas, now a homeless and disabled mother of two, pleaded no contest in 2015 to another misdemeanor charge of driving with a suspended license. She spent nine days in jail rather than pay a $300 fine, but was ordered to pay an additional $220 that the judge said could not be waived and would be referred to a collection agency if still unpaid by 2019.

On Tuesday, the appeals court ordered the sentencing judge to hold a new hearing, considering Dueñas’ ability to pay. The Legislature should consider rewriting the law to require such hearings, the court said.

The current law “serves no rational purpose ... and may be counterproductive,” Zelon said, because it doesn’t raise funds for the state’s programs and could encourage defendants to resort to lawbreaking to pay their fees.

Bob Egelko is a San Francisco Chronicle staff writer. Email: begelko@sfchronicle.com Twitter: @BobEgelko