-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathplugin.ts
More file actions
36 lines (30 loc) · 1.27 KB
/
plugin.ts
File metadata and controls
36 lines (30 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import {
ConfigObject,
Engine,
EnginePluginV1,
} from "@salesforce/code-analyzer-engine-api";
import {getMessage} from "./messages";
import { TemplateEngine } from "./engine";
// *** Change the Class Name to match your engine's name
export class TemplateEnginePlugin extends EnginePluginV1 {
// *** Change to match your engine's name
// *** If your plugin provides multiple engines, we accept that here
getAvailableEngineNames(): string[] {
return [TemplateEngine.NAME];
}
async createEngine(engineName: string, _resolvedConfig: ConfigObject): Promise<Engine> {
validateEngineName(engineName);
// *** Update to use _resolvedConfig, if user-configuration is desired
return new TemplateEngine();
}
// *** Methods available for use if user-configuration is desired
//describeEngineConfig(engineName: string): ConfigDescription;
//createEngineConfig(engineName: string, configValueExtractor: ConfigValueExtractor): Promise<ConfigObject>;
}
// *** Best Practice - validate the engine name in every public method
// since this library is public
function validateEngineName(engineName: string) {
if (engineName !== TemplateEngine.NAME) {
throw new Error(getMessage('UnsupportedEngineName', engineName));
}
}