Complex logical expressions should be extracted into well-named variables or functions to improve code readability and maintainability. This applies to:
Complex logical expressions should be extracted into well-named variables or functions to improve code readability and maintainability. This applies to:
Example - Before:
const classOrInterfaceDeclaration = declaration.parent?.kind === SyntaxKind.Constructor && getSyntacticModifierFlags(declaration) & ModifierFlags.AccessibilityModifier ? declaration.parent.parent : declaration.parent;
Example - After:
const isConstructorParamWithAccessModifier = declaration.parent?.kind === SyntaxKind.Constructor &&
getSyntacticModifierFlags(declaration) & ModifierFlags.AccessibilityModifier;
const classOrInterfaceDeclaration = isConstructorParamWithAccessModifier ? declaration.parent.parent : declaration.parent;
The extracted variable name should clearly describe the condition’s purpose. For frequently used conditions, consider extracting them into helper functions that can be reused across the codebase.
Enter the URL of a public GitHub repository