---
sourceDocument: Brazil ServiceNow AI Platform Administration
sourceDocumentLink: https://www.servicenow.com/docs/r/platform-administration

 Release :

    - brazil

ft:locale :

    - en-US

ft:publication_title :

    - Brazil ServiceNow AI Platform Administration

ft:clusterId :

    - platadm

bundleId :

    - platadm

workflow :

    - Platform


---

# Advanced linter check scripts

# Advanced linter check scripts {#ariaid-title1}

Release version: Brazil  
Updated September 10, 2026  
![](https://www.servicenow.com/docs/portal-asset/ico-clock) 3 minutes to read
Summarize  
![AI sparkle icon](https://servicenow.com/docs/portal-asset/ai-sparkle-icon) Summarized using AI  
This content was generated using new OpenAI-powered functionality. Results are provided on an as is basis and are not guaranteed to be accurate or complete.  

## Summary of Advanced linter check scripts

Advanced linter check scripts in ServiceNow help you identify issues in script code by analyzing its abstract syntax tree (AST).
When a linter check runs on a record with script content, it parses the code into an AST, enabling detailed inspection of code structures and patterns such as excessive nested if statements or inefficient API usage.
Show full answer Show less  

## Key Features

* **rootNode Object:** Represents the root of the AST for the script. It provides the `visit` function to traverse all nodes in the tree.
* **visit(callbackFunction):** Allows running a callback on every node. The callback receives the current node and can stop traversal early by returning false.
* **Node Functions:** Nodes in the AST expose methods to inspect code details, including:
  * `getTypeName()`: Retrieves the type of the node (e.g., "CALL" for function calls).
  * `getNameIdentifier()`: Returns the name string if the node is a "NAME" type (such as function or variable names).
  * `getParent()`, `getLineNo()`, `getColumnNo()`, `toSource()`, and others enable navigation and source extraction.
  * `debugPrint()`: Generates a hierarchical string representation of the AST from the current node.

## Practical Use

You can write custom linter checks by leveraging the `rootNode.visit()` method to scan scripts for specific code patterns or deprecated API usage. For example, detecting calls to a deprecated function `badFunction()` involves visiting each node, checking if it is a function call to `badFunction`, and incrementing findings accordingly.

When you run such a linter check scan, it analyzes all script-containing records and reports findings on any detected issues, helping maintain code quality and enforce best practices.

## Benefits for ServiceNow Customers

* Enables automated detection of problematic or deprecated code patterns within scripts across your ServiceNow instance.
* Helps enforce coding standards and improve script performance by identifying inefficient constructs.
* Provides detailed node-level inspection tools, allowing highly customized script validation rules.
* Facilitates early detection and remediation of scripting issues before deployment.  
Linter check scripts helps you in writing checks that look for issues in scripts. When a
linter check is run on a record, it provides an abstract syntax tree for its code. You can use
this abstract syntax tree to analyze issues with the code such as too many nested if statements or
usages of slow API in a while loop.

## Linter check usage {#hs-linter-check-scripts__section_zcb_151_dpb}

Linter checks have a unique object to use called `rootNode`. This is the root
node of the parsed abstract syntax tree (AST) for the script of the current record. This object
has many functions, but the `visit` function is the most important. The
`visit` function takes a callback function as a parameter which gets called on
every node of the tree. The callback function then takes a node as a parameter which represents
the current node during its iteration. You can return false from the callback function to stop
iterating the tree early, otherwise it keeps visiting every subnode in the tree of the node you
called `visit` on.  
For example, if you want to scan for a deprecated API called `badFunction()`. You can write a Linter Check with a script in the following example:

    (function(engine) {
    	engine.rootNode.visit(function(node) {
    		if (node.getTypeName() === "NAME" &&
    				node.getNameIdentifier() === "badFunction" &&
    				node.getParent().getTypeName() === "CALL") {
    			engine.finding.incrementWithNode(node);
    		}
    	});
    })(engine);

When you run a scan with this Linter Check, it checks every record in the scan with a script field. For example, if a record in that scan has a script that looks like the following, the scan picks up a finding for this record.

    /*
    badFunction()
    */
    // badFunction()
    function badFunction() {
    	return;
    }
    var GoodClass = Class.create();
    GoodClass.prototype = Object.extendsObject(Object, {
    	badFunction: function() {
    		// actually good
    	}
    });
    var badFunction = ["badFunction", "badFunction()"];
    badFunctionButSometimesGood();

    badFunction();

## Node functions {#hs-linter-check-scripts__section_q4q_zv1_dpb}

The following is a list of available functions to call on the node object.

* `getRootNode()`: Get the root node of the tree for this node
* `getParent()`: Get the parent of this node
* `getLineNo()`: Get the line number location for this node
* `getColumnNo()`: Get the column number location for this node
* `toSource()`: Get the source for this node. The source is based on this node and its children
* `getTypeName()`: Get the node type name of this node. For example, a function call in source is tokenized as a node with the type name of "CALL"  
  Note:  
  The values of `node.getTypeName()` are from different types of nodes in an Abstract Syntax Tree (AST). The possible values come from Rhino's AST parser itself.
* `getNameIdentifier()`: If the node type of this node is "NAME", then return the identifier, which is the string value of the name itself. A "NAME" node represents a simple name that is not a keyword, like a function name or a variable name.  
  Note:  
  If this node is not a NAME node, then the result is null.
* `getAbsolutePosition()`: Get the absolute position of this node. The absolute position is the number of characters from the start of the script to this node
* `compareTo(other)`: Compare this node with another node. The node with a greater absolute position and length will be the larger in comparison. `other` is a node to compare with this node
* `visit(callbackFunction)`: Visit each node in the subtree starting from this node and execute the given callback function on each node. `callbackFunction` is a function that will be executed on each node in the subtree of this node. This callback function takes a LinterCheckAstNode as a parameter which is will be the node being visited
* `debugPrint()`: Returns a string representation of the abstract syntax tree, starting from this node. Each line contains information about a node, and the indentation represents the hierarchy relationship between the nodes. The information in each line is arranged as follows
  1. Absolute position
  2. Node type name
  3. Position relative to parent
  4. Length
  5. Name identifier (if a NAME node)
  {#hs-linter-check-scripts__ol_hlh_q1b_dpb}

{#hs-linter-check-scripts__ul_vkj_bw1_dpb}For more information, see [LinterCheckAstNode API - Scoped,
Global](https://www.servicenow.com/docs/access?context=LinterCheckAstNodeAPIBoth&version=brazil&pubname=brazil-api-reference&ft:locale=en-US).

