Skip to content

unicorn/text-encoding-identifier-case Style

🛠️ An auto-fix is available for this rule.

What it does

This rule aims to enforce consistent case for text encoding identifiers.

Enforces 'utf8' for UTF-8 encoding Enforces 'ascii' for ASCII encoding.

Example

javascript
import fs from "node:fs/promises";
async function bad() {
  await fs.readFile(file, "UTF-8");

  await fs.readFile(file, "ASCII");

  const string = buffer.toString("utf-8");
}

async function good() {
  await fs.readFile(file, "utf8");

  await fs.readFile(file, "ascii");

  const string = buffer.toString("utf8");
}

References

Released under the MIT License.