noStringCaseMismatch (since v1.0.0)
Diagnostic Category: lint/correctness/noStringCaseMismatch
Sources:
- Same as: 
match_str_case_mismatch 
Disallow comparison of expressions modifying the string case with non-compliant value.
Examples
Section titled ExamplesInvalid
Section titled Invalidif (s.toUpperCase() === "Abc") {}code-block.js:1:5 lint/correctness/noStringCaseMismatch  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  ✖ This expression always returns false.
  
  > 1 │ if (s.toUpperCase() === "Abc") {}
      │     ^^^^^^^^^^^^^^^^^^^^^^^^^
    2 │ 
  
  ℹ This call convert the string to upper case
  
  > 1 │ if (s.toUpperCase() === "Abc") {}
      │     ^^^^^^^^^^^^^^^
    2 │ 
  
  ℹ ... but this value is not in upper case
  
  > 1 │ if (s.toUpperCase() === "Abc") {}
      │                         ^^^^^
    2 │ 
  
  ℹ Unsafe fix: Use upper case string value.
  
    1   │ - if·(s.toUpperCase()·===·"Abc")·{}
      1 │ + if·(s.toUpperCase()·===·"ABC")·{}
    2 2 │   
  
while (s.toLowerCase() === "Abc") {}code-block.js:1:8 lint/correctness/noStringCaseMismatch  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  ✖ This expression always returns false.
  
  > 1 │ while (s.toLowerCase() === "Abc") {}
      │        ^^^^^^^^^^^^^^^^^^^^^^^^^
    2 │ 
  
  ℹ This call convert the string to lower case
  
  > 1 │ while (s.toLowerCase() === "Abc") {}
      │        ^^^^^^^^^^^^^^^
    2 │ 
  
  ℹ ... but this value is not in lower case
  
  > 1 │ while (s.toLowerCase() === "Abc") {}
      │                            ^^^^^
    2 │ 
  
  ℹ Unsafe fix: Use lower case string value.
  
    1   │ - while·(s.toLowerCase()·===·"Abc")·{}
      1 │ + while·(s.toLowerCase()·===·"abc")·{}
    2 2 │   
  
Valid
Section titled Validif (s.toUpperCase() === "ABC") {}while (s.toLowerCase() === "abc") {}for (;s.toLocaleLowerCase() === "ABC";) {}while (s.toLocaleUpperCase() === "abc") {}for (let s = "abc"; s === "abc"; s = s.toUpperCase()) {}