Require Naming Convention
Enforce context-aware naming conventions because consistent casing per identifier type (camelCase for variables, PascalCase for classes, UPPER_SNAKE_CASE for constants) makes intent visible from the name alone.
Summary
The require-naming-convention rule checks identifier names against the expected casing for their declaration context.
UPPER_SNAKE_CASE is reserved for const declarations with immutable values (primitives and regex literals). Arrays, objects, instances, and function return values use camelCase even when declared with const.
Why Use This Rule?
- Casing tells the reader what kind of identifier it is —
MAX_RETRIESis a constant,maxRetriesis a variable,MaxRetriesis a class. - Prevents mixed conventions that make the codebase inconsistent and hard to scan.
- Catches common mistakes like
UPPER_SNAKE_CASEon a mutableletorcamelCaseon a class.
Examples
Configuration
Options
warning
ignoreFiles is an escape hatch for files where this rule genuinely does not apply. It is not intended for routine use.
| Option | Type | Default | Description |
|---|---|---|---|
classDeclaration | string | PascalCase | Casing for class names. |
classMethod | string | camelCase | Casing for class methods. |
classProperty | string | camelCase | Casing for class properties. |
constructorVariable | string | PascalCase | Casing for variables used with new. |
constant | string | UPPER_SNAKE_CASE | Casing for const with immutable values. |
enum | string | PascalCase | Casing for enum declarations. |
enumMember | string | PascalCase | Casing for enum members. |
function | string | camelCase | Casing for function declarations. |
ignoreFiles | string[] | [] | File patterns to skip. |
interface | string | PascalCase | Casing for interfaces. |
parameter | string | camelCase | Casing for function parameters. |
reactComponent | string | PascalCase | Casing for React component functions. |
typeAlias | string | PascalCase | Casing for type aliases. |
variable | string | camelCase | Casing for let/var variables. |
Autofix
Autofix is not available for this rule. Flagged code must be updated manually.
Troubleshooting
constarray is flagged for camelCase —UPPER_SNAKE_CASEis only forconstwith immutable values (primitives and regex literals). Arrays, objects, and function return values usecamelCaseeven when declared withconst.- Leading underscore is flagged — Leading underscores (e.g.,
_unused) are permitted for unused variable prefixes and are not checked against casing rules.