Skip to content

Commit 4d46c62

Browse files
committed
chore(eslint): add rule to protect against accessing __testing outside of test files
1 parent 12f78e1 commit 4d46c62

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

frontend/.eslintrc.cjs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,28 @@ module.exports = {
2424
settings: {
2525
lintAllEsApis: true,
2626
},
27+
rules: {
28+
// Prevent accessing __testing outside of test files
29+
"no-restricted-syntax": [
30+
"error",
31+
{
32+
selector: "MemberExpression[property.name='__testing']",
33+
message:
34+
"__testing should only be accessed in test files. Use the public API instead.",
35+
},
36+
],
37+
},
38+
overrides: [
39+
{
40+
// Allow __testing access in test files
41+
files: [
42+
"**/__tests__/**/*.{js,ts,tsx}",
43+
"**/*.{test,spec}.{js,ts,tsx}",
44+
"**/tests/**/*.{js,ts,tsx}",
45+
],
46+
rules: {
47+
"no-restricted-syntax": "off",
48+
},
49+
},
50+
],
2751
};

0 commit comments

Comments
 (0)