visitor-keys.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /**
  2. * @fileoverview The visitor keys for the node types Espree supports
  3. * @author Nicholas C. Zakas
  4. *
  5. * This file contains code from estraverse-fb.
  6. *
  7. * The MIT license. Copyright (c) 2014 Ingvar Stepanyan
  8. *
  9. * Permission is hereby granted, free of charge, to any person obtaining a copy
  10. * of this software and associated documentation files (the "Software"), to deal
  11. * in the Software without restriction, including without limitation the rights
  12. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  13. * copies of the Software, and to permit persons to whom the Software is
  14. * furnished to do so, subject to the following conditions:
  15. *
  16. * The above copyright notice and this permission notice shall be included in all
  17. * copies or substantial portions of the Software.
  18. *
  19. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  20. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  21. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  22. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  23. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  24. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  25. * SOFTWARE.
  26. */
  27. "use strict";
  28. //------------------------------------------------------------------------------
  29. // Requirements
  30. //------------------------------------------------------------------------------
  31. // None!
  32. //------------------------------------------------------------------------------
  33. // Public
  34. //------------------------------------------------------------------------------
  35. module.exports = {
  36. // ECMAScript
  37. AssignmentExpression: ["left", "right"],
  38. AssignmentPattern: ["left", "right"],
  39. ArrayExpression: ["elements"],
  40. ArrayPattern: ["elements"],
  41. ArrowFunctionExpression: ["params", "body"],
  42. BlockStatement: ["body"],
  43. BinaryExpression: ["left", "right"],
  44. BreakStatement: ["label"],
  45. CallExpression: ["callee", "arguments"],
  46. CatchClause: ["param", "body"],
  47. ClassBody: ["body"],
  48. ClassDeclaration: ["id", "superClass", "body"],
  49. ClassExpression: ["id", "superClass", "body"],
  50. ConditionalExpression: ["test", "consequent", "alternate"],
  51. ContinueStatement: ["label"],
  52. DebuggerStatement: [],
  53. DirectiveStatement: [],
  54. DoWhileStatement: ["body", "test"],
  55. EmptyStatement: [],
  56. ExportAllDeclaration: ["source"],
  57. ExportDefaultDeclaration: ["declaration"],
  58. ExportNamedDeclaration: ["declaration", "specifiers", "source"],
  59. ExportSpecifier: ["exported", "local"],
  60. ExpressionStatement: ["expression"],
  61. ForStatement: ["init", "test", "update", "body"],
  62. ForInStatement: ["left", "right", "body"],
  63. ForOfStatement: ["left", "right", "body"],
  64. FunctionDeclaration: ["id", "params", "body"],
  65. FunctionExpression: ["id", "params", "body"],
  66. Identifier: [],
  67. IfStatement: ["test", "consequent", "alternate"],
  68. ImportDeclaration: ["specifiers", "source"],
  69. ImportDefaultSpecifier: ["local"],
  70. ImportNamespaceSpecifier: ["local"],
  71. ImportSpecifier: ["imported", "local"],
  72. Literal: [],
  73. LabeledStatement: ["label", "body"],
  74. LogicalExpression: ["left", "right"],
  75. MemberExpression: ["object", "property"],
  76. MetaProperty: ["meta", "property"],
  77. MethodDefinition: ["key", "value"],
  78. ModuleSpecifier: [],
  79. NewExpression: ["callee", "arguments"],
  80. ObjectExpression: ["properties"],
  81. ObjectPattern: ["properties"],
  82. Program: ["body"],
  83. Property: ["key", "value"],
  84. RestElement: ["argument"],
  85. ReturnStatement: ["argument"],
  86. SequenceExpression: ["expressions"],
  87. SpreadElement: ["argument"],
  88. Super: [],
  89. SwitchStatement: ["discriminant", "cases"],
  90. SwitchCase: ["test", "consequent"],
  91. TaggedTemplateExpression: ["tag", "quasi"],
  92. TemplateElement: [],
  93. TemplateLiteral: ["quasis", "expressions"],
  94. ThisExpression: [],
  95. ThrowStatement: ["argument"],
  96. TryStatement: ["block", "handler", "finalizer"],
  97. UnaryExpression: ["argument"],
  98. UpdateExpression: ["argument"],
  99. VariableDeclaration: ["declarations"],
  100. VariableDeclarator: ["id", "init"],
  101. WhileStatement: ["test", "body"],
  102. WithStatement: ["object", "body"],
  103. YieldExpression: ["argument"],
  104. // JSX
  105. JSXIdentifier: [],
  106. JSXNamespacedName: ["namespace", "name"],
  107. JSXMemberExpression: ["object", "property"],
  108. JSXEmptyExpression: [],
  109. JSXExpressionContainer: ["expression"],
  110. JSXElement: ["openingElement", "closingElement", "children"],
  111. JSXClosingElement: ["name"],
  112. JSXOpeningElement: ["name", "attributes"],
  113. JSXAttribute: ["name", "value"],
  114. JSXText: null,
  115. JSXSpreadAttribute: ["argument"]
  116. };