(/** @type {DataFile} */ file)
| 1680 | } |
| 1681 | |
| 1682 | function assertFileHasNoBom(/** @type {DataFile} */ file) { |
| 1683 | const bomTypes = [ |
| 1684 | { name: 'UTF-8', signature: [0xef, 0xbb, 0xbf] }, |
| 1685 | { name: 'UTF-16 (BE)', signature: [0xfe, 0xff] }, |
| 1686 | { name: 'UTF-16 (LE)', signature: [0xff, 0xfe] }, |
| 1687 | { name: 'UTF-32 (BE)', signature: [0x00, 0x00, 0xff, 0xfe] }, |
| 1688 | { name: 'UTF-32 (LE)', signature: [0xff, 0xfe, 0x00, 0x00] }, |
| 1689 | ] |
| 1690 | |
| 1691 | for (const bom of bomTypes) { |
| 1692 | if (file.buffer.length >= bom.signature.length) { |
| 1693 | const bomFound = bom.signature.every( |
| 1694 | (value, index) => file.buffer[index] === value, |
| 1695 | ) |
| 1696 | |
| 1697 | if (bomFound) { |
| 1698 | printErrorAndExit(new Error(), [ |
| 1699 | `Expected to have no BOM (${bom.name} BOM) in file "./${file.path}"`, |
| 1700 | ]) |
| 1701 | } |
| 1702 | } |
| 1703 | } |
| 1704 | } |
| 1705 | |
| 1706 | async function assertFilePassesJsonLint( |
| 1707 | /** @type {DataFile} */ file, |
no test coverage detected