In landlord-tenant law, a warranty of habitability is implied in a residential lease. The law imposes certain duties on a landlord to maintain the premises in habitable condition. Failure to do so, such as providing adequate weatherproofing, available heat, water and electricity, and clean, sanitary and structurally safe premises, may be legal justification for a tenant's defensive acts, such as moving out (even in the middle of a lease), paying less rent, withholding the entire rent until the problem is fixed, making necessary repairs (or hiring someone to make them and deducting the cost from next month's rent).
There are no set rules. However, generally, the landlord must provide drinkable water, heat (in cold weather), a working sewer system, a safe, working electrical system, an operating smoke detector, a lock for your door, a home not filled with rodents and/or bugs, and a sanitary condition of the structure of the home and outside area.
The landlord must repair substantial defects in the rental unit and substantial failures to comply with state and local building and health codes. However, the landlord is not responsible under the implied warranty of habitability for repairing damages which were caused by the tenant or the tenant's family, guests, or pets. The landlord may be sued for a partial refund of past rent, and in some circumstances can be sued for the discomfort, annoyance and emotional distress caused by the substandard conditions.