Skip to content

stringCaseMismatches

Reports string case method calls compared against literals with mismatched casing.

✅ This rule is included in the ts logical presets.

When using .toLowerCase() or .toUpperCase() in comparisons, the compared string literal must match the expected case. Otherwise, the comparison will always produce the same result regardless of input.

For example, text.toLowerCase() === "VALUE" will always be false because .toLowerCase() returns a lowercase string, but "VALUE" is uppercase.

input.toLowerCase() === "VALUE";
input.toUpperCase() === "hello";

This rule is not configurable.

If you have code that intentionally uses mismatched case comparisons for testing or demonstration purposes, this rule might get in your way. You might consider using Flint disable comments and/or configuration file disables for those specific situations instead of completely disabling this rule.

Made with ❤️‍🔥 in Boston by Josh Goldberg and contributors.