π Enforce consistent case for text encoding identifiers.
πΌ This rule is enabled in the following configs: β
recommended, βοΈ unopinionated.
π§π‘ This rule is automatically fixable by the --fix CLI option and manually fixable by editor suggestions.
This rule only auto-fix encoding in fs.readFile() and fs.readFileSync().
// β
await fs.readFile(file, 'UTF-8');
// β
await fs.readFile(file, 'utf8');// β
await fs.readFile(file, 'ASCII');
// β
await fs.readFile(file, 'ascii');// β
const string = buffer.toString('utf-8');
// β
const string = buffer.toString('utf8');Type: object
Type: boolean
Default: false
Use WHATWG standard encoding notation with dashes (e.g., β utf-8 instead of β utf8).
// β
/* eslint unicorn/text-encoding-identifier-case: ["error", {"withDash": true}] */
await fs.readFile(file, 'utf8');// β
/* eslint unicorn/text-encoding-identifier-case: ["error", {"withDash": true}] */
await fs.readFile(file, 'utf-8');