-
Notifications
You must be signed in to change notification settings - Fork 26
Drop lodash #89
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
Drop lodash #89
Conversation
9f23922
to
033e75c
Compare
@windsurf-bot
windsurf-bot
bot
left a comment
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.
Other comments (4)
- src/transformations/compress.js (73-73) The change from `_.isEmpty(props.options)` to `props.options.length === 0` assumes that `props.options` is always an array. If `props.options` could be undefined, null, or an object in some cases, this change might introduce bugs. Consider adding a check to ensure `props.options` is an array or has a length property before accessing it.
- src/transformations/validate.js (91-91) The replacement of `_.isEmpty(props.hostnames)` with `!props.hostnames?.length` is close but not exactly equivalent. While it handles null/undefined cases correctly with the optional chaining, an empty array would evaluate to `length === 0` which is falsy. However, if you want to be more explicit, you could use `!props.hostnames || props.hostnames.length === 0`.
-
src/index.js (57-57)
For consistency with the other property checks, consider using optional chaining here as well:
if (source.name?.length > 0) {
-
src/index.js (57-57)
For consistency with how other properties are checked, consider simplifying this to match the pattern used elsewhere:
if (source.name?.length) {
💡 To request another review, post a new comment with "/windsurf-review".
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.
The replacement of _.trimStart(toTest, '://')
with toTest.replace('://', '')
might not be equivalent in all cases. trimStart
removes all leading occurrences of the specified characters, while replace
only replaces the first occurrence. Consider using toTest.substring(3)
instead for a more direct replacement.
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 equivalent. We already know that ://
is always at the start (that's what .startsWith(://)
for). So, it will always replace the leading one.
Also, unlike .slice(3)
, .replace()
prevents string CoW inside Node.js v8, which helps release memory pressure by allowing old strings to be GCed from the memory (.slice()
holds the reference of the original string, preventing that from being GCed).
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.
The replacement of _.isEmpty(filtered[i])
with filtered[i].length === 0
might not handle undefined
or null
values correctly. Consider using !filtered[i] || filtered[i].length === 0
to maintain the same behavior as lodash's isEmpty.
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 not necessary. We already know that the filtered
is string[]
, so filtered[i]
will never be nullish.
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.
The replacement of _.isEmpty(_.trim(ruleText))
with ruleText.trim().length === 0
might throw an error if ruleText
is undefined
or null
. Consider using a null check: !ruleText || ruleText.trim().length === 0
.
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.
We already know that ruleText
is a string and will never be falsy.
033e75c
to
df7ea3b
Compare
cc @jellizaveta
Would you like to review this?
Uh oh!
There was an error while loading. Please reload this page.
Drop lodash from
HostslistCompiler
.(削除) WIP: some unit tests are failing, still figuring out why. (削除ここまで)All fixed.