import-example
Ast Rule: import
import-example
function visit(node, filename, code) {
if (node.pkg && node.pkg.value) {
console.log(node.pkg.value);
}
if (node.importedNames) {
node.importedNames.forEach((n) => {
if (n && n.name && n.name.value && n.name.value === "usequery") {
const error = buildError(n.name.start.line,
n.name.start.col,
n.name.end.line,
n.name.end.col,
"do not use usequery", "CRITICAL", "SAFETY");
const edit = buildEditUpdate(
n.name.start.line, n.name.start.col,
n.name.end.line, n.name.end.col,
"useQuery");
const fix = buildFix("use useQuery instead", [edit]);
addError(error.addFix(fix));
}
});
}
}
test-import.ts
Expected test result: has error