Huntington Beach deserves to be sued.

California has a crippling housing shortage that has driven up home prices and rents, fueled homelessness and pushed residents and business out of the state. And yet the city’s leaders somehow think their wealthy Orange County coastal enclave should be exempt from producing its fair share of homes.

Of course the city shouldn’t be exempt. It’s welcome news that Gov. Gavin Newsom and Atty. Gen. Rob Bonta sued Huntington Beach for violating state housing laws. The lawsuit should be a warning to other communities: California is cracking down on cities that try to evade new laws aimed at encouraging homebuilding.

Huntington Beach and other cities complain heartily that state lawmakers trample on their local control. Indeed, the state has adopted ambitious new laws that, among other things, require that cities approve backyard homes and duplexes in single-family neighborhoods and enact enforceable plans that identify where new market-rate and affordable housing can be built.

Those laws, however, were adopted for good reason — cities failed to build housing. Over decades, local elected leaders bent to Not In My Backyard demands to block or restrict housing in the name of preventing traffic or protecting neighborhood character. As a result, the state hasn’t built enough housing to keep up with population growth.

To ease the shortage and bring down prices, California will need an additional 2.5 million homes by 2030. But the state builds only about 125,000 units a year. All cities will have to make it easier to build more homes. Even Huntington Beach.

Despite numerous warnings from state officials, the Huntington Beach City Council recently voted to refuse applications to build accessory dwelling units or duplexes in single-family zones, banning projects that are legal under state law.

The council is also planning to ignore applications filed under the “builders remedy,” a provision of state law that says housing developers can ignore local zoning and propose whatever they want in cities that have failed to write a housing plan that meets state requirements. Builders remedy projects just need to ensure 20% of the units are affordable. Huntington Beach — no surprise — does not have a compliant housing plan.

Hours after Newsom and Bonta’s announcement, Huntington Beach filed its own lawsuit in federal court, challenging the state requirement that the city make room for more than 13,000 new units in the coming years. The lawsuit accused the state of making an “unbridled power play” to turn Huntington Beach into a “high-density mecca.”

The beach city’s leaders seem more interested in preserving some idealized vision of suburbia than helping people who live and work in Huntington Beach and want more housing options. People such as Ty Youngblood, who planned to build an accessory dwelling unit at his 80-year-old mother’s house so his family could live with and take care of her. After paying for engineering and architectural plans, Youngblood said, his project is now blocked.

Though Huntington Beach is the most openly resistant to complying with state housing laws, there are other galling examples of cities trying to get around their obligations.

Officials in Sausalito proposed putting new housing on sites that are underwater. Woodside leaders, infamously, tried to declare the tony Bay Area community a mountain lion sanctuary to thwart duplex developments. And in La Cañada Flintridge, a pastor agreed to list her church as an “imaginary” site where affordable housing could be built so the city could claim its housing plan was in compliance with state rules.

California’s housing crisis is too severe to tolerate obstructionism. So, Newsom and Bonta, keep up the righteous fight against NIMBY cities.