Skip to content

Commit 801f73c

Browse files
committed
Add information diagnostic when a plugin has optional configSection. Closes #172
1 parent 9cd2fb5 commit 801f73c

File tree

4 files changed

+21
-2
lines changed

4 files changed

+21
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1212
### Added:
1313

1414
- Diagnostics: Ensure at least one plugin is enabled
15+
- Diagnostics: Information added to pluginName value when plugin can be configured with a configSection
1516

1617
### Changed:
1718

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ The following sections describe the features that the extension contributes to V
3636
- Check that schema matches installed version of Dev Proxy
3737
- Check that reporters are placed after plugins
3838
- Check that at least one plugin is enabled
39+
- Check that a plugin can be configured with a configSection
3940

4041
### Editor Actions
4142

src/diagnostics.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,21 @@ const checkPluginConfiguration = (pluginNode: parse.ObjectNode, diagnostics: vsc
198198
: vscode.DiagnosticSeverity.Warning
199199
)
200200
);
201+
} else if (pluginSnippet.config?.required === false) {
202+
const pluginNameNode = getASTNode(
203+
pluginNode.children,
204+
'Identifier',
205+
'name'
206+
);
207+
if (pluginNameNode) {
208+
diagnostics.push(
209+
new vscode.Diagnostic(
210+
getRangeFromASTNode(pluginNameNode.value),
211+
`${pluginName} can be configured with a configSection. Use '${pluginSnippet.config?.name}' snippet to create one.`,
212+
vscode.DiagnosticSeverity.Information
213+
)
214+
);
215+
}
201216
}
202217
} else {
203218
// if there is a config section defined on the plugin, we should have the config section defined in the document

src/test/extension.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -506,8 +506,10 @@ suite('schema', () => {
506506
await sleep(1000);
507507
const diagnostics = vscode.languages.getDiagnostics(document.uri);
508508

509-
const expected = 0;
510-
const actual = diagnostics.length;
509+
const expected = false;
510+
const actual = diagnostics.some((diagnostic) => {
511+
return diagnostic.severity === vscode.DiagnosticSeverity.Warning;
512+
});
511513
assert.deepStrictEqual(actual, expected);
512514
});
513515

0 commit comments

Comments
 (0)