Class CheckNestedNames

  • All Implemented Interfaces:
    CompilerPass, NodeTraversal.Callback

    public final class CheckNestedNames
    extends java.lang.Object
    implements CompilerPass, NodeTraversal.Callback
    Checks if code has a module-level static property assignment (`X.Y`) inside a `goog.module`. If yes, reports a linter warning on the `X.Y` if:
    1. X is any name {object, class, function, interface, enum, typedef}.
    2. Y is {class, interface, enum, typedef}

    For example, reports a linter finding in the following:

    { @code
    
     class C {}
     let obj = {...};
    
     /**
     * Reports nested name E on class C.
     * @enum {number}
     * /
     C.E={...}; // WARNING:
    
     /**
     * Reports nested interface I on variable obj.
     * @interface
     * /
     obj.I=class {}; // WARNING:
    
     // reports nested name D on class C.
     C.D=class {};
     }
     
    
     // Does not report on nested functions, or any nested property assigned to a value.
     C.F = function() {}
     obj.S = '';
     obj.Some = new Something();