Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private prepareRules(
config: EffectiveConfiguration,
sourceFile: ts.SourceFile,
programFactory: ProgramFactory | undefined,
noWarn: boolean,
) {
const rules: PreparedRule[] = [];
for (const [ruleName, {options, severity, rulesDirectories, rule}] of config.rules) {
if (severity === 'off')
continue;
const ctor = this.ruleLoader.loadRule(rule, rulesDirectories);
if (ctor === undefined)
continue;
if (ctor.deprecated)
this.deprecationHandler.handle(
DeprecationTarget.Rule,
ruleName,
typeof ctor.deprecated === 'string' ? ctor.deprecated : undefined,
);
if (programFactory === undefined && ctor.requiresTypeInformation) {
if (noWarn) {
log('Rule %s requires type information', ruleName);
} else {
this.logger.warn(`Rule '${ruleName}' requires type information.`);
}
continue;
}
if (ctor.supports !== undefined) {
const supports = ctor.supports(sourceFile, {
get program() { return programFactory && programFactory.getProgram(); },
get compilerOptions() { return programFactory && programFactory.getCompilerOptions(); },
options,