Service Now Linter Check || Instance Scan

AjeetS
Tera Contributor

I’ve created a custom ServiceNow Instance Scan (Linter) script to identify and flag instances where developers define variables using the name gr. While gr is commonly used as a shorthand for GlideRecord, using it as a variable name can lead to confusion or conflicts — especially in larger codebases or when multiple GlideRecord instances are involved.
To make the rule more precise, I want it to run only on the script field and exclude scripts from the sys_dictionary table (such as calculated field scripts), where this check may not be relevant.
Can anyone help me figure out how to reliably exclude sys_dictionary records in an Instance Scan Linter Check rule?

(function(engine) {
    engine.rootNode.visit(function(node) {
        if (node.getTypeName() === "NAME" &&
            node.getParent().getTypeName() === "VAR" &&
            node.getNameIdentifier() === "gr") {
            engine.finding.incrementWithNode(node);
        }
    });
})(engine);
0 REPLIES 0