Skip to content

bare-decimal (S291)

Fix is always available.

This rule is unstable and in preview. The --preview flag is required for use.

This rule is turned on by default.

What it does

Checks for floating point literals that begin or end in a bare decimal point, such as .5 or 2..

Why is this bad?

Floating point literals that begin or end in a bare decimal point can be missed and may lead to confusion. For example, .5 could be misread as 5. It is generally recommended to include a leading zero before the decimal point and a trailing zero after the decimal point for clarity, such as 0.5 and 2.0.