src/content/docs/linter/rules/no-string-case-mismatch.mdx
import { Tabs, TabItem } from '@astrojs/starlight/components';
<Tabs> <TabItem label="JavaScript (and super languages)" icon="seti:javascript"> ## Summary - Rule available since: `v1.0.0` - Diagnostic Category: [`lint/correctness/noStringCaseMismatch`](/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 [`match_str_case_mismatch`](https://rust-lang.github.io/rust-clippy/master/#match_str_case_mismatch){
"linter": {
"rules": {
"correctness": {
"noStringCaseMismatch": "error"
}
}
}
}
Disallow comparison of expressions modifying the string case with non-compliant value.
if (s.toUpperCase() === "Abc") {}
while (s.toLowerCase() === "Abc") {}
if (s.toUpperCase() === "ABC") {}
while (s.toLowerCase() === "abc") {}
for (;s.toLocaleLowerCase() === "ABC";) {}
while (s.toLocaleUpperCase() === "abc") {}
for (let s = "abc"; s === "abc"; s = s.toUpperCase()) {}