本文整理匯總了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;
}