@@ -60,4 +60,34 @@ export default [
6060 {
6161 ignores : [ ".stryker-tmp" , "webview-ui" , "out" ] ,
6262 } ,
63+ {
64+ // Tests inside __tests__/ directories must not traverse 3+ levels above
65+ // the test file. That escapes the src/ package root and makes Turbo
66+ // invisible to cache changes in those files.
67+ // pr-review-state-workflow.test.ts is the intentional exception: it reads
68+ // root-level config and runs in a dedicated non-Turbo CI step.
69+ files : [ "**/__tests__/**/*.test.ts" , "**/__tests__/**/*.spec.ts" ] ,
70+ ignores : [ "**/services/__tests__/pr-review-state-workflow.test.ts" ] ,
71+ rules : {
72+ "no-restricted-syntax" : [
73+ "error" ,
74+ {
75+ // Catches path.resolve(..., "../../..") — the three-level literal ends here.
76+ selector : "CallExpression > Literal[value=/\\.\\.\\W\\.\\.\\W\\.\\.$/]" ,
77+ message :
78+ "Do not read files 3+ levels above the test file. Tests reading root-level config must run in a dedicated non-Turbo-cached CI step." ,
79+ } ,
80+ {
81+ // Catches readFile("../../../.coderabbit.yaml") — three-level traversal
82+ // embedded inside a longer path string. Scoped to FS-reading calls so
83+ // vi.mock("../../../module") (module paths, not file reads) is not flagged.
84+ // Matches both bare readFileSync(...) and fs.readFileSync(...).
85+ selector :
86+ ":matches(CallExpression[callee.name=/^(readFile|readFileSync|open|openSync|stat|statSync|access|accessSync|watch|watchFile|readdir|readdirSync)/], CallExpression[callee.property.name=/^(readFile|readFileSync|open|openSync|stat|statSync|access|accessSync|watch|watchFile|readdir|readdirSync)/]) > Literal[value=/\\.\\.\\W\\.\\.\\W\\.\\./]" ,
87+ message :
88+ "Do not read files 3+ levels above the test file. Tests reading root-level config must run in a dedicated non-Turbo-cached CI step." ,
89+ } ,
90+ ] ,
91+ } ,
92+ } ,
6393]
0 commit comments