-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathplugin.ts
More file actions
38 lines (31 loc) · 962 Bytes
/
plugin.ts
File metadata and controls
38 lines (31 loc) · 962 Bytes
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
37
38
import type { AnalyzerConfig } from "./config";
import type { RulePlugin } from "./core/types";
export const PLUGIN_API_VERSION = 1;
export interface SlopScanPlugin {
meta: {
name: string;
version?: string;
namespace?: string;
apiVersion: typeof PLUGIN_API_VERSION;
};
rules?: Record<string, RulePlugin>;
configs?: Record<string, Partial<AnalyzerConfig>>;
}
export type PluginReference = SlopScanPlugin | string;
export interface LoadedPlugin {
namespace: string;
plugin: SlopScanPlugin;
source: string;
}
export interface ConfigFile extends Partial<AnalyzerConfig> {
extends?: string[];
plugins?: Record<string, PluginReference>;
}
/** Preserves type inference for plugin definitions. */
export function definePlugin<T extends SlopScanPlugin>(plugin: T): T {
return plugin;
}
/** Preserves type inference for config definitions. */
export function defineConfig<T extends ConfigFile>(config: T): T {
return config;
}