src/content/docs/linter/rules/no-constant-math-min-max-clamp.mdx
import { Tabs, TabItem } from '@astrojs/starlight/components';
<Tabs> <TabItem label="JavaScript (and super languages)" icon="seti:javascript"> ## Summary - Rule available since: `v1.7.0` - Diagnostic Category: [`lint/correctness/noConstantMathMinMaxClamp`](/reference/diagnostics#diagnostic-category) - This rule is **recommended**, meaning it is enabled by default. - This rule has an [**unsafe**](/linter/#unsafe-fixes) fix. - The default severity of this rule is [**error**](/reference/diagnostics#error). - Sources: - Same as [`min_max`](https://rust-lang.github.io/rust-clippy/master/#min_max){
"linter": {
"rules": {
"correctness": {
"noConstantMathMinMaxClamp": "error"
}
}
}
}
Disallow the use of Math.min and Math.max to clamp a value where the result itself is constant.
Math.min(0, Math.max(100, x));
Math.max(100, Math.min(0, x));
Math.min(100, Math.max(0, x));