Skip to content

Enforce consistent case for text encoding identifiers ​

💼 This rule is enabled in the ✅ recommended config.

🔧💡 This rule is automatically fixable by the --fix CLI option and manually fixable by editor suggestions.

  • Enforce 'utf8' for UTF-8 encoding.
  • Enforce 'ascii' for ASCII encoding.

This rule only auto-fix encoding in fs.readFile() and fs.readFileSync().

Fail ​

js
await fs.readFile(file, 'UTF-8');
js
await fs.readFile(file, 'ASCII');
js
const string = buffer.toString('utf-8');

Pass ​

js
await fs.readFile(file, 'utf8');
js
await fs.readFile(file, 'ascii');
js
const string = buffer.toString('utf8');

Released under the Apache License 2.0.