Skip to content

Commit

Permalink
Refactor: Switch from JSON to ESM
Browse files Browse the repository at this point in the history
  • Loading branch information
brettz9 committed Jun 23, 2021
1 parent 13561e3 commit b9e75d5
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 96 deletions.
6 changes: 1 addition & 5 deletions lib/index.js
Expand Up @@ -2,11 +2,7 @@
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
import { readFileSync } from "fs";

const KEYS = JSON.parse(
readFileSync(new URL("./visitor-keys.json", import.meta.url))
);
import KEYS from "./visitor-keys.js";

// Types.
const NODE_TYPES = Object.freeze(Object.keys(KEYS));
Expand Down
172 changes: 86 additions & 86 deletions lib/visitor-keys.json → lib/visitor-keys.js
@@ -1,289 +1,289 @@
{
"AssignmentExpression": [
export default {
AssignmentExpression: [
"left",
"right"
],
"AssignmentPattern": [
AssignmentPattern: [
"left",
"right"
],
"ArrayExpression": [
ArrayExpression: [
"elements"
],
"ArrayPattern": [
ArrayPattern: [
"elements"
],
"ArrowFunctionExpression": [
ArrowFunctionExpression: [
"params",
"body"
],
"AwaitExpression": [
AwaitExpression: [
"argument"
],
"BlockStatement": [
BlockStatement: [
"body"
],
"BinaryExpression": [
BinaryExpression: [
"left",
"right"
],
"BreakStatement": [
BreakStatement: [
"label"
],
"CallExpression": [
CallExpression: [
"callee",
"arguments"
],
"CatchClause": [
CatchClause: [
"param",
"body"
],
"ChainExpression": [
ChainExpression: [
"expression"
],
"ClassBody": [
ClassBody: [
"body"
],
"ClassDeclaration": [
ClassDeclaration: [
"id",
"superClass",
"body"
],
"ClassExpression": [
ClassExpression: [
"id",
"superClass",
"body"
],
"ConditionalExpression": [
ConditionalExpression: [
"test",
"consequent",
"alternate"
],
"ContinueStatement": [
ContinueStatement: [
"label"
],
"DebuggerStatement": [],
"DoWhileStatement": [
DebuggerStatement: [],
DoWhileStatement: [
"body",
"test"
],
"EmptyStatement": [],
"ExportAllDeclaration": [
EmptyStatement: [],
ExportAllDeclaration: [
"exported",
"source"
],
"ExportDefaultDeclaration": [
ExportDefaultDeclaration: [
"declaration"
],
"ExportNamedDeclaration": [
ExportNamedDeclaration: [
"declaration",
"specifiers",
"source"
],
"ExportSpecifier": [
ExportSpecifier: [
"exported",
"local"
],
"ExpressionStatement": [
ExpressionStatement: [
"expression"
],
"ExperimentalRestProperty": [
ExperimentalRestProperty: [
"argument"
],
"ExperimentalSpreadProperty": [
ExperimentalSpreadProperty: [
"argument"
],
"ForStatement": [
ForStatement: [
"init",
"test",
"update",
"body"
],
"ForInStatement": [
ForInStatement: [
"left",
"right",
"body"
],
"ForOfStatement": [
ForOfStatement: [
"left",
"right",
"body"
],
"FunctionDeclaration": [
FunctionDeclaration: [
"id",
"params",
"body"
],
"FunctionExpression": [
FunctionExpression: [
"id",
"params",
"body"
],
"Identifier": [],
"IfStatement": [
Identifier: [],
IfStatement: [
"test",
"consequent",
"alternate"
],
"ImportDeclaration": [
ImportDeclaration: [
"specifiers",
"source"
],
"ImportDefaultSpecifier": [
ImportDefaultSpecifier: [
"local"
],
"ImportExpression": [
ImportExpression: [
"source"
],
"ImportNamespaceSpecifier": [
ImportNamespaceSpecifier: [
"local"
],
"ImportSpecifier": [
ImportSpecifier: [
"imported",
"local"
],
"JSXAttribute": [
JSXAttribute: [
"name",
"value"
],
"JSXClosingElement": [
JSXClosingElement: [
"name"
],
"JSXElement": [
JSXElement: [
"openingElement",
"children",
"closingElement"
],
"JSXEmptyExpression": [],
"JSXExpressionContainer": [
JSXEmptyExpression: [],
JSXExpressionContainer: [
"expression"
],
"JSXIdentifier": [],
"JSXMemberExpression": [
JSXIdentifier: [],
JSXMemberExpression: [
"object",
"property"
],
"JSXNamespacedName": [
JSXNamespacedName: [
"namespace",
"name"
],
"JSXOpeningElement": [
JSXOpeningElement: [
"name",
"attributes"
],
"JSXSpreadAttribute": [
JSXSpreadAttribute: [
"argument"
],
"JSXText": [],
"JSXFragment": [
JSXText: [],
JSXFragment: [
"openingFragment",
"children",
"closingFragment"
],
"Literal": [],
"LabeledStatement": [
Literal: [],
LabeledStatement: [
"label",
"body"
],
"LogicalExpression": [
LogicalExpression: [
"left",
"right"
],
"MemberExpression": [
MemberExpression: [
"object",
"property"
],
"MetaProperty": [
MetaProperty: [
"meta",
"property"
],
"MethodDefinition": [
MethodDefinition: [
"key",
"value"
],
"NewExpression": [
NewExpression: [
"callee",
"arguments"
],
"ObjectExpression": [
ObjectExpression: [
"properties"
],
"ObjectPattern": [
ObjectPattern: [
"properties"
],
"PrivateIdentifier": [],
"Program": [
PrivateIdentifier: [],
Program: [
"body"
],
"Property": [
Property: [
"key",
"value"
],
"PropertyDefinition": [
PropertyDefinition: [
"key",
"value"
],
"RestElement": [
RestElement: [
"argument"
],
"ReturnStatement": [
ReturnStatement: [
"argument"
],
"SequenceExpression": [
SequenceExpression: [
"expressions"
],
"SpreadElement": [
SpreadElement: [
"argument"
],
"Super": [],
"SwitchStatement": [
Super: [],
SwitchStatement: [
"discriminant",
"cases"
],
"SwitchCase": [
SwitchCase: [
"test",
"consequent"
],
"TaggedTemplateExpression": [
TaggedTemplateExpression: [
"tag",
"quasi"
],
"TemplateElement": [],
"TemplateLiteral": [
TemplateElement: [],
TemplateLiteral: [
"quasis",
"expressions"
],
"ThisExpression": [],
"ThrowStatement": [
ThisExpression: [],
ThrowStatement: [
"argument"
],
"TryStatement": [
TryStatement: [
"block",
"handler",
"finalizer"
],
"UnaryExpression": [
UnaryExpression: [
"argument"
],
"UpdateExpression": [
UpdateExpression: [
"argument"
],
"VariableDeclaration": [
VariableDeclaration: [
"declarations"
],
"VariableDeclarator": [
VariableDeclarator: [
"id",
"init"
],
"WhileStatement": [
WhileStatement: [
"test",
"body"
],
"WithStatement": [
WithStatement: [
"object",
"body"
],
"YieldExpression": [
YieldExpression: [
"argument"
]
}
};

0 comments on commit b9e75d5

Please sign in to comment.