2 var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3 if (k2 === undefined) k2 = k;
4 Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5 }) : (function(o, m, k, k2) {
6 if (k2 === undefined) k2 = k;
9 var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10 Object.defineProperty(o, "default", { enumerable: true, value: v });
14 var __importStar = (this && this.__importStar) || function (mod) {
15 if (mod && mod.__esModule) return mod;
17 if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18 __setModuleDefault(result, mod);
21 Object.defineProperty(exports, "__esModule", { value: true });
22 exports.isParenthesized = exports.hasSideEffect = exports.getStringIfConstant = exports.getStaticValue = exports.getPropertyName = exports.getFunctionNameWithKind = exports.getFunctionHeadLocation = void 0;
23 const eslintUtils = __importStar(require("eslint-utils"));
25 * Get the proper location of a given function node to report.
27 * @see {@link https://eslint-utils.mysticatea.dev/api/ast-utils.html#getfunctionheadlocation}
29 const getFunctionHeadLocation = eslintUtils.getFunctionHeadLocation;
30 exports.getFunctionHeadLocation = getFunctionHeadLocation;
32 * Get the name and kind of a given function node.
34 * @see {@link https://eslint-utils.mysticatea.dev/api/ast-utils.html#getfunctionnamewithkind}
36 const getFunctionNameWithKind = eslintUtils.getFunctionNameWithKind;
37 exports.getFunctionNameWithKind = getFunctionNameWithKind;
39 * Get the property name of a given property node.
40 * If the node is a computed property, this tries to compute the property name by the getStringIfConstant function.
42 * @see {@link https://eslint-utils.mysticatea.dev/api/ast-utils.html#getpropertyname}
43 * @returns The property name of the node. If the property name is not constant then it returns `null`.
45 const getPropertyName = eslintUtils.getPropertyName;
46 exports.getPropertyName = getPropertyName;
48 * Get the value of a given node if it can decide the value statically.
49 * If the 2nd parameter `initialScope` was given, this function tries to resolve identifier references which are in the
50 * given node as much as possible. In the resolving way, it does on the assumption that built-in global objects have
52 * For example, it considers `Symbol.iterator`, ` String.raw``hello`` `, and `Object.freeze({a: 1}).a` as static.
54 * @see {@link https://eslint-utils.mysticatea.dev/api/ast-utils.html#getstaticvalue}
55 * @returns The `{ value: any }` shaped object. The `value` property is the static value. If it couldn't compute the
56 * static value of the node, it returns `null`.
58 const getStaticValue = eslintUtils.getStaticValue;
59 exports.getStaticValue = getStaticValue;
61 * Get the string value of a given node.
62 * This function is a tiny wrapper of the getStaticValue function.
64 * @see {@link https://eslint-utils.mysticatea.dev/api/ast-utils.html#getstringifconstant}
66 const getStringIfConstant = eslintUtils.getStringIfConstant;
67 exports.getStringIfConstant = getStringIfConstant;
69 * Check whether a given node has any side effect or not.
70 * The side effect means that it may modify a certain variable or object member. This function considers the node which
71 * contains the following types as the node which has side effects:
72 * - `AssignmentExpression`
75 * - `ImportExpression`
77 * - `UnaryExpression([operator = "delete"])`
78 * - `UpdateExpression`
80 * - When `options.considerGetters` is `true`:
81 * - `MemberExpression`
82 * - When `options.considerImplicitTypeConversion` is `true`:
83 * - `BinaryExpression([operator = "==" | "!=" | "<" | "<=" | ">" | ">=" | "<<" | ">>" | ">>>" | "+" | "-" | "*" | "/" | "%" | "|" | "^" | "&" | "in"])`
84 * - `MemberExpression([computed = true])`
85 * - `MethodDefinition([computed = true])`
86 * - `Property([computed = true])`
87 * - `UnaryExpression([operator = "-" | "+" | "!" | "~"])`
89 * @see {@link https://eslint-utils.mysticatea.dev/api/ast-utils.html#hassideeffect}
91 const hasSideEffect = eslintUtils.hasSideEffect;
92 exports.hasSideEffect = hasSideEffect;
94 * Check whether a given node is parenthesized or not.
95 * This function detects it correctly even if it's parenthesized by specific syntax.
97 * @see {@link https://eslint-utils.mysticatea.dev/api/ast-utils.html#isparenthesized}
98 * @returns `true` if the node is parenthesized.
99 * If `times` was given, it returns `true` only if the node is parenthesized the `times` times.
100 * For example, `isParenthesized(2, node, sourceCode)` returns true for `((foo))`, but not for `(foo)`.
102 const isParenthesized = eslintUtils.isParenthesized;
103 exports.isParenthesized = isParenthesized;
104 //# sourceMappingURL=astUtilities.js.map