Use naming that is explicit, consistent, and self-describing.
Rules:
today, midnightDate).untilStatement[1]).Example:
// Named constants (avoid magic strings)
export const STMT_STATE = 'state';
export const STMT_DIR = 'dir';
function getDirection(rootDoc) {
const doc = rootDoc.find((d) => d.stmt === STMT_DIR);
return doc;
}
// Shared ID generator (consistent IDs)
export const getEdgeId = (from, to, { counter = 0 } = {}) =>
`edge_${from}_${to}_${counter}`;
// Named capture groups (clarity)
const match = /^until\s+(?<ids>[\d\w- ]+)/.exec(str);
if (match) {
for (const id of match.groups.ids.split(' ')) {
// ...
}
}
Apply these consistently across the codebase to reduce confusion, prevent subtle mismatches (like casing), and make identifiers easier to search, understand, and maintain.
Enter the URL of a public GitHub repository