Debian Codegraph @

eslint/babel-eslint-plugin-development/src/utils/is-from-babel-types.cjs

raw symbols SCIP
1 const isBabelPluginFactory = require("./is-babel-plugin-factory.cjs");
2
3 // Check if a ReferenceOrigin (returned by ./get-reference-origin.js)
4 // is a reference to a @babel/types export.
5 module.exports = function isFromBabelTypes(
6 origin /*: ReferenceOrigin */,
7 scope /*: Scope */,
8 ) {
9 if (origin.kind === "import" && origin.source === "@babel/types") {
10 // imported from @babel/types
11 return true;
12 }
13
14 if (
15 origin.kind === "property" &&
16 origin.base.kind === "import" &&
17 origin.base.name === "types" &&
18 origin.base.source === "@babel/core"
19 ) {
20 // imported from @babel/core
21 return true;
22 }
23
24 if (
25 origin.kind === "property" &&
26 origin.base.kind === "param" &&
27 origin.base.index === 0
28 ) {
29 return isBabelPluginFactory(origin.base.functionNode, scope);
30 }
31
32 return false;
33 };