File tree Expand file tree Collapse file tree 5 files changed +43
-1
lines changed Expand file tree Collapse file tree 5 files changed +43
-1
lines changed Original file line number Diff line number Diff line change
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License. See License.txt in the project root for license information.
4
+ *--------------------------------------------------------------------------------------------*/
5
+
6
+ import * as eslint from 'eslint' ;
7
+ import { TSESTree } from '@typescript-eslint/experimental-utils' ;
8
+
9
+ export = new class ApiTypeDiscrimination implements eslint . Rule . RuleModule {
10
+
11
+ readonly meta : eslint . Rule . RuleMetaData = {
12
+ docs : { url : 'https://github.com/microsoft/vscode/wiki/Extension-API-guidelines' } ,
13
+ messages : {
14
+ noTypeDiscrimination : 'Do not use type descrimination properties'
15
+ }
16
+ } ;
17
+
18
+ create ( context : eslint . Rule . RuleContext ) : eslint . Rule . RuleListener {
19
+ return {
20
+ [ 'TSPropertySignature[optional=undefined] TSTypeAnnotation TSLiteralType Literal' ] : ( node : any ) => {
21
+
22
+ const raw = String ( ( < TSESTree . Literal > node ) . raw )
23
+
24
+ if ( / ^ ( ' | " ) .* \1$ / . test ( raw ) ) {
25
+
26
+ context . report ( {
27
+ node : node ,
28
+ messageId : 'noTypeDiscrimination'
29
+ } ) ;
30
+ }
31
+ }
32
+ }
33
+ }
34
+ } ;
Original file line number Diff line number Diff line change 130
130
"rules" : {
131
131
"local/vscode-dts-create-func" : " warn" ,
132
132
"local/vscode-dts-literal-or-types" : " warn" ,
133
+ "local/vscode-dts-string-type-literals" : " warn" ,
133
134
"local/vscode-dts-interface-naming" : " warn" ,
134
135
"local/vscode-dts-cancellation" : " warn" ,
135
136
"local/vscode-dts-use-thenable" : " warn" ,
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ declare module 'vscode' {
8
8
// See https://github.com/microsoft/vscode/issues/63943
9
9
10
10
export interface ThreadFocus {
11
+ // eslint-disable-next-line local/vscode-dts-string-type-literals
11
12
kind : 'thread' ;
12
13
13
14
/**
@@ -22,6 +23,7 @@ declare module 'vscode' {
22
23
}
23
24
24
25
export interface StackFrameFocus {
26
+ // eslint-disable-next-line local/vscode-dts-string-type-literals
25
27
kind : 'stackFrame' ;
26
28
27
29
/**
Original file line number Diff line number Diff line change @@ -159,6 +159,7 @@ declare module 'vscode' {
159
159
}
160
160
161
161
export interface InteractiveSessionVoteAction {
162
+ // eslint-disable-next-line local/vscode-dts-string-type-literals
162
163
kind : 'vote' ;
163
164
responseId : string ;
164
165
direction : InteractiveSessionVoteDirection ;
@@ -171,6 +172,7 @@ declare module 'vscode' {
171
172
}
172
173
173
174
export interface InteractiveSessionCopyAction {
175
+ // eslint-disable-next-line local/vscode-dts-string-type-literals
174
176
kind : 'copy' ;
175
177
responseId : string ;
176
178
codeBlockIndex : number ;
@@ -181,6 +183,7 @@ declare module 'vscode' {
181
183
}
182
184
183
185
export interface InteractiveSessionInsertAction {
186
+ // eslint-disable-next-line local/vscode-dts-string-type-literals
184
187
kind : 'insert' ;
185
188
responseId : string ;
186
189
codeBlockIndex : number ;
@@ -189,13 +192,15 @@ declare module 'vscode' {
189
192
}
190
193
191
194
export interface InteractiveSessionTerminalAction {
195
+ // eslint-disable-next-line local/vscode-dts-string-type-literals
192
196
kind : 'runInTerminal' ;
193
197
responseId : string ;
194
198
codeBlockIndex : number ;
195
199
languageId ?: string ;
196
200
}
197
201
198
202
export interface InteractiveSessionCommandAction {
203
+ // eslint-disable-next-line local/vscode-dts-string-type-literals
199
204
kind : 'command' ;
200
205
command : InteractiveResponseCommand ;
201
206
}
Original file line number Diff line number Diff line change @@ -173,7 +173,7 @@ declare module 'vscode' {
173
173
export interface ResourceLabelFormatting {
174
174
label : string ; // myLabel:/${path}
175
175
// For historic reasons we use an or string here. Once we finalize this API we should start using enums instead and adopt it in extensions.
176
- // eslint-disable-next-line local/vscode-dts-literal-or-types
176
+ // eslint-disable-next-line local/vscode-dts-literal-or-types, local/vscode-dts-string-type-literals
177
177
separator : '/' | '\\' | '' ;
178
178
tildify ?: boolean ;
179
179
normalizeDriveLetter ?: boolean ;
You can’t perform that action at this time.
0 commit comments