@@ -106,6 +106,7 @@ const checkPlugins = (pluginsNode: parse.PropertyNode | undefined, diagnostics:
106106 checkAtLeastOneEnabledPlugin ( pluginNodes , diagnostics , pluginsNode ) ;
107107 warnOnReporterPosition ( pluginNodes , diagnostics ) ;
108108 validatePluginConfigurations ( pluginNodes , diagnostics , documentNode ) ;
109+ checkForSummaryPluginWithoutReporter ( pluginNodes , diagnostics ) ;
109110 }
110111} ;
111112
@@ -290,3 +291,54 @@ const getObjectNodeFromDocument = (document: vscode.TextDocument): parse.ObjectN
290291 return parse ( document . getText ( ) ) as parse . ObjectNode ;
291292} ;
292293
294+ function checkForSummaryPluginWithoutReporter ( pluginNodes : parse . ObjectNode [ ] , diagnostics : vscode . Diagnostic [ ] ) {
295+ const summaryPluginNames = [ 'ExecutionSummaryPlugin' , 'UrlDiscoveryPlugin' ] ;
296+
297+ const summaryPlugin = pluginNodes . find ( ( pluginNode : parse . ObjectNode ) => {
298+ const pluginNameNode = getASTNode (
299+ pluginNode . children ,
300+ 'Identifier' ,
301+ 'name'
302+ ) ;
303+ const pluginName = ( pluginNameNode ?. value as parse . LiteralNode )
304+ . value as string ;
305+ const enabledNode = getASTNode (
306+ pluginNode . children ,
307+ 'Identifier' ,
308+ 'enabled'
309+ ) ;
310+ const isEnabled = ( enabledNode ?. value as parse . LiteralNode )
311+ . value as boolean ;
312+ return summaryPluginNames . includes ( pluginName ) && isEnabled ;
313+ } ) ;
314+
315+ if ( summaryPlugin ) {
316+ const reporterPlugin = pluginNodes . find ( ( pluginNode : parse . ObjectNode ) => {
317+ const pluginNameNode = getASTNode (
318+ pluginNode . children ,
319+ 'Identifier' ,
320+ 'name'
321+ ) ;
322+ const pluginName = ( pluginNameNode ?. value as parse . LiteralNode )
323+ . value as string ;
324+ const enabledNode = getASTNode (
325+ pluginNode . children ,
326+ 'Identifier' ,
327+ 'enabled'
328+ ) ;
329+ const isEnabled = ( enabledNode ?. value as parse . LiteralNode )
330+ . value as boolean ;
331+ return pluginName . toLowerCase ( ) . includes ( 'reporter' ) && isEnabled ;
332+ } ) ;
333+
334+ if ( ! reporterPlugin ) {
335+ diagnostics . push (
336+ new vscode . Diagnostic (
337+ getRangeFromASTNode ( summaryPlugin ) ,
338+ `Summary plugins should be used with a reporter plugin.` ,
339+ vscode . DiagnosticSeverity . Warning
340+ )
341+ ) ;
342+ }
343+ }
344+ }
0 commit comments