Files
node/tools/node_modules/@babel/eslint-parser/lib/worker/handle-message.cjs
T
Antoine du Hamel f26c2ce0a1 tools: add support for import assertions in linter
PR-URL: https://github.com/nodejs/node/pull/39924
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Bradley Farias <bradley.meck@gmail.com>
Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Zijian Liu <lxxyxzj@gmail.com>
2021-09-03 07:44:26 -07:00

42 lines
1.0 KiB
JavaScript

const babel = require("./babel-core.cjs");
const maybeParse = require("./maybeParse.cjs");
const {
getVisitorKeys,
getTokLabels
} = require("./ast-info.cjs");
const {
normalizeBabelParseConfig,
normalizeBabelParseConfigSync
} = require("./configuration.cjs");
module.exports = function handleMessage(action, payload) {
switch (action) {
case "GET_VERSION":
return babel.version;
case "GET_TYPES_INFO":
return {
FLOW_FLIPPED_ALIAS_KEYS: babel.types.FLIPPED_ALIAS_KEYS.Flow,
VISITOR_KEYS: babel.types.VISITOR_KEYS
};
case "GET_TOKEN_LABELS":
return getTokLabels();
case "GET_VISITOR_KEYS":
return getVisitorKeys();
case "MAYBE_PARSE":
return normalizeBabelParseConfig(payload.options).then(options => maybeParse(payload.code, options));
case "MAYBE_PARSE_SYNC":
{
return maybeParse(payload.code, normalizeBabelParseConfigSync(payload.options));
}
}
throw new Error(`Unknown internal parser worker action: ${action}`);
};