diff --git a/.github/workflows/lint-eslint.yml b/.github/workflows/lint-eslint.yml new file mode 100644 index 000000000..558c74431 --- /dev/null +++ b/.github/workflows/lint-eslint.yml @@ -0,0 +1,51 @@ +# This workflow is provided via the organization template repository +# +# https://github.com/nextcloud-libraries/.github +# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization +# +# SPDX-FileCopyrightText: 2021-2024 Nextcloud GmbH and Nextcloud contributors +# SPDX-License-Identifier: MIT + +name: Lint eslint + +on: pull_request + +permissions: + contents: read + +concurrency: + group: lint-eslint-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +jobs: + lint: + runs-on: ubuntu-latest + + name: eslint + + steps: + - name: Checkout + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 + with: + persist-credentials: false + + - name: Read package.json + uses: nextcloud-libraries/parse-package-engines-action@122ae05d4257008180a514e1ddeb0c1b9d094bdd # v0.1.0 + id: versions + + - name: Set up node + uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6.1.0 + with: + node-version: ${{ steps.versions.outputs.node-version }} + + - name: Set up npm + run: npm i -g 'npm@${{ steps.versions.outputs.package-manager-version }}' + + - name: Install dependencies + env: + CYPRESS_INSTALL_BINARY: 0 + PUPPETEER_SKIP_DOWNLOAD: true + run: npm ci + + - name: Lint + run: npm run lint diff --git a/lib/components/FilePicker/FileListRow.spec.ts b/lib/components/FilePicker/FileListRow.spec.ts index 3004cfc3d..c8ff51f13 100644 --- a/lib/components/FilePicker/FileListRow.spec.ts +++ b/lib/components/FilePicker/FileListRow.spec.ts @@ -3,7 +3,7 @@ * SPDX-License-Identifier: AGPL-3.0-or-later */ -import type { VueWrapper } from '@vue/test-utils' +import type { Wrapper } from '@vue/test-utils' import type { ComponentProps } from 'vue-component-type-helpers' import { afterEach, describe, expect, it, vi } from 'vitest' @@ -13,25 +13,27 @@ import { shallowMount } from '@vue/test-utils' import FileListRow from './FileListRow.vue' import { nextTick } from 'vue' -type SubmitAction = (wrapper: VueWrapper) => Promise +/* eslint-disable @typescript-eslint/no-explicit-any, jsdoc/require-jsdoc */ + +type SubmitAction = (wrapper: Wrapper) => Promise type ElementEvent = { 'update:selected': boolean | undefined, 'enter-directory': Folder | undefined } -async function clickCheckboxAction(wrapper: VueWrapper) { +async function clickCheckboxAction(wrapper: Wrapper) { wrapper.find('input[type="checkbox"]').trigger('click') } -async function clickElementAction(wrapper: VueWrapper) { +async function clickElementAction(wrapper: Wrapper) { wrapper.find('[data-testid="row-name"]').trigger('click') } -async function pressEnterAction(wrapper: VueWrapper) { +async function pressEnterAction(wrapper: Wrapper) { wrapper.element.dispatchEvent(new KeyboardEvent('keydown', { bubbles: true, key: 'Enter' })) await nextTick() } function testSubmitNode(name: string, propsData: ComponentProps, eventPayload: ElementEvent, actionCallback: SubmitAction) { it(name, async () => { - const wrapper = shallowMount(FileListRow, { + const wrapper = shallowMount(FileListRow as any, { propsData, stubs: { NcCheckboxRadioSwitch: { @@ -113,7 +115,7 @@ describe('FilePicker: FileListRow', () => { const consoleWarn = vi.spyOn(console, 'warn') const consoleError = vi.spyOn(console, 'error') - const wrapper = shallowMount(FileListRow, { + const wrapper = shallowMount(FileListRow as any, { propsData: { allowPickDirectory: true, selected: false, @@ -134,7 +136,7 @@ describe('FilePicker: FileListRow', () => { }) it('shows checkbox based on `showCheckbox` property', async () => { - const wrapper = shallowMount(FileListRow, { + const wrapper = shallowMount(FileListRow as any, { propsData: { allowPickDirectory: true, selected: false, diff --git a/lib/components/FilePicker/FilePickerBreadcrumbs.vue b/lib/components/FilePicker/FilePickerBreadcrumbs.vue index a12ff82c4..6e34adb9f 100644 --- a/lib/components/FilePicker/FilePickerBreadcrumbs.vue +++ b/lib/components/FilePicker/FilePickerBreadcrumbs.vue @@ -101,17 +101,17 @@ function validateInput() { } switch (error.reason) { - case InvalidFilenameErrorReason.Character: - validity = t('"{char}" is not allowed inside a folder name.', { char: error.segment }) - break - case InvalidFilenameErrorReason.ReservedName: - validity = t('"{segment}" is a reserved name and not allowed for folder names.', { segment: error.segment }) - break - case InvalidFilenameErrorReason.Extension: - validity = t('Folder names must not end with "{extension}".', { extension: error.segment }) - break - default: - validity = t('Invalid folder name.') + case InvalidFilenameErrorReason.Character: + validity = t('"{char}" is not allowed inside a folder name.', { char: error.segment }) + break + case InvalidFilenameErrorReason.ReservedName: + validity = t('"{segment}" is a reserved name and not allowed for folder names.', { segment: error.segment }) + break + case InvalidFilenameErrorReason.Extension: + validity = t('Folder names must not end with "{extension}".', { extension: error.segment }) + break + default: + validity = t('Invalid folder name.') } } if (input) { diff --git a/lib/components/FilePicker/FilePreview.vue b/lib/components/FilePicker/FilePreview.vue index 12d7213bb..3df784593 100644 --- a/lib/components/FilePicker/FilePreview.vue +++ b/lib/components/FilePicker/FilePreview.vue @@ -23,7 +23,7 @@