@binkylabs/muzzle
Version:
A muzzle for your TypeSpec linting rules. It's experimental, slightly unethical, and definitely effective.
25 lines • 832 B
JavaScript
import { getSourceLocation, } from "@typespec/compiler";
import { getNodeForTarget, SyntaxKind } from "@typespec/compiler/ast";
export function findSuppressTarget(target) {
if ("file" in target) {
return target;
}
const nodeTarget = getNodeForTarget(target);
if (!nodeTarget)
return undefined;
const node = findSuppressNode(nodeTarget);
return getSourceLocation(node);
}
/** Find the node where the suppression should be applied */
function findSuppressNode(node) {
switch (node.kind) {
case SyntaxKind.Identifier:
case SyntaxKind.TypeReference:
case SyntaxKind.UnionExpression:
case SyntaxKind.ModelExpression:
return findSuppressNode(node.parent);
default:
return node;
}
}
//# sourceMappingURL=typespec-imports.js.map