@code-warden/plugins
v1.0.1
Published
The extensibility layer for Code Warden. This package allows you to write custom static analysis rules and consensus constraints specific to your company's internal guidelines.
Readme
@code-warden/plugins
The extensibility layer for Code Warden. This package allows you to write custom static analysis rules and consensus constraints specific to your company's internal guidelines.
Writing a Custom Plugin
All custom rules must implement the Plugin interface:
import { BasePlugin, Finding, Severity } from '@code-warden/plugins';
export class NoConsoleLogPlugin extends BasePlugin {
name = 'no-console-log';
description = 'Blocks the use of console.log in production code';
async scan(filePath: string, content: string): Promise<Finding[]> {
const findings: Finding[] = [];
if (content.includes('console.log')) {
findings.push({
ruleId: this.name,
severity: Severity.WARNING,
message: 'console.log found. Use the official logger instead.',
file: filePath
});
}
return findings;
}
}Registering your Plugin
In your code-warden.config.ts:
import { NoConsoleLogPlugin } from './my-plugins';
export default {
plugins: [
new NoConsoleLogPlugin()
]
};