`{ email, password, …}` — the keys an object literal passes, not its bulk.
(node: SyntaxNode, source: string)
| 720 | |
| 721 | /** `{ email, password, …}` — the keys an object literal passes, not its bulk. */ |
| 722 | function objectKeys(node: SyntaxNode, source: string): string { |
| 723 | const keys: string[] = []; |
| 724 | let more = 0; |
| 725 | for (let i = 0; i < node.namedChildCount; i++) { |
| 726 | const c = node.namedChild(i); |
| 727 | if (!c || c.type === 'comment') continue; |
| 728 | let key: string | null = null; |
| 729 | if (c.type === 'pair') key = c.childForFieldName('key')?.text ?? null; |
| 730 | else if (c.type === 'shorthand_property_identifier' || c.type === 'shorthand_property_identifier_pattern') key = c.text; |
| 731 | else if (c.type === 'spread_element') key = collapse(c.text); |
| 732 | else if (c.type === 'method_definition') key = c.childForFieldName('name')?.text ?? null; |
| 733 | if (key === null) continue; |
| 734 | if (keys.length >= MAX_OBJECT_KEYS) { |
| 735 | more++; |
| 736 | continue; |
| 737 | } |
| 738 | keys.push(cut(key, 24)); |
| 739 | } |
| 740 | void source; |
| 741 | if (keys.length === 0) return '{…}'; |
| 742 | return `{ ${keys.join(', ')}${more > 0 ? ', …' : ''} }`; |
| 743 | } |
| 744 | |
| 745 | // ============================================================================= |
| 746 | // Triggers — what fires a site |
no test coverage detected