Skip to content

Commit 820cb1c

Browse files
committed
Add rule to prevent setting context from outside the ContextManager class
1 parent 2aa197c commit 820cb1c

File tree

1 file changed

+24
-11
lines changed

1 file changed

+24
-11
lines changed

.eslintrc.json

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,6 @@
2323
"import/internal-regex": "^@/"
2424
},
2525
"overrides": [
26-
{
27-
"files": ["test/**/*.{ts,tsx}", "**/*.{test,spec}.ts?(x)"],
28-
"settings": {
29-
"import/resolver": {
30-
"typescript": {
31-
// In tests, resolve using the test tsconfig
32-
"project": "test/tsconfig.json"
33-
}
34-
}
35-
}
36-
},
3726
{
3827
"files": ["*.ts"],
3928
"rules": {
@@ -53,6 +42,23 @@
5342
]
5443
}
5544
},
45+
{
46+
"files": ["test/**/*.{ts,tsx}", "**/*.{test,spec}.ts?(x)"],
47+
"settings": {
48+
"import/resolver": {
49+
"typescript": {
50+
// In tests, resolve using the test tsconfig
51+
"project": "test/tsconfig.json"
52+
}
53+
}
54+
}
55+
},
56+
{
57+
"files": ["src/core/contextManager.ts"],
58+
"rules": {
59+
"no-restricted-syntax": "off"
60+
}
61+
},
5662
{
5763
"extends": ["plugin:package-json/legacy-recommended"],
5864
"files": ["*.json"],
@@ -110,6 +116,13 @@
110116
"sublings_only": true
111117
}
112118
}
119+
],
120+
"no-restricted-syntax": [
121+
"error",
122+
{
123+
"selector": "CallExpression[callee.property.name='executeCommand'][arguments.0.value='setContext'][arguments.length>=3]",
124+
"message": "Do not use executeCommand('setContext', ...) directly. Use the ContextManager class instead."
125+
}
113126
]
114127
}
115128
}

0 commit comments

Comments
 (0)