Skip to content

Instantly share code, notes, and snippets.

@phenomnomnominal
Created March 11, 2019 11:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phenomnomnominal/7cc667d28504372580255df461d81104 to your computer and use it in GitHub Desktop.
Save phenomnomnominal/7cc667d28504372580255df461d81104 to your computer and use it in GitHub Desktop.
// 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