When adding validation logic that uses complex literals (especially RegExp), keep it consistent and maintainable:
isValidIpv6) so the parsing/intent is clear.eslint-disable when behavior is unchanged and the suppression is clearly justified.Example (centralizing a slug regex):
// Regex constants near other regexes
const slugRegex = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
export function isSlug(value: string): boolean {
return slugRegex.test(value);
}
// Reuse in validation instead of repeating the literal
// if (check.kind === "slug") { ... slugRegex ... }
This improves readability, reduces review/merge churn, and makes future tweaks to validation patterns less error-prone.
Enter the URL of a public GitHub repository