Created
March 11, 2019 11:14
-
-
Save phenomnomnominal/2cc7bd06fffe07da3a1c193da128895c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const FAILURE_MESSAGE = 'Found magic `loadChildren` string. Use a function with `import` instead.'; | |
export class Rule extends Rules.AbstractRule { | |
public apply(sourceFile: SourceFile): Array<RuleFailure> { | |
// ... | |
// Try to fix indentation in replacement: | |
const { character } = sourceFile.getLineAndCharacterOfPosition(result.getStart()); | |
fix = fix.replace(/\n/g, `\n${' '.repeat(character)}`); | |
const replacement = new Replacement(valueNode.getStart(), valueNode.getWidth(), fix); | |
return new RuleFailure(sourceFile, result.getStart(), result.getEnd(), FAILURE_MESSAGE, this.ruleName, replacement); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment