Skip to content
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

Merged
merged 5 commits into from
Jun 26, 2020
Merged

Conversation

P0lip
Copy link
Contributor

@P0lip P0lip commented Jun 25, 2020

We could tweak the regular expression, but this feels more readable to me.

Checklist

  • Tests added / updated
  • Docs added / updated

Does this PR introduce a breaking change?

  • Yes
  • No

@P0lip P0lip added the t/bug Something isn't working label Jun 25, 2020
@P0lip P0lip requested review from philsturgeon and nulltoken June 25, 2020 15:48
@P0lip P0lip self-assigned this Jun 25, 2020
targetVal.length === 1 &&
opts.separator !== void 0 &&
opts.separator.allowLeading === true &&
targetVal.endsWith(opts.separator.char)
Copy link
Contributor

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

Copy link
Contributor Author

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

opts.separator !== void 0 &&
opts.separator.allowLeading === true &&
// eslint-disable-next-line @typescript-eslint/prefer-string-starts-ends-with
targetVal[0] === opts.separator.char
Copy link
Contributor

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)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well, yeah, foolish me 🤦‍♂️

src/functions/casing.ts Outdated Show resolved Hide resolved
src/functions/casing.ts Outdated Show resolved Hide resolved
Co-authored-by: nulltoken <emeric.fermas@gmail.com>
@P0lip P0lip requested a review from nulltoken June 26, 2020 11:15
@nulltoken nulltoken merged commit 23e407a into develop Jun 26, 2020
@nulltoken nulltoken deleted the fix/leading-char-casing branch June 26, 2020 14:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
t/bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants