From 3cf210a9a52dd02fc92eda041a6284c28aa3f6e1 Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Wed, 15 Oct 2025 16:00:01 +0200 Subject: [PATCH] chore: ensure no `.only` is commited in test files `.only` is only to be used for development, but must not be committed. Instead failing tests which should be kept for later should be skipped (`.skip`). Signed-off-by: Ferdinand Thiessen --- cypress/e2e/files/files-copy-move.cy.ts | 2 +- eslint.config.mjs | 25 +++++++++++++++++++++---- package-lock.json | 11 +++++++++++ package.json | 1 + 4 files changed, 34 insertions(+), 5 deletions(-) diff --git a/cypress/e2e/files/files-copy-move.cy.ts b/cypress/e2e/files/files-copy-move.cy.ts index d020ec9c712..2a688e47785 100644 --- a/cypress/e2e/files/files-copy-move.cy.ts +++ b/cypress/e2e/files/files-copy-move.cy.ts @@ -77,7 +77,7 @@ describe('Files: Move or copy files', { testIsolation: true }, () => { getRowForFile('original folder').should('not.exist') }) - it.only('Can move a file to its parent folder', () => { + it('Can move a file to its parent folder', () => { cy.mkdir(currentUser, '/new-folder') cy.uploadContent(currentUser, new Blob(), 'text/plain', '/new-folder/original.txt') cy.login(currentUser) diff --git a/eslint.config.mjs b/eslint.config.mjs index 02ecf23e7f3..50a2366b281 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -6,6 +6,7 @@ import { includeIgnoreFile } from '@eslint/compat' import { recommendedVue2 } from '@nextcloud/eslint-config' import CypressEslint from 'eslint-plugin-cypress' +import noOnlyTests from 'eslint-plugin-no-only-tests' import { defineConfig } from 'eslint/config' import * as globals from 'globals' import { fileURLToPath } from 'node:url' @@ -22,9 +23,7 @@ export default defineConfig([ ...recommendedVue2, - // respect .gitignore - includeIgnoreFile(gitignorePath, 'Imported .gitignore patterns'), - + // add globals configuration for Webpack injected variables { name: 'server/custom-webpack-globals', files: ['**/*.js', '**/*.ts', '**/*.vue'], @@ -35,6 +34,7 @@ export default defineConfig([ }, }, + // Ensure that cjs files are treated as Node scripts { name: 'server/scripts-are-cjs', files: [ @@ -55,6 +55,7 @@ export default defineConfig([ 'jsdoc/require-jsdoc': 'off', }, }, + // Cypress setup { ...CypressEslint.configs.recommended, @@ -72,7 +73,23 @@ export default defineConfig([ '@typescript-eslint/no-unused-expressions': 'off', }, }, - // customer server ignore files + + // Forbid commiting .only in test files (skipping tests is very unexpected) + { + name: 'server/no-only-in-tests', + files: ['cypress/**', 'apps/**/*.spec.*', 'core/**/*.spec.*'], + plugins: { + 'no-only-tests': noOnlyTests, + }, + rules: { + 'no-only-tests/no-only-tests': 'error', + }, + }, + + // respect .gitignore + includeIgnoreFile(gitignorePath, 'Imported .gitignore patterns'), + + // custom server ignore files { name: 'server/ignored-files', ignores: [ diff --git a/package-lock.json b/package-lock.json index 4672581385b..26f4597da57 100644 --- a/package-lock.json +++ b/package-lock.json @@ -123,6 +123,7 @@ "dockerode": "^4.0.9", "eslint": "^9.36.0", "eslint-plugin-cypress": "^5.1.1", + "eslint-plugin-no-only-tests": "^3.3.0", "exports-loader": "^5.0.0", "file-loader": "^6.2.0", "handlebars-loader": "^1.7.3", @@ -11766,6 +11767,16 @@ "node": ">=10" } }, + "node_modules/eslint-plugin-no-only-tests": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-no-only-tests/-/eslint-plugin-no-only-tests-3.3.0.tgz", + "integrity": "sha512-brcKcxGnISN2CcVhXJ/kEQlNa0MEfGRtwKtWA16SkqXHKitaKIMrfemJKLKX1YqDU5C/5JY3PvZXd5jEW04e0Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=5.0.0" + } + }, "node_modules/eslint-plugin-perfectionist": { "version": "4.15.0", "resolved": "https://registry.npmjs.org/eslint-plugin-perfectionist/-/eslint-plugin-perfectionist-4.15.0.tgz", diff --git a/package.json b/package.json index 9258134d6e9..8228f280903 100644 --- a/package.json +++ b/package.json @@ -157,6 +157,7 @@ "dockerode": "^4.0.9", "eslint": "^9.36.0", "eslint-plugin-cypress": "^5.1.1", + "eslint-plugin-no-only-tests": "^3.3.0", "exports-loader": "^5.0.0", "file-loader": "^6.2.0", "handlebars-loader": "^1.7.3",