diff --git a/__mocks__/@nextcloud/auth.ts b/__mocks__/@nextcloud/auth.ts index 8d341dadad7..85aa2042b06 100644 --- a/__mocks__/@nextcloud/auth.ts +++ b/__mocks__/@nextcloud/auth.ts @@ -2,7 +2,8 @@ * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors * SPDX-License-Identifier: AGPL-3.0-or-later */ -export const getCurrentUser = function() { + +export function getCurrentUser() { return { uid: 'test', displayName: 'Test', @@ -10,8 +11,8 @@ export const getCurrentUser = function() { } } -export const getRequestToken = function() { +export function getRequestToken() { return 'test-token-1234' } -export const onRequestTokenUpdate = function() {} +export function onRequestTokenUpdate() {} diff --git a/__mocks__/@nextcloud/capabilities.ts b/__mocks__/@nextcloud/capabilities.ts index b2b33773403..a8943a68306 100644 --- a/__mocks__/@nextcloud/capabilities.ts +++ b/__mocks__/@nextcloud/capabilities.ts @@ -2,9 +2,10 @@ * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors * SPDX-License-Identifier: AGPL-3.0-or-later */ -import type { Capabilities } from '../../apps/files/src/types' -export const getCapabilities = (): Capabilities => { +import type { Capabilities } from '../../apps/files/src/types.ts' + +export function getCapabilities(): Capabilities { return { files: { bigfilechunking: true, diff --git a/__mocks__/@nextcloud/initial-state.ts b/__mocks__/@nextcloud/initial-state.ts index a562259b93f..9955bcd8b3b 100644 --- a/__mocks__/@nextcloud/initial-state.ts +++ b/__mocks__/@nextcloud/initial-state.ts @@ -3,6 +3,6 @@ * SPDX-License-Identifier: AGPL-3.0-or-later */ -export const loadState = function(app: string, key: string, fallback?: any) { +export function loadState(app: string, key: string, fallback?: any) { return fallback } diff --git a/__mocks__/webdav.ts b/__mocks__/webdav.ts index 7f56c7000b0..8ac599f9e49 100644 --- a/__mocks__/webdav.ts +++ b/__mocks__/webdav.ts @@ -2,9 +2,10 @@ * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors * SPDX-License-Identifier: AGPL-3.0-or-later */ -export const createClient = () => {} -export const getPatcher = () => { + +export function createClient() {} +export function getPatcher() { return { - patch: () => {} + patch: () => {}, } } diff --git a/__tests__/FileSystemAPIUtils.ts b/__tests__/FileSystemAPIUtils.ts index d03bbf2d586..9e72fb16389 100644 --- a/__tests__/FileSystemAPIUtils.ts +++ b/__tests__/FileSystemAPIUtils.ts @@ -2,11 +2,11 @@ * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors * SPDX-License-Identifier: AGPL-3.0-or-later */ -import { basename } from 'node:path' + import mime from 'mime' +import { basename } from 'node:path' class FileSystemEntry { - private _isFile: boolean private _fullPath: string @@ -26,11 +26,9 @@ class FileSystemEntry { get name() { return basename(this._fullPath) } - } export class FileSystemFileEntry extends FileSystemEntry { - private _contents: string private _lastModified: number @@ -46,11 +44,9 @@ export class FileSystemFileEntry extends FileSystemEntry { const type = mime.getType(this.name) || '' success(new File([this._contents], this.name, { lastModified, type })) } - } export class FileSystemDirectoryEntry extends FileSystemEntry { - private _entries: FileSystemEntry[] constructor(fullPath: string, entries: FileSystemEntry[]) { @@ -70,7 +66,6 @@ export class FileSystemDirectoryEntry extends FileSystemEntry { }, } } - } /** @@ -79,7 +74,6 @@ export class FileSystemDirectoryEntry extends FileSystemEntry { * File API in the same test suite. */ export class DataTransferItem { - private _type: string private _entry: FileSystemEntry @@ -104,7 +98,7 @@ export class DataTransferItem { return this._type } - getAsFile(): File|null { + getAsFile(): File | null { if (this._entry.isFile && this._entry instanceof FileSystemFileEntry) { let file: File | null = null this._entry.file((f) => { @@ -116,10 +110,9 @@ export class DataTransferItem { // The browser will return an empty File object if the entry is a directory return new File([], this._entry.name, { type: '' }) } - } -export const fileSystemEntryToDataTransferItem = (entry: FileSystemEntry, isFileSystemAPIAvailable = true): DataTransferItem => { +export function fileSystemEntryToDataTransferItem(entry: FileSystemEntry, isFileSystemAPIAvailable = true): DataTransferItem { return new DataTransferItem( entry.isFile ? 'text/plain' : 'httpd/unix-directory', entry, diff --git a/apps/comments/src/actions/inlineUnreadCommentsAction.spec.ts b/apps/comments/src/actions/inlineUnreadCommentsAction.spec.ts index e8020f1f029..7894afab214 100644 --- a/apps/comments/src/actions/inlineUnreadCommentsAction.spec.ts +++ b/apps/comments/src/actions/inlineUnreadCommentsAction.spec.ts @@ -2,11 +2,13 @@ * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors * SPDX-License-Identifier: AGPL-3.0-or-later */ -import { File, Permission, View, FileAction } from '@nextcloud/files' -import { describe, expect, test, vi } from 'vitest' -import { action } from './inlineUnreadCommentsAction' -import logger from '../logger' +import type { View } from '@nextcloud/files' + +import { File, FileAction, Permission } from '@nextcloud/files' +import { describe, expect, test, vi } from 'vitest' +import logger from '../logger.js' +import { action } from './inlineUnreadCommentsAction.ts' const view = { id: 'files', @@ -120,6 +122,7 @@ describe('Inline unread comments action execute tests', () => { const setActiveTabMock = vi.fn() window.OCA = { Files: { + // @ts-expect-error Mocking for testing Sidebar: { open: openMock, setActiveTab: setActiveTabMock, @@ -146,10 +149,13 @@ describe('Inline unread comments action execute tests', () => { }) test('Action handles sidebar open failure', async () => { - const openMock = vi.fn(() => { throw new Error('Mock error') }) + const openMock = vi.fn(() => { + throw new Error('Mock error') + }) const setActiveTabMock = vi.fn() window.OCA = { Files: { + // @ts-expect-error Mocking for testing Sidebar: { open: openMock, setActiveTab: setActiveTabMock, diff --git a/apps/comments/src/actions/inlineUnreadCommentsAction.ts b/apps/comments/src/actions/inlineUnreadCommentsAction.ts index 0afd93d7606..302107604ba 100644 --- a/apps/comments/src/actions/inlineUnreadCommentsAction.ts +++ b/apps/comments/src/actions/inlineUnreadCommentsAction.ts @@ -2,11 +2,13 @@ * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors * SPDX-License-Identifier: AGPL-3.0-or-later */ -import { FileAction, Node } from '@nextcloud/files' -import { translate as t, translatePlural as n } from '@nextcloud/l10n' -import CommentProcessingSvg from '@mdi/svg/svg/comment-processing.svg?raw' -import logger from '../logger' +import type { Node } from '@nextcloud/files' + +import CommentProcessingSvg from '@mdi/svg/svg/comment-processing.svg?raw' +import { FileAction } from '@nextcloud/files' +import { n, t } from '@nextcloud/l10n' +import logger from '../logger.js' export const action = new FileAction({ id: 'comments-unread', @@ -25,7 +27,7 @@ export const action = new FileAction({ iconSvgInline: () => CommentProcessingSvg, enabled(nodes: Node[]) { - const unread = nodes[0].attributes['comments-unread'] as number|undefined + const unread = nodes[0].attributes['comments-unread'] as number | undefined return typeof unread === 'number' && unread > 0 }, diff --git a/apps/comments/src/comments-activity-tab.ts b/apps/comments/src/comments-activity-tab.ts index 77f6c9bca04..1c6eef75b8e 100644 --- a/apps/comments/src/comments-activity-tab.ts +++ b/apps/comments/src/comments-activity-tab.ts @@ -2,13 +2,13 @@ * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors * SPDX-License-Identifier: AGPL-3.0-or-later */ + import moment from '@nextcloud/moment' +import { createPinia, PiniaVuePlugin } from 'pinia' import Vue, { type ComponentPublicInstance } from 'vue' import logger from './logger.js' import { getComments } from './services/GetComments.js' -import { PiniaVuePlugin, createPinia } from 'pinia' - Vue.use(PiniaVuePlugin) let ActivityTabPluginView diff --git a/apps/comments/src/comments-app.js b/apps/comments/src/comments-app.js index a91a4bb37bb..ea99517e280 100644 --- a/apps/comments/src/comments-app.js +++ b/apps/comments/src/comments-app.js @@ -3,6 +3,7 @@ * SPDX-License-Identifier: AGPL-3.0-or-later */ +import logger from './logger.js' import CommentsInstance from './services/CommentsInstance.js' // Init Comments @@ -12,4 +13,4 @@ if (window.OCA && !window.OCA.Comments) { // Init Comments App view Object.assign(window.OCA.Comments, { View: CommentsInstance }) -console.debug('OCA.Comments.View initialized') +logger.debug('OCA.Comments.View initialized') diff --git a/apps/comments/src/comments-tab.js b/apps/comments/src/comments-tab.js index d3ebe3e9596..044ba4a60eb 100644 --- a/apps/comments/src/comments-tab.js +++ b/apps/comments/src/comments-tab.js @@ -3,7 +3,6 @@ * SPDX-License-Identifier: AGPL-3.0-or-later */ -// eslint-disable-next-line n/no-missing-import, import/no-unresolved import MessageReplyText from '@mdi/svg/svg/message-reply-text.svg?raw' import { getCSPNonce } from '@nextcloud/auth' import { loadState } from '@nextcloud/initial-state' diff --git a/apps/comments/src/components/Comment.vue b/apps/comments/src/components/Comment.vue index 970bb444f42..a658598bb9d 100644 --- a/apps/comments/src/components/Comment.vue +++ b/apps/comments/src/components/Comment.vue @@ -3,14 +3,16 @@ - SPDX-License-Identifier: AGPL-3.0-or-later -->