Skip to main content

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?

  1. Casing tells the reader what kind of identifier it is — MAX_RETRIES is a constant, maxRetries is a variable, MaxRetries is a class.
  2. Prevents mixed conventions that make the codebase inconsistent and hard to scan.
  3. Catches common mistakes like UPPER_SNAKE_CASE on a mutable let or camelCase on 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.

OptionTypeDefaultDescription
classDeclarationstringPascalCaseCasing for class names.
classMethodstringcamelCaseCasing for class methods.
classPropertystringcamelCaseCasing for class properties.
constructorVariablestringPascalCaseCasing for variables used with new.
constantstringUPPER_SNAKE_CASECasing for const with immutable values.
enumstringPascalCaseCasing for enum declarations.
enumMemberstringPascalCaseCasing for enum members.
functionstringcamelCaseCasing for function declarations.
ignoreFilesstring[][]File patterns to skip.
interfacestringPascalCaseCasing for interfaces.
parameterstringcamelCaseCasing for function parameters.
reactComponentstringPascalCaseCasing for React component functions.
typeAliasstringPascalCaseCasing for type aliases.
variablestringcamelCaseCasing for let/var variables.

Autofix

Autofix is not available for this rule. Flagged code must be updated manually.

Troubleshooting

  • const array is flagged for camelCaseUPPER_SNAKE_CASE is only for const with immutable values (primitives and regex literals). Arrays, objects, and function return values use camelCase even when declared with const.
  • Leading underscore is flagged — Leading underscores (e.g., _unused) are permitted for unused variable prefixes and are not checked against casing rules.