Commit 956c501c authored by DatHV's avatar DatHV
Browse files

update build x-app-sdk

parent 9bb8aadd
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = is;
var _shallowEqual = require("../utils/shallowEqual.js");
var _isType = require("./isType.js");
var _isPlaceholderType = require("./isPlaceholderType.js");
var _index = require("../definitions/index.js");
function is(type, node, opts) {
if (!node) return false;
const matches = (0, _isType.default)(node.type, type);
if (!matches) {
if (!opts && node.type === "Placeholder" && type in _index.FLIPPED_ALIAS_KEYS) {
return (0, _isPlaceholderType.default)(node.expectedNode, type);
}
return false;
}
if (opts === undefined) {
return true;
} else {
return (0, _shallowEqual.default)(node, opts);
}
}
//# sourceMappingURL=is.js.map
{"version":3,"names":["_shallowEqual","require","_isType","_isPlaceholderType","_index","is","type","node","opts","matches","isType","FLIPPED_ALIAS_KEYS","isPlaceholderType","expectedNode","undefined","shallowEqual"],"sources":["../../src/validators/is.ts"],"sourcesContent":["import shallowEqual from \"../utils/shallowEqual.ts\";\nimport isType from \"./isType.ts\";\nimport isPlaceholderType from \"./isPlaceholderType.ts\";\nimport { FLIPPED_ALIAS_KEYS } from \"../definitions/index.ts\";\nimport type * as t from \"../index.ts\";\n\nexport default function is<T extends t.Node[\"type\"]>(\n type: T,\n node: t.Node | null | undefined,\n opts?: undefined,\n): node is Extract<t.Node, { type: T }>;\n\nexport default function is<\n T extends t.Node[\"type\"],\n P extends Extract<t.Node, { type: T }>,\n>(type: T, n: t.Node | null | undefined, required: Partial<P>): n is P;\n\nexport default function is<P extends t.Node>(\n type: string,\n node: t.Node | null | undefined,\n opts: Partial<P>,\n): node is P;\n\nexport default function is(\n type: string,\n node: t.Node | null | undefined,\n opts?: Partial<t.Node>,\n): node is t.Node;\n/**\n * Returns whether `node` is of given `type`.\n *\n * For better performance, use this instead of `is[Type]` when `type` is unknown.\n */\nexport default function is(\n type: string,\n node: t.Node | null | undefined,\n opts?: Partial<t.Node>,\n): node is t.Node {\n if (!node) return false;\n\n const matches = isType(node.type, type);\n if (!matches) {\n if (!opts && node.type === \"Placeholder\" && type in FLIPPED_ALIAS_KEYS) {\n // We can only return true if the placeholder doesn't replace a real node,\n // but it replaces a category of nodes (an alias).\n //\n // t.is(\"Identifier\", node) gives some guarantees about node's shape, so we\n // can't say that Placeholder(expectedNode: \"Identifier\") is an identifier\n // because it doesn't have the same properties.\n // On the other hand, t.is(\"Expression\", node) doesn't say anything about\n // the shape of node because Expression can be many different nodes: we can,\n // and should, safely report expression placeholders as Expressions.\n return isPlaceholderType(node.expectedNode, type);\n }\n return false;\n }\n\n if (opts === undefined) {\n return true;\n } else {\n return shallowEqual(node, opts);\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,aAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,kBAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AA8Be,SAASI,EAAEA,CACxBC,IAAY,EACZC,IAA+B,EAC/BC,IAAsB,EACN;EAChB,IAAI,CAACD,IAAI,EAAE,OAAO,KAAK;EAEvB,MAAME,OAAO,GAAG,IAAAC,eAAM,EAACH,IAAI,CAACD,IAAI,EAAEA,IAAI,CAAC;EACvC,IAAI,CAACG,OAAO,EAAE;IACZ,IAAI,CAACD,IAAI,IAAID,IAAI,CAACD,IAAI,KAAK,aAAa,IAAIA,IAAI,IAAIK,yBAAkB,EAAE;MAUtE,OAAO,IAAAC,0BAAiB,EAACL,IAAI,CAACM,YAAY,EAAEP,IAAI,CAAC;IACnD;IACA,OAAO,KAAK;EACd;EAEA,IAAIE,IAAI,KAAKM,SAAS,EAAE;IACtB,OAAO,IAAI;EACb,CAAC,MAAM;IACL,OAAO,IAAAC,qBAAY,EAACR,IAAI,EAAEC,IAAI,CAAC;EACjC;AACF","ignoreList":[]}
\ No newline at end of file
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = isBinding;
var _getBindingIdentifiers = require("../retrievers/getBindingIdentifiers.js");
function isBinding(node, parent, grandparent) {
if (grandparent && node.type === "Identifier" && parent.type === "ObjectProperty" && grandparent.type === "ObjectExpression") {
return false;
}
const keys = _getBindingIdentifiers.default.keys[parent.type];
if (keys) {
for (let i = 0; i < keys.length; i++) {
const key = keys[i];
const val = parent[key];
if (Array.isArray(val)) {
if (val.includes(node)) return true;
} else {
if (val === node) return true;
}
}
}
return false;
}
//# sourceMappingURL=isBinding.js.map
{"version":3,"names":["_getBindingIdentifiers","require","isBinding","node","parent","grandparent","type","keys","getBindingIdentifiers","i","length","key","val","Array","isArray","includes"],"sources":["../../src/validators/isBinding.ts"],"sourcesContent":["import getBindingIdentifiers from \"../retrievers/getBindingIdentifiers.ts\";\nimport type * as t from \"../index.ts\";\n/**\n * Check if the input `node` is a binding identifier.\n */\nexport default function isBinding(\n node: t.Node,\n parent: t.Node,\n grandparent?: t.Node,\n): boolean {\n if (\n grandparent &&\n node.type === \"Identifier\" &&\n parent.type === \"ObjectProperty\" &&\n grandparent.type === \"ObjectExpression\"\n ) {\n // We need to special-case this, because getBindingIdentifiers\n // has an ObjectProperty->value entry for destructuring patterns.\n return false;\n }\n\n const keys = getBindingIdentifiers.keys[parent.type];\n if (keys) {\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i];\n const val =\n // @ts-expect-error key must present in parent\n parent[key];\n if (Array.isArray(val)) {\n if (val.includes(node)) return true;\n } else {\n if (val === node) return true;\n }\n }\n }\n\n return false;\n}\n"],"mappings":";;;;;;AAAA,IAAAA,sBAAA,GAAAC,OAAA;AAKe,SAASC,SAASA,CAC/BC,IAAY,EACZC,MAAc,EACdC,WAAoB,EACX;EACT,IACEA,WAAW,IACXF,IAAI,CAACG,IAAI,KAAK,YAAY,IAC1BF,MAAM,CAACE,IAAI,KAAK,gBAAgB,IAChCD,WAAW,CAACC,IAAI,KAAK,kBAAkB,EACvC;IAGA,OAAO,KAAK;EACd;EAEA,MAAMC,IAAI,GAAGC,8BAAqB,CAACD,IAAI,CAACH,MAAM,CAACE,IAAI,CAAC;EACpD,IAAIC,IAAI,EAAE;IACR,KAAK,IAAIE,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGF,IAAI,CAACG,MAAM,EAAED,CAAC,EAAE,EAAE;MACpC,MAAME,GAAG,GAAGJ,IAAI,CAACE,CAAC,CAAC;MACnB,MAAMG,GAAG,GAEPR,MAAM,CAACO,GAAG,CAAC;MACb,IAAIE,KAAK,CAACC,OAAO,CAACF,GAAG,CAAC,EAAE;QACtB,IAAIA,GAAG,CAACG,QAAQ,CAACZ,IAAI,CAAC,EAAE,OAAO,IAAI;MACrC,CAAC,MAAM;QACL,IAAIS,GAAG,KAAKT,IAAI,EAAE,OAAO,IAAI;MAC/B;IACF;EACF;EAEA,OAAO,KAAK;AACd","ignoreList":[]}
\ No newline at end of file
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = isBlockScoped;
var _index = require("./generated/index.js");
var _isLet = require("./isLet.js");
function isBlockScoped(node) {
return (0, _index.isFunctionDeclaration)(node) || (0, _index.isClassDeclaration)(node) || (0, _isLet.default)(node);
}
//# sourceMappingURL=isBlockScoped.js.map
{"version":3,"names":["_index","require","_isLet","isBlockScoped","node","isFunctionDeclaration","isClassDeclaration","isLet"],"sources":["../../src/validators/isBlockScoped.ts"],"sourcesContent":["import {\n isClassDeclaration,\n isFunctionDeclaration,\n} from \"./generated/index.ts\";\nimport isLet from \"./isLet.ts\";\nimport type * as t from \"../index.ts\";\n\n/**\n * Check if the input `node` is block scoped.\n */\nexport default function isBlockScoped(node: t.Node): boolean {\n return isFunctionDeclaration(node) || isClassDeclaration(node) || isLet(node);\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAIA,IAAAC,MAAA,GAAAD,OAAA;AAMe,SAASE,aAAaA,CAACC,IAAY,EAAW;EAC3D,OAAO,IAAAC,4BAAqB,EAACD,IAAI,CAAC,IAAI,IAAAE,yBAAkB,EAACF,IAAI,CAAC,IAAI,IAAAG,cAAK,EAACH,IAAI,CAAC;AAC/E","ignoreList":[]}
\ No newline at end of file
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = isImmutable;
var _isType = require("./isType.js");
var _index = require("./generated/index.js");
function isImmutable(node) {
if ((0, _isType.default)(node.type, "Immutable")) return true;
if ((0, _index.isIdentifier)(node)) {
if (node.name === "undefined") {
return true;
} else {
return false;
}
}
return false;
}
//# sourceMappingURL=isImmutable.js.map
{"version":3,"names":["_isType","require","_index","isImmutable","node","isType","type","isIdentifier","name"],"sources":["../../src/validators/isImmutable.ts"],"sourcesContent":["import isType from \"./isType.ts\";\nimport { isIdentifier } from \"./generated/index.ts\";\nimport type * as t from \"../index.ts\";\n\n/**\n * Check if the input `node` is definitely immutable.\n */\nexport default function isImmutable(node: t.Node): boolean {\n if (isType(node.type, \"Immutable\")) return true;\n\n if (isIdentifier(node)) {\n if (node.name === \"undefined\") {\n // immutable!\n return true;\n } else {\n // no idea...\n return false;\n }\n }\n\n return false;\n}\n"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAMe,SAASE,WAAWA,CAACC,IAAY,EAAW;EACzD,IAAI,IAAAC,eAAM,EAACD,IAAI,CAACE,IAAI,EAAE,WAAW,CAAC,EAAE,OAAO,IAAI;EAE/C,IAAI,IAAAC,mBAAY,EAACH,IAAI,CAAC,EAAE;IACtB,IAAIA,IAAI,CAACI,IAAI,KAAK,WAAW,EAAE;MAE7B,OAAO,IAAI;IACb,CAAC,MAAM;MAEL,OAAO,KAAK;IACd;EACF;EAEA,OAAO,KAAK;AACd","ignoreList":[]}
\ No newline at end of file
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = isLet;
var _index = require("./generated/index.js");
{
var BLOCK_SCOPED_SYMBOL = Symbol.for("var used to be block scoped");
}
function isLet(node) {
{
return (0, _index.isVariableDeclaration)(node) && (node.kind !== "var" || node[BLOCK_SCOPED_SYMBOL]);
}
}
//# sourceMappingURL=isLet.js.map
{"version":3,"names":["_index","require","BLOCK_SCOPED_SYMBOL","Symbol","for","isLet","node","isVariableDeclaration","kind"],"sources":["../../src/validators/isLet.ts"],"sourcesContent":["import { isVariableDeclaration } from \"./generated/index.ts\";\nimport type * as t from \"../index.ts\";\n\nif (!process.env.BABEL_8_BREAKING) {\n // eslint-disable-next-line no-var\n var BLOCK_SCOPED_SYMBOL = Symbol.for(\"var used to be block scoped\");\n}\n\n/**\n * Check if the input `node` is a `let` variable declaration.\n */\nexport default function isLet(node: t.Node): boolean {\n if (process.env.BABEL_8_BREAKING) {\n return isVariableDeclaration(node) && node.kind !== \"var\";\n } else {\n return (\n isVariableDeclaration(node) &&\n (node.kind !== \"var\" ||\n // @ts-expect-error Fixme: document private properties\n node[BLOCK_SCOPED_SYMBOL])\n );\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAGmC;EAEjC,IAAIC,mBAAmB,GAAGC,MAAM,CAACC,GAAG,CAAC,6BAA6B,CAAC;AACrE;AAKe,SAASC,KAAKA,CAACC,IAAY,EAAW;EAG5C;IACL,OACE,IAAAC,4BAAqB,EAACD,IAAI,CAAC,KAC1BA,IAAI,CAACE,IAAI,KAAK,KAAK,IAElBF,IAAI,CAACJ,mBAAmB,CAAC,CAAC;EAEhC;AACF","ignoreList":[]}
\ No newline at end of file
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = isNode;
var _index = require("../definitions/index.js");
function isNode(node) {
return !!(node && _index.VISITOR_KEYS[node.type]);
}
//# sourceMappingURL=isNode.js.map
{"version":3,"names":["_index","require","isNode","node","VISITOR_KEYS","type"],"sources":["../../src/validators/isNode.ts"],"sourcesContent":["import { VISITOR_KEYS } from \"../definitions/index.ts\";\nimport type * as t from \"../index.ts\";\n\nexport default function isNode(node: any): node is t.Node {\n return !!(node && VISITOR_KEYS[node.type]);\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAGe,SAASC,MAAMA,CAACC,IAAS,EAAkB;EACxD,OAAO,CAAC,EAAEA,IAAI,IAAIC,mBAAY,CAACD,IAAI,CAACE,IAAI,CAAC,CAAC;AAC5C","ignoreList":[]}
\ No newline at end of file
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = isNodesEquivalent;
var _index = require("../definitions/index.js");
function isNodesEquivalent(a, b) {
if (typeof a !== "object" || typeof b !== "object" || a == null || b == null) {
return a === b;
}
if (a.type !== b.type) {
return false;
}
const fields = Object.keys(_index.NODE_FIELDS[a.type] || a.type);
const visitorKeys = _index.VISITOR_KEYS[a.type];
for (const field of fields) {
const val_a = a[field];
const val_b = b[field];
if (typeof val_a !== typeof val_b) {
return false;
}
if (val_a == null && val_b == null) {
continue;
} else if (val_a == null || val_b == null) {
return false;
}
if (Array.isArray(val_a)) {
if (!Array.isArray(val_b)) {
return false;
}
if (val_a.length !== val_b.length) {
return false;
}
for (let i = 0; i < val_a.length; i++) {
if (!isNodesEquivalent(val_a[i], val_b[i])) {
return false;
}
}
continue;
}
if (typeof val_a === "object" && !(visitorKeys != null && visitorKeys.includes(field))) {
for (const key of Object.keys(val_a)) {
if (val_a[key] !== val_b[key]) {
return false;
}
}
continue;
}
if (!isNodesEquivalent(val_a, val_b)) {
return false;
}
}
return true;
}
//# sourceMappingURL=isNodesEquivalent.js.map
{"version":3,"names":["_index","require","isNodesEquivalent","a","b","type","fields","Object","keys","NODE_FIELDS","visitorKeys","VISITOR_KEYS","field","val_a","val_b","Array","isArray","length","i","includes","key"],"sources":["../../src/validators/isNodesEquivalent.ts"],"sourcesContent":["import { NODE_FIELDS, VISITOR_KEYS } from \"../definitions/index.ts\";\nimport type * as t from \"../index.ts\";\n\n/**\n * Check if two nodes are equivalent\n */\nexport default function isNodesEquivalent<T extends Partial<t.Node>>(\n a: T,\n b: any,\n): b is T {\n if (\n typeof a !== \"object\" ||\n typeof b !== \"object\" ||\n a == null ||\n b == null\n ) {\n return a === b;\n }\n\n if (a.type !== b.type) {\n return false;\n }\n\n const fields = Object.keys(NODE_FIELDS[a.type] || a.type);\n const visitorKeys = VISITOR_KEYS[a.type];\n\n for (const field of fields) {\n const val_a =\n // @ts-expect-error field must present in a\n a[field];\n const val_b = b[field];\n if (typeof val_a !== typeof val_b) {\n return false;\n }\n if (val_a == null && val_b == null) {\n continue;\n } else if (val_a == null || val_b == null) {\n return false;\n }\n\n if (Array.isArray(val_a)) {\n if (!Array.isArray(val_b)) {\n return false;\n }\n if (val_a.length !== val_b.length) {\n return false;\n }\n\n for (let i = 0; i < val_a.length; i++) {\n if (!isNodesEquivalent(val_a[i], val_b[i])) {\n return false;\n }\n }\n continue;\n }\n\n if (typeof val_a === \"object\" && !visitorKeys?.includes(field)) {\n for (const key of Object.keys(val_a)) {\n if (val_a[key] !== val_b[key]) {\n return false;\n }\n }\n continue;\n }\n\n if (!isNodesEquivalent(val_a, val_b)) {\n return false;\n }\n }\n\n return true;\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAMe,SAASC,iBAAiBA,CACvCC,CAAI,EACJC,CAAM,EACE;EACR,IACE,OAAOD,CAAC,KAAK,QAAQ,IACrB,OAAOC,CAAC,KAAK,QAAQ,IACrBD,CAAC,IAAI,IAAI,IACTC,CAAC,IAAI,IAAI,EACT;IACA,OAAOD,CAAC,KAAKC,CAAC;EAChB;EAEA,IAAID,CAAC,CAACE,IAAI,KAAKD,CAAC,CAACC,IAAI,EAAE;IACrB,OAAO,KAAK;EACd;EAEA,MAAMC,MAAM,GAAGC,MAAM,CAACC,IAAI,CAACC,kBAAW,CAACN,CAAC,CAACE,IAAI,CAAC,IAAIF,CAAC,CAACE,IAAI,CAAC;EACzD,MAAMK,WAAW,GAAGC,mBAAY,CAACR,CAAC,CAACE,IAAI,CAAC;EAExC,KAAK,MAAMO,KAAK,IAAIN,MAAM,EAAE;IAC1B,MAAMO,KAAK,GAETV,CAAC,CAACS,KAAK,CAAC;IACV,MAAME,KAAK,GAAGV,CAAC,CAACQ,KAAK,CAAC;IACtB,IAAI,OAAOC,KAAK,KAAK,OAAOC,KAAK,EAAE;MACjC,OAAO,KAAK;IACd;IACA,IAAID,KAAK,IAAI,IAAI,IAAIC,KAAK,IAAI,IAAI,EAAE;MAClC;IACF,CAAC,MAAM,IAAID,KAAK,IAAI,IAAI,IAAIC,KAAK,IAAI,IAAI,EAAE;MACzC,OAAO,KAAK;IACd;IAEA,IAAIC,KAAK,CAACC,OAAO,CAACH,KAAK,CAAC,EAAE;MACxB,IAAI,CAACE,KAAK,CAACC,OAAO,CAACF,KAAK,CAAC,EAAE;QACzB,OAAO,KAAK;MACd;MACA,IAAID,KAAK,CAACI,MAAM,KAAKH,KAAK,CAACG,MAAM,EAAE;QACjC,OAAO,KAAK;MACd;MAEA,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGL,KAAK,CAACI,MAAM,EAAEC,CAAC,EAAE,EAAE;QACrC,IAAI,CAAChB,iBAAiB,CAACW,KAAK,CAACK,CAAC,CAAC,EAAEJ,KAAK,CAACI,CAAC,CAAC,CAAC,EAAE;UAC1C,OAAO,KAAK;QACd;MACF;MACA;IACF;IAEA,IAAI,OAAOL,KAAK,KAAK,QAAQ,IAAI,EAACH,WAAW,YAAXA,WAAW,CAAES,QAAQ,CAACP,KAAK,CAAC,GAAE;MAC9D,KAAK,MAAMQ,GAAG,IAAIb,MAAM,CAACC,IAAI,CAACK,KAAK,CAAC,EAAE;QACpC,IAAIA,KAAK,CAACO,GAAG,CAAC,KAAKN,KAAK,CAACM,GAAG,CAAC,EAAE;UAC7B,OAAO,KAAK;QACd;MACF;MACA;IACF;IAEA,IAAI,CAAClB,iBAAiB,CAACW,KAAK,EAAEC,KAAK,CAAC,EAAE;MACpC,OAAO,KAAK;IACd;EACF;EAEA,OAAO,IAAI;AACb","ignoreList":[]}
\ No newline at end of file
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = isPlaceholderType;
var _index = require("../definitions/index.js");
function isPlaceholderType(placeholderType, targetType) {
if (placeholderType === targetType) return true;
const aliases = _index.PLACEHOLDERS_ALIAS[placeholderType];
if (aliases != null && aliases.includes(targetType)) return true;
return false;
}
//# sourceMappingURL=isPlaceholderType.js.map
{"version":3,"names":["_index","require","isPlaceholderType","placeholderType","targetType","aliases","PLACEHOLDERS_ALIAS","includes"],"sources":["../../src/validators/isPlaceholderType.ts"],"sourcesContent":["import { PLACEHOLDERS_ALIAS } from \"../definitions/index.ts\";\n\n/**\n * Test if a `placeholderType` is a `targetType` or if `targetType` is an alias of `placeholderType`.\n */\nexport default function isPlaceholderType(\n placeholderType: string,\n targetType: string,\n): boolean {\n if (placeholderType === targetType) return true;\n\n const aliases: Array<string> | undefined =\n PLACEHOLDERS_ALIAS[placeholderType];\n if (aliases?.includes(targetType)) return true;\n\n return false;\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAKe,SAASC,iBAAiBA,CACvCC,eAAuB,EACvBC,UAAkB,EACT;EACT,IAAID,eAAe,KAAKC,UAAU,EAAE,OAAO,IAAI;EAE/C,MAAMC,OAAkC,GACtCC,yBAAkB,CAACH,eAAe,CAAC;EACrC,IAAIE,OAAO,YAAPA,OAAO,CAAEE,QAAQ,CAACH,UAAU,CAAC,EAAE,OAAO,IAAI;EAE9C,OAAO,KAAK;AACd","ignoreList":[]}
\ No newline at end of file
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = isReferenced;
function isReferenced(node, parent, grandparent) {
switch (parent.type) {
case "MemberExpression":
case "OptionalMemberExpression":
if (parent.property === node) {
return !!parent.computed;
}
return parent.object === node;
case "JSXMemberExpression":
return parent.object === node;
case "VariableDeclarator":
return parent.init === node;
case "ArrowFunctionExpression":
return parent.body === node;
case "PrivateName":
return false;
case "ClassMethod":
case "ClassPrivateMethod":
case "ObjectMethod":
if (parent.key === node) {
return !!parent.computed;
}
return false;
case "ObjectProperty":
if (parent.key === node) {
return !!parent.computed;
}
return !grandparent || grandparent.type !== "ObjectPattern";
case "ClassProperty":
case "ClassAccessorProperty":
if (parent.key === node) {
return !!parent.computed;
}
return true;
case "ClassPrivateProperty":
return parent.key !== node;
case "ClassDeclaration":
case "ClassExpression":
return parent.superClass === node;
case "AssignmentExpression":
return parent.right === node;
case "AssignmentPattern":
return parent.right === node;
case "LabeledStatement":
return false;
case "CatchClause":
return false;
case "RestElement":
return false;
case "BreakStatement":
case "ContinueStatement":
return false;
case "FunctionDeclaration":
case "FunctionExpression":
return false;
case "ExportNamespaceSpecifier":
case "ExportDefaultSpecifier":
return false;
case "ExportSpecifier":
if (grandparent != null && grandparent.source) {
return false;
}
return parent.local === node;
case "ImportDefaultSpecifier":
case "ImportNamespaceSpecifier":
case "ImportSpecifier":
return false;
case "ImportAttribute":
return false;
case "JSXAttribute":
return false;
case "ObjectPattern":
case "ArrayPattern":
return false;
case "MetaProperty":
return false;
case "ObjectTypeProperty":
return parent.key !== node;
case "TSEnumMember":
return parent.id !== node;
case "TSPropertySignature":
if (parent.key === node) {
return !!parent.computed;
}
return true;
}
return true;
}
//# sourceMappingURL=isReferenced.js.map
{"version":3,"names":["isReferenced","node","parent","grandparent","type","property","computed","object","init","body","key","superClass","right","source","local","id"],"sources":["../../src/validators/isReferenced.ts"],"sourcesContent":["import type * as t from \"../index.ts\";\n\n/**\n * Check if the input `node` is a reference to a bound variable.\n */\nexport default function isReferenced(\n node: t.Node,\n parent: t.Node,\n grandparent?: t.Node,\n): boolean {\n switch (parent.type) {\n // yes: PARENT[NODE]\n // yes: NODE.child\n // no: parent.NODE\n case \"MemberExpression\":\n case \"OptionalMemberExpression\":\n if (parent.property === node) {\n return !!parent.computed;\n }\n return parent.object === node;\n\n case \"JSXMemberExpression\":\n return parent.object === node;\n // no: let NODE = init;\n // yes: let id = NODE;\n case \"VariableDeclarator\":\n return parent.init === node;\n\n // yes: () => NODE\n // no: (NODE) => {}\n case \"ArrowFunctionExpression\":\n return parent.body === node;\n\n // no: class { #NODE; }\n // no: class { get #NODE() {} }\n // no: class { #NODE() {} }\n // no: class { fn() { return this.#NODE; } }\n case \"PrivateName\":\n return false;\n\n // no: class { NODE() {} }\n // yes: class { [NODE]() {} }\n // no: class { foo(NODE) {} }\n case \"ClassMethod\":\n case \"ClassPrivateMethod\":\n case \"ObjectMethod\":\n if (parent.key === node) {\n return !!parent.computed;\n }\n return false;\n\n // yes: { [NODE]: \"\" }\n // no: { NODE: \"\" }\n // depends: { NODE }\n // depends: { key: NODE }\n case \"ObjectProperty\":\n if (parent.key === node) {\n return !!parent.computed;\n }\n // parent.value === node\n return !grandparent || grandparent.type !== \"ObjectPattern\";\n // no: class { NODE = value; }\n // yes: class { [NODE] = value; }\n // yes: class { key = NODE; }\n case \"ClassProperty\":\n case \"ClassAccessorProperty\":\n if (parent.key === node) {\n return !!parent.computed;\n }\n return true;\n case \"ClassPrivateProperty\":\n return parent.key !== node;\n\n // no: class NODE {}\n // yes: class Foo extends NODE {}\n case \"ClassDeclaration\":\n case \"ClassExpression\":\n return parent.superClass === node;\n\n // yes: left = NODE;\n // no: NODE = right;\n case \"AssignmentExpression\":\n return parent.right === node;\n\n // no: [NODE = foo] = [];\n // yes: [foo = NODE] = [];\n case \"AssignmentPattern\":\n return parent.right === node;\n\n // no: NODE: for (;;) {}\n case \"LabeledStatement\":\n return false;\n\n // no: try {} catch (NODE) {}\n case \"CatchClause\":\n return false;\n\n // no: function foo(...NODE) {}\n case \"RestElement\":\n return false;\n\n case \"BreakStatement\":\n case \"ContinueStatement\":\n return false;\n\n // no: function NODE() {}\n // no: function foo(NODE) {}\n case \"FunctionDeclaration\":\n case \"FunctionExpression\":\n return false;\n\n // no: export NODE from \"foo\";\n // no: export * as NODE from \"foo\";\n case \"ExportNamespaceSpecifier\":\n case \"ExportDefaultSpecifier\":\n return false;\n\n // no: export { foo as NODE };\n // yes: export { NODE as foo };\n // no: export { NODE as foo } from \"foo\";\n case \"ExportSpecifier\":\n // @ts-expect-error todo(flow->ts): Property 'source' does not exist on type 'AnyTypeAnnotation'.\n if (grandparent?.source) {\n return false;\n }\n return parent.local === node;\n\n // no: import NODE from \"foo\";\n // no: import * as NODE from \"foo\";\n // no: import { NODE as foo } from \"foo\";\n // no: import { foo as NODE } from \"foo\";\n // no: import NODE from \"bar\";\n case \"ImportDefaultSpecifier\":\n case \"ImportNamespaceSpecifier\":\n case \"ImportSpecifier\":\n return false;\n\n // no: import \"foo\" assert { NODE: \"json\" }\n case \"ImportAttribute\":\n return false;\n\n // no: <div NODE=\"foo\" />\n case \"JSXAttribute\":\n return false;\n\n // no: [NODE] = [];\n // no: ({ NODE }) = [];\n case \"ObjectPattern\":\n case \"ArrayPattern\":\n return false;\n\n // no: new.NODE\n // no: NODE.target\n case \"MetaProperty\":\n return false;\n\n // yes: type X = { someProperty: NODE }\n // no: type X = { NODE: OtherType }\n case \"ObjectTypeProperty\":\n return parent.key !== node;\n\n // yes: enum X { Foo = NODE }\n // no: enum X { NODE }\n case \"TSEnumMember\":\n return parent.id !== node;\n\n // yes: { [NODE]: value }\n // no: { NODE: value }\n case \"TSPropertySignature\":\n if (parent.key === node) {\n return !!parent.computed;\n }\n\n return true;\n }\n\n return true;\n}\n"],"mappings":";;;;;;AAKe,SAASA,YAAYA,CAClCC,IAAY,EACZC,MAAc,EACdC,WAAoB,EACX;EACT,QAAQD,MAAM,CAACE,IAAI;IAIjB,KAAK,kBAAkB;IACvB,KAAK,0BAA0B;MAC7B,IAAIF,MAAM,CAACG,QAAQ,KAAKJ,IAAI,EAAE;QAC5B,OAAO,CAAC,CAACC,MAAM,CAACI,QAAQ;MAC1B;MACA,OAAOJ,MAAM,CAACK,MAAM,KAAKN,IAAI;IAE/B,KAAK,qBAAqB;MACxB,OAAOC,MAAM,CAACK,MAAM,KAAKN,IAAI;IAG/B,KAAK,oBAAoB;MACvB,OAAOC,MAAM,CAACM,IAAI,KAAKP,IAAI;IAI7B,KAAK,yBAAyB;MAC5B,OAAOC,MAAM,CAACO,IAAI,KAAKR,IAAI;IAM7B,KAAK,aAAa;MAChB,OAAO,KAAK;IAKd,KAAK,aAAa;IAClB,KAAK,oBAAoB;IACzB,KAAK,cAAc;MACjB,IAAIC,MAAM,CAACQ,GAAG,KAAKT,IAAI,EAAE;QACvB,OAAO,CAAC,CAACC,MAAM,CAACI,QAAQ;MAC1B;MACA,OAAO,KAAK;IAMd,KAAK,gBAAgB;MACnB,IAAIJ,MAAM,CAACQ,GAAG,KAAKT,IAAI,EAAE;QACvB,OAAO,CAAC,CAACC,MAAM,CAACI,QAAQ;MAC1B;MAEA,OAAO,CAACH,WAAW,IAAIA,WAAW,CAACC,IAAI,KAAK,eAAe;IAI7D,KAAK,eAAe;IACpB,KAAK,uBAAuB;MAC1B,IAAIF,MAAM,CAACQ,GAAG,KAAKT,IAAI,EAAE;QACvB,OAAO,CAAC,CAACC,MAAM,CAACI,QAAQ;MAC1B;MACA,OAAO,IAAI;IACb,KAAK,sBAAsB;MACzB,OAAOJ,MAAM,CAACQ,GAAG,KAAKT,IAAI;IAI5B,KAAK,kBAAkB;IACvB,KAAK,iBAAiB;MACpB,OAAOC,MAAM,CAACS,UAAU,KAAKV,IAAI;IAInC,KAAK,sBAAsB;MACzB,OAAOC,MAAM,CAACU,KAAK,KAAKX,IAAI;IAI9B,KAAK,mBAAmB;MACtB,OAAOC,MAAM,CAACU,KAAK,KAAKX,IAAI;IAG9B,KAAK,kBAAkB;MACrB,OAAO,KAAK;IAGd,KAAK,aAAa;MAChB,OAAO,KAAK;IAGd,KAAK,aAAa;MAChB,OAAO,KAAK;IAEd,KAAK,gBAAgB;IACrB,KAAK,mBAAmB;MACtB,OAAO,KAAK;IAId,KAAK,qBAAqB;IAC1B,KAAK,oBAAoB;MACvB,OAAO,KAAK;IAId,KAAK,0BAA0B;IAC/B,KAAK,wBAAwB;MAC3B,OAAO,KAAK;IAKd,KAAK,iBAAiB;MAEpB,IAAIE,WAAW,YAAXA,WAAW,CAAEU,MAAM,EAAE;QACvB,OAAO,KAAK;MACd;MACA,OAAOX,MAAM,CAACY,KAAK,KAAKb,IAAI;IAO9B,KAAK,wBAAwB;IAC7B,KAAK,0BAA0B;IAC/B,KAAK,iBAAiB;MACpB,OAAO,KAAK;IAGd,KAAK,iBAAiB;MACpB,OAAO,KAAK;IAGd,KAAK,cAAc;MACjB,OAAO,KAAK;IAId,KAAK,eAAe;IACpB,KAAK,cAAc;MACjB,OAAO,KAAK;IAId,KAAK,cAAc;MACjB,OAAO,KAAK;IAId,KAAK,oBAAoB;MACvB,OAAOC,MAAM,CAACQ,GAAG,KAAKT,IAAI;IAI5B,KAAK,cAAc;MACjB,OAAOC,MAAM,CAACa,EAAE,KAAKd,IAAI;IAI3B,KAAK,qBAAqB;MACxB,IAAIC,MAAM,CAACQ,GAAG,KAAKT,IAAI,EAAE;QACvB,OAAO,CAAC,CAACC,MAAM,CAACI,QAAQ;MAC1B;MAEA,OAAO,IAAI;EACf;EAEA,OAAO,IAAI;AACb","ignoreList":[]}
\ No newline at end of file
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = isScope;
var _index = require("./generated/index.js");
function isScope(node, parent) {
if ((0, _index.isBlockStatement)(node) && ((0, _index.isFunction)(parent) || (0, _index.isCatchClause)(parent))) {
return false;
}
if ((0, _index.isPattern)(node) && ((0, _index.isFunction)(parent) || (0, _index.isCatchClause)(parent))) {
return true;
}
return (0, _index.isScopable)(node);
}
//# sourceMappingURL=isScope.js.map
{"version":3,"names":["_index","require","isScope","node","parent","isBlockStatement","isFunction","isCatchClause","isPattern","isScopable"],"sources":["../../src/validators/isScope.ts"],"sourcesContent":["import {\n isFunction,\n isCatchClause,\n isBlockStatement,\n isScopable,\n isPattern,\n} from \"./generated/index.ts\";\nimport type * as t from \"../index.ts\";\n\n/**\n * Check if the input `node` is a scope.\n */\nexport default function isScope(node: t.Node, parent: t.Node): boolean {\n // If a BlockStatement is an immediate descendent of a Function/CatchClause, it must be in the body.\n // Hence we skipped the parentKey === \"params\" check\n if (isBlockStatement(node) && (isFunction(parent) || isCatchClause(parent))) {\n return false;\n }\n\n // If a Pattern is an immediate descendent of a Function/CatchClause, it must be in the params.\n // Hence we skipped the parentKey === \"params\" check\n if (isPattern(node) && (isFunction(parent) || isCatchClause(parent))) {\n return true;\n }\n\n return isScopable(node);\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAYe,SAASC,OAAOA,CAACC,IAAY,EAAEC,MAAc,EAAW;EAGrE,IAAI,IAAAC,uBAAgB,EAACF,IAAI,CAAC,KAAK,IAAAG,iBAAU,EAACF,MAAM,CAAC,IAAI,IAAAG,oBAAa,EAACH,MAAM,CAAC,CAAC,EAAE;IAC3E,OAAO,KAAK;EACd;EAIA,IAAI,IAAAI,gBAAS,EAACL,IAAI,CAAC,KAAK,IAAAG,iBAAU,EAACF,MAAM,CAAC,IAAI,IAAAG,oBAAa,EAACH,MAAM,CAAC,CAAC,EAAE;IACpE,OAAO,IAAI;EACb;EAEA,OAAO,IAAAK,iBAAU,EAACN,IAAI,CAAC;AACzB","ignoreList":[]}
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment