Variable and function names should clearly communicate their purpose, type, and scope without requiring additional context. Avoid confusing naming patterns and follow established conventions to improve code readability and maintainability.
Key Guidelines:
statement_, _areMergeablePolicyStatements) - they suggest private members or temporary variablesEffect, Action) - capitalization implies class constructorsserviceDir instead of sDir, shouldMinify instead of minify)isConsoleDevMode, shouldMinify, isInteractiveTerminal)kmsKeyArn for ARN values, resolvedPath vs entryFileRealPath)websocket not websockets to match event names)Example:
// Avoid
const statement_ = statements.find(el => ...);
const Effect = statement.Effect; // Looks like constructor
const sDir = fixture.servicePath;
const minify = this.options['minify-template'];
// Prefer
const matchingStatement = statements.find(el => ...);
const effect = statement.Effect; // Clear it's a value
const serviceDir = fixture.servicePath;
const shouldMinify = this.options['minify-template'];
Well-chosen names serve as inline documentation, reducing cognitive load and making code self-explanatory to future maintainers.
Enter the URL of a public GitHub repository