I would like to add some custom rules for use with the Mozilla codebase. 
One of the first I have chosen is to deal with is Cu.import:
Cu.import("resource://gre/modules/XPCOMUtils.jsm");; // Should produce a 
global XPCOMUtils... the right thing to do in 99% of our cases.

Picking out XPCOMUtils from the code is simple enough but I don't see how 
to add XPCOMUtils as a global.

This is what I have so far:
```
module.exports = function(context) {
    return {
        ExpressionStatement: function(node) {
            var source = context.getSource(node);
            var matches = 
source.match(/^(?:Cu|Components\.utils)\.import\(".*\/(\w+)\.\w+"\);?$/);

            if (matches) {
                var imported = matches[1];
                var scope = context.getScope();
                var variables = scope.variables;

                variables.push(imported); // Obviously does not work... how 
the heck do I add XPCOMUtils as a global?
            }
        }
    };
};
```

-- 
You received this message because you are subscribed to the Google Groups 
"ESLint" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to