Back to all reviewers

Use descriptive variable names

prettier/prettier
Based on 8 comments
JavaScript

Choose variable and function names that clearly communicate their purpose, type, and context. Avoid abbreviations, overly generic terms, and names that could be confused for different types.

Naming Conventions JavaScript

Reviewer Prompt

Choose variable and function names that clearly communicate their purpose, type, and context. Avoid abbreviations, overly generic terms, and names that could be confused for different types.

Key principles:

  • Communicate intent: Use array instead of xs, whitespaceCharacters instead of characters
  • Indicate type when ambiguous: Use shouldCache for booleans instead of cache, clonedNode instead of clone (which sounds like a function)
  • Be appropriately specific: Use createCachedSearchFunction instead of the too-generic createCachedFunction, isPrevNodeMarkdownlintComment instead of isPrevNodeSpecificComment
  • Include context in method names: Use splitByContinuousWhitespace instead of just split

Example improvements:

// Before: unclear and generic
function chunk(xs, chunkSize) { ... }
const cache = new Map();
function createCachedFunction(function_) { ... }

// After: descriptive and clear
function chunk(array, size) { ... }
const shouldCache = true;
function createCachedSearchFunction(searchFunction) { ... }

This approach makes code self-documenting and reduces the cognitive load for other developers reading and maintaining the code.

8
Comments Analyzed
JavaScript
Primary Language
Naming Conventions
Category

Source Discussions