Created
March 11, 2019 11:04
-
-
Save phenomnomnominal/7cc667d28504372580255df461d81104 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
// Constants: | |
const LOAD_CHILDREN_VALUE_QUERY = `StringLiteral[value=/.*${LOAD_CHILDREN_SPLIT}.*/]`; | |
const LOAD_CHILDREN_ASSIGNMENT_QUERY = `PropertyAssignment:not(:has(Identifier[name="children"])):has(Identifier[name="loadChildren"]):has(${LOAD_CHILDREN_VALUE_QUERY})`; | |
export class Rule extends Rules.AbstractRule { | |
public apply(sourceFile: SourceFile): Array<RuleFailure> { | |
const options = this.getOptions(); | |
const [preferAsync] = options.ruleArguments; | |
return tsquery(sourceFile, LOAD_CHILDREN_ASSIGNMENT_QUERY).map(result => { | |
const [valueNode] = tsquery(result, LOAD_CHILDREN_VALUE_QUERY); | |
// ... | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment