From 4d46c62982559853823907c1a4bae26ed8947bd5 Mon Sep 17 00:00:00 2001 From: Miodec Date: Mon, 1 Sep 2025 14:25:44 +0200 Subject: [PATCH] chore(eslint): add rule to protect against accessing __testing outside of test files --- frontend/.eslintrc.cjs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/frontend/.eslintrc.cjs b/frontend/.eslintrc.cjs index 14d903fae..20b6695b1 100644 --- a/frontend/.eslintrc.cjs +++ b/frontend/.eslintrc.cjs @@ -24,4 +24,28 @@ module.exports = { settings: { lintAllEsApis: true, }, + rules: { + // Prevent accessing __testing outside of test files + "no-restricted-syntax": [ + "error", + { + selector: "MemberExpression[property.name='__testing']", + message: + "__testing should only be accessed in test files. Use the public API instead.", + }, + ], + }, + overrides: [ + { + // Allow __testing access in test files + files: [ + "**/__tests__/**/*.{js,ts,tsx}", + "**/*.{test,spec}.{js,ts,tsx}", + "**/tests/**/*.{js,ts,tsx}", + ], + rules: { + "no-restricted-syntax": "off", + }, + }, + ], };