@@ -8,9 +8,20 @@ import { errMsgs } from '../../lib/rules/no-banned-usages'
88import { getRuleTester } from '../testUtil'
99
1010getRuleTester ( ) . run ( 'no-banned-usages' , rules [ 'no-banned-usages' ] , {
11- valid : [ "vscode.commands.executeCommand('foo', 'aws.foo', true, 42)" ] ,
11+ valid : [
12+ // setContext
13+ "vscode.commands.executeCommand('foo', 'aws.foo', true, 42)" ,
14+ // globalState
15+ 'globals.globalState' ,
16+ 'await globals.globalState.update("foo", 42)' ,
17+ 'globals.globalState.get("foo")' ,
18+ 'globalState.get("foo")' ,
19+ ] ,
1220
1321 invalid : [
22+ //
23+ // setContext
24+ //
1425 {
1526 code : "async function test() { await vscode.commands.executeCommand('setContext', key, val) }" ,
1627 errors : [ errMsgs . setContext ] ,
@@ -35,5 +46,31 @@ getRuleTester().run('no-banned-usages', rules['no-banned-usages'], {
3546 code : "const x = vscode.commands.executeCommand('setContext', key, val).catch(e => { return e })" ,
3647 errors : [ errMsgs . setContext ] ,
3748 } ,
49+
50+ //
51+ // globalState
52+ //
53+ {
54+ code : 'const memento = globals.context.globalState' ,
55+ errors : [ errMsgs . globalState ] ,
56+ } ,
57+ {
58+ code : 'const val = globals.context.globalState.get("foo")' ,
59+ errors : [ errMsgs . globalState ] ,
60+ } ,
61+ {
62+ code : 'const val = extContext.globalState.get("foo")' ,
63+ errors : [ errMsgs . globalState ] ,
64+ } ,
65+ {
66+ code : 'return this.openState(targetContext.globalState, key)' ,
67+ errors : [ errMsgs . globalState ] ,
68+ } ,
69+
70+ // TODO: prevent assignment of GlobalState to Memento.
71+ // {
72+ // code: 'const state: vscode.Memento = globals.globalState',
73+ // errors: [errMsgs.globalState],
74+ // },
3875 ] ,
3976} )
0 commit comments