Hi Patrick,

No work has been done on this. If you'd like to suggest something, please
open an issue on GitHub.

-N
On Thu, Dec 3, 2015 at 2:02 AM Patrick Brosset <[email protected]>
wrote:

> It looks like the internal scope variables API has changed a little bit in
> v1.10.3. Now, adding global variables like this doesn't seem quite enough.
> Indeed, getVariableByName in ast-utils.js looks for defined variables in
> scopes by using the scope.set Map.
> It looks like this was changed with this commit:
> https://github.com/eslint/eslint/commit/65c33d85268790a095210c0d6d587ed636ebd2d3
>
> So on top of pushing new global variables to scope.variables, we'd also
> need to add them to the map: globalScope.set.set(name, variable);
>
> Can you confirm this is correct?
> Has there been work done on providing an officially supported way to do
> this?
>
> Thanks!
>
> Le vendredi 22 mai 2015 12:10:41 UTC+2, Mike Ratcliffe a écrit :
>>
>> 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.
>

-- 
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