| |
| |
| |
| |
|
|
| import { countBraces } from '../src/edit.mjs'; |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| export const noBomRule = { |
| id: 'no-bom', |
| level: 'error', |
| when: () => true, |
| check: (record) => !record.bom, |
| message: (record) => `${record.path}: file has a UTF-8 BOM (unexpected for history/common data files)`, |
| note: 'Vanilla history/common data files never carry a BOM; one appearing here most likely means ' |
| + 'the file was saved by an editor that adds one by default, and the game may not parse it correctly.', |
| }; |
|
|
| |
| |
| |
| |
| |
| |
| |
| export const noAstralRule = { |
| id: 'no-astral', |
| level: 'error', |
| when: () => true, |
| check: (record) => ![...record.text].some((ch) => ch.codePointAt(0) > 0xffff), |
| message: (record) => `${record.path}: contains a character above U+FFFF (likely a mis-encoding, not an intentional character)`, |
| note: 'EU4 data/localisation text is not expected to legitimately contain astral characters; when ' |
| + 'one appears it has, in practice, been two independent CP1252-mapped bytes recombining into a ' |
| + 'surrogate pair on decode — a mis-encoding, not real content.', |
| }; |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| export const braceBalanceRule = { |
| id: 'brace-balance', |
| level: 'error', |
| when: () => true, |
| check: (record) => { |
| const { open, close } = countBraces(record.text); |
| return open === close; |
| }, |
| message: (record) => { |
| const { open, close } = countBraces(record.text); |
| return `${record.path}: unbalanced braces (open=${open}, close=${close})`; |
| }, |
| note: 'An unbalanced file will either fail to load or silently absorb everything after the ' |
| + 'imbalance into the wrong scope. Comment-aware counting (via edit.mjs\'s countBraces) avoids ' |
| + 'false positives from braces inside comments, e.g. "# The Eden Agreement }".', |
| }; |
|
|
| export default [noBomRule, noAstralRule, braceBalanceRule]; |
|
|