ACROCase

Acronyms Consistently Retain Original Case

The web platform has hundreds of APIs that contain acronyms. With remarkable consistency, those acronyms are kept uppercase: innerHTML, XMLDocument, toJSON, encodeURIComponent. ACROCase is a name for this convention, and an ESLint plugin to enforce it.

Acronyms in Web APIs

AcronymWeb platform APIs
HTMLHTMLElement, HTMLCollection, innerHTML, outerHTML
CSSCSSStyleSheet, CSSRule, CSSStyleDeclaration
DOMDOMParser, DOMRect, DOMTokenList, DOMException
SVGSVGElement, SVGPathElement, SVGRectElement
URLURL, URLSearchParams, URLPattern, createObjectURL
URIencodeURI, decodeURI, encodeURIComponent
JSONJSON.parse(), JSON.stringify(), toJSON
XMLXMLDocument, XMLSerializer, XMLHttpRequest
GPUGPUDevice, GPUBuffer, GPUTexture, GPUAdapter
RTCRTCPeerConnection, RTCDataChannel, RTCSessionDescription
IDBIDBDatabase, IDBObjectStore, IDBTransaction
USBUSB, USBDevice, USBConfiguration
HIDHID, HIDDevice, HIDConnectionEvent
MIDIMIDIAccess, MIDIInput, MIDIOutput
GATTBluetoothRemoteGATTServer, BluetoothRemoteGATTService
BYOBReadableStreamBYOBReader, ReadableStreamBYOBRequest
VTTVTTCue, VTTRegion
XRXRSystem, XRSession, XRFrame
DTMFRTCDTMFSender, RTCDTMFToneChangeEvent

100+ HTML* interfaces. 80+ SVG*. 50+ CSS*. 30+ each for GPU*, RTC*, and XR*.

Not Acronyms

Id is an abbreviation, not an acronym.The DOM uses getElementById, elementId, clientId.Similarly, the Internationalization API is Intl, not INTL.

Chaining

When two acronyms are adjacent, one gets titlecased.XMLHttpRequest should be XMLHTTPRequest by the convention's own logic, but XMLHTTP is where you lose the boundary.

The Web Crypto API titlecases all its acronyms for the same reason:

WebRTC does the same selectively: RTCDtlsTransport, RTCRtpSender.But not always: RTCDTMFSender keeps DTMF uppercase.

The Convention

acroCaseUpperACROCase
StarturlStringURLString
EndimageURLImageURL
MultiplehtmlToJSONHTMLToJSON

ESLint Plugin

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

Auto-fixable. Ships with a dictionary of 139 acronyms. Extensible:

{
  "acrocase/acrocase": ["error", {
    "acronyms": ["GCP", "NATS"]
  }]
}