A smoke detector is ALWAYS recommended and required by code as listed below:
In dwelling units, smoke detectors shall be mounted on the ceiling or wall at a point centrally located in the corridor or area giving access to each separate sleeping area.
In dwelling units built after 1991 or when additions, alterations or repairs to the interior exceed $1,000 in valuation and require a building permit, smoke detectors shall be installed in each sleeping room and at a point centrally located in the corridor or area giving access to each sleeping area.
In all cases, when a dwelling unit has more than one story or has a basement, a smoke detector shall be installed on each story and in the basement.