Merge pull request #17496 from desktop/lower-dash

Avoid importing all of lodash
This commit is contained in:
Markus Olsson 2023-10-05 15:44:56 +02:00 committed by GitHub
commit 89a832e9c6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 27 additions and 25 deletions

View file

@ -38,6 +38,7 @@
"fs-admin": "^0.19.0",
"fuzzaldrin-plus": "^0.6.0",
"keytar": "^7.8.0",
"lodash": "^4.17.21",
"marked": "^4.0.10",
"mem": "^4.3.0",
"memoize-one": "^4.0.3",

View file

@ -1,4 +1,4 @@
import { escapeRegExp } from 'lodash'
import escapeRegExp from 'lodash/escapeRegExp'
import { GitHubRepository } from '../../models/github-repository'
import { getHTMLURL } from '../api'
import { INodeFilter } from './node-filter'

View file

@ -1,7 +1,7 @@
import { INodeFilter } from './node-filter'
import { fileURLToPath } from 'url'
import { readFile } from 'fs/promises'
import { escapeRegExp } from 'lodash'
import escapeRegExp from 'lodash/escapeRegExp'
/**
* The Emoji Markdown filter will take a text node and create multiple text and

View file

@ -1,4 +1,4 @@
import { escapeRegExp } from 'lodash'
import escapeRegExp from 'lodash/escapeRegExp'
import { GitHubRepository } from '../../models/github-repository'
import { getHTMLURL } from '../api'
import { INodeFilter } from './node-filter'

View file

@ -1,4 +1,4 @@
import { escapeRegExp } from 'lodash'
import escapeRegExp from 'lodash/escapeRegExp'
const user_images_cdn_url = 'https://user-images.githubusercontent.com'

View file

@ -17,7 +17,7 @@ import {
getCheckRunActionsWorkflowRuns,
manuallySetChecksToPending,
} from '../ci-checks/ci-checks'
import _ from 'lodash'
import xor from 'lodash/xor'
import { offsetFromNow } from '../offset-from'
interface ICommitStatusCacheEntry {
@ -343,7 +343,7 @@ export class CommitStatusStore {
existingChecks !== undefined &&
existingChecks.check !== null &&
existingChecks.check.checks.some(c => c.actionsWorkflow !== undefined) &&
_.xor(
xor(
existingChecks.check.checks.map(cr => cr.id),
checks.map(cr => cr.id)
).length === 0

View file

@ -1,16 +1,13 @@
import _ from 'lodash'
import uniqWith from 'lodash/uniqWith'
import { KnownAuthor } from '../models/author'
import { Commit } from '../models/commit'
import { GitAuthor } from '../models/git-author'
export function getUniqueCoauthorsAsAuthors(
commits: ReadonlyArray<Commit>
): ReadonlyArray<KnownAuthor> {
const allCommitsCoAuthors: GitAuthor[] = _.flatten(
commits.map(c => c.coAuthors)
)
const allCommitsCoAuthors = commits.flatMap(c => c.coAuthors)
const uniqueCoAuthors = _.uniqWith(
const uniqueCoAuthors = uniqWith(
allCommitsCoAuthors,
(a, b) => a.email === b.email && a.name === b.name
)

View file

@ -5,7 +5,7 @@ import TransportStream, { TransportStreamOptions } from 'winston-transport'
import { EOL } from 'os'
import { readdir, unlink } from 'fs/promises'
import { promisify } from 'util'
import { escapeRegExp } from 'lodash'
import escapeRegExp from 'lodash/escapeRegExp'
type DesktopFileTransportOptions = TransportStreamOptions & {
readonly logDirectory: string

View file

@ -1,7 +1,7 @@
import * as winston from 'winston'
import { getLogDirectoryPath } from '../lib/logging/get-log-path'
import { LogLevel } from '../lib/logging/log-level'
import { noop } from 'lodash'
import noop from 'lodash/noop'
import { DesktopConsoleTransport } from './desktop-console-transport'
import memoizeOne from 'memoize-one'
import { mkdir } from 'fs/promises'

View file

@ -1,4 +1,4 @@
import { debounce } from 'lodash'
import debounce from 'lodash/debounce'
import React, { Component } from 'react'
interface IAriaLiveContainerProps {

View file

@ -2,7 +2,8 @@ import { IAPIRepository } from '../../lib/api'
import { IFilterListGroup, IFilterListItem } from '../lib/filter-list'
import { OcticonSymbolType } from '../octicons'
import * as OcticonSymbol from '../octicons/octicons.generated'
import { entries, groupBy } from 'lodash'
import entries from 'lodash/entries'
import groupBy from 'lodash/groupBy'
import { caseInsensitiveEquals, compare } from '../../lib/compare'
/** The identifier for the "Your Repositories" grouping. */

