UNPKG

prettier-plugin-multiline-arrays

Version:
31 lines (30 loc) 979 B
import { extractTextBetweenRanges } from '../augments/array.js'; export function containsTrailingComma(nodeLocation, children, originalLines, // eslint-disable-next-line @typescript-eslint/no-unused-vars debug) { const lastElement = children[children.length - 1]; if (lastElement) { const startLocation = lastElement.loc?.end; if (!startLocation) { return false; } const endLocation = nodeLocation?.end; if (!endLocation) { return false; } const textPastLastElement = extractTextBetweenRanges(originalLines, { start: { column: startLocation.column - 1, line: startLocation.line - 1, }, end: { column: endLocation.column - 1, line: endLocation.line - 1, }, }); if (textPastLastElement.includes(',')) { return true; } } return false; }