source: imaps-frontend/node_modules/eslint-plugin-react/lib/util/eslint.js@ d565449

main
Last change on this file since d565449 was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 1.3 KB
Line 
1'use strict';
2
3function getSourceCode(context) {
4 return context.getSourceCode ? context.getSourceCode() : context.sourceCode;
5}
6
7function getAncestors(context, node) {
8 const sourceCode = getSourceCode(context);
9 return sourceCode.getAncestors ? sourceCode.getAncestors(node) : context.getAncestors();
10}
11
12function getScope(context, node) {
13 const sourceCode = getSourceCode(context);
14 if (sourceCode.getScope) {
15 return sourceCode.getScope(node);
16 }
17
18 return context.getScope();
19}
20
21function markVariableAsUsed(name, node, context) {
22 const sourceCode = getSourceCode(context);
23 return sourceCode.markVariableAsUsed
24 ? sourceCode.markVariableAsUsed(name, node)
25 : context.markVariableAsUsed(name);
26}
27
28function getFirstTokens(context, node, count) {
29 const sourceCode = getSourceCode(context);
30 return sourceCode.getFirstTokens ? sourceCode.getFirstTokens(node, count) : context.getFirstTokens(node, count);
31}
32
33function getText(context) {
34 const sourceCode = getSourceCode(context);
35 const args = Array.prototype.slice.call(arguments, 1);
36 return sourceCode.getText ? sourceCode.getText.apply(sourceCode, args) : context.getSource.apply(context, args);
37}
38
39module.exports = {
40 getAncestors,
41 getFirstTokens,
42 getScope,
43 getSourceCode,
44 getText,
45 markVariableAsUsed,
46};
Note: See TracBrowser for help on using the repository browser.