mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-16 10:37:20 +02:00
refactor: ensure lodash is default-imported (#6716)
This commit is contained in:
parent
47c9a37c5f
commit
ea6ceaa371
44 changed files with 239 additions and 221 deletions
|
@ -28,7 +28,7 @@ import {
|
|||
posixPath,
|
||||
readOutputHTMLFile,
|
||||
} from '../index';
|
||||
import {sum} from 'lodash';
|
||||
import _ from 'lodash';
|
||||
import fs from 'fs-extra';
|
||||
import path from 'path';
|
||||
|
||||
|
@ -322,7 +322,7 @@ describe('mapAsyncSequential', () => {
|
|||
|
||||
const timeTotal = timeAfter - timeBefore;
|
||||
|
||||
const totalTimeouts = sum(Object.values(itemToTimeout));
|
||||
const totalTimeouts = _.sum(Object.values(itemToTimeout));
|
||||
expect(timeTotal).toBeGreaterThanOrEqual(totalTimeouts - 20);
|
||||
|
||||
expect(itemMapStartsAt['1']).toBeGreaterThanOrEqual(0);
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
|
||||
import {createHash} from 'crypto';
|
||||
import {kebabCase} from 'lodash';
|
||||
import _ from 'lodash';
|
||||
import {shortName, isNameTooLong} from './pathUtils';
|
||||
|
||||
export function md5Hash(str: string): string {
|
||||
|
@ -29,9 +29,9 @@ export function docuHash(str: string): string {
|
|||
return 'index';
|
||||
}
|
||||
const shortHash = simpleHash(str, 3);
|
||||
const parsedPath = `${kebabCase(str)}-${shortHash}`;
|
||||
const parsedPath = `${_.kebabCase(str)}-${shortHash}`;
|
||||
if (isNameTooLong(parsedPath)) {
|
||||
return `${shortName(kebabCase(str))}-${shortHash}`;
|
||||
return `${shortName(_.kebabCase(str))}-${shortHash}`;
|
||||
}
|
||||
return parsedPath;
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
import logger from '@docusaurus/logger';
|
||||
import path from 'path';
|
||||
import {createHash} from 'crypto';
|
||||
import {mapValues} from 'lodash';
|
||||
import _ from 'lodash';
|
||||
import fs from 'fs-extra';
|
||||
import {URL} from 'url';
|
||||
import type {
|
||||
|
@ -361,7 +361,7 @@ export function updateTranslationFileMessages(
|
|||
): TranslationFile {
|
||||
return {
|
||||
...translationFile,
|
||||
content: mapValues(translationFile.content, (translation) => ({
|
||||
content: _.mapValues(translationFile.content, (translation) => ({
|
||||
...translation,
|
||||
message: updateMessage(translation.message),
|
||||
})),
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import {kebabCase, uniq, uniqBy} from 'lodash';
|
||||
import _ from 'lodash';
|
||||
import {normalizeUrl} from './urlUtils';
|
||||
|
||||
export type Tag = {
|
||||
|
@ -22,7 +22,7 @@ export function normalizeFrontMatterTag(
|
|||
function toTagObject(tagString: string): Tag {
|
||||
return {
|
||||
label: tagString,
|
||||
permalink: kebabCase(tagString),
|
||||
permalink: _.kebabCase(tagString),
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -53,7 +53,7 @@ export function normalizeFrontMatterTags(
|
|||
normalizeFrontMatterTag(tagsPath, tag),
|
||||
);
|
||||
|
||||
return uniqBy(tags, (tag) => tag.permalink);
|
||||
return _.uniqBy(tags, (tag) => tag.permalink);
|
||||
}
|
||||
|
||||
export type TaggedItemGroup<Item> = {
|
||||
|
@ -98,7 +98,7 @@ export function groupTaggedItems<Item>(
|
|||
// If user add twice the same tag to a md doc (weird but possible),
|
||||
// we don't want the item to appear twice in the list...
|
||||
Object.values(result).forEach((group) => {
|
||||
group.items = uniq(group.items);
|
||||
group.items = _.uniq(group.items);
|
||||
});
|
||||
|
||||
return result;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue