naming-convention
Configuration
Rule Details
Enforces naming conventions for everything across a codebase.
This rule allows you to enforce conventions for any identifier, using granular selectors to create a fine-grained style guide. It supports a wide variety of selectors, modifiers, formats, and custom patterns. Each selector can be configured independently, and more specific selectors take precedence over less specific ones.
Examples of incorrect code for this rule (with default config):
Examples of correct code for this rule (with default config):
Options
This rule accepts an array of objects, where each object describes a naming convention to enforce. Each object can have the following properties:
selector
(Required) The selector(s) to apply the convention to. Can be a string or an array of strings.
Individual selectors: variable, function, parameter, property, parameterProperty, accessor, enumMember, classMethod, objectLiteralMethod, typeMethod, classProperty, objectLiteralProperty, typeProperty, class, interface, typeAlias, enum, typeParameter, import
Group selectors: default (matches all), variableLike (variable, function, parameter), memberLike (property, parameterProperty, enumMember, classMethod, objectLiteralMethod, typeMethod, classProperty, objectLiteralProperty, typeProperty, accessor), typeLike (class, interface, typeAlias, enum), method (classMethod, objectLiteralMethod, typeMethod), objectLiteralMember (objectLiteralProperty, objectLiteralMethod)
format
The format(s) that the identifier must match. Set to null to skip format checking (useful for names that require quotes). Can be an array to allow multiple formats.
Allowed values: camelCase, strictCamelCase, PascalCase, StrictPascalCase, snake_case, UPPER_CASE
leadingUnderscore / trailingUnderscore
Controls whether leading/trailing underscores are allowed, required, or forbidden.
Allowed values: forbid, require, requireDouble, allow, allowDouble, allowSingleOrDouble
prefix / suffix
Requires identifiers to start/end with one of the given strings. The prefix/suffix is stripped before format checking.
custom
A custom regex pattern that the identifier must match (or not match). Requires a regex string and a match boolean.
filter
A regex filter to limit which identifiers are checked by this selector. Identifiers matching the filter are skipped (match: false) or exclusively checked (match: true).
modifiers
Limits the selector to only match identifiers with the specified modifiers. All specified modifiers must be present for the selector to match.
Allowed values: const, readonly, static, public, protected, private, #private, abstract, destructured, global, exported, unused, requiresQuotes, override, async, default, namespace
types
Limits the selector to only match identifiers whose type matches. Only available for: variable, parameter, classProperty, objectLiteralProperty, typeProperty, accessor, property, parameterProperty.
Allowed values: boolean, string, number, function, array
Default Configuration
When no options are provided, the rule uses the following defaults: