Skip to content

brainkim/acrocase

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

eslint-plugin-acrocase

ESLint plugin to enforce ACROCase naming conventions.

Acronyms Consistently Retain Original Case

Installation

npm install eslint-plugin-acrocase --save-dev

Usage

{
  "plugins": ["acrocase"],
  "rules": {
    "acrocase/acrocase": "error"
  }
}

Or use the recommended config:

{
  "extends": ["plugin:acrocase/recommended"]
}

What it does

The rule enforces that known acronyms retain their uppercase form in camelCase and PascalCase identifiers. It also catches abbreviations that are commonly mistaken for acronyms (like ID instead of Id).

Correct

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

class HTTPClient {}
class APIResponse {}

Incorrect

const imageUrl = "https://example.com/img.png";  // imageURL
const userID = 12345;                             // userId
data.toJson();                                    // toJSON

class HttpClient {}   // HTTPClient
class ApiResponse {}  // APIResponse

Options

acronyms

Add project-specific acronyms on top of the built-in dictionary:

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

Auto-fix

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

Dictionary

The plugin ships with a dictionary of common acronyms sourced from web platform APIs and general programming. It includes exceptions for abbreviations like Id and Intl that follow normal casing despite looking like acronyms.

License

MIT

About

ACROCase naming convention style guide and ESLint plugin

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors