From e6f315d2fc8c3489c84f5417134626ae6aaa49ad Mon Sep 17 00:00:00 2001 From: Johannes Date: Tue, 1 Oct 2024 21:57:30 +0200 Subject: [PATCH] eng - use `esModuleInterop` for extensions --- extensions/extension-editing/src/extensionLinter.ts | 2 +- extensions/git/src/git.ts | 2 +- extensions/git/src/repository.ts | 2 +- extensions/git/src/test/smoke.test.ts | 2 +- extensions/git/src/util.ts | 2 +- .../html-language-features/server/src/test/words.test.ts | 2 +- extensions/ipynb/src/notebookSerializer.ts | 2 +- extensions/markdown-language-features/src/markdownEngine.ts | 4 ++-- extensions/npm/src/npmMain.ts | 2 +- extensions/npm/src/preferred-pm.ts | 4 ++-- extensions/npm/src/tasks.ts | 2 +- .../php-language-features/src/features/validationProvider.ts | 2 +- extensions/tsconfig.base.json | 1 + .../src/singlefolder-tests/mappedEdits.test.ts | 2 +- .../vscode-api-tests/src/singlefolder-tests/workspace.test.ts | 2 +- 15 files changed, 17 insertions(+), 16 deletions(-) diff --git a/extensions/extension-editing/src/extensionLinter.ts b/extensions/extension-editing/src/extensionLinter.ts index b69dac0e2dd..be7eea1a49b 100644 --- a/extensions/extension-editing/src/extensionLinter.ts +++ b/extensions/extension-editing/src/extensionLinter.ts @@ -290,7 +290,7 @@ export class ExtensionLinter { const text = document.getText(); if (!this.markdownIt) { - this.markdownIt = new (await import('markdown-it')); + this.markdownIt = new ((await import('markdown-it')).default); } const tokens = this.markdownIt.parse(text, {}); const tokensAndPositions: TokenAndPosition[] = (function toTokensAndPositions(this: ExtensionLinter, tokens: MarkdownItType.Token[], begin = 0, end = text.length): TokenAndPosition[] { diff --git a/extensions/git/src/git.ts b/extensions/git/src/git.ts index 2a729ae08fb..fadcced6faa 100644 --- a/extensions/git/src/git.ts +++ b/extensions/git/src/git.ts @@ -8,7 +8,7 @@ import * as path from 'path'; import * as os from 'os'; import * as cp from 'child_process'; import { fileURLToPath } from 'url'; -import * as which from 'which'; +import which from 'which'; import { EventEmitter } from 'events'; import * as iconv from '@vscode/iconv-lite-umd'; import * as filetype from 'file-type'; diff --git a/extensions/git/src/repository.ts b/extensions/git/src/repository.ts index 5788d7ee2a7..ee1a5c24552 100644 --- a/extensions/git/src/repository.ts +++ b/extensions/git/src/repository.ts @@ -6,7 +6,7 @@ import TelemetryReporter from '@vscode/extension-telemetry'; import * as fs from 'fs'; import * as path from 'path'; -import * as picomatch from 'picomatch'; +import picomatch from 'picomatch'; import { CancellationError, CancellationToken, CancellationTokenSource, Command, commands, Disposable, Event, EventEmitter, FileDecoration, l10n, LogLevel, LogOutputChannel, Memento, ProgressLocation, ProgressOptions, RelativePattern, scm, SourceControl, SourceControlInputBox, SourceControlInputBoxValidation, SourceControlInputBoxValidationType, SourceControlResourceDecorations, SourceControlResourceGroup, SourceControlResourceState, TabInputNotebookDiff, TabInputTextDiff, TabInputTextMultiDiff, ThemeColor, Uri, window, workspace, WorkspaceEdit } from 'vscode'; import { ActionButton } from './actionButton'; import { ApiRepository } from './api/api1'; diff --git a/extensions/git/src/test/smoke.test.ts b/extensions/git/src/test/smoke.test.ts index 173364c7f09..b9a3ddfd063 100644 --- a/extensions/git/src/test/smoke.test.ts +++ b/extensions/git/src/test/smoke.test.ts @@ -4,7 +4,7 @@ *--------------------------------------------------------------------------------------------*/ import 'mocha'; -import * as assert from 'assert'; +import assert from 'assert'; import { workspace, commands, window, Uri, WorkspaceEdit, Range, TextDocument, extensions, TabInputTextDiff } from 'vscode'; import * as cp from 'child_process'; import * as fs from 'fs'; diff --git a/extensions/git/src/util.ts b/extensions/git/src/util.ts index bf33411c3b3..b8764f43d61 100644 --- a/extensions/git/src/util.ts +++ b/extensions/git/src/util.ts @@ -7,7 +7,7 @@ import { Event, Disposable, EventEmitter, SourceControlHistoryItemRef } from 'vs import { dirname, sep, relative } from 'path'; import { Readable } from 'stream'; import { promises as fs, createReadStream } from 'fs'; -import * as byline from 'byline'; +import byline from 'byline'; export const isMacintosh = process.platform === 'darwin'; export const isWindows = process.platform === 'win32'; diff --git a/extensions/html-language-features/server/src/test/words.test.ts b/extensions/html-language-features/server/src/test/words.test.ts index 132589e6867..7316204db92 100644 --- a/extensions/html-language-features/server/src/test/words.test.ts +++ b/extensions/html-language-features/server/src/test/words.test.ts @@ -2,7 +2,7 @@ * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import * as assert from 'assert'; +import assert from 'assert'; import * as words from '../utils/strings'; import * as fs from 'fs'; import * as path from 'path'; diff --git a/extensions/ipynb/src/notebookSerializer.ts b/extensions/ipynb/src/notebookSerializer.ts index 898b4ff9362..6eb1fab75d8 100644 --- a/extensions/ipynb/src/notebookSerializer.ts +++ b/extensions/ipynb/src/notebookSerializer.ts @@ -4,7 +4,7 @@ *--------------------------------------------------------------------------------------------*/ import type * as nbformat from '@jupyterlab/nbformat'; -import * as detectIndent from 'detect-indent'; +import detectIndent from 'detect-indent'; import * as vscode from 'vscode'; import { getPreferredLanguage, jupyterNotebookModelToNotebookData } from './deserializers'; import * as fnv from '@enonic/fnv-plus'; diff --git a/extensions/markdown-language-features/src/markdownEngine.ts b/extensions/markdown-language-features/src/markdownEngine.ts index 5f6e746a82d..83925eab132 100644 --- a/extensions/markdown-language-features/src/markdownEngine.ts +++ b/extensions/markdown-language-features/src/markdownEngine.ts @@ -129,7 +129,7 @@ export class MarkdownItEngine implements IMdParser { if (!this._md) { this._md = (async () => { const markdownIt = await import('markdown-it'); - let md: MarkdownIt = markdownIt(await getMarkdownOptions(() => md)); + let md: MarkdownIt = markdownIt.default(await getMarkdownOptions(() => md)); md.linkify.set({ fuzzyLink: false }); for (const plugin of this._contributionProvider.contributions.markdownItPlugins.values()) { @@ -143,7 +143,7 @@ export class MarkdownItEngine implements IMdParser { const frontMatterPlugin = await import('markdown-it-front-matter'); // Extract rules from front matter plugin and apply at a lower precedence let fontMatterRule: any; - frontMatterPlugin({ + frontMatterPlugin.default({ block: { ruler: { before: (_id: any, _id2: any, rule: any) => { fontMatterRule = rule; } diff --git a/extensions/npm/src/npmMain.ts b/extensions/npm/src/npmMain.ts index c8cfc11fb11..60758c8cb64 100644 --- a/extensions/npm/src/npmMain.ts +++ b/extensions/npm/src/npmMain.ts @@ -11,7 +11,7 @@ import { NpmScriptsTreeDataProvider } from './npmView'; import { getPackageManager, invalidateTasksCache, NpmTaskProvider, hasPackageJson } from './tasks'; import { invalidateHoverScriptsCache, NpmScriptHoverProvider } from './scriptHover'; import { NpmScriptLensProvider } from './npmScriptLens'; -import * as which from 'which'; +import which from 'which'; let treeDataProvider: NpmScriptsTreeDataProvider | undefined; diff --git a/extensions/npm/src/preferred-pm.ts b/extensions/npm/src/preferred-pm.ts index 0c5b383c6a6..c85b65b6ea3 100644 --- a/extensions/npm/src/preferred-pm.ts +++ b/extensions/npm/src/preferred-pm.ts @@ -4,9 +4,9 @@ *--------------------------------------------------------------------------------------------*/ import findWorkspaceRoot = require('../node_modules/find-yarn-workspace-root'); -import * as findUp from 'find-up'; +import findUp from 'find-up'; import * as path from 'path'; -import * as whichPM from 'which-pm'; +import whichPM from 'which-pm'; import { Uri, workspace } from 'vscode'; interface PreferredProperties { diff --git a/extensions/npm/src/tasks.ts b/extensions/npm/src/tasks.ts index 2bb314c9fa1..6f1a1fbe649 100644 --- a/extensions/npm/src/tasks.ts +++ b/extensions/npm/src/tasks.ts @@ -10,7 +10,7 @@ import { } from 'vscode'; import * as path from 'path'; import * as fs from 'fs'; -import * as minimatch from 'minimatch'; +import minimatch from 'minimatch'; import { Utils } from 'vscode-uri'; import { findPreferredPM } from './preferred-pm'; import { readScripts } from './readScripts'; diff --git a/extensions/php-language-features/src/features/validationProvider.ts b/extensions/php-language-features/src/features/validationProvider.ts index a4adc43617d..b6e38ee27cc 100644 --- a/extensions/php-language-features/src/features/validationProvider.ts +++ b/extensions/php-language-features/src/features/validationProvider.ts @@ -5,7 +5,7 @@ import * as cp from 'child_process'; import { StringDecoder } from 'string_decoder'; -import * as which from 'which'; +import which from 'which'; import * as path from 'path'; import * as vscode from 'vscode'; import { ThrottledDelayer } from './utils/async'; diff --git a/extensions/tsconfig.base.json b/extensions/tsconfig.base.json index 2e4a6009a02..8aa0dbff51e 100644 --- a/extensions/tsconfig.base.json +++ b/extensions/tsconfig.base.json @@ -1,5 +1,6 @@ { "compilerOptions": { + "esModuleInterop": true, "target": "es2020", "lib": [ "ES2016", diff --git a/extensions/vscode-api-tests/src/singlefolder-tests/mappedEdits.test.ts b/extensions/vscode-api-tests/src/singlefolder-tests/mappedEdits.test.ts index 72413a2773f..2fa19a2bd0a 100644 --- a/extensions/vscode-api-tests/src/singlefolder-tests/mappedEdits.test.ts +++ b/extensions/vscode-api-tests/src/singlefolder-tests/mappedEdits.test.ts @@ -5,7 +5,7 @@ import * as path from 'path'; import * as vscode from 'vscode'; -import * as assert from 'assert'; +import assert from 'assert'; suite('mapped edits provider', () => { diff --git a/extensions/vscode-api-tests/src/singlefolder-tests/workspace.test.ts b/extensions/vscode-api-tests/src/singlefolder-tests/workspace.test.ts index e5d9af5791e..23162569705 100644 --- a/extensions/vscode-api-tests/src/singlefolder-tests/workspace.test.ts +++ b/extensions/vscode-api-tests/src/singlefolder-tests/workspace.test.ts @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import * as assert from 'assert'; +import assert from 'assert'; import * as fs from 'fs'; import { basename, join, posix } from 'path'; import * as vscode from 'vscode';