Context and all of the methods under it is something specific to ESLint. 
There's a RuleContext.js file that sets up context and define some of the 
methods. Others are defined directly in eslint.js. You can take a look at 
other rules to get an example of usage of some of the methods in context, 
but in short:
getScope - retrieve scope of the current program, this is retrieved by 
EScope (https://github.com/Constellation/escope)
getSource - retrieve a string with source code of the node (+/- some 
characters)
getAncestors - retrieves a list of parent AST nodes for a given node.

Thanks,

Ilya Volodin

On Tuesday, March 11, 2014 8:47:35 PM UTC-4, Danny Fritz wrote:

> I'm trying to create a rule to enforce all vars are specified at the top 
> of the functional scope. This is very similar to one-var, but allows more 
> than one var as long as they are all at the top.
>
> Here is a blog post on the issue.
> http://danielhough.co.uk/blog/single-var-pattern-rant/
>
> I'm having a really hard to figuring out how to create a custom rule 
> follwoing this: 
> http://eslint.org/docs/developer-guide/working-with-rules.html. I have 
> the basic framework setup and am running tests on my custom rule, but I am 
> very confused about what the various `context` methods do. I'm seeing 
> `getScope`, `getSource`, `getAncestors`, among others. Are these defined in 
> AST or ESLint?
>
> Any help appreciated.
>
> Danny
>

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