本文整理汇总了TypeScript中tslint.RuleFailure.setRuleSeverity方法的典型用法代码示例。如果您正苦于以下问题:TypeScript RuleFailure.setRuleSeverity方法的具体用法?TypeScript RuleFailure.setRuleSeverity怎么用?TypeScript RuleFailure.setRuleSeverity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tslint.RuleFailure
的用法示例。
在下文中一共展示了RuleFailure.setRuleSeverity方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: analyze
ts.forEachChild(sourceFile, function analyze(node) {
if (ts.isPropertyAssignment(node) &&
(ts.isIdentifier(node.name) || ts.isStringLiteral(node.name)) &&
node.name.text === 'loadChildren' &&
ts.isStringLiteral(node.initializer)) {
const valueNode = node.initializer;
const parts = valueNode.text.split(LOAD_CHILDREN_SPLIT);
const path = parts[0];
const moduleName = parts[1] || 'default';
let fix = `() => import('${path}').then(m => m.${moduleName})`;
// Try to fix indentation in replacement:
const { character } = ast.getLineAndCharacterOfPosition(node.getStart());
fix = fix.replace(/\n/g, `\n${' '.repeat(character)}`);
const replacement = new Replacement(valueNode.getStart(), valueNode.getWidth(), fix);
const start = node.getStart();
const end = node.getEnd();
const change = new RuleFailure(ast, start, end, FAILURE_MESSAGE, ruleName, replacement);
change.setRuleSeverity('warning');
changes.push(change);
}
ts.forEachChild(node, analyze);
});
示例2: createFailure
export function createFailure(
sourceFile: ts.SourceFile,
start: number,
end: number,
failure: string,
ruleName: string,
fix?: Fix,
ruleSeverity: RuleSeverity = "warning",
) {
const rule = new RuleFailure(sourceFile, start, end, failure, ruleName, fix);
rule.setRuleSeverity(ruleSeverity);
return rule;
}