-
-
Notifications
You must be signed in to change notification settings - Fork 240
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: casing fn handles leading char #1256
Conversation
src/functions/casing.ts
Outdated
targetVal.length === 1 && | ||
opts.separator !== void 0 && | ||
opts.separator.allowLeading === true && | ||
targetVal.endsWith(opts.separator.char) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@P0lip endsWith
seems a bit "weird" to me here especially when targetVal length == 1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is due to eslint
rule.
I can change it to targetVal[0]
and disable the rule for this particular line, because it indeed feels weird
src/functions/casing.ts
Outdated
opts.separator !== void 0 && | ||
opts.separator.allowLeading === true && | ||
// eslint-disable-next-line @typescript-eslint/prefer-string-starts-ends-with | ||
targetVal[0] === opts.separator.char |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@P0lip There might be something I don't understand (and in that case I apologize in advance for being that thick), but we know targetVal is one char long, we also know the separator is also one char long (enforced through schema rule). Can't we just compare them directly (ie. targetVal === opts.separator.char
)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well, yeah, foolish me 🤦♂️
Co-authored-by: nulltoken <emeric.fermas@gmail.com>
We could tweak the regular expression, but this feels more readable to me.
Checklist
Does this PR introduce a breaking change?