ACROCase

Acronyms Consistently Retain Original Case

The Problem

How should acronyms like HTTP, URL, and JSON appear in camelCase and PascalCase identifiers?

acroCase

httpURL

Lowercase acronyms

httpUrl

The Rule

Acronyms are acronyms, not words. Preserve their uppercase form. This matches the web platform and keeps acronyms recognizable.

AcronymacroCaseUpperACROCase
HTTPhttpRequestHTTPRequest
URLimageURL, urlStringURLParser
XMLxmlDocumentXMLDocument
APIrestAPI, apiKeyAPIKey
HTMLinnerHTML, htmlStringHTMLElement
JSONtoJSON, jsonStringJSONParser
Note: When an acronym starts a camelCase identifier, it's lowercase (urlString). When it appears elsewhere, it's uppercase (imageURL).

Why ACROCase?

1. Acronyms Stay Recognizable

Acronyms are abbreviations with established uppercase forms. URL is instantly recognizable; Url looks like a misspelling.

Recognizable

parseURL, toJSON

Looks wrong

parseUrl, toJson

2. Matches the Web Platform

The DOM and web APIs consistently use uppercase acronyms:

3. Acronyms Are Not Words

Treating acronyms as words loses information. URL is an acronym; Url is nothing.

Preserved

parseURL, HTMLElement

Lost

parseUrl, HtmlElement

Web Platform Examples

The web platform preserves acronym casing:

APIAcronym
innerHTML, outerHTMLHTML
toJSONJSON
encodeURIComponent, decodeURIURI
HTMLElement, HTMLCollectionHTML
XMLDocument, XMLSerializerXML
CSSStyleSheet, CSS.supports()CSS

Exceptions

The web platform treats a few abbreviations as words rather than acronyms:

"Id" not "ID"

The DOM uses getElementById, elementId, and clientId.

Web platform style

userId, getElementById

Inconsistent

userID, getElementByID

"Intl" not "INTL"

The Internationalization API uses Intl, not INTL.

Web platform style

Intl.DateTimeFormat

Inconsistent

INTL.DateTimeFormat

Avoid Chaining Acronyms

Don't put acronyms next to each other. The result is always hard to read:

Restructured

HTMLParser, parseJSON

Chained acronyms

XMLHTTPRequest, ABORTURI

XMLHttpRequest exists because of a poor naming choice. When naming new code, restructure to avoid adjacent acronyms entirely.

acroCase vs UpperACROCase

Just like camelCase and UpperCamelCase (PascalCase), ACROCase has two variants:

StyleFirst wordExample
acroCaselowercaseparseURL, toJSON, innerHTML
UpperACROCasecapitalizedURLParser, JSONResponse, HTMLElement

When an acronym starts an identifier, its casing depends on the style:

PositionacroCaseUpperACROCase
StarturlStringURLString
Middle/EndimageURLImageURL

ESLint Plugin

Enforce ACROCase with eslint-plugin-acrocase:

npm install eslint-plugin-acrocase --save-dev
{
  "plugins": ["acrocase"],
  "rules": {
    "acrocase/acrocase": "error"
  }
}

The plugin is auto-fixable. Run eslint --fix to automatically correct violations.

With existing ESLint casing rules

ESLint's built-in camelcase rule and @typescript-eslint/naming-convention enforce lowercase acronyms by default. To use ACROCase, disable their acronym handling:

{
  "rules": {
    // Disable the built-in camelcase rule
    "camelcase": "off",
    // Or with @typescript-eslint, allow uppercase acronyms
    "@typescript-eslint/naming-convention": [
      "error",
      {
        "selector": "default",
        "format": ["camelCase", "PascalCase"],
        "filter": {
          "regex": "^(HTTP|URL|HTML|JSON|XML|API|CSS|DOM|URI|SVG|SQL|UUID).*|.*(HTTP|URL|HTML|JSON|XML|API|CSS|DOM|URI|SVG|SQL|UUID)$",
          "match": false
        }
      }
    ],
    // Then let acrocase handle acronym casing
    "acrocase/acrocase": "error"
  }
}

Dictionary

A machine-readable dictionary.json is available with all recognized acronyms, exceptions, and examples.

Summary

Match the web platform: keep acronyms uppercase (URL, HTML, JSON), use Id not ID, and avoid chaining acronyms.

// acroCase
const imageURL = "https://example.com/img.png";
const userId = 12345;
element.innerHTML = "<p>Hello</p>";
data.toJSON();

// UpperACROCase
class HTTPClient {}
interface APIResponse {}
const doc = new XMLDocument();