Linter Check

Junaid Ansari
Tera Contributor

I have a requirement to scan for date format anywhere in the scripting which is used in "yyyy-MM-dd" this format using Linter Check.
I tried to this with node.getNameIdentifier() but it is not working for me. Its possible that I am using it in wrong way.
Can anyone help me to achieve this requirement please. I am new in Servicenow.

4 REPLIES 4

Mark Roethof
Tera Patron
Tera Patron

Hi there,

 

Can you share what you tried and is not working?

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

Hi Mark,
I tried these line of codes. I am new so I don't know much about the APIs used in Linter check. I was trying to achieve the requirement as per my understanding.

(
function (engine) {

    // Add your code here
    engine.rootNode.visit(function(node)
    {
        if(node.getTypeName() === 'NAME' &&
        node.getNameIdentifier() === "yyyy-MM-dd")
        {
            engine.finding.incrementWithNode(node);
        }
    });

})(engine);

Oke and how did you come up with this? Did you see this somewhere? Or just made it up? For me looking at it, it will never work, though more interesting is your journey behind this. I can just copy/paste working code, though that will learn you nothing at all.

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

You are right Mark,
As I said I am learning and started reading about Linter Checks from yesterday only. May be after exploring more, I get to know more about these things.
please suggest me how can Improve my theoretical learning along with use cases so that it will help code correctly.


Thanks and Regards.