Pattern: Non-standard whitespace character in code
Issue: -
Irregular whitespace characters (like non-breaking spaces, zero-width spaces, or various Unicode spaces) can cause visual inconsistencies and make code harder to maintain. These characters often appear when copying code from word processors or websites.
Example of incorrect code:
function foo() { // Has irregular space
return 42;
}
const items = ['foo', 'bar']; // Has irregular space
if (condition) {
doSomething();⠀⠀// Has irregular spaces
}
Example of correct code:
function foo() { // Uses regular space
return 42;
}
const items = ['foo', 'bar']; // Uses regular space
if (condition) {
doSomething(); // Uses regular spaces
}