Skip to content

Commit f606bc2

Browse files
authored
refactor: replace lodash with lodash-es (#86)
1 parent ad13d01 commit f606bc2

File tree

9 files changed

+42
-10
lines changed

9 files changed

+42
-10
lines changed

package-lock.json

Lines changed: 30 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -825,6 +825,7 @@
825825
"@types/express": "^4.17.1",
826826
"@types/glob": "^7.1.4",
827827
"@types/lodash": "^4.14.178",
828+
"@types/lodash-es": "^4.17.6",
828829
"@types/markdown-it": "^12.2.3",
829830
"@types/mime-types": "^2.1.1",
830831
"@types/mocha": "^9.0.0",
@@ -877,6 +878,7 @@
877878
"form-data": "^4.0.0",
878879
"is-wsl": "^2.2.0",
879880
"lodash": "^4.17.21",
881+
"lodash-es": "^4.17.21",
880882
"markdown-it": "^12.3.2",
881883
"markdown-it-table-of-contents": "^0.6.0",
882884
"mime-types": "^2.1.34",

src/commands/posts-list/rename-post.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { escapeRegExp } from 'lodash';
1+
import { escapeRegExp } from 'lodash-es';
22
import path = require('path');
33
import { MessageOptions, ProgressLocation, Uri, window, workspace } from 'vscode';
44
import { Post } from '../../models/post';

src/models/user-settings.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { trim } from 'lodash';
1+
import { trim } from 'lodash-es';
22

33
export class UserAuthorizationInfo {
44
constructor(public idToken: string, public accessToken: string, expiresIn: number, public tokenType: string) {}

src/services/account.service.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ export class AccountService extends vscode.Disposable {
5353
if (authorizationInfo && !err) return this.handleAuthorized(authorizationInfo);
5454
});
5555
const { clientId, responseType, scope, authorizeEndpoint, authority, clientSecret } = globalState.config.oauth;
56-
let url = `${authority}${authorizeEndpoint}`;
5756
const search = new URLSearchParams([
5857
['client_id', clientId],
5958
['response_type', responseType],
@@ -64,8 +63,10 @@ export class AccountService extends vscode.Disposable {
6463
['scope', scope],
6564
['client_secret', clientSecret],
6665
]);
67-
url = `${url}?${search.toString()}`;
68-
await vscode.commands.executeCommand('vscode.open', vscode.Uri.parse(url));
66+
await vscode.commands.executeCommand(
67+
'vscode.open',
68+
vscode.Uri.parse(`${authority}${authorizeEndpoint}?${search.toString()}`)
69+
);
6970
accountViewDataProvider.fireTreeDataChangedEvent();
7071
postsDataProvider.fireTreeDataChangedEvent(undefined);
7172
postCategoriesDataProvider.fireTreeDataChangedEvent();

src/services/cnblogs-oauth.service.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export class CnblogsOAuthService extends Disposable {
4444
}
4545

4646
async getAuthorizationInfo(authorizationCode: string, codeVerifier: string): Promise<UserAuthorizationInfo> {
47-
let url = globalState.config.oauth.authority + globalState.config.oauth.tokenEndpoint;
47+
const url = globalState.config.oauth.authority + globalState.config.oauth.tokenEndpoint;
4848
const { clientId, clientSecret } = globalState.config.oauth;
4949
const s = new URLSearchParams([
5050
['code', authorizationCode],
@@ -54,7 +54,6 @@ export class CnblogsOAuthService extends Disposable {
5454
['client_secret', clientSecret],
5555
['redirect_uri', this.listenUrl],
5656
]);
57-
url = `${url}`;
5857
const res = await fetch(url, {
5958
method: 'POST',
6059
body: s,

src/services/post-configuration-panel.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { cloneDeep } from 'lodash';
1+
import { cloneDeep } from 'lodash-es';
22
import vscode, { Uri } from 'vscode';
33
import path from 'path';
44
import { Post } from '../models/post';

src/services/settings.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { homedir, platform } from 'os';
22
import fs from 'fs';
33
import { ConfigurationTarget, Uri, workspace } from 'vscode';
44
import { MarkdownImagesExtractor } from './images-extractor.service';
5-
import { isNumber } from 'lodash';
5+
import { isNumber } from 'lodash-es';
66

77
export class Settings {
88
static readonly postsListPageSizeKey = 'pageSize.postsList';

src/tree-view-providers/post-categories-tree-data-provider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { flattenDepth, take } from 'lodash';
1+
import { flattenDepth, take } from 'lodash-es';
22
import { commands, EventEmitter, MessageOptions, ProviderResult, TreeDataProvider, TreeItem, window } from 'vscode';
33
import { PostCategories } from '../models/post-category';
44
import { globalState } from '../services/global-state';

0 commit comments

Comments
 (0)