prefer-code-point
March 27, 2026 ยท View on GitHub
๐ Prefer String#codePointAt(โฆ) over String#charCodeAt(โฆ) and String.fromCodePoint(โฆ) over String.fromCharCode(โฆ).
๐ผ This rule is enabled in the following configs: โ
recommended, โ๏ธ unopinionated.
๐ก This rule is manually fixable by editor suggestions.
Unicode is better supported in String#codePointAt() and String.fromCodePoint().
Examples
// โ
const unicorn = '๐ฆ'.charCodeAt(0).toString(16);
// โ
const unicorn = '๐ฆ'.codePointAt(0).toString(16);
// โ
const unicorn = String.fromCharCode(0x1f984);
// โ
const unicorn = String.fromCodePoint(0x1f984);