Heavy rainfall has flooded parts of Massachusetts and Rhode Island, with one city declaring a state of emergency.