Debian Codegraph @

eslint/babel-eslint-parser/src/worker/ast-info.cjs

raw symbols SCIP
1 const ESLINT_VISITOR_KEYS = require("eslint-visitor-keys").KEYS;
2 const babel = require("./babel-core.cjs");
3
4 let visitorKeys;
5 exports.getVisitorKeys = function getVisitorKeys() {
6 if (!visitorKeys) {
7 // AST Types that are not presented in Babel AST
8 const newTypes = {
9 ChainExpression: ESLINT_VISITOR_KEYS.ChainExpression,
10 ImportExpression: ESLINT_VISITOR_KEYS.ImportExpression,
11 Literal: ESLINT_VISITOR_KEYS.Literal,
12 MethodDefinition: ["decorators"].concat(
13 ESLINT_VISITOR_KEYS.MethodDefinition,
14 ),
15 Property: ["decorators"].concat(ESLINT_VISITOR_KEYS.Property),
16 PropertyDefinition: ["decorators", "typeAnnotation"].concat(
17 ESLINT_VISITOR_KEYS.PropertyDefinition,
18 ),
19 };
20
21 // AST Types that shares `"type"` property with Babel but have different shape
22 const conflictTypes = {
23 // todo: remove this when we drop Babel 7 support
24 ClassPrivateMethod: ["decorators"].concat(
25 ESLINT_VISITOR_KEYS.MethodDefinition,
26 ),
27 ExportAllDeclaration: ESLINT_VISITOR_KEYS.ExportAllDeclaration,
28 };
29
30 visitorKeys = {
31 ...newTypes,
32 ...babel.types.VISITOR_KEYS,
33 ...conflictTypes,
34 };
35 }
36 return visitorKeys;
37 };
38
39 let tokLabels;
40 exports.getTokLabels = function getTokLabels() {
41 return (tokLabels ||= (
42 process.env.BABEL_8_BREAKING
43 ? Object.fromEntries
44 : p => p.reduce((o, [k, v]) => ({ ...o, [k]: v }), {})
45 )(Object.entries(babel.tokTypes).map(([key, tok]) => [key, tok.label])));
46 };