@eslint-react/ast 5.24.0-beta.0 → 5.24.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +11 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -178,6 +178,16 @@ const isConditional = isOneOf([
|
|
|
178
178
|
//#endregion
|
|
179
179
|
//#region ../../.pkgs/eff/dist/index.js
|
|
180
180
|
/**
|
|
181
|
+
* A function that checks if the passed parameter is a string and narrows its type accordingly.
|
|
182
|
+
*
|
|
183
|
+
* @param data - The variable to check.
|
|
184
|
+
* @returns True if the passed input is a string, false otherwise.
|
|
185
|
+
* @category guards
|
|
186
|
+
*/
|
|
187
|
+
function isString(data) {
|
|
188
|
+
return typeof data === "string";
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
181
191
|
* Applies a `pipe` method's variadic arguments to an initial value from left
|
|
182
192
|
* to right.
|
|
183
193
|
*
|
|
@@ -746,7 +756,7 @@ function getPropertyName(property, effort = "min") {
|
|
|
746
756
|
const key = unwrap(property.key);
|
|
747
757
|
if (isIdentifier(key) && !property.computed) return key.name;
|
|
748
758
|
if (effort === "min") return null;
|
|
749
|
-
if (key.type === AST_NODE_TYPES.Literal &&
|
|
759
|
+
if (key.type === AST_NODE_TYPES.Literal && isString(key.value)) return key.value;
|
|
750
760
|
if (key.type === AST_NODE_TYPES.TemplateLiteral && key.expressions.length === 0) return key.quasis[0]?.value.cooked ?? key.quasis[0]?.value.raw ?? null;
|
|
751
761
|
return null;
|
|
752
762
|
}
|