Skip to main content

max-identifier-blocks

Restrict identifier complexity to at most four casing blocks.

Targeted pattern scopeโ€‹

This rule checks identifier names in:

  • declaration identifiers (Identifier.id), and
  • non-shorthand object property keys (Identifier.key where shorthand is false).

It counts naming "blocks" by splitting on case transitions and non-alphanumeric separators.

What this rule reportsโ€‹

This rule reports identifiers that contain more than four casing blocks (for example, AaaBbbCccDddEee).

Why this rule existsโ€‹

Long compound identifiers are harder to read and often indicate mixed concerns in one symbol.

โŒ Incorrectโ€‹

const AaaBbbCccDddEee = 1;
function aaaBbbCccDddEee() {}

const obj = {
veryLongCompoundIdentifierName: 1,
};

โœ… Correctโ€‹

const AaaBbbCccDdd = 1;
function aaaBbbCccDdd() {}

Behavior and migration notesโ€‹

The block limit is fixed at 4 in the current implementation.

This rule reports only and does not provide an autofix.

Optionsโ€‹

This rule has no options.

Additional examplesโ€‹

const parse_http_response_body = true;
// underscore-separated segments are also counted as blocks

const parseHttpBody = true;
// โœ… shorter identifier

ESLint flat config exampleโ€‹

import etcMisc from "eslint-plugin-etc-misc";

export default [
{
plugins: { "etc-misc": etcMisc },
rules: {
"etc-misc/max-identifier-blocks": "error",
},
},
];

When not to use itโ€‹

Disable this rule if your project allows long compound identifier names.

Package documentationโ€‹

Rule catalog ID: R015

Further readingโ€‹

Adoption resourcesโ€‹

  • Start at warning level in CI, then move to error after cleanup.
  • Use focused codemods/autofix batches per package or directory.