Skip to main content

no-invalid-repeat-count

Disallow invalid fixed repeat counts in CSS Grid track templates.

The first argument to a fixed repeat() must be a positive integer. Counts such as 0, negative numbers, and decimals make the track template invalid. This rule leaves auto-fit, auto-fill, and dynamic values to the rules that own those cases.

Incorrectโ€‹

.layout {
grid-template-columns: repeat(0, 1fr);
}
.layout {
grid-template-rows: repeat(2.5, auto);
}

Correctโ€‹

.layout {
grid-template-columns: repeat(3, minmax(0, 1fr));
}
.layout {
grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
}

Stylelint Configโ€‹

export default {
plugins: ["stylelint-plugin-grid"],
rules: {
"grid/no-invalid-repeat-count": true
}
};