# Naming conventions are consistent

- **Pattern:** `ab-000669` (`code-maintainability.naming-conventions.consistent-naming`)
- **Severity:** medium
- **Lifecycle:** active
- **Last modified:** 2026-04-18
- **Canonical URL:** https://auditbuffet.com/patterns/ab-000669
- **License:** CC-BY-4.0 — attribute to AuditBuffet Pattern Catalog (https://auditbuffet.com/patterns/ab-000669)

## Why it matters

Mixed naming conventions — camelCase functions next to snake_case utilities, PascalCase components alongside kebab-case file names — slow down code review, create false matches during search, and generate typo-based import errors that TypeScript only catches if the module resolution fails. ISO 25010 maintainability.analysability degrades because developers cannot predict where code lives or what it's called. AI-generated projects are especially prone to this: convention drift accumulates across sessions as the model applies whatever convention seems locally natural.

## Severity rationale

Medium because naming inconsistencies slow every code review and search task, but they do not break runtime behavior unless they cause import resolution failures.

## Remediation

Codify the convention in ESLint so violations are flagged automatically:

```json
"@typescript-eslint/naming-convention": ["warn",
  { "selector": "variable", "format": ["camelCase", "UPPER_CASE"] },
  { "selector": "function", "format": ["camelCase"] },
  { "selector": "typeLike", "format": ["PascalCase"] }
]
```

Run `eslint --fix` across the codebase to catch and flag existing violations. For file names, use a consistent casing convention and enforce it in CI with a filename linter.

## Detection

- **ID:** `consistent-naming`
- **Severity:** `medium`
- **What to look for:** Examine variable, function, component, and file naming across 10-15 source files. Check for consistency in:
  - Variables and functions: camelCase (`getUserData`, not `get_user_data` or `GetUserData`)
  - React/Vue/Svelte components: PascalCase (`UserCard`, not `userCard` or `user-card`)
  - Files containing components: PascalCase (`UserCard.tsx`, not `userCard.tsx` or `user-card.tsx`)
  - Constants: UPPER_SNAKE_CASE (`MAX_RETRY_COUNT`) or camelCase — whichever is used, it should be consistent
  - CSS class names: kebab-case or camelCase — whichever the project uses, it should be consistent

  Look for mixed conventions: some files use camelCase for components, others use PascalCase; some functions use camelCase, others use snake_case. AI-generated code is prone to convention drift between sessions.
- **Pass criteria:** Enumerate all naming patterns found across at least 10 source files. The project consistently follows language conventions for naming (camelCase for variables/functions, PascalCase for classes/components) with no more than 2 deviations found across the files examined. Report the count: "Examined X files, found Y naming convention deviations."
- **Fail criteria:** 3 or more naming convention violations found, or two fundamentally different conventions are used for the same category of identifiers (e.g., some functions are camelCase, others are snake_case).
- **Skip (N/A) when:** The project has fewer than 3 source files to examine. Signal: fewer than 3 source files.
- **Detail on fail:** `"Mixed naming found: 4 component files use PascalCase (UserCard.tsx) but 3 use kebab-case (user-profile.tsx). 2 utility functions use snake_case (get_user_by_id) while surrounding code uses camelCase."`
- **Remediation:** Inconsistent naming signals a project assembled in multiple AI sessions without a coherent convention. It slows code review, increases typos in imports, and creates false matches when searching.

  Pick a convention and codify it in ESLint:
  ```json
  // .eslintrc.json
  {
    "rules": {
      "camelcase": "warn",
      "@typescript-eslint/naming-convention": ["warn",
        { "selector": "variable", "format": ["camelCase", "UPPER_CASE"] },
        { "selector": "function", "format": ["camelCase"] },
        { "selector": "typeLike", "format": ["PascalCase"] }
      ]
    }
  }
  ```

  Then run ESLint with `--fix` across the codebase to catch and flag violations automatically.

## External references

- iso-25010 maintainability.analysability
- iso-25010 maintainability.modifiability

Taxons: code-quality

HTML version: https://auditbuffet.com/patterns/ab-000669
