Debian Codegraph @

eslint/babel-eslint-plugin-development/src/rules/no-undefined-identifier.cjs

raw symbols SCIP
1 const getReferenceOrigin = require("../utils/get-reference-origin.cjs");
2 const isFromBabelTypes = require("../utils/is-from-babel-types.cjs");
3
4 function firstArgumentIsUndefinedString(argumentsArray) {
5 return (
6 argumentsArray.length > 0 &&
7 argumentsArray[0].type === "Literal" &&
8 argumentsArray[0].value === "undefined"
9 );
10 }
11
12 module.exports = {
13 meta: {
14 schema: [],
15 },
16 create(context) {
17 return {
18 CallExpression(node) {
19 const { callee } = node;
20 const scope = context.getScope();
21
22 const origin = getReferenceOrigin(callee, scope);
23 if (!origin) return;
24
25 const { name } = origin;
26 if (
27 (name === "identifier" || name === "Identifier") &&
28 firstArgumentIsUndefinedString(node.arguments) &&
29 isFromBabelTypes(origin, scope)
30 ) {
31 context.report(
32 node,
33 "Use path.scope.buildUndefinedNode() to create an undefined identifier directly.",
34 );
35 }
36 },
37 };
38 },
39 };