aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files/src
diff options
context:
space:
mode:
authorFerdinand Thiessen <opensource@fthiessen.de>2024-06-25 00:00:31 +0200
committerFerdinand Thiessen <opensource@fthiessen.de>2024-07-09 17:13:30 +0200
commit691f570237e26398aa22f40c0efca23141d5583e (patch)
tree4409270ac8ee482ad03f745f77003c726ffbf09f /apps/files/src
parent3a97dbf248b3e581b5782a638743958eb6f2a640 (diff)
downloadnextcloud-server-691f570237e26398aa22f40c0efca23141d5583e.tar.gz
nextcloud-server-691f570237e26398aa22f40c0efca23141d5583e.zip
chore: Enable ESLint for apps and fix all errors
Nevertheless this causes a huge amount of new warnings. Previously the shell script for directories to lint was wrong it was generating all app names to lint, but was missing the `apps/` prefix. Causing only `core` to be linted. Co-authored-by: Grigorii K. Shartsev <me@shgk.me> Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
Diffstat (limited to 'apps/files/src')
-rw-r--r--apps/files/src/actions/deleteAction.ts2
-rw-r--r--apps/files/src/actions/sidebarAction.ts2
-rw-r--r--apps/files/src/components/FileEntryMixin.ts4
-rw-r--r--apps/files/src/components/NavigationQuota.vue10
-rw-r--r--apps/files/src/components/TransferOwnershipDialogue.vue6
-rw-r--r--apps/files/src/components/VirtualList.vue10
-rw-r--r--apps/files/src/composables/useNavigation.spec.ts16
-rw-r--r--apps/files/src/init.ts1
-rw-r--r--apps/files/src/main.ts6
-rw-r--r--apps/files/src/plugins/search/folderSearch.ts4
-rw-r--r--apps/files/src/services/LivePhotos.ts3
-rw-r--r--apps/files/src/services/PreviewService.ts1
-rw-r--r--apps/files/src/store/dragging.ts1
-rw-r--r--apps/files/src/store/files.ts4
-rw-r--r--apps/files/src/store/keyboard.ts1
-rw-r--r--apps/files/src/store/selection.ts2
-rw-r--r--apps/files/src/store/userconfig.ts4
-rw-r--r--apps/files/src/store/viewConfig.ts9
18 files changed, 57 insertions, 29 deletions
diff --git a/apps/files/src/actions/deleteAction.ts b/apps/files/src/actions/deleteAction.ts
index be39ecdcf04..b4958ac0262 100644
--- a/apps/files/src/actions/deleteAction.ts
+++ b/apps/files/src/actions/deleteAction.ts
@@ -126,7 +126,7 @@ export const action = new FileAction({
.every(permission => (permission & Permission.DELETE) !== 0)
},
- async exec(node: Node, view: View, dir: string) {
+ async exec(node: Node) {
try {
await axios.delete(node.encodedSource)
diff --git a/apps/files/src/actions/sidebarAction.ts b/apps/files/src/actions/sidebarAction.ts
index aeb09490fb0..9ac52159761 100644
--- a/apps/files/src/actions/sidebarAction.ts
+++ b/apps/files/src/actions/sidebarAction.ts
@@ -2,7 +2,7 @@
* SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
-import { Permission, type Node, View, FileAction, FileType } from '@nextcloud/files'
+import { Permission, type Node, View, FileAction } from '@nextcloud/files'
import { translate as t } from '@nextcloud/l10n'
import InformationSvg from '@mdi/svg/svg/information-variant.svg?raw'
diff --git a/apps/files/src/components/FileEntryMixin.ts b/apps/files/src/components/FileEntryMixin.ts
index 243b963c7b2..6c0b278c61b 100644
--- a/apps/files/src/components/FileEntryMixin.ts
+++ b/apps/files/src/components/FileEntryMixin.ts
@@ -7,7 +7,7 @@ import type { ComponentPublicInstance, PropType } from 'vue'
import type { FileSource } from '../types.ts'
import { showError } from '@nextcloud/dialogs'
-import { FileType, Permission, Folder, File as NcFile, NodeStatus, Node, View } from '@nextcloud/files'
+import { FileType, Permission, Folder, File as NcFile, NodeStatus, Node } from '@nextcloud/files'
import { translate as t } from '@nextcloud/l10n'
import { generateUrl } from '@nextcloud/router'
import { vOnClickOutside } from '@vueuse/components'
@@ -179,6 +179,8 @@ export default defineComponent({
/**
* When the source changes, reset the preview
* and fetch the new one.
+ * @param a
+ * @param b
*/
source(a: Node, b: Node) {
if (a.source !== b.source) {
diff --git a/apps/files/src/components/NavigationQuota.vue b/apps/files/src/components/NavigationQuota.vue
index 9cbee4c6672..557fb240797 100644
--- a/apps/files/src/components/NavigationQuota.vue
+++ b/apps/files/src/components/NavigationQuota.vue
@@ -94,12 +94,12 @@ export default {
mounted() {
// If the user has a quota set, warn if the available account storage is <=0
//
- // NOTE: This doesn't catch situations where actual *server*
+ // NOTE: This doesn't catch situations where actual *server*
// disk (non-quota) space is low, but those should probably
// be handled differently anyway since a regular user can't
- // can't do much about them (If we did want to indicate server disk
+ // can't do much about them (If we did want to indicate server disk
// space matters to users, we'd probably want to use a warning
- // specific to that situation anyhow. So this covers warning covers
+ // specific to that situation anyhow. So this covers warning covers
// our primary day-to-day concern (individual account quota usage).
//
if (this.storageStats?.quota > 0 && this.storageStats?.free <= 0) {
@@ -121,7 +121,7 @@ export default {
* Update the storage stats
* Throttled at max 1 refresh per minute
*
- * @param {Event} [event = null] if user interaction
+ * @param {Event} [event] if user interaction
*/
async updateStorageStats(event = null) {
if (this.loadingStorageStats) {
@@ -135,7 +135,7 @@ export default {
throw new Error('Invalid storage stats')
}
- // Warn the user if the available account storage changed from > 0 to 0
+ // Warn the user if the available account storage changed from > 0 to 0
// (unless only because quota was intentionally set to 0 by admin in the interim)
if (this.storageStats?.free > 0 && response.data.data?.free <= 0 && response.data.data?.quota > 0) {
this.showStorageFullWarning()
diff --git a/apps/files/src/components/TransferOwnershipDialogue.vue b/apps/files/src/components/TransferOwnershipDialogue.vue
index 7c2dbd7d8e1..346bc3bbeb8 100644
--- a/apps/files/src/components/TransferOwnershipDialogue.vue
+++ b/apps/files/src/components/TransferOwnershipDialogue.vue
@@ -9,7 +9,7 @@
<form @submit.prevent="submit">
<p class="transfer-select-row">
<span>{{ readableDirectory }}</span>
- <NcButton v-if="directory === undefined"
+ <NcButton v-if="directory === undefined"
class="transfer-select-row__choose_button"
@click.prevent="start">
{{ t('files', 'Choose file or folder to transfer') }}
@@ -22,8 +22,8 @@
<label for="targetUser">
<span>{{ t('files', 'New owner') }}</span>
</label>
- <NcSelect input-id="targetUser"
- v-model="selectedUser"
+ <NcSelect v-model="selectedUser"
+ input-id="targetUser"
:options="formatedUserSuggestions"
:multiple="false"
:loading="loadingUsers"
diff --git a/apps/files/src/components/VirtualList.vue b/apps/files/src/components/VirtualList.vue
index 0ca2d869d17..3a08ab590e0 100644
--- a/apps/files/src/components/VirtualList.vue
+++ b/apps/files/src/components/VirtualList.vue
@@ -62,6 +62,10 @@ interface RecycledPoolItem {
item: Node,
}
+type DataSource = File | Folder
+
+type DataSourceKey = keyof DataSource
+
export default Vue.extend({
name: 'VirtualList',
@@ -73,11 +77,11 @@ export default Vue.extend({
required: true,
},
dataKey: {
- type: String,
+ type: String as PropType<DataSourceKey>,
required: true,
},
dataSources: {
- type: Array as PropType<(File | Folder)[]>,
+ type: Array as PropType<DataSource[]>,
required: true,
},
extraProps: {
@@ -260,7 +264,7 @@ export default Vue.extend({
// Adding scroll listener AFTER the initial scroll to index
this.$el.addEventListener('scroll', this.onScroll, { passive: true })
- this.$_recycledPool = {} as Record<string, any>
+ this.$_recycledPool = {} as Record<string, DataSource[DataSourceKey]>
},
beforeDestroy() {
diff --git a/apps/files/src/composables/useNavigation.spec.ts b/apps/files/src/composables/useNavigation.spec.ts
index 360e12660f3..364c9ab653d 100644
--- a/apps/files/src/composables/useNavigation.spec.ts
+++ b/apps/files/src/composables/useNavigation.spec.ts
@@ -3,13 +3,11 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
import { beforeEach, describe, expect, it, jest } from '@jest/globals'
-import { Navigation, View } from '@nextcloud/files'
+import nextcloudFiles, { Navigation, View } from '@nextcloud/files'
import { mount } from '@vue/test-utils'
-import { defineComponent, nextTick } from 'vue'
+import { defineComponent } from 'vue'
import { useNavigation } from './useNavigation'
-import nextcloudFiles from '@nextcloud/files'
-
// Just a wrapper so we can test the composable
const TestComponent = defineComponent({
template: '<div></div>',
@@ -38,7 +36,7 @@ describe('Composables: useNavigation', () => {
})
it('should return already active navigation', async () => {
- const view = new View({ getContents: () => Promise.reject(), icon: '<svg></svg>', id: 'view-1', name: 'My View 1', order: 0 })
+ const view = new View({ getContents: () => Promise.reject(new Error()), icon: '<svg></svg>', id: 'view-1', name: 'My View 1', order: 0 })
navigation.register(view)
navigation.setActive(view)
// Now the navigation is already set it should take the active navigation
@@ -47,7 +45,7 @@ describe('Composables: useNavigation', () => {
})
it('should be reactive on updating active navigation', async () => {
- const view = new View({ getContents: () => Promise.reject(), icon: '<svg></svg>', id: 'view-1', name: 'My View 1', order: 0 })
+ const view = new View({ getContents: () => Promise.reject(new Error()), icon: '<svg></svg>', id: 'view-1', name: 'My View 1', order: 0 })
navigation.register(view)
const wrapper = mount(TestComponent)
@@ -72,7 +70,7 @@ describe('Composables: useNavigation', () => {
})
it('should return already registered views', () => {
- const view = new View({ getContents: () => Promise.reject(), icon: '<svg></svg>', id: 'view-1', name: 'My View 1', order: 0 })
+ const view = new View({ getContents: () => Promise.reject(new Error()), icon: '<svg></svg>', id: 'view-1', name: 'My View 1', order: 0 })
// register before mount
navigation.register(view)
// now mount and check that the view is listed
@@ -81,8 +79,8 @@ describe('Composables: useNavigation', () => {
})
it('should be reactive on registering new views', () => {
- const view = new View({ getContents: () => Promise.reject(), icon: '<svg></svg>', id: 'view-1', name: 'My View 1', order: 0 })
- const view2 = new View({ getContents: () => Promise.reject(), icon: '<svg></svg>', id: 'view-2', name: 'My View 2', order: 1 })
+ const view = new View({ getContents: () => Promise.reject(new Error()), icon: '<svg></svg>', id: 'view-1', name: 'My View 1', order: 0 })
+ const view2 = new View({ getContents: () => Promise.reject(new Error()), icon: '<svg></svg>', id: 'view-2', name: 'My View 2', order: 1 })
// register before mount
navigation.register(view)
diff --git a/apps/files/src/init.ts b/apps/files/src/init.ts
index d5ecf8c65da..25bcc1072f0 100644
--- a/apps/files/src/init.ts
+++ b/apps/files/src/init.ts
@@ -24,7 +24,6 @@ import registerPersonalFilesView from './views/personal-files'
import registerFilesView from './views/files'
import registerPreviewServiceWorker from './services/ServiceWorker.js'
-
import { initLivePhotos } from './services/LivePhotos'
// Register file actions
diff --git a/apps/files/src/main.ts b/apps/files/src/main.ts
index 25fac9c1a94..9b057a5d378 100644
--- a/apps/files/src/main.ts
+++ b/apps/files/src/main.ts
@@ -19,9 +19,9 @@ __webpack_nonce__ = btoa(getRequestToken())
declare global {
interface Window {
- OC: any;
- OCA: any;
- OCP: any;
+ OC: Nextcloud.v28.OC;
+ OCA: Record<string, unknown>;
+ OCP: Nextcloud.v28.OCP;
}
}
diff --git a/apps/files/src/plugins/search/folderSearch.ts b/apps/files/src/plugins/search/folderSearch.ts
index 25049fc25b4..2b29c7aec4d 100644
--- a/apps/files/src/plugins/search/folderSearch.ts
+++ b/apps/files/src/plugins/search/folderSearch.ts
@@ -5,7 +5,7 @@
import type { Node } from '@nextcloud/files'
import { emit } from '@nextcloud/event-bus'
-import { getFilePickerBuilder } from '@nextcloud/dialogs';
+import { getFilePickerBuilder } from '@nextcloud/dialogs'
import { imagePath } from '@nextcloud/router'
import { translate as t } from '@nextcloud/l10n'
import logger from '../../logger'
@@ -19,7 +19,7 @@ function init() {
return
}
- logger.info('Initializing unified search plugin: folder search from files app');
+ logger.info('Initializing unified search plugin: folder search from files app')
OCA.UnifiedSearch.registerFilterAction({
id: 'files',
appId: 'files',
diff --git a/apps/files/src/services/LivePhotos.ts b/apps/files/src/services/LivePhotos.ts
index aee89ac6c3d..10be42444e2 100644
--- a/apps/files/src/services/LivePhotos.ts
+++ b/apps/files/src/services/LivePhotos.ts
@@ -4,6 +4,9 @@
*/
import { Node, registerDavProperty } from '@nextcloud/files'
+/**
+ *
+ */
export function initLivePhotos(): void {
registerDavProperty('nc:metadata-files-live-photo', { nc: 'http://nextcloud.org/ns' })
}
diff --git a/apps/files/src/services/PreviewService.ts b/apps/files/src/services/PreviewService.ts
index 44864b18c01..769a1fcfb9f 100644
--- a/apps/files/src/services/PreviewService.ts
+++ b/apps/files/src/services/PreviewService.ts
@@ -8,6 +8,7 @@ const SWCacheName = 'previews'
/**
* Check if the preview is already cached by the service worker
+ * @param previewUrl
*/
export const isCachedPreview = function(previewUrl: string): Promise<boolean> {
if (!window?.caches?.open) {
diff --git a/apps/files/src/store/dragging.ts b/apps/files/src/store/dragging.ts
index 74de1c4af16..667c6fe67a7 100644
--- a/apps/files/src/store/dragging.ts
+++ b/apps/files/src/store/dragging.ts
@@ -14,6 +14,7 @@ export const useDragAndDropStore = defineStore('dragging', {
actions: {
/**
* Set the selection of fileIds
+ * @param selection
*/
set(selection = [] as FileSource[]) {
Vue.set(this, 'dragging', selection)
diff --git a/apps/files/src/store/files.ts b/apps/files/src/store/files.ts
index 0b541024018..f9024b0a6bd 100644
--- a/apps/files/src/store/files.ts
+++ b/apps/files/src/store/files.ts
@@ -34,12 +34,14 @@ export const useFilesStore = function(...args) {
getters: {
/**
* Get a file or folder by its source
+ * @param state
*/
getNode: (state) => (source: FileSource): Node|undefined => state.files[source],
/**
* Get a list of files or folders by their IDs
* Note: does not return undefined values
+ * @param state
*/
getNodes: (state) => (sources: FileSource[]): Node[] => sources
.map(source => state.files[source])
@@ -49,11 +51,13 @@ export const useFilesStore = function(...args) {
* Get files or folders by their file ID
* Multiple nodes can have the same file ID but different sources
* (e.g. in a shared context)
+ * @param state
*/
getNodesById: (state) => (fileId: number): Node[] => Object.values(state.files).filter(node => node.fileid === fileId),
/**
* Get the root folder of a service
+ * @param state
*/
getRoot: (state) => (service: Service): Folder|undefined => state.roots[service],
},
diff --git a/apps/files/src/store/keyboard.ts b/apps/files/src/store/keyboard.ts
index 2b092c89ff8..f2654933895 100644
--- a/apps/files/src/store/keyboard.ts
+++ b/apps/files/src/store/keyboard.ts
@@ -9,6 +9,7 @@ import Vue from 'vue'
* Observe various events and save the current
* special keys states. Useful for checking the
* current status of a key when executing a method.
+ * @param {...any} args
*/
export const useKeyboardStore = function(...args) {
const store = defineStore('keyboard', {
diff --git a/apps/files/src/store/selection.ts b/apps/files/src/store/selection.ts
index c8c5c6d7de3..fa35d953406 100644
--- a/apps/files/src/store/selection.ts
+++ b/apps/files/src/store/selection.ts
@@ -16,6 +16,7 @@ export const useSelectionStore = defineStore('selection', {
actions: {
/**
* Set the selection of fileIds
+ * @param selection
*/
set(selection = [] as FileSource[]) {
Vue.set(this, 'selected', [...new Set(selection)])
@@ -23,6 +24,7 @@ export const useSelectionStore = defineStore('selection', {
/**
* Set the last selected index
+ * @param lastSelectedIndex
*/
setLastIndex(lastSelectedIndex = null as number | null) {
// Update the last selection if we provided a new selection starting point
diff --git a/apps/files/src/store/userconfig.ts b/apps/files/src/store/userconfig.ts
index 4faa63a068a..78b4a2e656c 100644
--- a/apps/files/src/store/userconfig.ts
+++ b/apps/files/src/store/userconfig.ts
@@ -27,6 +27,8 @@ export const useUserConfigStore = function(...args) {
actions: {
/**
* Update the user config local store
+ * @param key
+ * @param value
*/
onUpdate(key: string, value: boolean) {
Vue.set(this.userConfig, key, value)
@@ -34,6 +36,8 @@ export const useUserConfigStore = function(...args) {
/**
* Update the user config local store AND on server side
+ * @param key
+ * @param value
*/
async update(key: string, value: boolean) {
await axios.put(generateUrl('/apps/files/api/v1/config/' + key), {
diff --git a/apps/files/src/store/viewConfig.ts b/apps/files/src/store/viewConfig.ts
index eed17cd1b17..f3021077c54 100644
--- a/apps/files/src/store/viewConfig.ts
+++ b/apps/files/src/store/viewConfig.ts
@@ -26,6 +26,9 @@ export const useViewConfigStore = function(...args) {
actions: {
/**
* Update the view config local store
+ * @param view
+ * @param key
+ * @param value
*/
onUpdate(view: ViewId, key: string, value: string | number | boolean) {
if (!this.viewConfig[view]) {
@@ -36,6 +39,9 @@ export const useViewConfigStore = function(...args) {
/**
* Update the view config local store AND on server side
+ * @param view
+ * @param key
+ * @param value
*/
async update(view: ViewId, key: string, value: string | number | boolean) {
axios.put(generateUrl(`/apps/files/api/v1/views/${view}/${key}`), {
@@ -49,6 +55,8 @@ export const useViewConfigStore = function(...args) {
* Set the sorting key AND sort by ASC
* The key param must be a valid key of a File object
* If not found, will be searched within the File attributes
+ * @param key
+ * @param view
*/
setSortingBy(key = 'basename', view = 'files') {
// Save new config
@@ -58,6 +66,7 @@ export const useViewConfigStore = function(...args) {
/**
* Toggle the sorting direction
+ * @param view
*/
toggleSortingDirection(view = 'files') {
const config = this.getConfig(view) || { sorting_direction: 'asc' }