refactor: prefer native methods to lodash where possible #328
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Replace most (not all)
lodash
methods with native methodsDetails
_.endsWith
-> String.endsWith_.concat
-> Array.concat_.each
-> Array.forEach_.filter
-> Array.filter_.map
-> Array.map_.some
-> Array.some_.has
->key in Object
_.defaults
-> Object.assign_.get
->?.
and??
(optional chaining and nullish coalescing)refactor: replace fairly complicated
expandIncludeWithDirs
func to just use a few simpleforEach
srefactor: add a
getDiagnostics
helper to DRY up some codea few places are still using lodash, but this paves the way toward removing it or replacing it with much smaller individual deps
_.compact
still used because Array.filter heavily complicates the type-checking currently_.isFunction
still used because while it's a one-liner natively, need to import a function in several placeslodash.isFunction
is lodash v3 and quite different from the v4 implementation, so couldn't replace with it unfortunately_.merge
is a deep merge, so there's no native version of thistsconfigOverride
where TS does so -- matchtsconfig
extends
#86 (comment)), or could replace this with a smallerlodash.merge
package or similarsee also https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore
Review Notes
Unit tests still pass, so other than looking equivalent and typing equivalently, usage still works equivalently (caveat though:
tscache
andindex
aren't yet tested)