View file

@ -11,7 +11,7 @@ import { ICommitMessage } from '../../models/commit-message'
import { IAutocompletionProvider } from '../autocompletion'
import { Author, UnknownAuthor } from '../../models/author'
import { CommitMessage } from '../changes/commit-message'
import { noop } from 'lodash'
import noop from 'lodash/noop'
import { Popup } from '../../models/popup'
import { Foldout } from '../../lib/app-state'
import { Account } from '../../models/account'

View file

@ -20,6 +20,7 @@ import { Loading } from '../lib/loading'
import { getFileContents, IFileContents } from './syntax-highlighting'
import { getTextDiffWithBottomDummyHunk } from './text-diff-expansion'
import { textDiffEquals } from './diff-helpers'
import noop from 'lodash/noop'
/**
* The time (in milliseconds) we allow when loading a diff before
@ -116,9 +117,6 @@ interface ISeamlessDiffSwitcherState {
readonly fileContents: IFileContents | null
}
/** I'm super useful */
function noop() {}
function isSameFile(prevFile: ChangedFile, newFile: ChangedFile) {
return prevFile === newFile || prevFile.id === newFile.id
}

View file

@ -62,7 +62,7 @@ import {
} from './text-diff-expansion'
import { IMenuItem } from '../../lib/menu-item'
import { HiddenBidiCharsWarning } from './hidden-bidi-chars-warning'
import { escapeRegExp } from 'lodash'
import escapeRegExp from 'lodash/escapeRegExp'
const DefaultRowHeight = 20

View file

@ -15,7 +15,7 @@ import { DiffOptions } from '../diff/diff-options'
import { IChangesetData } from '../../lib/git'
import { TooltippedContent } from '../lib/tooltipped-content'
import { AppFileStatusKind } from '../../models/status'
import _ from 'lodash'
import uniqWith from 'lodash/uniqWith'
import { LinkButton } from '../lib/link-button'
import { UnreachableCommitsTab } from './unreachable-commits-dialog'
import { TooltippedCommitSHA } from '../lib/tooltipped-commit-sha'
@ -128,7 +128,7 @@ function createState(
getAvatarUsersForCommit(repository.gitHubRepository, c)
)
const avatarUsers = _.uniqWith(
const avatarUsers = uniqWith(
allAvatarUsers,
(a, b) => a.email === b.email && a.name === b.name
)

View file

@ -1,5 +1,5 @@
import { access } from 'fs/promises'
import { constant } from 'lodash'
import constant from 'lodash/constant'
/**
* Returns a value indicating whether or not the provided path exists (as in

View file

@ -6,7 +6,7 @@ import { readFile } from 'fs/promises'
import { Tooltip } from './tooltip'
import { createObservableRef } from './observable-ref'
import { getObjectId } from './object-id'
import { debounce } from 'lodash'
import debounce from 'lodash/debounce'
import {
MarkdownEmitter,
parseMarkdown,

View file

@ -657,6 +657,11 @@ lie@~3.3.0:
dependencies:
immediate "~3.0.5"
lodash@^4.17.21:
version "4.17.21"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c"
integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==
logform@^2.3.2, logform@^2.4.0:
version "2.4.0"
resolved "https://registry.yarnpkg.com/logform/-/logform-2.4.0.tgz#131651715a17d50f09c2a2c1a524ff1a4164bcfe"