From 8099313834357fe05287e8d3008dd5175e29f33e Mon Sep 17 00:00:00 2001 From: philschatz <253202+philschatz@users.noreply.github.com> Date: Wed, 6 Dec 2023 08:49:47 +0000 Subject: [PATCH] :shirt: lint --- .eslintignore | 3 ++ client/specs/book-tocs.spec.ts | 2 +- client/specs/cnxml-preview.spec.ts | 20 +++---- client/specs/disposable.spec.ts | 4 +- client/specs/extension.spec.ts | 20 +++---- client/specs/generate-readme.spec.ts | 4 +- client/specs/image-upload.spec.ts | 4 +- client/specs/panel-toc-editor.spec.ts | 32 ++++++------ client/specs/panel.spec.ts | 6 +-- client/specs/push-content.spec.ts | 22 ++++---- client/specs/requests.spec.ts | 4 +- client/specs/utils.spec.ts | 12 ++--- client/src/book-tocs.ts | 6 +-- client/src/extension.ts | 8 +-- client/src/generate-readme.ts | 2 +- client/src/git-api/git.d.ts | 4 +- client/src/panel-cnxml-preview.ts | 2 +- client/src/panel-image-manager.ts | 4 +- client/src/panel-toc-editor.ts | 14 ++--- client/src/panel.ts | 14 ++--- client/src/push-content.ts | 11 ++-- client/src/toc-trees-provider.ts | 6 +-- client/src/utils.ts | 5 +- .../webview-js/cnxml-preview/cnxml-preview.js | 2 +- .../src/webview-js/toc-editor/toc-editor.jsx | 6 +-- client/tsconfig.json | 2 - common/src/requests.ts | 6 +-- cypress/e2e/cnxml-preview-spec.cy.ts | 6 +-- cypress/e2e/toc-editor-spec.cy.ts | 2 +- cypress/index.d.ts | 4 +- server/src/book-toc-utils.ts | 12 ++--- server/src/fix-document-ids.spec.ts | 2 +- server/src/fix-document-ids.ts | 2 +- server/src/job-runner.spec.ts | 2 +- server/src/job-runner.ts | 20 +++---- server/src/model-manager.spec.ts | 26 +++++----- server/src/model-manager.ts | 52 +++++++++---------- server/src/model/_cli.ts | 28 +++++----- server/src/model/book.spec.ts | 2 +- server/src/model/book.ts | 12 ++--- server/src/model/bundle.spec.ts | 2 +- server/src/model/bundle.ts | 8 +-- server/src/model/factory.ts | 2 +- server/src/model/fileish.spec.ts | 2 +- server/src/model/fileish.ts | 2 +- server/src/model/page.spec.ts | 2 +- server/src/model/page.ts | 6 +-- server/src/model/quarx.spec.ts | 4 +- server/src/model/resource.ts | 2 +- server/src/model/spec-helpers.spec.ts | 20 +++---- server/src/model/utils.ts | 8 +-- server/src/readme-generator.spec.ts | 4 +- server/src/readme-generator.ts | 2 +- server/src/server-handler.ts | 6 +-- server/src/server.ts | 14 ++--- 55 files changed, 242 insertions(+), 237 deletions(-) create mode 100644 .eslintignore diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 00000000..d033b7c1 --- /dev/null +++ b/.eslintignore @@ -0,0 +1,3 @@ +/cypress.config.ts +/client/src/webview-js/cnxml-preview/cnxml-preview.js +/client/src/webview-js/toc-editor/toc-editor.jsx diff --git a/client/specs/book-tocs.spec.ts b/client/specs/book-tocs.spec.ts index a992c4b3..9379008c 100644 --- a/client/specs/book-tocs.spec.ts +++ b/client/specs/book-tocs.spec.ts @@ -1,6 +1,6 @@ import { expect } from '@jest/globals' -import { BookRootNode, BookToc, ClientTocNode, TocNodeKind } from '../../common/src/toc' +import { BookRootNode, type BookToc, type ClientTocNode, TocNodeKind } from '../../common/src/toc' import { TocsTreeProvider } from '../src/book-tocs' const testTocPage: ClientTocNode = { diff --git a/client/specs/cnxml-preview.spec.ts b/client/specs/cnxml-preview.spec.ts index 858e5004..fe76691c 100644 --- a/client/specs/cnxml-preview.spec.ts +++ b/client/specs/cnxml-preview.spec.ts @@ -5,12 +5,12 @@ import mockfs from 'mock-fs' import { DOMParser, XMLSerializer } from 'xmldom' import { CnxmlPreviewPanel, rawTextHtml, tagElementsWithLineNumbers } from '../src/panel-cnxml-preview' -import vscode, { TextDocument, Uri } from 'vscode' +import vscode, { type TextDocument, type Uri } from 'vscode' import * as utils from '../src/utils' // Used for dependency mocking in tests import { EMPTY_BOOKS_AND_ORPHANS } from '../../common/src/requests' import { join } from 'path' -import { ExtensionEvents } from '../src/panel' -import { LanguageClient } from 'vscode-languageclient/node' +import { type ExtensionEvents } from '../src/panel' +import { type LanguageClient } from 'vscode-languageclient/node' import { PanelStateMessageType } from '../../common/src/webview-constants' import { readFileSync } from 'fs' @@ -37,7 +37,7 @@ function expectValue(v: T | null | undefined) { function makeDocument(uri: Uri, content: string) { const document: vscode.TextDocument = { - uri: uri, + uri, languageId: 'xml', lineAt: () => ({ text: 'fakedata2' }), positionAt: () => -123, @@ -104,8 +104,8 @@ describe('cnxml-preview', () => { const fakeEditor: vscode.TextEditor = { document: { lineAt: () => ({ text: 'fakedata' }), - languageId: languageId, - uri: uri + languageId, + uri }, // used by panel-cnxml-preview scrollToRangeStartOfEditor visibleRanges: [ @@ -149,7 +149,7 @@ describe('cnxml-preview', () => { }) it('rebinds to resource in the active editor', async () => { - const panel = new CnxmlPreviewPanel({ bookTocs: EMPTY_BOOKS_AND_ORPHANS, resourceRootDir, client: createMockClient(), events: events }) + const panel = new CnxmlPreviewPanel({ bookTocs: EMPTY_BOOKS_AND_ORPHANS, resourceRootDir, client: createMockClient(), events }) const postMessage = sinon.spy(panel, 'postMessage') expect((panel as any).resourceBinding).toBe(null) @@ -178,12 +178,12 @@ describe('cnxml-preview', () => { join(resourceRootDir, 'cnxml-to-html5.xsl'), 'utf-8' ) - expect(postMessage.calledWith({ type: PanelStateMessageType.Response, state: { xml: xmlExpectedSecond, xsl: xsl } })).toBe(true) + expect(postMessage.calledWith({ type: PanelStateMessageType.Response, state: { xml: xmlExpectedSecond, xsl } })).toBe(true) expect((panel as any).resourceBinding.fsPath).toBe(resourceSecond.fsPath) }) it('only rebinds to cnxml', async () => { - const panel = new CnxmlPreviewPanel({ bookTocs: EMPTY_BOOKS_AND_ORPHANS, resourceRootDir, client: createMockClient(), events: events }) + const panel = new CnxmlPreviewPanel({ bookTocs: EMPTY_BOOKS_AND_ORPHANS, resourceRootDir, client: createMockClient(), events }) const postMessage = sinon.spy(panel, 'postMessage') const documentFirst = await vscode.workspace.openTextDocument(resourceFirst) @@ -232,7 +232,7 @@ describe('cnxml-preview', () => { function revealRange(textEditor: vscode.TextEditor, range: vscode.Range, strategy: vscode.TextEditorRevealType) { (textEditor as any).visibleRanges = [range] const evt: vscode.TextEditorVisibleRangesChangeEvent = { - textEditor: textEditor, + textEditor, visibleRanges: [range] } odctevr.getCalls().forEach(c => c.firstArg(evt)) diff --git a/client/specs/disposable.spec.ts b/client/specs/disposable.spec.ts index cbd3b847..15684d4b 100644 --- a/client/specs/disposable.spec.ts +++ b/client/specs/disposable.spec.ts @@ -4,9 +4,9 @@ import vscode from 'vscode' import SinonRoot from 'sinon' import 'source-map-support/register' import { rawTextHtml } from '../src/panel-cnxml-preview' -import { LanguageClient } from 'vscode-languageclient/node' +import { type LanguageClient } from 'vscode-languageclient/node' import { EMPTY_BOOKS_AND_ORPHANS } from '../../common/src/requests' -import { Disposer, ExtensionEvents, ExtensionHostContext, Panel } from '../src/panel' +import { Disposer, type ExtensionEvents, type ExtensionHostContext, Panel } from '../src/panel' // Test runs in out/client/src/test/suite, not src/client/src/test/suite const TEST_OUT_DIR = path.join(__dirname, '../../') diff --git a/client/specs/extension.spec.ts b/client/specs/extension.spec.ts index 26f09f00..1bdaae29 100644 --- a/client/specs/extension.spec.ts +++ b/client/specs/extension.spec.ts @@ -3,22 +3,22 @@ import { expect } from '@jest/globals' import mockfs from 'mock-fs' import { activate, deactivate, forwardOnDidChangeWorkspaceFolders, setLanguageServerLauncher, setResourceRootDir } from '../src/extension' -import { Extension, ExtensionContext, WebviewPanel } from 'vscode' +import { type Extension, type ExtensionContext, type WebviewPanel } from 'vscode' import * as vscode from 'vscode' import * as utils from '../src/utils' // Used for dependency mocking in tests import Sinon from 'sinon' -import { LanguageClient } from 'vscode-languageclient/node' +import { type LanguageClient } from 'vscode-languageclient/node' import { OpenstaxCommand } from '../src/extension-types' -import { TocEditorPanel } from '../src/panel-toc-editor' -import { BooksAndOrphans, ExtensionServerNotification } from '../../common/src/requests' -import { PanelManager } from '../src/panel' -import { CnxmlPreviewPanel } from '../src/panel-cnxml-preview' +import { type TocEditorPanel } from '../src/panel-toc-editor' +import { type BooksAndOrphans, ExtensionServerNotification } from '../../common/src/requests' +import { type PanelManager } from '../src/panel' +import { type CnxmlPreviewPanel } from '../src/panel-cnxml-preview' import * as pushContent from '../src/push-content' describe('Extension', () => { const sinon = Sinon.createSandbox() beforeEach(async () => sinon.stub(pushContent, 'setDefaultGitConfig').resolves()) - afterEach(async () => sinon.restore()) + afterEach(async () => { sinon.restore() }) it('forwardOnDidChangeWorkspaceFolders sends a request to the language server', async function () { const stub = sinon.stub() const client = { sendRequest: stub } as unknown as LanguageClient @@ -46,7 +46,7 @@ describe('Extension', () => { const extensionContext = { asAbsolutePath: (p: string) => join(__dirname, '..', '..', p) } as unknown as ExtensionContext - afterEach(async () => await deactivate()) + afterEach(async () => { await deactivate() }) it('Starts up', async function () { await expect(activate(extensionContext)).resolves.toBeTruthy() }) @@ -83,7 +83,7 @@ describe('Extension', () => { } mockfs(fs) }) - afterEach(() => mockfs.restore()) + afterEach(() => { mockfs.restore() }) // Copy-pasta const extensionContext = { @@ -101,7 +101,7 @@ describe('Extension', () => { sinon.stub(utils, 'getRootPathUri').returns(vscode.Uri.file(fakeWorkspacePath)) setResourceRootDir(fakeResourceRootDir) }) - afterEach(async () => await deactivate()) + afterEach(async () => { await deactivate() }) it('show cnxml preview with no file open', async () => { expect(vscode.window.activeTextEditor).toBeUndefined() diff --git a/client/specs/generate-readme.spec.ts b/client/specs/generate-readme.spec.ts index ff0e4560..b8ea6cf0 100644 --- a/client/specs/generate-readme.spec.ts +++ b/client/specs/generate-readme.spec.ts @@ -1,7 +1,7 @@ import { expect } from '@jest/globals' import Sinon from 'sinon' import * as vscode from 'vscode' -import { LanguageClient } from 'vscode-languageclient/node' +import { type LanguageClient } from 'vscode-languageclient/node' import { ExtensionServerRequest } from '../../common/src/requests' import { setLanguageServerLauncher } from '../src/extension' import { readmeGenerator } from '../src/generate-readme' @@ -10,7 +10,7 @@ import * as utils from '../src/utils' describe('Request readme generated', () => { const sinon = Sinon.createSandbox() - afterEach(() => sinon.restore()) + afterEach(() => { sinon.restore() }) it('uses correct request type and uri', async () => { const fakeWorkspacePath = vscode.Uri.file('/a/b/c/d') diff --git a/client/specs/image-upload.spec.ts b/client/specs/image-upload.spec.ts index df657310..012548ca 100644 --- a/client/specs/image-upload.spec.ts +++ b/client/specs/image-upload.spec.ts @@ -5,9 +5,9 @@ import mockfs from 'mock-fs' import vscode from 'vscode' import * as utils from '../src/utils' // Used for dependency mocking in tests -import { LanguageClient } from 'vscode-languageclient/node' +import { type LanguageClient } from 'vscode-languageclient/node' import { EMPTY_BOOKS_AND_ORPHANS } from '../../common/src/requests' -import { ExtensionEvents } from '../src/panel' +import { type ExtensionEvents } from '../src/panel' import { ImageManagerPanel } from '../src/panel-image-manager' const actualResourceRootDir = join(__dirname, '../static') diff --git a/client/specs/panel-toc-editor.spec.ts b/client/specs/panel-toc-editor.spec.ts index aad83678..740a4b64 100644 --- a/client/specs/panel-toc-editor.spec.ts +++ b/client/specs/panel-toc-editor.spec.ts @@ -1,17 +1,17 @@ import { join } from 'path' import { expect } from '@jest/globals' -import SinonRoot, { SinonStub } from 'sinon' +import SinonRoot, { type SinonStub } from 'sinon' -import vscode, { Disposable, Event, EventEmitter, Uri, ViewColumn, WebviewPanel } from 'vscode' -import { BookRootNode, BookToc, TocNodeKind, TocModificationKind } from '../../common/src/toc' +import vscode, { Disposable, type Event, EventEmitter, Uri, ViewColumn, type WebviewPanel } from 'vscode' +import { BookRootNode, type BookToc, TocNodeKind, TocModificationKind } from '../../common/src/toc' import * as utils from '../src/utils' // Used for dependency mocking in tests import { TocItemIcon, TocTreeItem, TocTreesProvider, toggleTocTreesFilteringHandler } from '../src/toc-trees-provider' -import { PanelIncomingMessage, TocEditorPanel } from '../src/panel-toc-editor' -import { LanguageClient } from 'vscode-languageclient/node' +import { type PanelIncomingMessage, TocEditorPanel } from '../src/panel-toc-editor' +import { type LanguageClient } from 'vscode-languageclient/node' import { EMPTY_BOOKS_AND_ORPHANS, ExtensionServerRequest } from '../../common/src/requests' -import { ExtensionEvents, ExtensionHostContext } from '../src/panel' -import { BookOrTocNode, TocsTreeProvider } from '../src/book-tocs' -import { PanelStateMessage, PanelStateMessageType } from '../../common/src/webview-constants' +import { type ExtensionEvents, type ExtensionHostContext } from '../src/panel' +import { type BookOrTocNode, type TocsTreeProvider } from '../src/book-tocs' +import { type PanelStateMessage, PanelStateMessageType } from '../../common/src/webview-constants' const TEST_OUT_DIR = join(__dirname, '../src') const resourceRootDir = TEST_OUT_DIR @@ -33,7 +33,7 @@ const createMockClient = () => { type ExtractEventGeneric = GenericEvent extends Event ? X : never type ExtensionEventEmitters = { [key in keyof ExtensionEvents]: EventEmitter> } const createMockEvents = (): { emitters: ExtensionEventEmitters, events: ExtensionEvents } => { - const onDidChangeWatchedFilesEmitter: EventEmitter = new EventEmitter() + const onDidChangeWatchedFilesEmitter = new EventEmitter() const emitters = { onDidChangeWatchedFiles: onDidChangeWatchedFilesEmitter } @@ -45,7 +45,7 @@ const createMockEvents = (): { emitters: ExtensionEventEmitters, events: Extensi describe('Toc Editor', () => { const sinon = SinonRoot.createSandbox() - afterEach(() => sinon.restore()) + afterEach(() => { sinon.restore() }) it('TocTreesProvider returns expected TocTreeItems', async () => { const fakeTreeBooks: BookToc[] = [] fakeTreeBooks.push( @@ -174,10 +174,10 @@ describe('Toc Editor', () => { sendRequestMock.onCall(0).resolves(null) sendRequestMock.onCall(1).resolves(fakeTreeBooks) - expect(await tocTreesProvider.getChildren(undefined)).toMatchSnapshot() - expect(await tocTreesProvider.getChildren(undefined)).toMatchSnapshot() + expect(tocTreesProvider.getChildren(undefined)).toMatchSnapshot() + expect(tocTreesProvider.getChildren(undefined)).toMatchSnapshot() expect(book1Item).toMatchSnapshot() - expect(await tocTreesProvider.getChildren(book2Item)).toMatchSnapshot() + expect(tocTreesProvider.getChildren(book2Item)).toMatchSnapshot() expect(tocTreesProvider.getTreeItem(book2Item)).toMatchSnapshot() expect(await tocTreesProvider.getParent(book2Item)).toMatchSnapshot() expect(await tocTreesProvider.getParent(module3Item)).toMatchSnapshot() @@ -258,7 +258,7 @@ describe('Toc Editor', () => { expect(getMessage().title).toBe('new_title') }) it('disposes', () => { - expect(() => p.dispose()).not.toThrow() + expect(() => { p.dispose() }).not.toThrow() }) it('sends a message to Webview when a fileChanged event is emitted', () => { expect(postMessageStub.callCount).toBe(0) @@ -298,8 +298,8 @@ describe('Toc Editor', () => { expect(postMessageStub.callCount).toBe(1) expect(postMessageStub.firstCall.args).toMatchSnapshot() }) - it('does not send a message to Webview when panel is disposed', async () => { - await expect(p.refreshPanel({} as unknown as WebviewPanel, client)).rejects + it('does not send a message to Webview when panel is disposed', () => { + expect(p.refreshPanel({} as unknown as WebviewPanel, client)).rejects // eslint-disable-line @typescript-eslint/no-unused-expressions }) it('refreshes when server watched file changes', async () => { const refreshStub = sinon.stub(p, 'refreshPanel') diff --git a/client/specs/panel.spec.ts b/client/specs/panel.spec.ts index 37f1fbdf..7888db55 100644 --- a/client/specs/panel.spec.ts +++ b/client/specs/panel.spec.ts @@ -1,7 +1,7 @@ import Sinon from 'sinon' import { expect } from '@jest/globals' -import { Disposer, ExtensionHostContext, Panel, PanelManager } from '../src/panel' -import { Disposable, WebviewPanel } from 'vscode' +import { Disposer, type ExtensionHostContext, Panel, PanelManager } from '../src/panel' +import { Disposable, type WebviewPanel } from 'vscode' describe('panel', () => { const sinon = Sinon.createSandbox() @@ -27,7 +27,7 @@ describe('panel', () => { async handleMessage(message: boolean) {} } - afterEach(() => sinon.restore()) + afterEach(() => { sinon.restore() }) it('handles onDidDispose', () => { const panel = new TestPanel() diff --git a/client/specs/push-content.spec.ts b/client/specs/push-content.spec.ts index f88df98e..1d1575c1 100644 --- a/client/specs/push-content.spec.ts +++ b/client/specs/push-content.spec.ts @@ -1,11 +1,11 @@ import Sinon from 'sinon' import * as pushContent from '../src/push-content' import * as utils from '../src/utils' -import { Repository, Change, Status, CommitOptions, GitExtension, GitErrorCodes, Branch, RepositoryState } from '../src/git-api/git.d' +import { type Repository, type Change, Status, type CommitOptions, type GitExtension, GitErrorCodes, type Branch, type RepositoryState } from '../src/git-api/git.d' import vscode from 'vscode' import { expect } from '@jest/globals' import { Substitute } from '@fluffy-spoon/substitute' -import { ExtensionHostContext } from '../src/panel' +import { type ExtensionHostContext } from '../src/panel' import { DiagnosticSource, ExtensionServerRequest } from '../../common/src/requests' const makeCaptureMessage = (messages: string[]): (message: string) => Promise => { @@ -29,7 +29,7 @@ describe('Push Button Test Suite', () => { .resolves(new Map>()) sinon.stub(utils, 'getRootPathUri').returns(vscode.Uri.file('test')) }) - afterEach(() => sinon.restore()) + afterEach(() => { sinon.restore() }) const commitOptions: CommitOptions = { all: true } const sendRequestMock = sinon.stub() const mockHostContext: ExtensionHostContext = { @@ -316,7 +316,7 @@ describe('Push Button Test Suite', () => { describe('tests with sinon', () => { const sinon = Sinon.createSandbox() - afterEach(async () => sinon.restore()) + afterEach(async () => { sinon.restore() }) beforeEach(() => { sinon.stub(utils, 'getRootPathUri').returns(vscode.Uri.file('test')) }) @@ -360,7 +360,7 @@ describe('tests with sinon', () => { vscode.Uri.file('/c.xhtml') ].map((uri, i) => ({ originalUri: uri, - uri: uri, + uri, renameUri: undefined, status: i === 0 ? Status.DELETED : Status.MODIFIED })) @@ -374,10 +374,10 @@ describe('tests with sinon', () => { const toOpen = await pushContent.getDocumentsToOpen(pushContent.DocumentsToOpen.modified) changesToReturn .filter(c => c.status !== Status.DELETED) - .forEach(c => expect(toOpen.has(c.uri.toString())).toBe(true)) + .forEach(c => { expect(toOpen.has(c.uri.toString())).toBe(true) }) changesToReturn .filter(c => c.status === Status.DELETED) - .forEach(c => expect(toOpen.has(c.uri.toString())).toBe(false)) + .forEach(c => { expect(toOpen.has(c.uri.toString())).toBe(false) }) expect(toOpen.size === 2) }) }) @@ -428,9 +428,11 @@ describe('tests with sinon', () => { const getDocumentsToOpenStub = sinon.stub(pushContent, 'getDocumentsToOpen') const showTextDocumentStub = sinon.stub(vscode.window, 'showTextDocument') .callsFake((uri: vscode.Uri, options?: vscode.TextDocumentShowOptions): Thenable => { - return new Promise((resolve, reject) => resolve( - { document: { uri: uri } as any as vscode.TextDocument } as any as vscode.TextEditor - )) + return new Promise((resolve, reject) => { + resolve( + { document: { uri } as any as vscode.TextDocument } as any as vscode.TextEditor + ) + }) }) const executeCommandStub = sinon.stub(vscode.commands, 'executeCommand').resolves() const getDiagnosticsStub = sinon.stub(vscode.languages, 'getDiagnostics') diff --git a/client/specs/requests.spec.ts b/client/specs/requests.spec.ts index 834178d9..832d6483 100644 --- a/client/specs/requests.spec.ts +++ b/client/specs/requests.spec.ts @@ -4,7 +4,7 @@ import { expect } from '@jest/globals' describe('ensureIds', () => { const sinon = Sinon.createSandbox() - afterEach(() => sinon.restore()) + afterEach(() => { sinon.restore() }) it('runs and yields a response', async () => { const client = { @@ -17,7 +17,7 @@ describe('ensureIds', () => { describe('generateReadme', () => { const sinon = Sinon.createSandbox() - afterEach(() => sinon.restore()) + afterEach(() => { sinon.restore() }) it('runs and yields a response', async () => { const client = { diff --git a/client/specs/utils.spec.ts b/client/specs/utils.spec.ts index c288b86f..be665f75 100644 --- a/client/specs/utils.spec.ts +++ b/client/specs/utils.spec.ts @@ -1,12 +1,12 @@ import { expect } from '@jest/globals' import Sinon from 'sinon' import mockfs from 'mock-fs' -import vscode, { ExtensionContext, Uri, Webview } from 'vscode' +import vscode, { type ExtensionContext, Uri, type Webview } from 'vscode' import { addBaseHref, fixResourceReferences, fixCspSourceReferences, ensureCatch, ensureCatchPromise, expect as expectOrig, getErrorDiagnosticsBySource, populateXsdSchemaFiles, configureWorkspaceSettings, launchLanguageServer } from '../src/utils' import { Panel } from '../src/panel' import { join } from 'path' import { existsSync, mkdirSync, writeFileSync } from 'fs' -import { LanguageClient } from 'vscode-languageclient/node' +import { type LanguageClient } from 'vscode-languageclient/node' const TEST_OUT_DIR = join(__dirname, '../static') // contains 'xsd/' dir @@ -27,7 +27,7 @@ describe('expectValue', () => { describe('tests with sinon', () => { const sinon = Sinon.createSandbox() - afterEach(() => sinon.restore()) + afterEach(() => { sinon.restore() }) describe('ensureCatch', () => { it('ensureCatch throws when its argument throws', async () => { @@ -36,7 +36,7 @@ describe('tests with sinon', () => { const s = sinon.spy(vscode.window, 'showErrorMessage') const wrapped = ensureCatch(fn) - await expect(async () => await wrapped()).rejects.toThrow(errMessage) + await expect(async () => { await wrapped() }).rejects.toThrow(errMessage) // Verify that a message was sent to the user expect(s.callCount).toBe(1) }) @@ -46,7 +46,7 @@ describe('tests with sinon', () => { const s = sinon.spy(vscode.window, 'showErrorMessage') const promise = fn() - await expect(async () => await ensureCatchPromise(promise)).rejects.toThrow(errMessage) + await expect(async () => { await ensureCatchPromise(promise) }).rejects.toThrow(errMessage) // Verify that a message was sent to the user expect(s.callCount).toBe(1) }) @@ -136,7 +136,7 @@ describe('tests with sinon', () => { } as any as vscode.Extension sinon.stub(vscode.extensions, 'getExtension').withArgs('redhat.vscode-xml').returns(fakeXmlExtension) }) - afterEach(() => mockfs.restore()) + afterEach(() => { mockfs.restore() }) it('schema files are populated when not existing', async () => { const schemaPath = join(WORKSPACE_ROOT, '.xsd') diff --git a/client/src/book-tocs.ts b/client/src/book-tocs.ts index 3e710ffd..9215a009 100644 --- a/client/src/book-tocs.ts +++ b/client/src/book-tocs.ts @@ -1,6 +1,6 @@ -import { EventEmitter, TreeItemCollapsibleState, Uri, TreeDataProvider } from 'vscode' +import { EventEmitter, TreeItemCollapsibleState, Uri, type TreeDataProvider } from 'vscode' -import { BookToc, ClientTocNode, BookRootNode, TocNodeKind } from '../../common/src/toc' +import { type BookToc, type ClientTocNode, BookRootNode, TocNodeKind } from '../../common/src/toc' import { TocItemIcon } from './toc-trees-provider' export type BookOrTocNode = BookToc | ClientTocNode @@ -25,7 +25,7 @@ export class TocsTreeProvider implements TreeDataProvider { public update(n: BookToc[]) { this.bookTocs = n this.parentsMap.clear() - this.bookTocs.forEach(n => this.recAddParent(n)) + this.bookTocs.forEach(n => { this.recAddParent(n) }) this._onDidChangeTreeData.fire() } diff --git a/client/src/extension.ts b/client/src/extension.ts index 0241ccb3..556729a7 100644 --- a/client/src/extension.ts +++ b/client/src/extension.ts @@ -1,17 +1,17 @@ import path from 'path' import fs from 'fs' import vscode from 'vscode' -import { LanguageClient } from 'vscode-languageclient/node' +import { type LanguageClient } from 'vscode-languageclient/node' import { pushContent, validateContent, setDefaultGitConfig } from './push-content' import { TocEditorPanel } from './panel-toc-editor' import { CnxmlPreviewPanel } from './panel-cnxml-preview' import { expect, ensureCatch, ensureCatchPromise, launchLanguageServer, populateXsdSchemaFiles, getRootPathUri, configureWorkspaceSettings } from './utils' import { OpenstaxCommand } from './extension-types' -import { ExtensionHostContext, Panel, PanelManager } from './panel' +import { type ExtensionHostContext, type Panel, PanelManager } from './panel' import { ImageManagerPanel } from './panel-image-manager' import { toggleTocTreesFilteringHandler } from './toc-trees-provider' -import { BookOrTocNode, TocsTreeProvider } from './book-tocs' -import { BooksAndOrphans, EMPTY_BOOKS_AND_ORPHANS, ExtensionServerNotification } from '../../common/src/requests' +import { type BookOrTocNode, TocsTreeProvider } from './book-tocs' +import { type BooksAndOrphans, EMPTY_BOOKS_AND_ORPHANS, ExtensionServerNotification } from '../../common/src/requests' import { readmeGenerator } from './generate-readme' let tocTreesView: vscode.TreeView diff --git a/client/src/generate-readme.ts b/client/src/generate-readme.ts index 28f23d66..ac3ea330 100644 --- a/client/src/generate-readme.ts +++ b/client/src/generate-readme.ts @@ -1,6 +1,6 @@ import vscode from 'vscode' import { requestGenerateReadme } from '../../common/src/requests' -import { ExtensionHostContext } from './panel' +import { type ExtensionHostContext } from './panel' import { expect, getRootPathUri } from './utils' export function readmeGenerator(hostContext: ExtensionHostContext) { diff --git a/client/src/git-api/git.d.ts b/client/src/git-api/git.d.ts index d3d66846..dfd45aab 100644 --- a/client/src/git-api/git.d.ts +++ b/client/src/git-api/git.d.ts @@ -3,8 +3,8 @@ * Licensed under the MIT License. See LICENSE in this directory for license information. *-------------------------------------------------------------------------------------------- */ -import { Uri, Event, Disposable, ProviderResult } from 'vscode' -export { ProviderResult } from 'vscode' +import { type Uri, type Event, type Disposable, type ProviderResult } from 'vscode' +export type { ProviderResult } from 'vscode' export interface Git { readonly path: string diff --git a/client/src/panel-cnxml-preview.ts b/client/src/panel-cnxml-preview.ts index 42c22754..86680963 100644 --- a/client/src/panel-cnxml-preview.ts +++ b/client/src/panel-cnxml-preview.ts @@ -4,7 +4,7 @@ import path from 'path' import { fixResourceReferences, fixCspSourceReferences, addBaseHref, expect, getRootPathUri, ensureCatchPromise, ensureCatch } from './utils' import { PanelType } from './extension-types' import { DOMParser, XMLSerializer } from 'xmldom' -import { ExtensionHostContext, Panel } from './panel' +import { type ExtensionHostContext, Panel } from './panel' // Line is one-indexed export interface ScrollInEditorIncoming { diff --git a/client/src/panel-image-manager.ts b/client/src/panel-image-manager.ts index ff78c4e8..70ecc821 100644 --- a/client/src/panel-image-manager.ts +++ b/client/src/panel-image-manager.ts @@ -3,10 +3,10 @@ import fs from 'fs' import path from 'path' import { fixResourceReferences, fixCspSourceReferences, getRootPathUri, expect } from './utils' import { PanelType } from './extension-types' -import { ExtensionHostContext, Panel } from './panel' +import { type ExtensionHostContext, Panel } from './panel' export interface PanelIncomingMessage { - mediaUploads: Array<{mediaName: string, data: string}> + mediaUploads: Array<{ mediaName: string, data: string }> } const initPanel = (context: ExtensionHostContext): vscode.WebviewPanel => { diff --git a/client/src/panel-toc-editor.ts b/client/src/panel-toc-editor.ts index 214b601f..8ffa3534 100644 --- a/client/src/panel-toc-editor.ts +++ b/client/src/panel-toc-editor.ts @@ -2,13 +2,13 @@ import fs from 'fs' import path from 'path' import vscode from 'vscode' -import { TreeItem as TreeItemUI } from 'react-sortable-tree' +import { type TreeItem as TreeItemUI } from 'react-sortable-tree' import { fixResourceReferences, fixCspSourceReferences, getRootPathUri, expect, ensureCatch } from './utils' -import { ClientPageish, ClientTocNode, TocNodeKind, PageRenameEvent, SubbookRenameEvent, TocMoveEvent, TocRemoveEvent, CreatePageEvent, CreateSubbookEvent, TocModification, TocModificationKind, TocModificationParams } from '../../common/src/toc' +import { type ClientPageish, type ClientTocNode, TocNodeKind, type PageRenameEvent, type SubbookRenameEvent, type TocMoveEvent, type TocRemoveEvent, type CreatePageEvent, type CreateSubbookEvent, type TocModification, TocModificationKind, type TocModificationParams } from '../../common/src/toc' import { PanelType } from './extension-types' -import { LanguageClient } from 'vscode-languageclient/node' -import { BooksAndOrphans, EMPTY_BOOKS_AND_ORPHANS, ExtensionServerRequest, Opt } from '../../common/src/requests' -import { ExtensionHostContext, Panel } from './panel' +import { type LanguageClient } from 'vscode-languageclient/node' +import { type BooksAndOrphans, EMPTY_BOOKS_AND_ORPHANS, ExtensionServerRequest, type Opt } from '../../common/src/requests' +import { type ExtensionHostContext, Panel } from './panel' export const NS_COLLECTION = 'http://cnx.rice.edu/collxml' export const NS_CNXML = 'http://cnx.rice.edu/cnxml' @@ -124,7 +124,7 @@ export class TocEditorPanel extends Panel { const workspaceUri = expect(getRootPathUri(), 'No root path in which to generate a module').toString() - let event: Opt + let event: Opt if (m.type === TocModificationKind.Move || m.type === TocModificationKind.Remove || m.type === TocModificationKind.PageRename || m.type === TocModificationKind.SubbookRename) { event = m } else if (m.type === TocNodeKind.Page) { @@ -168,7 +168,7 @@ export class TocEditorPanel extends Panel b.tocTree.forEach(recAddModules)) + this.state.books.forEach(b => { b.tocTree.forEach(recAddModules) }) const orphanModules = this.state.orphans const allModulesSorted = Array.from(allModules).sort(fileIdSorter) diff --git a/client/src/panel.ts b/client/src/panel.ts index 4ed27d0e..9172984d 100644 --- a/client/src/panel.ts +++ b/client/src/panel.ts @@ -1,7 +1,7 @@ import vscode from 'vscode' -import { LanguageClient } from 'vscode-languageclient/node' -import { BooksAndOrphans } from '../../common/src/requests' -import { PanelStateMessageType, PanelStateMessage } from '../../common/src/webview-constants' +import { type LanguageClient } from 'vscode-languageclient/node' +import { type BooksAndOrphans } from '../../common/src/requests' +import { PanelStateMessageType, type PanelStateMessage } from '../../common/src/webview-constants' import { ensureCatchPromise, genNonce, injectCspNonce } from './utils' // Modified from https://github.com/microsoft/vscode/blob/main/extensions/markdown-language-features/src/util/dispose.ts @@ -77,7 +77,7 @@ export abstract class Panel implements DisposableS this.panel = innerPanel this.nonce = genNonce() this.registerDisposable(this.panel) - this.panel.onDidDispose(() => this.dispose()) + this.panel.onDidDispose(() => { this.dispose() }) this.registerDisposable(this.panel.webview.onDidReceiveMessage((message) => { /* istanbul ignore if */ @@ -152,15 +152,15 @@ export abstract class Panel implements DisposableS } readonly reveal: Panel['panel']['reveal'] = (...args) => { - return this.panel.reveal(...args) + this.panel.reveal(...args) } readonly onDidDispose: Panel['disposer']['onDidDispose'] = (...args) => { - return this.disposer.onDidDispose(...args) + this.disposer.onDidDispose(...args) } readonly dispose: Panel['disposer']['dispose'] = (...args) => { - return this.disposer.dispose(...args) + this.disposer.dispose(...args) } readonly registerDisposable: Panel['disposer']['registerDisposable'] = (...args) => { diff --git a/client/src/push-content.ts b/client/src/push-content.ts index f4f90826..7ce46a80 100644 --- a/client/src/push-content.ts +++ b/client/src/push-content.ts @@ -1,7 +1,7 @@ import vscode from 'vscode' import { expect, getErrorDiagnosticsBySource, getRootPathUri } from './utils' -import { GitExtension, GitErrorCodes, CommitOptions, Repository, Status } from './git-api/git' -import { ExtensionHostContext } from './panel' +import { type GitExtension, GitErrorCodes, type CommitOptions, type Repository, Status } from './git-api/git' +import { type ExtensionHostContext } from './panel' import { DiagnosticSource, requestEnsureIds } from '../../common/src/requests' export enum DocumentsToOpen { @@ -41,7 +41,7 @@ export const closeValidDocuments = async ( openedEditors: vscode.TextEditor[], errorsBySource: Map> ) => { - const urisWithErrors: Set = new Set() + const urisWithErrors = new Set() for (const errors of errorsBySource.values()) { errors.forEach(e => urisWithErrors.add(e[0].toString())) } @@ -83,7 +83,7 @@ export const progressWithTimeEst = async( increment: value.increment }) } else { - progress.report({ message: message }) + progress.report({ message }) } } } @@ -269,7 +269,8 @@ export const _pushContent = ( if (e.stdout.includes('nothing to commit')) { void errorReporter('No changes to push.') } else { - const message: string = e.gitErrorCode === undefined ? e.message : /* istanbul ignore next */ e.gitErrorCode + /* istanbul ignore next */ + const message: string = e.gitErrorCode ?? e.message void errorReporter(`Push failed: ${message}`) } } diff --git a/client/src/toc-trees-provider.ts b/client/src/toc-trees-provider.ts index a364fe05..4adb0d70 100644 --- a/client/src/toc-trees-provider.ts +++ b/client/src/toc-trees-provider.ts @@ -1,7 +1,7 @@ import vscode, { ThemeIcon } from 'vscode' -import { BookRootNode, ClientTocNode, TocNodeKind } from '../../common/src/toc' -import { TocsTreeProvider, BookOrTocNode } from './book-tocs' -import { ExtensionHostContext } from './panel' +import { BookRootNode, type ClientTocNode, TocNodeKind } from '../../common/src/toc' +import { type TocsTreeProvider, type BookOrTocNode } from './book-tocs' +import { type ExtensionHostContext } from './panel' export const TocItemIcon = { Page: ThemeIcon.File, diff --git a/client/src/utils.ts b/client/src/utils.ts index 8544bc51..9cfa4be3 100644 --- a/client/src/utils.ts +++ b/client/src/utils.ts @@ -1,11 +1,10 @@ - import vscode from 'vscode' import path from 'path' import fs from 'fs' import { LanguageClient, - LanguageClientOptions, - ServerOptions, + type LanguageClientOptions, + type ServerOptions, TransportKind } from 'vscode-languageclient/node' diff --git a/client/src/webview-js/cnxml-preview/cnxml-preview.js b/client/src/webview-js/cnxml-preview/cnxml-preview.js index 66807e8d..93257fd6 100644 --- a/client/src/webview-js/cnxml-preview/cnxml-preview.js +++ b/client/src/webview-js/cnxml-preview/cnxml-preview.js @@ -27,7 +27,7 @@ const getElementBoundsOfInfluence = ({ element }) => { const height = Math.max(1, (childBounds.top - myBounds.top)) return { top: myBounds.top, - height: height + height } } return { diff --git a/client/src/webview-js/toc-editor/toc-editor.jsx b/client/src/webview-js/toc-editor/toc-editor.jsx index 255d1417..ef4252e9 100644 --- a/client/src/webview-js/toc-editor/toc-editor.jsx +++ b/client/src/webview-js/toc-editor/toc-editor.jsx @@ -420,7 +420,7 @@ const App = (props) => ( function walkTree(n /*: TreeItemWithToken */, fn /*: (TreeItemWithToken) => void */) { fn(n) if (n.children) { - n.children.forEach(c => walkTree(c, fn)) + n.children.forEach(c => { walkTree(c, fn) }) } } @@ -445,8 +445,8 @@ window.addEventListener('message', event => { /* istanbul ignore if */ if (oldBook === undefined || newBook === undefined) { break } const expandedTitles = new Map() - oldBook.tocTree.forEach(t => walkTree(t, n => { n.expanded && expandedTitles.set(n.title, n.expanded) })) - newBook.tocTree.forEach(t => walkTree(t, n => { n.expanded = expandedTitles.get(n.title) })) + oldBook.tocTree.forEach(t => { walkTree(t, n => { n.expanded && expandedTitles.set(n.title, n.expanded) }) }) + newBook.tocTree.forEach(t => { walkTree(t, n => { n.expanded = expandedTitles.get(n.title) }) }) } } const selectionIndices = previousState ? previousState.selectionIndices : { editable: 0, uneditable: 0 } diff --git a/client/tsconfig.json b/client/tsconfig.json index 0af17a7c..90f5a3a6 100644 --- a/client/tsconfig.json +++ b/client/tsconfig.json @@ -6,8 +6,6 @@ "include": [ "specs/**/*.spec.ts", "src/**/*.ts", - "src/**/*.js", - "src/**/*.jsx", "../common/src/**/*.ts" ], "exclude": [ diff --git a/common/src/requests.ts b/common/src/requests.ts index 80475c6f..31d426dc 100644 --- a/common/src/requests.ts +++ b/common/src/requests.ts @@ -1,4 +1,4 @@ -import { BookToc, ClientPageish } from './toc' +import { type BookToc, type ClientPageish } from './toc' export enum DiagnosticSource { xml = 'xml', @@ -58,9 +58,9 @@ export interface BundleGenerateReadme { } export const requestEnsureIds = async (client: LanguageClient, args: BundleEnsureIdsParams): Promise => { - return await client.sendRequest(ExtensionServerRequest.BundleEnsureIds, args) + await client.sendRequest(ExtensionServerRequest.BundleEnsureIds, args) } export const requestGenerateReadme = async (client: LanguageClient, args: BundleGenerateReadme): Promise => { - return await client.sendRequest(ExtensionServerRequest.GenerateReadme, args) + await client.sendRequest(ExtensionServerRequest.GenerateReadme, args) } diff --git a/cypress/e2e/cnxml-preview-spec.cy.ts b/cypress/e2e/cnxml-preview-spec.cy.ts index 0eca8747..b5cc5a1c 100644 --- a/cypress/e2e/cnxml-preview-spec.cy.ts +++ b/cypress/e2e/cnxml-preview-spec.cy.ts @@ -1,6 +1,6 @@ // Shares a namespace with the other specfiles if not scoped -import { PanelIncomingMessage, ScrollInEditorIncoming, ScrollToLineOutgoing } from '../../client/src/panel-cnxml-preview' -import { PanelStateMessage, PanelStateMessageType } from '../../common/src/webview-constants' +import { type PanelIncomingMessage, type ScrollInEditorIncoming, type ScrollToLineOutgoing } from '../../client/src/panel-cnxml-preview' +import { type PanelStateMessage, PanelStateMessageType } from '../../common/src/webview-constants' { // The HTML file that cypress should load when running tests (relative to the project root) const htmlPath = './client/dist/static-resources/cnxml-preview.html' @@ -13,7 +13,7 @@ import { PanelStateMessage, PanelStateMessageType } from '../../common/src/webvi } function sendXml(xmlStr: string): void { cy.fixture('cnxml-to-html5.xsl').then(xsl => { - sendMessage({ type: PanelStateMessageType.Response, state: { xml: xmlStr, xsl: xsl } }) + sendMessage({ type: PanelStateMessageType.Response, state: { xml: xmlStr, xsl } }) }) } function createCnxmlFromContent(content: string): string { diff --git a/cypress/e2e/toc-editor-spec.cy.ts b/cypress/e2e/toc-editor-spec.cy.ts index e5bcb35d..c8f4537c 100644 --- a/cypress/e2e/toc-editor-spec.cy.ts +++ b/cypress/e2e/toc-editor-spec.cy.ts @@ -1,5 +1,5 @@ // Shares a namespace with the other specfiles if not scoped -import { PanelIncomingMessage, Bookish, TreeItemWithToken, PanelState } from '../../client/src/panel-toc-editor' +import { type PanelIncomingMessage, type Bookish, type TreeItemWithToken, type PanelState } from '../../client/src/panel-toc-editor' import { TocNodeKind } from '../../common/src/toc' import { PanelStateMessageType } from '../../common/src/webview-constants' { diff --git a/cypress/index.d.ts b/cypress/index.d.ts index d6d56bb4..1b8bade3 100644 --- a/cypress/index.d.ts +++ b/cypress/index.d.ts @@ -3,7 +3,7 @@ declare namespace Cypress { /** * Select an element to DnD. See ./support/ for details. */ - dnd: (targetSelector: string, options?: {offsetX?: number, offsetY?: number}) => void + dnd: (targetSelector: string, options?: { offsetX?: number, offsetY?: number }) => void /** * Simulate dropping a file onto the previous element in the chain. The given filename must be in fixtures. */ @@ -15,6 +15,6 @@ declare namespace Cypress { */ awaitInternalEvent: (event: T, func: () => void) => Cypress.Chainable - snapshot: (options?: string | {name?: string, json?: boolean}) => void + snapshot: (options?: string | { name?: string, json?: boolean }) => void } } diff --git a/server/src/book-toc-utils.ts b/server/src/book-toc-utils.ts index 48741f5c..f02a23b4 100644 --- a/server/src/book-toc-utils.ts +++ b/server/src/book-toc-utils.ts @@ -1,9 +1,9 @@ import xmlFormat from 'xml-formatter' import { DOMParser, XMLSerializer } from 'xmldom' -import { BookRootNode, BookToc, ClientPageish, ClientTocNode, TocPage } from '../../common/src/toc' +import { BookRootNode, type BookToc, type ClientPageish, type ClientTocNode, type TocPage } from '../../common/src/toc' import { pageToModuleId } from './model-manager' -import { BookNode, TocSubbookWithRange, TocNodeWithRange } from './model/book' -import { PageNode } from './model/page' +import { type BookNode, type TocSubbookWithRange, type TocNodeWithRange } from './model/book' +import { type PageNode } from './model/page' import { selectOne, NS_COLLECTION, NS_METADATA, TocNodeKind, equalsArray } from './model/utils' export const equalsTocNode = (n1: ClientTocNode, n2: ClientTocNode): boolean => { @@ -53,7 +53,7 @@ const BOOK_XML_TEMPLATE = ` { it('Triggers a ToC autorun when the Page title changes', () => { diff --git a/server/src/model/resource.ts b/server/src/model/resource.ts index 0475dcb2..de9e725f 100644 --- a/server/src/model/resource.ts +++ b/server/src/model/resource.ts @@ -1,6 +1,6 @@ import I from 'immutable' import { Fileish, ValidationKind } from './fileish' -import { NOWHERE, Range } from './utils' +import { NOWHERE, type Range } from './utils' // This can be an Image or an IFrame export class ResourceNode extends Fileish { diff --git a/server/src/model/spec-helpers.spec.ts b/server/src/model/spec-helpers.spec.ts index 1029f8c0..dba6bc5c 100644 --- a/server/src/model/spec-helpers.spec.ts +++ b/server/src/model/spec-helpers.spec.ts @@ -2,9 +2,9 @@ import { expect } from '@jest/globals' import SinonRoot from 'sinon' import { readFileSync } from 'fs' import * as path from 'path' -import I from 'immutable' +import type I from 'immutable' import { Bundle } from './bundle' -import { Fileish, ValidationKind } from './fileish' +import { type Fileish, type ValidationKind } from './fileish' describe('spec-helpers Dummy', () => { it('trivially passes because Jest requires every spec file to have at least one test', () => { @@ -24,8 +24,8 @@ interface PathHelper { } export const FS_PATH_HELPER: PathHelper = { - join: path.join, - dirname: path.dirname, + join: (root, ...components) => path.join(root, ...components), + dirname: (p) => path.dirname(p), canonicalize: (x) => x } @@ -63,17 +63,17 @@ export interface PageInfo { title?: string | null // null means omit the whole element elementIds?: string[] imageHrefs?: string[] - pageLinks?: Array<{targetPage?: string, targetId?: string, url?: string}> + pageLinks?: Array<{ targetPage?: string, targetId?: string, url?: string }> extraCnxml?: string } export function pageMaker(info: PageInfo) { const i = { title: info.title !== undefined ? info.title : 'TestTitle', - uuid: info.uuid !== undefined ? info.uuid : '00000000-0000-4000-0000-000000000000', - elementIds: info.elementIds !== undefined ? info.elementIds : [], - imageHrefs: info.imageHrefs !== undefined ? info.imageHrefs : [], + uuid: info.uuid ?? '00000000-0000-4000-0000-000000000000', + elementIds: info.elementIds ?? [], + imageHrefs: info.imageHrefs ?? [], pageLinks: info.pageLinks !== undefined ? info.pageLinks.map(({ targetPage, targetId, url }) => ({ targetPage, targetId, url })) : [], - extraCnxml: info.extraCnxml !== undefined ? info.extraCnxml : '' + extraCnxml: info.extraCnxml ?? '' } const titleElement = i.title === null ? '' : `${i.title}` return ` @@ -151,7 +151,7 @@ function tocToString(node: BookMakerTocNode): string { interface BundleMakerInfo { version?: number - books?: Array + books?: Array } export function bundleMaker(info: BundleMakerInfo) { const i = { diff --git a/server/src/model/utils.ts b/server/src/model/utils.ts index b264f98f..9e6f08f6 100644 --- a/server/src/model/utils.ts +++ b/server/src/model/utils.ts @@ -1,9 +1,9 @@ import path from 'path' -import I from 'immutable' +import type I from 'immutable' import * as xpath from 'xpath-ts' -import { PageNode } from './page' -import { Factory } from './factory' -import { ResourceNode } from './resource' +import { type PageNode } from './page' +import { type Factory } from './factory' +import { type ResourceNode } from './resource' export const NS_COLLECTION = 'http://cnx.rice.edu/collxml' const NS_CNXML = 'http://cnx.rice.edu/cnxml' diff --git a/server/src/readme-generator.spec.ts b/server/src/readme-generator.spec.ts index b38aea22..e95cc6c9 100644 --- a/server/src/readme-generator.spec.ts +++ b/server/src/readme-generator.spec.ts @@ -1,6 +1,6 @@ import { expect } from '@jest/globals' -import I from 'immutable' -import { BookNode } from './model/book' +import type I from 'immutable' +import { type BookNode } from './model/book' import { bookMaker, bundleMaker, makeBundle } from './model/spec-helpers.spec' import { generateReadmeForWorkspace } from './readme-generator' diff --git a/server/src/readme-generator.ts b/server/src/readme-generator.ts index c7a6af91..d1789128 100644 --- a/server/src/readme-generator.ts +++ b/server/src/readme-generator.ts @@ -1,7 +1,7 @@ import { licenseEqual } from './model/cc-license' import { expectValue } from './model/utils' -import { BookNode } from './model/book' +import { type BookNode } from './model/book' // Maybe these templates should be in files so they can be edited more easily? const bookTemplate = `\ diff --git a/server/src/server-handler.ts b/server/src/server-handler.ts index 343e397a..a77c0b46 100644 --- a/server/src/server-handler.ts +++ b/server/src/server-handler.ts @@ -1,10 +1,10 @@ import fs from 'node:fs' -import { BundleGenerateReadme, BundleEnsureIdsParams } from '../../common/src/requests' +import { type BundleGenerateReadme, type BundleEnsureIdsParams } from '../../common/src/requests' import { idFixer } from './fix-document-ids' import { bundleFactory } from './server' -import { ModelManager } from './model-manager' -import { CompletionItem, CompletionParams } from 'vscode-languageserver/node' +import { type ModelManager } from './model-manager' +import { type CompletionItem, type CompletionParams } from 'vscode-languageserver/node' import { PageValidationKind } from './model/page' import { generateReadmeForWorkspace } from './readme-generator' import { URI } from 'vscode-uri' diff --git a/server/src/server.ts b/server/src/server.ts index de75f35f..77ff19e0 100644 --- a/server/src/server.ts +++ b/server/src/server.ts @@ -2,12 +2,12 @@ import { createConnection, TextDocuments, ProposedFeatures, - InitializeParams, + type InitializeParams, TextDocumentSyncKind, - InitializeResult, - CompletionItem, - CancellationToken, - CompletionParams + type InitializeResult, + type CompletionItem, + type CancellationToken, + type CompletionParams } from 'vscode-languageserver/node' import { TextDocument } from 'vscode-languageserver-textdocument' @@ -22,7 +22,7 @@ import { Bundle } from './model/bundle' import { Factory } from './model/factory' import { ModelManager } from './model-manager' import { JobRunner } from './job-runner' -import { TocModificationParams, TocNodeKind } from '../../common/src/toc' +import { type TocModificationParams, TocNodeKind } from '../../common/src/toc' import { Fileish } from './model/fileish' sourcemaps.install() @@ -31,7 +31,7 @@ sourcemaps.install() const connection = createConnection(ProposedFeatures.all) // Create a simple text document manager. -const documents: TextDocuments = new TextDocuments(TextDocument) +const documents = new TextDocuments(TextDocument) function getBundleForUri(uri: string): ModelManager { const bundles = bundleFactory.all.filter(b => uri.startsWith(b.bundle.workspaceRootUri))