From 36b09845c0a7363aae6893e8a33de49a6ba12cf6 Mon Sep 17 00:00:00 2001 From: Lukas Schaefer Date: Fri, 13 Feb 2026 10:28:09 -0500 Subject: [PATCH 1/3] Implement typescript Signed-off-by: Lukas Schaefer --- .github/workflows/lint-typescript.yml | 100 ++++++++++++++++++++++++++ env.d.ts | 28 ++++++++ package-lock.json | 18 +++++ package.json | 6 +- src/files/actions/requestAction.ts | 2 +- src/files/actions/respondAction.ts | 1 + tsconfig.json | 32 +++++++++ vite.config.js | 3 + 8 files changed, 187 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/lint-typescript.yml create mode 100644 env.d.ts create mode 100644 tsconfig.json diff --git a/.github/workflows/lint-typescript.yml b/.github/workflows/lint-typescript.yml new file mode 100644 index 00000000..d697e276 --- /dev/null +++ b/.github/workflows/lint-typescript.yml @@ -0,0 +1,100 @@ +# This workflow is provided via the organization template repository +# +# https://github.com/nextcloud/.github +# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization +# +# SPDX-FileCopyrightText: 2023-2024 Nextcloud GmbH and Nextcloud contributors +# SPDX-License-Identifier: MIT + +name: Type checking + +on: + pull_request: + push: + branches: + - main + - master + - stable* + +permissions: + contents: read + +concurrency: + group: lint-typescript-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +jobs: + changes: + runs-on: ubuntu-latest-low + permissions: + contents: read + pull-requests: read + + outputs: + src: ${{ steps.changes.outputs.src}} + + steps: + - uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2 + id: changes + continue-on-error: true + with: + filters: | + src: + - '.github/workflows/lint-typescript.yml' + - 'package.json' + - 'package-lock.json' + - 'tsconfig.json' + - '**.ts' + - '**.vue' + + test: + runs-on: ubuntu-latest + + needs: changes + if: needs.changes.outputs.src != 'false' + + steps: + - name: Checkout + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + persist-credentials: false + + - name: Read package.json node and npm engines version + uses: skjnldsv/read-package-engines-version-actions@06d6baf7d8f41934ab630e97d9e6c0bc9c9ac5e4 # v3 + id: versions + with: + fallbackNode: '^24' + fallbackNpm: '^11.3' + + - name: Set up node ${{ steps.versions.outputs.nodeVersion }} + uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0 + with: + node-version: ${{ steps.versions.outputs.nodeVersion }} + + - name: Set up npm ${{ steps.versions.outputs.npmVersion }} + run: npm i -g 'npm@${{ steps.versions.outputs.npmVersion }}' + + - name: Install dependencies + env: + CYPRESS_INSTALL_BINARY: 0 + run: | + npm ci + + - name: Check types + run: | + npm run --if-present check-types + npm run --if-present ts:check + + summary: + permissions: + contents: none + runs-on: ubuntu-latest-low + needs: [changes, test] + + if: always() + + name: typescript-summary + + steps: + - name: Summary status + run: if ${{ needs.changes.outputs.src != 'false' && needs.test.result != 'success' }}; then exit 1; fi diff --git a/env.d.ts b/env.d.ts new file mode 100644 index 00000000..9f3fb3f1 --- /dev/null +++ b/env.d.ts @@ -0,0 +1,28 @@ +/** + * SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + * + * Type declarations for TypeScript (globals, Vite asset imports, and modules). + */ + +/// + +import { translate } from '@nextcloud/l10n' + +declare global { + const t: typeof translate + + const OCA: { + Approval: { + actionIgnoreLists: string[] + userRules?: unknown[] + } + } +} + +declare module '*.svg?raw' { + const content: string + export default content +} + +export {} diff --git a/package-lock.json b/package-lock.json index 592390d6..bbf4de9f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -30,6 +30,7 @@ "@nextcloud/eslint-config": "^8.4.2", "@nextcloud/stylelint-config": "^3.0.1", "@nextcloud/vite-config": "^2.3.5", + "@types/node": "^24.0.0", "typescript": "~5.5.4", "vite-plugin-eslint": "^1.8.1", "vite-plugin-stylelint": "^6.0.0" @@ -4453,6 +4454,16 @@ "integrity": "sha512-GsCCIZDE/p3i96vtEqx+7dBUGXrc7zeSK3wwPHIaRThS+9OhWIXRqzs4d6k1SVU8g91DrNRWxWUGhp5KXQb2VA==", "license": "MIT" }, + "node_modules/@types/node": { + "version": "24.10.13", + "resolved": "https://registry.npmjs.org/@types/node/-/node-24.10.13.tgz", + "integrity": "sha512-oH72nZRfDv9lADUBSo104Aq7gPHpQZc4BTx38r9xf9pg5LfP6EzSyH2n7qFmmxRQXh7YlUXODcYsg6PuTDSxGg==", + "dev": true, + "license": "MIT", + "dependencies": { + "undici-types": "~7.16.0" + } + }, "node_modules/@types/semver": { "version": "7.7.1", "resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.7.1.tgz", @@ -14486,6 +14497,13 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/undici-types": { + "version": "7.16.0", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.16.0.tgz", + "integrity": "sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw==", + "dev": true, + "license": "MIT" + }, "node_modules/unicode-canonical-property-names-ecmascript": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-2.0.1.tgz", diff --git a/package.json b/package.json index b47a3507..f63802c2 100644 --- a/package.json +++ b/package.json @@ -7,8 +7,9 @@ "build": "NODE_ENV=production vite --mode production build", "dev": "NODE_ENV=development vite --mode development build", "watch": "NODE_ENV=development vite --mode development build --watch", - "lint": "eslint --ext .js,.vue src", - "lint:fix": "eslint --ext .js,.vue src --fix", + "lint": "eslint --ext .js,.ts,.vue src vite.config.ts", + "lint:fix": "eslint --ext .js,.ts,.vue src vite.config.ts --fix", + "check-types": "tsc --noEmit", "stylelint": "stylelint src/**/*.vue src/**/*.scss src/**/*.css", "stylelint:fix": "stylelint src/**/*.vue src/**/*.scss src/**/*.css --fix" }, @@ -50,6 +51,7 @@ "vue-material-design-icons": "^5.1.1" }, "devDependencies": { + "@types/node": "^24.0.0", "@nextcloud/babel-config": "^1.2.0", "@nextcloud/browserslist-config": "^3.0.1", "@nextcloud/eslint-config": "^8.4.2", diff --git a/src/files/actions/requestAction.ts b/src/files/actions/requestAction.ts index dd1e3cad..bc66ff87 100644 --- a/src/files/actions/requestAction.ts +++ b/src/files/actions/requestAction.ts @@ -19,7 +19,7 @@ export const requestAction: IFileAction = { } return !OCA.Approval.actionIgnoreLists.includes(view.id) && !nodes.some(({ permissions }) => (permissions & Permission.READ) === 0) - && OCA.Approval.userRules && OCA.Approval.userRules.length > 0 + && !!OCA.Approval.userRules?.length // && nodes.every(({ type }) => type === FileType.File) // && nodes.every(({ mime }) => mime === 'application/some+type') }, diff --git a/src/files/actions/respondAction.ts b/src/files/actions/respondAction.ts index a1b494cd..6df5a3ba 100644 --- a/src/files/actions/respondAction.ts +++ b/src/files/actions/respondAction.ts @@ -35,5 +35,6 @@ export const respondAction: IFileAction = { return null }, async execBatch() { + return [] }, } diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 00000000..4d9ebc9a --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,32 @@ +/** + * SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ +{ + "compilerOptions": { + "target": "ES2022", + "module": "ESNext", + "moduleResolution": "bundler", + "lib": ["ES2022", "DOM", "DOM.Iterable"], + "types": ["node"], + "allowJs": true, + "checkJs": false, + "noEmit": true, + "strict": true, + "skipLibCheck": true, + "resolveJsonModule": true, + "isolatedModules": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "forceConsistentCasingInFileNames": true, + "paths": { + "vite-plugin-eslint": ["./node_modules/vite-plugin-eslint/dist/index.d.ts"] + } + }, + "include": [ + "src/**/*.ts", + "vite.config.js", + "env.d.ts" + ], + "exclude": ["node_modules"] +} diff --git a/vite.config.js b/vite.config.js index 87ecfe52..0d06d169 100644 --- a/vite.config.js +++ b/vite.config.js @@ -2,8 +2,11 @@ * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors * SPDX-License-Identifier: AGPL-3.0-or-later */ +// eslint-disable-next-line n/no-unpublished-import import { createAppConfig } from '@nextcloud/vite-config' +// eslint-disable-next-line n/no-unpublished-import import eslint from 'vite-plugin-eslint' +// eslint-disable-next-line n/no-unpublished-import import stylelint from 'vite-plugin-stylelint' import { join } from 'path' From 8848dded06b6a2085efbc306fa0f7c69b45a8314 Mon Sep 17 00:00:00 2001 From: Lukas Schaefer Date: Fri, 13 Feb 2026 10:43:59 -0500 Subject: [PATCH 2/3] Use more readable syntax Signed-off-by: Lukas Schaefer --- src/files/actions/requestAction.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/files/actions/requestAction.ts b/src/files/actions/requestAction.ts index bc66ff87..b027e1d7 100644 --- a/src/files/actions/requestAction.ts +++ b/src/files/actions/requestAction.ts @@ -19,7 +19,7 @@ export const requestAction: IFileAction = { } return !OCA.Approval.actionIgnoreLists.includes(view.id) && !nodes.some(({ permissions }) => (permissions & Permission.READ) === 0) - && !!OCA.Approval.userRules?.length + && (OCA.Approval.userRules?.length ?? 0) > 0 // && nodes.every(({ type }) => type === FileType.File) // && nodes.every(({ mime }) => mime === 'application/some+type') }, From cd78b6d3038fda36d8c75397ce0987500c8d8fe6 Mon Sep 17 00:00:00 2001 From: Lukas Schaefer Date: Fri, 13 Feb 2026 10:45:33 -0500 Subject: [PATCH 3/3] Forgot vite config rename Signed-off-by: Lukas Schaefer --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index f63802c2..0be1b470 100644 --- a/package.json +++ b/package.json @@ -7,8 +7,8 @@ "build": "NODE_ENV=production vite --mode production build", "dev": "NODE_ENV=development vite --mode development build", "watch": "NODE_ENV=development vite --mode development build --watch", - "lint": "eslint --ext .js,.ts,.vue src vite.config.ts", - "lint:fix": "eslint --ext .js,.ts,.vue src vite.config.ts --fix", + "lint": "eslint --ext .js,.ts,.vue src vite.config.js", + "lint:fix": "eslint --ext .js,.ts,.vue src vite.config.js --fix", "check-types": "tsc --noEmit", "stylelint": "stylelint src/**/*.vue src/**/*.scss src/**/*.css", "stylelint:fix": "stylelint src/**/*.vue src/**/*.scss src/**/*.css --fix"