@ryhrm-gz/xincodo-lib
Version:
Utilities for working with Xincodo body documents.
64 lines (47 loc) • 1.79 kB
Markdown
# Lint Codes and Severities
`lintBody(input, options)` returns a `BodyLintReport`.
```ts
type BodyLintReport = {
valid: boolean;
issues: BodyLintIssue[];
errors: BodyLintIssue[];
warnings: BodyLintIssue[];
infos: BodyLintIssue[];
};
```
`valid` is `true` when there are no `errors`. Warnings and infos are
non-blocking by default unless the consuming application chooses otherwise.
## Options
```ts
type BodyLintOptions = {
requireImageAlt?: boolean;
validateUrls?: boolean;
maxDepth?: number;
};
```
Defaults:
- `requireImageAlt: true`
- `validateUrls: true`
- `maxDepth`: unset
## Error Codes
- `duplicate_id`: the same block or gallery image id appears more than once
- `empty_page_reference`: `page_link.page.pageId` is blank
- `inconsistent_table_columns`: table rows have different cell counts
- `invalid_numbered_list_start`: `numbered_list.start` is not a positive integer
- `invalid_url`: URL or href failed validation
## Warning Codes
- `empty_gallery`: gallery has no images
- `empty_table`: table has no rows or rows have no cells
- `heading_level_jump`: heading level jumps by more than one
- `max_depth_exceeded`: block nesting exceeds `maxDepth`
- `missing_image_alt`: image or gallery image has no alt text
## Info Codes
- `empty_list`: list has no items
- `empty_rich_text`: rich text has no visible text, a text inline is empty, or a list item has no text or child blocks
## URL Rules
When `validateUrls` is enabled:
- text links accept absolute URLs with `http:`, `https:`, `mailto:`, or `tel:`
- text links also accept root-relative paths and hash fragments
- `page_link` URL references use the same href rules
- `external` image sources must be absolute `http` or `https` URLs
- `file` image sources accept any valid href without whitespace