chaffjs 0.17.0 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +52 -56
- package/bin/chaff.js +17 -2
- package/dist/acronym-expansions.d.ts +26 -0
- package/dist/acronym-expansions.d.ts.map +1 -0
- package/dist/acronym-expansions.js +88 -0
- package/dist/acronym-expansions.js.map +1 -0
- package/dist/announced-count.d.ts +26 -0
- package/dist/announced-count.d.ts.map +1 -0
- package/dist/announced-count.js +138 -0
- package/dist/announced-count.js.map +1 -0
- package/dist/announced-list.d.ts +30 -0
- package/dist/announced-list.d.ts.map +1 -0
- package/dist/announced-list.js +95 -0
- package/dist/announced-list.js.map +1 -0
- package/dist/api.d.ts +168 -0
- package/dist/api.d.ts.map +1 -0
- package/dist/api.js +10 -0
- package/dist/api.js.map +1 -0
- package/dist/bare-url.d.ts +14 -0
- package/dist/bare-url.d.ts.map +1 -0
- package/dist/bare-url.js +28 -0
- package/dist/bare-url.js.map +1 -0
- package/dist/baseline.d.ts +5 -0
- package/dist/baseline.d.ts.map +1 -1
- package/dist/baseline.js +16 -1
- package/dist/baseline.js.map +1 -1
- package/dist/body-section.d.ts +7 -0
- package/dist/body-section.d.ts.map +1 -0
- package/dist/body-section.js +6 -0
- package/dist/body-section.js.map +1 -0
- package/dist/calendar-number.d.ts +2 -0
- package/dist/calendar-number.d.ts.map +1 -1
- package/dist/calendar-number.js +9 -2
- package/dist/calendar-number.js.map +1 -1
- package/dist/cli-args.d.ts +4 -0
- package/dist/cli-args.d.ts.map +1 -1
- package/dist/cli-args.js +5 -0
- package/dist/cli-args.js.map +1 -1
- package/dist/cli-text.d.ts +0 -1
- package/dist/cli-text.d.ts.map +1 -1
- package/dist/cli-text.js +14 -18
- package/dist/cli-text.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +83 -84
- package/dist/cli.js.map +1 -1
- package/dist/closing-paragraph.d.ts +7 -0
- package/dist/closing-paragraph.d.ts.map +1 -0
- package/dist/closing-paragraph.js +22 -0
- package/dist/closing-paragraph.js.map +1 -0
- package/dist/commands/compare.d.ts +15 -0
- package/dist/commands/compare.d.ts.map +1 -0
- package/dist/commands/compare.js +64 -0
- package/dist/commands/compare.js.map +1 -0
- package/dist/commands/document-commands.d.ts +9 -0
- package/dist/commands/document-commands.d.ts.map +1 -0
- package/dist/commands/document-commands.js +17 -0
- package/dist/commands/document-commands.js.map +1 -0
- package/dist/commands/eval.d.ts.map +1 -1
- package/dist/commands/eval.js +19 -10
- package/dist/commands/eval.js.map +1 -1
- package/dist/commands/facts.d.ts +8 -0
- package/dist/commands/facts.d.ts.map +1 -0
- package/dist/commands/facts.js +30 -0
- package/dist/commands/facts.js.map +1 -0
- package/dist/commands/feedback.d.ts +15 -2
- package/dist/commands/feedback.d.ts.map +1 -1
- package/dist/commands/feedback.js +36 -6
- package/dist/commands/feedback.js.map +1 -1
- package/dist/commands/fix-plan.d.ts +13 -0
- package/dist/commands/fix-plan.d.ts.map +1 -0
- package/dist/commands/fix-plan.js +44 -0
- package/dist/commands/fix-plan.js.map +1 -0
- package/dist/commands/outline.d.ts +8 -0
- package/dist/commands/outline.d.ts.map +1 -0
- package/dist/commands/outline.js +43 -0
- package/dist/commands/outline.js.map +1 -0
- package/dist/commands/read-document.d.ts +14 -0
- package/dist/commands/read-document.d.ts.map +1 -0
- package/dist/commands/read-document.js +21 -0
- package/dist/commands/read-document.js.map +1 -0
- package/dist/commands/suppressions.d.ts +7 -0
- package/dist/commands/suppressions.d.ts.map +1 -0
- package/dist/commands/suppressions.js +9 -0
- package/dist/commands/suppressions.js.map +1 -0
- package/dist/commands/test.d.ts.map +1 -1
- package/dist/commands/test.js +3 -5
- package/dist/commands/test.js.map +1 -1
- package/dist/commands/tree.d.ts +13 -0
- package/dist/commands/tree.d.ts.map +1 -1
- package/dist/commands/tree.js +35 -5
- package/dist/commands/tree.js.map +1 -1
- package/dist/compare/atom.d.ts +31 -0
- package/dist/compare/atom.d.ts.map +1 -0
- package/dist/compare/atom.js +4 -0
- package/dist/compare/atom.js.map +1 -0
- package/dist/compare/clock-time.d.ts +8 -0
- package/dist/compare/clock-time.d.ts.map +1 -0
- package/dist/compare/clock-time.js +68 -0
- package/dist/compare/clock-time.js.map +1 -0
- package/dist/compare/distinct.d.ts +9 -0
- package/dist/compare/distinct.d.ts.map +1 -0
- package/dist/compare/distinct.js +12 -0
- package/dist/compare/distinct.js.map +1 -0
- package/dist/compare/extract.d.ts +15 -0
- package/dist/compare/extract.d.ts.map +1 -0
- package/dist/compare/extract.js +60 -0
- package/dist/compare/extract.js.map +1 -0
- package/dist/compare/fact-key.d.ts +17 -0
- package/dist/compare/fact-key.d.ts.map +1 -0
- package/dist/compare/fact-key.js +25 -0
- package/dist/compare/fact-key.js.map +1 -0
- package/dist/compare/fact-text.d.ts +28 -0
- package/dist/compare/fact-text.d.ts.map +1 -0
- package/dist/compare/fact-text.js +61 -0
- package/dist/compare/fact-text.js.map +1 -0
- package/dist/compare/facts-render.d.ts +17 -0
- package/dist/compare/facts-render.d.ts.map +1 -0
- package/dist/compare/facts-render.js +43 -0
- package/dist/compare/facts-render.js.map +1 -0
- package/dist/compare/facts-text.d.ts +15 -0
- package/dist/compare/facts-text.d.ts.map +1 -0
- package/dist/compare/facts-text.js +27 -0
- package/dist/compare/facts-text.js.map +1 -0
- package/dist/compare/markup-atoms.d.ts +11 -0
- package/dist/compare/markup-atoms.d.ts.map +1 -0
- package/dist/compare/markup-atoms.js +23 -0
- package/dist/compare/markup-atoms.js.map +1 -0
- package/dist/compare/match.d.ts +20 -0
- package/dist/compare/match.d.ts.map +1 -0
- package/dist/compare/match.js +84 -0
- package/dist/compare/match.js.map +1 -0
- package/dist/compare/outcome.d.ts +36 -0
- package/dist/compare/outcome.d.ts.map +1 -0
- package/dist/compare/outcome.js +46 -0
- package/dist/compare/outcome.js.map +1 -0
- package/dist/compare/proper-nouns.d.ts +19 -0
- package/dist/compare/proper-nouns.d.ts.map +1 -0
- package/dist/compare/proper-nouns.js +43 -0
- package/dist/compare/proper-nouns.js.map +1 -0
- package/dist/compare/render.d.ts +13 -0
- package/dist/compare/render.d.ts.map +1 -0
- package/dist/compare/render.js +64 -0
- package/dist/compare/render.js.map +1 -0
- package/dist/compare/spans.d.ts +9 -0
- package/dist/compare/spans.d.ts.map +1 -0
- package/dist/compare/spans.js +11 -0
- package/dist/compare/spans.js.map +1 -0
- package/dist/compare/text-atoms.d.ts +27 -0
- package/dist/compare/text-atoms.d.ts.map +1 -0
- package/dist/compare/text-atoms.js +69 -0
- package/dist/compare/text-atoms.js.map +1 -0
- package/dist/compare/text.d.ts +24 -0
- package/dist/compare/text.d.ts.map +1 -0
- package/dist/compare/text.js +90 -0
- package/dist/compare/text.js.map +1 -0
- package/dist/compare/tree-atoms.d.ts +20 -0
- package/dist/compare/tree-atoms.d.ts.map +1 -0
- package/dist/compare/tree-atoms.js +58 -0
- package/dist/compare/tree-atoms.js.map +1 -0
- package/dist/compare/written-names.d.ts +8 -0
- package/dist/compare/written-names.d.ts.map +1 -0
- package/dist/compare/written-names.js +24 -0
- package/dist/compare/written-names.js.map +1 -0
- package/dist/config/load.d.ts +23 -0
- package/dist/config/load.d.ts.map +1 -1
- package/dist/config/load.js +6 -0
- package/dist/config/load.js.map +1 -1
- package/dist/config/option-problems.d.ts +17 -0
- package/dist/config/option-problems.d.ts.map +1 -0
- package/dist/config/option-problems.js +59 -0
- package/dist/config/option-problems.js.map +1 -0
- package/dist/config/read.d.ts +4 -0
- package/dist/config/read.d.ts.map +1 -0
- package/dist/config/read.js +8 -0
- package/dist/config/read.js.map +1 -0
- package/dist/config/rule-problems.d.ts +2 -4
- package/dist/config/rule-problems.d.ts.map +1 -1
- package/dist/config/rule-problems.js +7 -1
- package/dist/config/rule-problems.js.map +1 -1
- package/dist/config/style.d.ts +21 -0
- package/dist/config/style.d.ts.map +1 -0
- package/dist/config/style.js +48 -0
- package/dist/config/style.js.map +1 -0
- package/dist/config/warnings.d.ts +6 -0
- package/dist/config/warnings.d.ts.map +1 -0
- package/dist/config/warnings.js +10 -0
- package/dist/config/warnings.js.map +1 -0
- package/dist/config/write.d.ts.map +1 -1
- package/dist/config/write.js +17 -4
- package/dist/config/write.js.map +1 -1
- package/dist/custom/bounded-match.d.ts +15 -0
- package/dist/custom/bounded-match.d.ts.map +1 -0
- package/dist/custom/bounded-match.js +43 -0
- package/dist/custom/bounded-match.js.map +1 -0
- package/dist/custom/load.d.ts +11 -0
- package/dist/custom/load.d.ts.map +1 -0
- package/dist/custom/load.js +19 -0
- package/dist/custom/load.js.map +1 -0
- package/dist/custom/module-path.d.ts +11 -0
- package/dist/custom/module-path.d.ts.map +1 -0
- package/dist/custom/module-path.js +15 -0
- package/dist/custom/module-path.js.map +1 -0
- package/dist/custom/parse.d.ts +84 -0
- package/dist/custom/parse.d.ts.map +1 -0
- package/dist/custom/parse.js +258 -0
- package/dist/custom/parse.js.map +1 -0
- package/dist/custom/problems.d.ts +8 -0
- package/dist/custom/problems.d.ts.map +1 -0
- package/dist/custom/problems.js +95 -0
- package/dist/custom/problems.js.map +1 -0
- package/dist/custom/regex-safety.d.ts +11 -0
- package/dist/custom/regex-safety.d.ts.map +1 -0
- package/dist/custom/regex-safety.js +110 -0
- package/dist/custom/regex-safety.js.map +1 -0
- package/dist/custom/token-pattern.d.ts +8 -0
- package/dist/custom/token-pattern.d.ts.map +1 -0
- package/dist/custom/token-pattern.js +75 -0
- package/dist/custom/token-pattern.js.map +1 -0
- package/dist/detect-language.js +1 -1
- package/dist/detect.d.ts.map +1 -1
- package/dist/detect.js +30 -2
- package/dist/detect.js.map +1 -1
- package/dist/detectors/acronym-context.d.ts +2 -0
- package/dist/detectors/acronym-context.d.ts.map +1 -1
- package/dist/detectors/acronym-context.js +12 -4
- package/dist/detectors/acronym-context.js.map +1 -1
- package/dist/detectors/ai-phrasing.d.ts +23 -0
- package/dist/detectors/ai-phrasing.d.ts.map +1 -0
- package/dist/detectors/ai-phrasing.js +116 -0
- package/dist/detectors/ai-phrasing.js.map +1 -0
- package/dist/detectors/announced-count.d.ts +4 -0
- package/dist/detectors/announced-count.d.ts.map +1 -0
- package/dist/detectors/announced-count.js +20 -0
- package/dist/detectors/announced-count.js.map +1 -0
- package/dist/detectors/bold-label.d.ts +10 -0
- package/dist/detectors/bold-label.d.ts.map +1 -0
- package/dist/detectors/bold-label.js +44 -0
- package/dist/detectors/bold-label.js.map +1 -0
- package/dist/detectors/broken-link.d.ts +17 -0
- package/dist/detectors/broken-link.d.ts.map +1 -0
- package/dist/detectors/broken-link.js +66 -0
- package/dist/detectors/broken-link.js.map +1 -0
- package/dist/detectors/cited-name.d.ts.map +1 -1
- package/dist/detectors/cited-name.js +4 -4
- package/dist/detectors/cited-name.js.map +1 -1
- package/dist/detectors/cited-title.d.ts +11 -0
- package/dist/detectors/cited-title.d.ts.map +1 -0
- package/dist/detectors/cited-title.js +75 -0
- package/dist/detectors/cited-title.js.map +1 -0
- package/dist/detectors/concrete-evidence.d.ts +1 -1
- package/dist/detectors/concrete-evidence.d.ts.map +1 -1
- package/dist/detectors/concrete-evidence.js +2 -1
- package/dist/detectors/concrete-evidence.js.map +1 -1
- package/dist/detectors/contrast-frame.d.ts +17 -0
- package/dist/detectors/contrast-frame.d.ts.map +1 -0
- package/dist/detectors/contrast-frame.js +32 -0
- package/dist/detectors/contrast-frame.js.map +1 -0
- package/dist/detectors/custom.d.ts +8 -0
- package/dist/detectors/custom.d.ts.map +1 -0
- package/dist/detectors/custom.js +71 -0
- package/dist/detectors/custom.js.map +1 -0
- package/dist/detectors/dangling-figure.d.ts +7 -0
- package/dist/detectors/dangling-figure.d.ts.map +1 -0
- package/dist/detectors/dangling-figure.js +20 -0
- package/dist/detectors/dangling-figure.js.map +1 -0
- package/dist/detectors/definition-use.d.ts +8 -0
- package/dist/detectors/definition-use.d.ts.map +1 -0
- package/dist/detectors/definition-use.js +32 -0
- package/dist/detectors/definition-use.js.map +1 -0
- package/dist/detectors/doubled-punctuation.d.ts +9 -0
- package/dist/detectors/doubled-punctuation.d.ts.map +1 -0
- package/dist/detectors/doubled-punctuation.js +35 -0
- package/dist/detectors/doubled-punctuation.js.map +1 -0
- package/dist/detectors/doubled-word.d.ts +5 -0
- package/dist/detectors/doubled-word.d.ts.map +1 -1
- package/dist/detectors/doubled-word.js +24 -11
- package/dist/detectors/doubled-word.js.map +1 -1
- package/dist/detectors/duplicate-heading.d.ts +14 -0
- package/dist/detectors/duplicate-heading.d.ts.map +1 -0
- package/dist/detectors/duplicate-heading.js +39 -0
- package/dist/detectors/duplicate-heading.js.map +1 -0
- package/dist/detectors/empty-section.d.ts +8 -0
- package/dist/detectors/empty-section.d.ts.map +1 -0
- package/dist/detectors/empty-section.js +16 -0
- package/dist/detectors/empty-section.js.map +1 -0
- package/dist/detectors/enumerated-runs.d.ts +1 -1
- package/dist/detectors/enumerated-runs.d.ts.map +1 -1
- package/dist/detectors/enumerated-runs.js +15 -4
- package/dist/detectors/enumerated-runs.js.map +1 -1
- package/dist/detectors/fullwidth-alnum.d.ts +24 -0
- package/dist/detectors/fullwidth-alnum.d.ts.map +1 -0
- package/dist/detectors/fullwidth-alnum.js +88 -0
- package/dist/detectors/fullwidth-alnum.js.map +1 -0
- package/dist/detectors/gram-furniture.d.ts +6 -0
- package/dist/detectors/gram-furniture.d.ts.map +1 -0
- package/dist/detectors/gram-furniture.js +21 -0
- package/dist/detectors/gram-furniture.js.map +1 -0
- package/dist/detectors/gram-place.d.ts +2 -0
- package/dist/detectors/gram-place.d.ts.map +1 -1
- package/dist/detectors/gram-place.js +9 -7
- package/dist/detectors/gram-place.js.map +1 -1
- package/dist/detectors/gram-windows.d.ts +9 -0
- package/dist/detectors/gram-windows.d.ts.map +1 -0
- package/dist/detectors/gram-windows.js +27 -0
- package/dist/detectors/gram-windows.js.map +1 -0
- package/dist/detectors/hankaku-kana.d.ts +9 -0
- package/dist/detectors/hankaku-kana.d.ts.map +1 -0
- package/dist/detectors/hankaku-kana.js +27 -0
- package/dist/detectors/hankaku-kana.js.map +1 -0
- package/dist/detectors/heading-case.d.ts +2 -0
- package/dist/detectors/heading-case.d.ts.map +1 -1
- package/dist/detectors/heading-case.js +29 -2
- package/dist/detectors/heading-case.js.map +1 -1
- package/dist/detectors/heading-code-words.d.ts +6 -0
- package/dist/detectors/heading-code-words.d.ts.map +1 -0
- package/dist/detectors/heading-code-words.js +29 -0
- package/dist/detectors/heading-code-words.js.map +1 -0
- package/dist/detectors/heading-echo.d.ts.map +1 -1
- package/dist/detectors/heading-echo.js +7 -4
- package/dist/detectors/heading-echo.js.map +1 -1
- package/dist/detectors/heading-level-skip.d.ts +12 -0
- package/dist/detectors/heading-level-skip.d.ts.map +1 -0
- package/dist/detectors/heading-level-skip.js +11 -0
- package/dist/detectors/heading-level-skip.js.map +1 -0
- package/dist/detectors/image-alt-text.d.ts +3 -0
- package/dist/detectors/image-alt-text.d.ts.map +1 -0
- package/dist/detectors/image-alt-text.js +9 -0
- package/dist/detectors/image-alt-text.js.map +1 -0
- package/dist/detectors/index.d.ts.map +1 -1
- package/dist/detectors/index.js +70 -1
- package/dist/detectors/index.js.map +1 -1
- package/dist/detectors/invisible-character.d.ts +20 -0
- package/dist/detectors/invisible-character.d.ts.map +1 -0
- package/dist/detectors/invisible-character.js +143 -0
- package/dist/detectors/invisible-character.js.map +1 -0
- package/dist/detectors/kutoten-consistency.d.ts +24 -0
- package/dist/detectors/kutoten-consistency.d.ts.map +1 -0
- package/dist/detectors/kutoten-consistency.js +77 -0
- package/dist/detectors/kutoten-consistency.js.map +1 -0
- package/dist/detectors/lead-in.d.ts +1 -0
- package/dist/detectors/lead-in.d.ts.map +1 -1
- package/dist/detectors/lead-in.js +2 -1
- package/dist/detectors/lead-in.js.map +1 -1
- package/dist/detectors/lexicon-match.d.ts +14 -1
- package/dist/detectors/lexicon-match.d.ts.map +1 -1
- package/dist/detectors/lexicon-match.js +32 -2
- package/dist/detectors/lexicon-match.js.map +1 -1
- package/dist/detectors/lexicon.d.ts +6 -1
- package/dist/detectors/lexicon.d.ts.map +1 -1
- package/dist/detectors/lexicon.js +31 -13
- package/dist/detectors/lexicon.js.map +1 -1
- package/dist/detectors/list-item.d.ts +45 -0
- package/dist/detectors/list-item.d.ts.map +1 -0
- package/dist/detectors/list-item.js +88 -0
- package/dist/detectors/list-item.js.map +1 -0
- package/dist/detectors/list-items.d.ts +31 -0
- package/dist/detectors/list-items.d.ts.map +1 -0
- package/dist/detectors/list-items.js +113 -0
- package/dist/detectors/list-items.js.map +1 -0
- package/dist/detectors/list-lead-in.d.ts +7 -0
- package/dist/detectors/list-lead-in.d.ts.map +1 -0
- package/dist/detectors/list-lead-in.js +28 -0
- package/dist/detectors/list-lead-in.js.map +1 -0
- package/dist/detectors/list-sentence.d.ts +67 -0
- package/dist/detectors/list-sentence.d.ts.map +1 -0
- package/dist/detectors/list-sentence.js +130 -0
- package/dist/detectors/list-sentence.js.map +1 -0
- package/dist/detectors/list-view.d.ts +34 -0
- package/dist/detectors/list-view.d.ts.map +1 -0
- package/dist/detectors/list-view.js +137 -0
- package/dist/detectors/list-view.js.map +1 -0
- package/dist/detectors/long-vowel.d.ts +7 -0
- package/dist/detectors/long-vowel.d.ts.map +1 -0
- package/dist/detectors/long-vowel.js +71 -0
- package/dist/detectors/long-vowel.js.map +1 -0
- package/dist/detectors/markup-finding.d.ts +8 -0
- package/dist/detectors/markup-finding.d.ts.map +1 -0
- package/dist/detectors/markup-finding.js +29 -0
- package/dist/detectors/markup-finding.js.map +1 -0
- package/dist/detectors/modal-conflict.d.ts +4 -0
- package/dist/detectors/modal-conflict.d.ts.map +1 -0
- package/dist/detectors/modal-conflict.js +22 -0
- package/dist/detectors/modal-conflict.js.map +1 -0
- package/dist/detectors/name-numeral.d.ts +1 -1
- package/dist/detectors/name-numeral.d.ts.map +1 -1
- package/dist/detectors/name-numeral.js +2 -7
- package/dist/detectors/name-numeral.js.map +1 -1
- package/dist/detectors/name-variant.d.ts +4 -0
- package/dist/detectors/name-variant.d.ts.map +1 -0
- package/dist/detectors/name-variant.js +13 -0
- package/dist/detectors/name-variant.js.map +1 -0
- package/dist/detectors/nominalization.d.ts +11 -0
- package/dist/detectors/nominalization.d.ts.map +1 -0
- package/dist/detectors/nominalization.js +56 -0
- package/dist/detectors/nominalization.js.map +1 -0
- package/dist/detectors/orthography.d.ts.map +1 -1
- package/dist/detectors/orthography.js +72 -37
- package/dist/detectors/orthography.js.map +1 -1
- package/dist/detectors/outside-announced-list.d.ts +4 -0
- package/dist/detectors/outside-announced-list.d.ts.map +1 -0
- package/dist/detectors/outside-announced-list.js +24 -0
- package/dist/detectors/outside-announced-list.js.map +1 -0
- package/dist/detectors/oxford-comma.d.ts +7 -1
- package/dist/detectors/oxford-comma.d.ts.map +1 -1
- package/dist/detectors/oxford-comma.js +136 -229
- package/dist/detectors/oxford-comma.js.map +1 -1
- package/dist/detectors/phrase-match.d.ts +4 -1
- package/dist/detectors/phrase-match.d.ts.map +1 -1
- package/dist/detectors/phrase-match.js +26 -7
- package/dist/detectors/phrase-match.js.map +1 -1
- package/dist/detectors/place-run.d.ts.map +1 -1
- package/dist/detectors/place-run.js +10 -6
- package/dist/detectors/place-run.js.map +1 -1
- package/dist/detectors/placeholder-text.d.ts +9 -0
- package/dist/detectors/placeholder-text.d.ts.map +1 -0
- package/dist/detectors/placeholder-text.js +18 -0
- package/dist/detectors/placeholder-text.js.map +1 -0
- package/dist/detectors/quote-around.d.ts +3 -0
- package/dist/detectors/quote-around.d.ts.map +1 -0
- package/dist/detectors/quote-around.js +8 -0
- package/dist/detectors/quote-around.js.map +1 -0
- package/dist/detectors/ra-nuki.d.ts +9 -0
- package/dist/detectors/ra-nuki.d.ts.map +1 -0
- package/dist/detectors/ra-nuki.js +30 -0
- package/dist/detectors/ra-nuki.js.map +1 -0
- package/dist/detectors/register.d.ts +11 -3
- package/dist/detectors/register.d.ts.map +1 -1
- package/dist/detectors/register.js +28 -9
- package/dist/detectors/register.js.map +1 -1
- package/dist/detectors/requirement-modal.d.ts +5 -0
- package/dist/detectors/requirement-modal.d.ts.map +1 -0
- package/dist/detectors/requirement-modal.js +54 -0
- package/dist/detectors/requirement-modal.js.map +1 -0
- package/dist/detectors/requirement-smell.d.ts +4 -0
- package/dist/detectors/requirement-smell.d.ts.map +1 -0
- package/dist/detectors/requirement-smell.js +41 -0
- package/dist/detectors/requirement-smell.js.map +1 -0
- package/dist/detectors/roman-numeral.d.ts +2 -0
- package/dist/detectors/roman-numeral.d.ts.map +1 -1
- package/dist/detectors/roman-numeral.js +2 -0
- package/dist/detectors/roman-numeral.js.map +1 -1
- package/dist/detectors/sentence-ending.d.ts +17 -1
- package/dist/detectors/sentence-ending.d.ts.map +1 -1
- package/dist/detectors/sentence-ending.js +13 -7
- package/dist/detectors/sentence-ending.js.map +1 -1
- package/dist/detectors/sentence-length.d.ts.map +1 -1
- package/dist/detectors/sentence-length.js +13 -4
- package/dist/detectors/sentence-length.js.map +1 -1
- package/dist/detectors/signals.d.ts +8 -0
- package/dist/detectors/signals.d.ts.map +1 -1
- package/dist/detectors/signals.js +67 -46
- package/dist/detectors/signals.js.map +1 -1
- package/dist/detectors/space-before-punctuation.d.ts +8 -0
- package/dist/detectors/space-before-punctuation.d.ts.map +1 -0
- package/dist/detectors/space-before-punctuation.js +24 -0
- package/dist/detectors/space-before-punctuation.js.map +1 -0
- package/dist/detectors/spelling-variety.d.ts +23 -0
- package/dist/detectors/spelling-variety.d.ts.map +1 -0
- package/dist/detectors/spelling-variety.js +59 -0
- package/dist/detectors/spelling-variety.js.map +1 -0
- package/dist/detectors/structure-tree.d.ts +6 -0
- package/dist/detectors/structure-tree.d.ts.map +1 -1
- package/dist/detectors/structure-tree.js +39 -1
- package/dist/detectors/structure-tree.js.map +1 -1
- package/dist/detectors/structure.d.ts +1 -3
- package/dist/detectors/structure.d.ts.map +1 -1
- package/dist/detectors/structure.js +19 -6
- package/dist/detectors/structure.js.map +1 -1
- package/dist/detectors/superlative-comparison.d.ts +20 -0
- package/dist/detectors/superlative-comparison.d.ts.map +1 -0
- package/dist/detectors/superlative-comparison.js +32 -0
- package/dist/detectors/superlative-comparison.js.map +1 -0
- package/dist/detectors/superlative-name.d.ts.map +1 -1
- package/dist/detectors/superlative-name.js +8 -5
- package/dist/detectors/superlative-name.js.map +1 -1
- package/dist/detectors/superlative-scope.d.ts.map +1 -1
- package/dist/detectors/superlative-scope.js +9 -4
- package/dist/detectors/superlative-scope.js.map +1 -1
- package/dist/detectors/token-column.d.ts +46 -0
- package/dist/detectors/token-column.d.ts.map +1 -0
- package/dist/detectors/token-column.js +95 -0
- package/dist/detectors/token-column.js.map +1 -0
- package/dist/detectors/unbalanced-bracket.d.ts +22 -0
- package/dist/detectors/unbalanced-bracket.d.ts.map +1 -0
- package/dist/detectors/unbalanced-bracket.js +119 -0
- package/dist/detectors/unbalanced-bracket.js.map +1 -0
- package/dist/detectors/url-run-on.d.ts +9 -0
- package/dist/detectors/url-run-on.d.ts.map +1 -0
- package/dist/detectors/url-run-on.js +24 -0
- package/dist/detectors/url-run-on.js.map +1 -0
- package/dist/detectors/vague-figure-pointer.d.ts +10 -0
- package/dist/detectors/vague-figure-pointer.d.ts.map +1 -0
- package/dist/detectors/vague-figure-pointer.js +46 -0
- package/dist/detectors/vague-figure-pointer.js.map +1 -0
- package/dist/detectors/word-list.d.ts +2 -0
- package/dist/detectors/word-list.d.ts.map +1 -1
- package/dist/detectors/word-list.js +4 -1
- package/dist/detectors/word-list.js.map +1 -1
- package/dist/document-sections.d.ts +13 -0
- package/dist/document-sections.d.ts.map +1 -0
- package/dist/document-sections.js +32 -0
- package/dist/document-sections.js.map +1 -0
- package/dist/document.d.ts +20 -7
- package/dist/document.d.ts.map +1 -1
- package/dist/document.js +140 -125
- package/dist/document.js.map +1 -1
- package/dist/email-parts.d.ts +28 -0
- package/dist/email-parts.d.ts.map +1 -0
- package/dist/email-parts.js +230 -0
- package/dist/email-parts.js.map +1 -0
- package/dist/eval.d.ts +2 -1
- package/dist/eval.d.ts.map +1 -1
- package/dist/eval.js +16 -4
- package/dist/eval.js.map +1 -1
- package/dist/extension/document-view.d.ts +7 -0
- package/dist/extension/document-view.d.ts.map +1 -0
- package/dist/extension/document-view.js +91 -0
- package/dist/extension/document-view.js.map +1 -0
- package/dist/extension/failure-text.d.ts +5 -0
- package/dist/extension/failure-text.d.ts.map +1 -0
- package/dist/extension/failure-text.js +33 -0
- package/dist/extension/failure-text.js.map +1 -0
- package/dist/extension/import-default.d.ts +7 -0
- package/dist/extension/import-default.d.ts.map +1 -0
- package/dist/extension/import-default.js +21 -0
- package/dist/extension/import-default.js.map +1 -0
- package/dist/extension/load.d.ts +28 -0
- package/dist/extension/load.d.ts.map +1 -0
- package/dist/extension/load.js +51 -0
- package/dist/extension/load.js.map +1 -0
- package/dist/extension/module-detector.d.ts +21 -0
- package/dist/extension/module-detector.d.ts.map +1 -0
- package/dist/extension/module-detector.js +49 -0
- package/dist/extension/module-detector.js.map +1 -0
- package/dist/extension/plugin-load.d.ts +9 -0
- package/dist/extension/plugin-load.d.ts.map +1 -0
- package/dist/extension/plugin-load.js +68 -0
- package/dist/extension/plugin-load.js.map +1 -0
- package/dist/extension/plugin-name.d.ts +8 -0
- package/dist/extension/plugin-name.d.ts.map +1 -0
- package/dist/extension/plugin-name.js +22 -0
- package/dist/extension/plugin-name.js.map +1 -0
- package/dist/extension/plugin-parse.d.ts +41 -0
- package/dist/extension/plugin-parse.d.ts.map +1 -0
- package/dist/extension/plugin-parse.js +156 -0
- package/dist/extension/plugin-parse.js.map +1 -0
- package/dist/extension/problem-text.d.ts +5 -0
- package/dist/extension/problem-text.d.ts.map +1 -0
- package/dist/extension/problem-text.js +74 -0
- package/dist/extension/problem-text.js.map +1 -0
- package/dist/extension/real-path.d.ts +3 -0
- package/dist/extension/real-path.d.ts.map +1 -0
- package/dist/extension/real-path.js +8 -0
- package/dist/extension/real-path.js.map +1 -0
- package/dist/extension/returned-findings.d.ts +17 -0
- package/dist/extension/returned-findings.d.ts.map +1 -0
- package/dist/extension/returned-findings.js +48 -0
- package/dist/extension/returned-findings.js.map +1 -0
- package/dist/extension/rule-export.d.ts +13 -0
- package/dist/extension/rule-export.d.ts.map +1 -0
- package/dist/extension/rule-export.js +16 -0
- package/dist/extension/rule-export.js.map +1 -0
- package/dist/feedback/draft.d.ts +2 -0
- package/dist/feedback/draft.d.ts.map +1 -1
- package/dist/feedback/draft.js +3 -0
- package/dist/feedback/draft.js.map +1 -1
- package/dist/figure-references.d.ts +39 -0
- package/dist/figure-references.d.ts.map +1 -0
- package/dist/figure-references.js +113 -0
- package/dist/figure-references.js.map +1 -0
- package/dist/files.d.ts +2 -0
- package/dist/files.d.ts.map +1 -1
- package/dist/files.js +4 -0
- package/dist/files.js.map +1 -1
- package/dist/finding-order.d.ts +9 -0
- package/dist/finding-order.d.ts.map +1 -0
- package/dist/finding-order.js +3 -0
- package/dist/finding-order.js.map +1 -0
- package/dist/fix-plan/mode.d.ts +21 -0
- package/dist/fix-plan/mode.d.ts.map +1 -0
- package/dist/fix-plan/mode.js +16 -0
- package/dist/fix-plan/mode.js.map +1 -0
- package/dist/fix-plan/plan.d.ts +77 -0
- package/dist/fix-plan/plan.d.ts.map +1 -0
- package/dist/fix-plan/plan.js +100 -0
- package/dist/fix-plan/plan.js.map +1 -0
- package/dist/fix-plan/render.d.ts +6 -0
- package/dist/fix-plan/render.d.ts.map +1 -0
- package/dist/fix-plan/render.js +101 -0
- package/dist/fix-plan/render.js.map +1 -0
- package/dist/fix-plan/text.d.ts +35 -0
- package/dist/fix-plan/text.d.ts.map +1 -0
- package/dist/fix-plan/text.js +95 -0
- package/dist/fix-plan/text.js.map +1 -0
- package/dist/heading-label.d.ts +22 -0
- package/dist/heading-label.d.ts.map +1 -0
- package/dist/heading-label.js +50 -0
- package/dist/heading-label.js.map +1 -0
- package/dist/in-page-nav.d.ts +4 -1
- package/dist/in-page-nav.d.ts.map +1 -1
- package/dist/in-page-nav.js +53 -18
- package/dist/in-page-nav.js.map +1 -1
- package/dist/joined-view.d.ts.map +1 -1
- package/dist/joined-view.js +1 -0
- package/dist/joined-view.js.map +1 -1
- package/dist/language-sample.d.ts +2 -0
- package/dist/language-sample.d.ts.map +1 -0
- package/dist/language-sample.js +41 -0
- package/dist/language-sample.js.map +1 -0
- package/dist/levels.d.ts +5 -1
- package/dist/levels.d.ts.map +1 -1
- package/dist/levels.js +9 -0
- package/dist/levels.js.map +1 -1
- package/dist/line-paragraphs.d.ts +8 -0
- package/dist/line-paragraphs.d.ts.map +1 -1
- package/dist/line-paragraphs.js +33 -10
- package/dist/line-paragraphs.js.map +1 -1
- package/dist/link-line.d.ts +8 -0
- package/dist/link-line.d.ts.map +1 -0
- package/dist/link-line.js +12 -0
- package/dist/link-line.js.map +1 -0
- package/dist/long-vowel.d.ts +38 -0
- package/dist/long-vowel.d.ts.map +1 -0
- package/dist/long-vowel.js +78 -0
- package/dist/long-vowel.js.map +1 -0
- package/dist/markdown-node.d.ts +19 -0
- package/dist/markdown-node.d.ts.map +1 -0
- package/dist/markdown-node.js +6 -0
- package/dist/markdown-node.js.map +1 -0
- package/dist/markdown-read.d.ts +17 -0
- package/dist/markdown-read.d.ts.map +1 -0
- package/dist/markdown-read.js +37 -0
- package/dist/markdown-read.js.map +1 -0
- package/dist/markup.d.ts +22 -0
- package/dist/markup.d.ts.map +1 -0
- package/dist/markup.js +182 -0
- package/dist/markup.js.map +1 -0
- package/dist/mask.js +8 -5
- package/dist/mask.js.map +1 -1
- package/dist/name-variants.d.ts +25 -0
- package/dist/name-variants.d.ts.map +1 -0
- package/dist/name-variants.js +181 -0
- package/dist/name-variants.js.map +1 -0
- package/dist/node-version.d.ts +7 -0
- package/dist/node-version.d.ts.map +1 -0
- package/dist/node-version.js +19 -0
- package/dist/node-version.js.map +1 -0
- package/dist/not-run.d.ts +14 -0
- package/dist/not-run.d.ts.map +1 -0
- package/dist/not-run.js +12 -0
- package/dist/not-run.js.map +1 -0
- package/dist/number-name.d.ts +21 -5
- package/dist/number-name.d.ts.map +1 -1
- package/dist/number-name.js +119 -17
- package/dist/number-name.js.map +1 -1
- package/dist/orthography.d.ts +10 -1
- package/dist/orthography.d.ts.map +1 -1
- package/dist/orthography.js +42 -16
- package/dist/orthography.js.map +1 -1
- package/dist/outline/render.d.ts +18 -0
- package/dist/outline/render.d.ts.map +1 -0
- package/dist/outline/render.js +60 -0
- package/dist/outline/render.js.map +1 -0
- package/dist/outline/shape.d.ts +26 -0
- package/dist/outline/shape.d.ts.map +1 -0
- package/dist/outline/shape.js +37 -0
- package/dist/outline/shape.js.map +1 -0
- package/dist/outline/text.d.ts +21 -0
- package/dist/outline/text.d.ts.map +1 -0
- package/dist/outline/text.js +30 -0
- package/dist/outline/text.js.map +1 -0
- package/dist/page-furniture.d.ts +5 -2
- package/dist/page-furniture.d.ts.map +1 -1
- package/dist/page-furniture.js +8 -2
- package/dist/page-furniture.js.map +1 -1
- package/dist/plain-source.d.ts +1 -0
- package/dist/plain-source.d.ts.map +1 -1
- package/dist/plain-source.js +2 -1
- package/dist/plain-source.js.map +1 -1
- package/dist/plugin.d.ts +138 -1
- package/dist/plugin.d.ts.map +1 -1
- package/dist/profile/for-file.d.ts.map +1 -1
- package/dist/profile/for-file.js +3 -1
- package/dist/profile/for-file.js.map +1 -1
- package/dist/quoted-span.d.ts.map +1 -1
- package/dist/quoted-span.js +8 -3
- package/dist/quoted-span.js.map +1 -1
- package/dist/reasons.d.ts +4 -0
- package/dist/reasons.d.ts.map +1 -1
- package/dist/reasons.js +8 -0
- package/dist/reasons.js.map +1 -1
- package/dist/reference-lists.d.ts +3 -0
- package/dist/reference-lists.d.ts.map +1 -0
- package/dist/reference-lists.js +75 -0
- package/dist/reference-lists.js.map +1 -0
- package/dist/render/compact.d.ts +3 -1
- package/dist/render/compact.d.ts.map +1 -1
- package/dist/render/compact.js +8 -2
- package/dist/render/compact.js.map +1 -1
- package/dist/render/explain.d.ts +9 -1
- package/dist/render/explain.d.ts.map +1 -1
- package/dist/render/explain.js +54 -13
- package/dist/render/explain.js.map +1 -1
- package/dist/render/friendly.d.ts.map +1 -1
- package/dist/render/friendly.js +19 -9
- package/dist/render/friendly.js.map +1 -1
- package/dist/render/options.d.ts +7 -0
- package/dist/render/options.d.ts.map +1 -0
- package/dist/render/options.js +50 -0
- package/dist/render/options.js.map +1 -0
- package/dist/render/rules-json.d.ts +4 -1
- package/dist/render/rules-json.d.ts.map +1 -1
- package/dist/render/rules-json.js +110 -16
- package/dist/render/rules-json.js.map +1 -1
- package/dist/render/rules-table.d.ts +4 -0
- package/dist/render/rules-table.d.ts.map +1 -0
- package/dist/render/rules-table.js +70 -0
- package/dist/render/rules-table.js.map +1 -0
- package/dist/render/sarif.js +4 -4
- package/dist/render/sarif.js.map +1 -1
- package/dist/render/semantic.js +3 -3
- package/dist/render/semantic.js.map +1 -1
- package/dist/render/severity-name.d.ts +6 -0
- package/dist/render/severity-name.d.ts.map +1 -0
- package/dist/render/severity-name.js +7 -0
- package/dist/render/severity-name.js.map +1 -0
- package/dist/render/suppressions.d.ts +3 -0
- package/dist/render/suppressions.d.ts.map +1 -1
- package/dist/render/suppressions.js +20 -1
- package/dist/render/suppressions.js.map +1 -1
- package/dist/render/text.d.ts +7 -2
- package/dist/render/text.d.ts.map +1 -1
- package/dist/render/text.js +15 -4
- package/dist/render/text.js.map +1 -1
- package/dist/resolve-genre.d.ts +1 -1
- package/dist/resolve-genre.d.ts.map +1 -1
- package/dist/resolve-genre.js +4 -1
- package/dist/resolve-genre.js.map +1 -1
- package/dist/rule-genres.d.ts +24 -0
- package/dist/rule-genres.d.ts.map +1 -0
- package/dist/rule-genres.js +11 -0
- package/dist/rule-genres.js.map +1 -0
- package/dist/rule-guide.d.ts +73 -0
- package/dist/rule-guide.d.ts.map +1 -0
- package/dist/rule-guide.js +95 -0
- package/dist/rule-guide.js.map +1 -0
- package/dist/rule-load.d.ts.map +1 -1
- package/dist/rule-load.js +87 -33
- package/dist/rule-load.js.map +1 -1
- package/dist/rule-options.d.ts +50 -0
- package/dist/rule-options.d.ts.map +1 -0
- package/dist/rule-options.js +106 -0
- package/dist/rule-options.js.map +1 -0
- package/dist/run-semantic.d.ts.map +1 -1
- package/dist/run-semantic.js +2 -1
- package/dist/run-semantic.js.map +1 -1
- package/dist/run.d.ts +18 -1
- package/dist/run.d.ts.map +1 -1
- package/dist/run.js +80 -19
- package/dist/run.js.map +1 -1
- package/dist/sentence-shape.d.ts.map +1 -1
- package/dist/sentence-shape.js +4 -4
- package/dist/sentence-shape.js.map +1 -1
- package/dist/setting-problems.d.ts +2 -1
- package/dist/setting-problems.d.ts.map +1 -1
- package/dist/setting-problems.js +8 -1
- package/dist/setting-problems.js.map +1 -1
- package/dist/spacing-minority.d.ts +16 -0
- package/dist/spacing-minority.d.ts.map +1 -0
- package/dist/spacing-minority.js +23 -0
- package/dist/spacing-minority.js.map +1 -0
- package/dist/span-cut.d.ts +6 -0
- package/dist/span-cut.d.ts.map +1 -0
- package/dist/span-cut.js +22 -0
- package/dist/span-cut.js.map +1 -0
- package/dist/stet-block.d.ts +5 -0
- package/dist/stet-block.d.ts.map +1 -0
- package/dist/stet-block.js +59 -0
- package/dist/stet-block.js.map +1 -0
- package/dist/stet.d.ts +4 -0
- package/dist/stet.d.ts.map +1 -1
- package/dist/stet.js +31 -11
- package/dist/stet.js.map +1 -1
- package/dist/structure/aside-depth.d.ts +21 -0
- package/dist/structure/aside-depth.d.ts.map +1 -0
- package/dist/structure/aside-depth.js +65 -0
- package/dist/structure/aside-depth.js.map +1 -0
- package/dist/structure/build.d.ts +5 -1
- package/dist/structure/build.d.ts.map +1 -1
- package/dist/structure/build.js +29 -17
- package/dist/structure/build.js.map +1 -1
- package/dist/structure/closed-pairs.d.ts +8 -0
- package/dist/structure/closed-pairs.d.ts.map +1 -0
- package/dist/structure/closed-pairs.js +22 -0
- package/dist/structure/closed-pairs.js.map +1 -0
- package/dist/structure/date-range.d.ts +31 -0
- package/dist/structure/date-range.d.ts.map +1 -0
- package/dist/structure/date-range.js +77 -0
- package/dist/structure/date-range.js.map +1 -0
- package/dist/structure/definition-use.d.ts +32 -0
- package/dist/structure/definition-use.d.ts.map +1 -0
- package/dist/structure/definition-use.js +102 -0
- package/dist/structure/definition-use.js.map +1 -0
- package/dist/structure/known-mentions.d.ts +18 -0
- package/dist/structure/known-mentions.d.ts.map +1 -0
- package/dist/structure/known-mentions.js +78 -0
- package/dist/structure/known-mentions.js.map +1 -0
- package/dist/structure/lazy-tree.d.ts +8 -0
- package/dist/structure/lazy-tree.d.ts.map +1 -0
- package/dist/structure/lazy-tree.js +14 -0
- package/dist/structure/lazy-tree.js.map +1 -0
- package/dist/structure/modal-conflict.d.ts +28 -0
- package/dist/structure/modal-conflict.d.ts.map +1 -0
- package/dist/structure/modal-conflict.js +74 -0
- package/dist/structure/modal-conflict.js.map +1 -0
- package/dist/structure/numbered-clauses.d.ts +4 -0
- package/dist/structure/numbered-clauses.d.ts.map +1 -0
- package/dist/structure/numbered-clauses.js +9 -0
- package/dist/structure/numbered-clauses.js.map +1 -0
- package/dist/structure/numbering.d.ts +1 -0
- package/dist/structure/numbering.d.ts.map +1 -1
- package/dist/structure/numbering.js +11 -6
- package/dist/structure/numbering.js.map +1 -1
- package/dist/structure/of.d.ts +3 -1
- package/dist/structure/of.d.ts.map +1 -1
- package/dist/structure/of.js +5 -1
- package/dist/structure/of.js.map +1 -1
- package/dist/structure/percent-sum.d.ts +16 -0
- package/dist/structure/percent-sum.d.ts.map +1 -0
- package/dist/structure/percent-sum.js +104 -0
- package/dist/structure/percent-sum.js.map +1 -0
- package/dist/structure/quoted-number.d.ts +8 -0
- package/dist/structure/quoted-number.d.ts.map +1 -0
- package/dist/structure/quoted-number.js +34 -0
- package/dist/structure/quoted-number.js.map +1 -0
- package/dist/structure/relative-find.d.ts.map +1 -1
- package/dist/structure/relative-find.js +34 -46
- package/dist/structure/relative-find.js.map +1 -1
- package/dist/structure/relative-resolve.d.ts.map +1 -1
- package/dist/structure/relative-resolve.js +76 -30
- package/dist/structure/relative-resolve.js.map +1 -1
- package/dist/structure/runs.d.ts +2 -0
- package/dist/structure/runs.d.ts.map +1 -1
- package/dist/structure/runs.js +2 -2
- package/dist/structure/runs.js.map +1 -1
- package/dist/structure/sexp.d.ts +1 -1
- package/dist/structure/sexp.d.ts.map +1 -1
- package/dist/structure/sexp.js +18 -6
- package/dist/structure/sexp.js.map +1 -1
- package/dist/structure/total.d.ts +3 -0
- package/dist/structure/total.d.ts.map +1 -1
- package/dist/structure/total.js +2 -2
- package/dist/structure/total.js.map +1 -1
- package/dist/structure/universal.d.ts +14 -2
- package/dist/structure/universal.d.ts.map +1 -1
- package/dist/structure/universal.js +24 -3
- package/dist/structure/universal.js.map +1 -1
- package/dist/structure/wrapped-tail.d.ts +14 -7
- package/dist/structure/wrapped-tail.d.ts.map +1 -1
- package/dist/structure/wrapped-tail.js +33 -8
- package/dist/structure/wrapped-tail.js.map +1 -1
- package/dist/style-load.d.ts +4 -0
- package/dist/style-load.d.ts.map +1 -0
- package/dist/style-load.js +28 -0
- package/dist/style-load.js.map +1 -0
- package/dist/style-parse.d.ts +25 -0
- package/dist/style-parse.d.ts.map +1 -0
- package/dist/style-parse.js +88 -0
- package/dist/style-parse.js.map +1 -0
- package/dist/subheading-line.d.ts +23 -0
- package/dist/subheading-line.d.ts.map +1 -0
- package/dist/subheading-line.js +85 -0
- package/dist/subheading-line.js.map +1 -0
- package/dist/tag-coverage.d.ts +8 -0
- package/dist/tag-coverage.d.ts.map +1 -0
- package/dist/tag-coverage.js +7 -0
- package/dist/tag-coverage.js.map +1 -0
- package/dist/template-syntax.d.ts +17 -0
- package/dist/template-syntax.d.ts.map +1 -0
- package/dist/template-syntax.js +140 -0
- package/dist/template-syntax.js.map +1 -0
- package/dist/text-above.d.ts +19 -0
- package/dist/text-above.d.ts.map +1 -0
- package/dist/text-above.js +43 -0
- package/dist/text-above.js.map +1 -0
- package/dist/text-figures.d.ts +10 -0
- package/dist/text-figures.d.ts.map +1 -0
- package/dist/text-figures.js +131 -0
- package/dist/text-figures.js.map +1 -0
- package/dist/trailing-aside.d.ts +2 -0
- package/dist/trailing-aside.d.ts.map +1 -0
- package/dist/trailing-aside.js +53 -0
- package/dist/trailing-aside.js.map +1 -0
- package/dist/tree-walk.d.ts +18 -0
- package/dist/tree-walk.d.ts.map +1 -0
- package/dist/tree-walk.js +45 -0
- package/dist/tree-walk.js.map +1 -0
- package/genres.yaml +68 -0
- package/package.json +9 -3
- package/reference-headings.yaml +17 -0
- package/rules/acronym-expansion-conflict.yaml +82 -0
- package/rules/adverb-overuse.yaml +19 -0
- package/rules/agentless-passive.yaml +47 -0
- package/rules/agreement-slip.yaml +14 -1
- package/rules/ai-generated-composite.yaml +102 -0
- package/rules/ai-tell.yaml +57 -0
- package/rules/announced-count-mismatch.yaml +57 -0
- package/rules/announcing-opener.yaml +82 -0
- package/rules/assistant-residue.yaml +82 -0
- package/rules/bold-density.yaml +59 -0
- package/rules/bold-label-list.yaml +81 -0
- package/rules/broken-link.yaml +65 -0
- package/rules/closing-cliche.yaml +58 -0
- package/rules/colon-lead-in.yaml +83 -0
- package/rules/concrete-evidence-density.yaml +41 -0
- package/rules/contraction-consistency.yaml +18 -0
- package/rules/contrast-framing.yaml +88 -0
- package/rules/cushion-phrase-density.yaml +53 -1
- package/rules/dangling-figure-reference.yaml +61 -0
- package/rules/dangling-reference.yaml +54 -1
- package/rules/date-order.yaml +34 -1
- package/rules/date-range-reversed.yaml +46 -0
- package/rules/date-weekday-mismatch.yaml +17 -1
- package/rules/double-keigo.yaml +16 -0
- package/rules/double-negative.yaml +51 -0
- package/rules/doubled-punctuation.yaml +45 -0
- package/rules/doubled-word.yaml +18 -2
- package/rules/duplicate-definition.yaml +59 -1
- package/rules/duplicate-heading.yaml +78 -0
- package/rules/emoji-density.yaml +28 -2
- package/rules/empty-conclusion.yaml +28 -0
- package/rules/empty-intensifier.yaml +44 -0
- package/rules/empty-section.yaml +74 -0
- package/rules/excessive-hedging.yaml +49 -2
- package/rules/expletive-construction.yaml +19 -0
- package/rules/fullwidth-alnum-consistency.yaml +53 -0
- package/rules/hankaku-kana.yaml +41 -0
- package/rules/heading-echo.yaml +31 -0
- package/rules/heading-level-skip.yaml +78 -0
- package/rules/hiragana-fukushi.yaml +16 -0
- package/rules/image-alt-text.yaml +54 -0
- package/rules/internal-jargon.yaml +21 -0
- package/rules/invisible-character.yaml +63 -0
- package/rules/katakana-long-vowel.yaml +99 -0
- package/rules/kutoten-consistency.yaml +53 -0
- package/rules/latin-spacing.yaml +30 -4
- package/rules/max-kanji-continuous.yaml +17 -0
- package/rules/max-paragraph-length.yaml +34 -0
- package/rules/max-sentence-length.yaml +58 -0
- package/rules/modal-conflict.yaml +106 -0
- package/rules/name-variant.yaml +88 -0
- package/rules/ngram-repetition.yaml +29 -2
- package/rules/no-doubled-joshi.yaml +17 -0
- package/rules/no-em-dash.yaml +49 -0
- package/rules/no-mixed-desumasu.yaml +28 -2
- package/rules/no-nakaguro-parallel.yaml +20 -0
- package/rules/nominalization.yaml +89 -0
- package/rules/numbering-gap.yaml +53 -1
- package/rules/outside-announced-list.yaml +80 -0
- package/rules/oxford-comma-consistency.yaml +18 -0
- package/rules/padded-intro.yaml +44 -0
- package/rules/paragraph-length-variance.yaml +73 -0
- package/rules/percent-sum-mismatch.yaml +58 -0
- package/rules/preamble-length.yaml +56 -0
- package/rules/preferred-term.yaml +28 -0
- package/rules/proper-noun-density.yaml +37 -2
- package/rules/ra-nuki.yaml +43 -0
- package/rules/repeated-conjunction.yaml +47 -0
- package/rules/repeated-sentence-head.yaml +23 -0
- package/rules/required-sections.yaml +49 -0
- package/rules/requirement-modal.yaml +94 -0
- package/rules/requirement-smell.yaml +70 -0
- package/rules/risk-disclosure.yaml +22 -0
- package/rules/rule-of-three.yaml +143 -0
- package/rules/sasete-itadaku.yaml +18 -0
- package/rules/section-length-uniformity.yaml +113 -0
- package/rules/sentence-initial-conjunction-run.yaml +18 -0
- package/rules/sentence-rhythm.yaml +51 -0
- package/rules/space-before-punctuation.yaml +41 -0
- package/rules/spelling-consistency.yaml +47 -0
- package/rules/stock-transition.yaml +86 -0
- package/rules/stray-space.yaml +18 -0
- package/rules/taigen-dome-in-prose.yaml +33 -0
- package/rules/title-case-consistency.yaml +42 -0
- package/rules/total-mismatch.yaml +38 -1
- package/rules/unbalanced-bracket.yaml +56 -0
- package/rules/undefined-acronym.yaml +23 -0
- package/rules/unfilled-placeholder.yaml +50 -0
- package/rules/unqualified-superlative.yaml +20 -0
- package/rules/unsourced-number.yaml +16 -0
- package/rules/unused-definition.yaml +75 -0
- package/rules/url-run-on.yaml +45 -0
- package/rules/use-before-definition.yaml +77 -0
- package/rules/vague-figure-reference.yaml +66 -0
- package/skills/chaff/SKILL.md +171 -1
- package/src/acronym-expansions.ts +106 -0
- package/src/announced-count.ts +190 -0
- package/src/announced-list.ts +120 -0
- package/src/api.ts +154 -0
- package/src/bare-url.ts +35 -0
- package/src/baseline.ts +17 -1
- package/src/body-section.ts +7 -0
- package/src/calendar-number.ts +18 -4
- package/src/cli-args.ts +6 -0
- package/src/cli-text.ts +14 -15
- package/src/cli.ts +93 -92
- package/src/closing-paragraph.ts +24 -0
- package/src/commands/compare.ts +73 -0
- package/src/commands/document-commands.ts +19 -0
- package/src/commands/eval.ts +22 -10
- package/src/commands/facts.ts +33 -0
- package/src/commands/feedback.ts +45 -7
- package/src/commands/fix-plan.ts +53 -0
- package/src/commands/outline.ts +49 -0
- package/src/commands/read-document.ts +24 -0
- package/src/commands/suppressions.ts +19 -0
- package/src/commands/test.ts +3 -5
- package/src/commands/tree.ts +41 -5
- package/src/compare/atom.ts +33 -0
- package/src/compare/clock-time.ts +89 -0
- package/src/compare/distinct.ts +13 -0
- package/src/compare/extract.ts +80 -0
- package/src/compare/fact-key.ts +31 -0
- package/src/compare/fact-text.ts +87 -0
- package/src/compare/facts-render.ts +63 -0
- package/src/compare/facts-text.ts +41 -0
- package/src/compare/markup-atoms.ts +29 -0
- package/src/compare/match.ts +105 -0
- package/src/compare/outcome.ts +80 -0
- package/src/compare/proper-nouns.ts +65 -0
- package/src/compare/render.ts +102 -0
- package/src/compare/spans.ts +17 -0
- package/src/compare/text-atoms.ts +96 -0
- package/src/compare/text.ts +121 -0
- package/src/compare/tree-atoms.ts +80 -0
- package/src/compare/written-names.ts +26 -0
- package/src/config/load.ts +30 -0
- package/src/config/option-problems.ts +72 -0
- package/src/config/read.ts +8 -0
- package/src/config/rule-problems.ts +12 -2
- package/src/config/style.ts +55 -0
- package/src/config/warnings.ts +13 -0
- package/src/config/write.ts +18 -4
- package/src/custom/bounded-match.ts +58 -0
- package/src/custom/load.ts +23 -0
- package/src/custom/module-path.ts +23 -0
- package/src/custom/parse.ts +323 -0
- package/src/custom/problems.ts +111 -0
- package/src/custom/regex-safety.ts +118 -0
- package/src/custom/token-pattern.ts +84 -0
- package/src/detect-language.ts +1 -1
- package/src/detect.ts +35 -2
- package/src/detectors/acronym-context.ts +16 -4
- package/src/detectors/ai-phrasing.ts +141 -0
- package/src/detectors/announced-count.ts +25 -0
- package/src/detectors/bold-label.ts +55 -0
- package/src/detectors/broken-link.ts +90 -0
- package/src/detectors/cited-name.ts +6 -5
- package/src/detectors/cited-title.ts +96 -0
- package/src/detectors/concrete-evidence.ts +3 -2
- package/src/detectors/contrast-frame.ts +54 -0
- package/src/detectors/custom.ts +89 -0
- package/src/detectors/dangling-figure.ts +26 -0
- package/src/detectors/definition-use.ts +41 -0
- package/src/detectors/doubled-punctuation.ts +52 -0
- package/src/detectors/doubled-word.ts +19 -4
- package/src/detectors/duplicate-heading.ts +47 -0
- package/src/detectors/empty-section.ts +21 -0
- package/src/detectors/enumerated-runs.ts +13 -4
- package/src/detectors/fullwidth-alnum.ts +118 -0
- package/src/detectors/gram-furniture.ts +30 -0
- package/src/detectors/gram-place.ts +9 -5
- package/src/detectors/gram-windows.ts +31 -0
- package/src/detectors/hankaku-kana.ts +38 -0
- package/src/detectors/heading-case.ts +30 -2
- package/src/detectors/heading-code-words.ts +35 -0
- package/src/detectors/heading-echo.ts +8 -4
- package/src/detectors/heading-level-skip.ts +19 -0
- package/src/detectors/image-alt-text.ts +11 -0
- package/src/detectors/index.ts +79 -1
- package/src/detectors/invisible-character.ts +190 -0
- package/src/detectors/kutoten-consistency.ts +96 -0
- package/src/detectors/lead-in.ts +3 -1
- package/src/detectors/lexicon-match.ts +41 -2
- package/src/detectors/lexicon.ts +40 -13
- package/src/detectors/list-item.ts +122 -0
- package/src/detectors/list-items.ts +163 -0
- package/src/detectors/list-lead-in.ts +33 -0
- package/src/detectors/list-sentence.ts +198 -0
- package/src/detectors/list-view.ts +157 -0
- package/src/detectors/long-vowel.ts +82 -0
- package/src/detectors/markup-finding.ts +39 -0
- package/src/detectors/modal-conflict.ts +26 -0
- package/src/detectors/name-numeral.ts +4 -2
- package/src/detectors/name-variant.ts +15 -0
- package/src/detectors/nominalization.ts +73 -0
- package/src/detectors/orthography.ts +97 -41
- package/src/detectors/outside-announced-list.ts +25 -0
- package/src/detectors/oxford-comma.ts +179 -283
- package/src/detectors/phrase-match.ts +27 -7
- package/src/detectors/place-run.ts +7 -4
- package/src/detectors/placeholder-text.ts +27 -0
- package/src/detectors/quote-around.ts +9 -0
- package/src/detectors/ra-nuki.ts +38 -0
- package/src/detectors/register.ts +37 -10
- package/src/detectors/requirement-modal.ts +67 -0
- package/src/detectors/requirement-smell.ts +52 -0
- package/src/detectors/roman-numeral.ts +3 -0
- package/src/detectors/sentence-ending.ts +14 -7
- package/src/detectors/sentence-length.ts +16 -5
- package/src/detectors/signals.ts +80 -46
- package/src/detectors/space-before-punctuation.ts +32 -0
- package/src/detectors/spelling-variety.ts +81 -0
- package/src/detectors/structure-tree.ts +47 -1
- package/src/detectors/structure.ts +20 -7
- package/src/detectors/superlative-comparison.ts +47 -0
- package/src/detectors/superlative-name.ts +7 -4
- package/src/detectors/superlative-scope.ts +8 -3
- package/src/detectors/token-column.ts +149 -0
- package/src/detectors/unbalanced-bracket.ts +153 -0
- package/src/detectors/url-run-on.ts +33 -0
- package/src/detectors/vague-figure-pointer.ts +58 -0
- package/src/detectors/word-list.ts +6 -1
- package/src/document-sections.ts +46 -0
- package/src/document.ts +188 -173
- package/src/email-parts.ts +269 -0
- package/src/eval.ts +14 -4
- package/src/extension/document-view.ts +109 -0
- package/src/extension/failure-text.ts +46 -0
- package/src/extension/import-default.ts +13 -0
- package/src/extension/load.ts +97 -0
- package/src/extension/module-detector.ts +61 -0
- package/src/extension/plugin-load.ts +82 -0
- package/src/extension/plugin-name.ts +26 -0
- package/src/extension/plugin-parse.ts +229 -0
- package/src/extension/problem-text.ts +103 -0
- package/src/extension/real-path.ts +10 -0
- package/src/extension/returned-findings.ts +62 -0
- package/src/extension/rule-export.ts +23 -0
- package/src/feedback/draft.ts +6 -0
- package/src/figure-references.ts +173 -0
- package/src/files.ts +5 -0
- package/src/finding-order.ts +3 -0
- package/src/fix-plan/mode.ts +34 -0
- package/src/fix-plan/plan.ts +181 -0
- package/src/fix-plan/render.ts +128 -0
- package/src/fix-plan/text.ts +133 -0
- package/src/heading-label.ts +55 -0
- package/src/in-page-nav.ts +48 -19
- package/src/joined-view.ts +1 -0
- package/src/language-sample.ts +48 -0
- package/src/levels.ts +14 -1
- package/src/line-paragraphs.ts +52 -9
- package/src/link-line.ts +13 -0
- package/src/long-vowel.ts +109 -0
- package/src/markdown-node.ts +19 -0
- package/src/markdown-read.ts +44 -0
- package/src/markup.ts +212 -0
- package/src/mask.ts +8 -8
- package/src/name-variants.ts +217 -0
- package/src/node-version.ts +22 -0
- package/src/not-run.ts +16 -0
- package/src/number-name.ts +151 -24
- package/src/orthography.ts +50 -14
- package/src/outline/render.ts +85 -0
- package/src/outline/shape.ts +72 -0
- package/src/outline/text.ts +50 -0
- package/src/page-furniture.ts +11 -2
- package/src/plain-source.ts +2 -1
- package/src/plugin.ts +120 -3
- package/src/profile/for-file.ts +3 -1
- package/src/quoted-span.ts +9 -3
- package/src/reasons.ts +12 -0
- package/src/reference-lists.ts +91 -0
- package/src/render/compact.ts +13 -3
- package/src/render/explain.ts +75 -14
- package/src/render/friendly.ts +20 -9
- package/src/render/options.ts +58 -0
- package/src/render/rules-json.ts +140 -18
- package/src/render/rules-table.ts +91 -0
- package/src/render/sarif.ts +4 -4
- package/src/render/semantic.ts +3 -3
- package/src/render/severity-name.ts +10 -0
- package/src/render/suppressions.ts +30 -2
- package/src/render/text.ts +21 -7
- package/src/resolve-genre.ts +4 -1
- package/src/rule-genres.ts +25 -0
- package/src/rule-guide.ts +173 -0
- package/src/rule-load.ts +91 -34
- package/src/rule-options.ts +131 -0
- package/src/run-semantic.ts +2 -1
- package/src/run.ts +105 -22
- package/src/sentence-shape.ts +4 -5
- package/src/setting-problems.ts +9 -1
- package/src/spacing-minority.ts +27 -0
- package/src/span-cut.ts +28 -0
- package/src/stet-block.ts +60 -0
- package/src/stet.ts +41 -15
- package/src/structure/aside-depth.ts +67 -0
- package/src/structure/build.ts +38 -19
- package/src/structure/closed-pairs.ts +20 -0
- package/src/structure/date-range.ts +117 -0
- package/src/structure/definition-use.ts +130 -0
- package/src/structure/known-mentions.ts +96 -0
- package/src/structure/lazy-tree.ts +15 -0
- package/src/structure/modal-conflict.ts +86 -0
- package/src/structure/numbered-clauses.ts +11 -0
- package/src/structure/numbering.ts +9 -5
- package/src/structure/of.ts +11 -3
- package/src/structure/percent-sum.ts +135 -0
- package/src/structure/quoted-number.ts +36 -0
- package/src/structure/relative-find.ts +34 -47
- package/src/structure/relative-resolve.ts +77 -30
- package/src/structure/runs.ts +2 -2
- package/src/structure/sexp.ts +17 -5
- package/src/structure/total.ts +2 -2
- package/src/structure/universal.ts +33 -5
- package/src/structure/wrapped-tail.ts +38 -13
- package/src/style-load.ts +28 -0
- package/src/style-parse.ts +112 -0
- package/src/subheading-line.ts +106 -0
- package/src/tag-coverage.ts +13 -0
- package/src/template-syntax.ts +164 -0
- package/src/text-above.ts +49 -0
- package/src/text-figures.ts +147 -0
- package/src/trailing-aside.ts +50 -0
- package/src/tree-walk.ts +48 -0
- package/styles/bunkacho.yaml +25 -0
- package/styles/ieice.yaml +30 -0
- package/styles/jis-z8301-2011.yaml +28 -0
- package/styles/jis-z8301-2019.yaml +31 -0
- package/styles/koyobun.yaml +35 -0
- package/dist/legal-address.d.ts +0 -2
- package/dist/legal-address.d.ts.map +0 -1
- package/dist/legal-address.js +0 -16
- package/dist/legal-address.js.map +0 -1
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { createContext, Script } from "node:vm";
|
|
2
|
+
|
|
3
|
+
// A team's regular expression, run with a time limit. regex-safety.ts refuses the shapes known to run away before a pattern
|
|
4
|
+
// is used; no reading of the pattern can prove every shape safe, so this is the backstop. V8 can interrupt a regular
|
|
5
|
+
// expression only through vm's timeout, so the matching runs in a vm context.
|
|
6
|
+
|
|
7
|
+
/** How long one rule's pattern may take over one document. Far above what a sane pattern needs on any real document. */
|
|
8
|
+
export const PATTERN_BUDGET_MS = 1000;
|
|
9
|
+
|
|
10
|
+
/** A pattern that did not finish within its budget. run.ts lists the rule as not run, with this as the reason. */
|
|
11
|
+
export class PatternTimeout extends Error {
|
|
12
|
+
readonly budget_ms: number;
|
|
13
|
+
constructor(budgetMs: number) {
|
|
14
|
+
super(`the pattern did not finish within ${String(budgetMs)} ms`);
|
|
15
|
+
this.name = "PatternTimeout";
|
|
16
|
+
this.budget_ms = budgetMs;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** Each text's matches: where it starts and what it matched. Empty matches are left out. */
|
|
21
|
+
export type TextMatches = readonly (readonly { readonly index: number; readonly text: string }[])[];
|
|
22
|
+
|
|
23
|
+
const SCRIPT = new Script(
|
|
24
|
+
`texts.map((text) => [...text.matchAll(new RegExp(source, flags))].filter((m) => m[0] !== "").map((m) => ({ index: m.index, text: m[0] })))`,
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
const isTimeout = (error: unknown): boolean => typeof error === "object" && error !== null && "code" in error && error.code === "ERR_SCRIPT_EXECUTION_TIMEOUT";
|
|
28
|
+
|
|
29
|
+
const isMatches = (value: unknown): value is TextMatches =>
|
|
30
|
+
Array.isArray(value) &&
|
|
31
|
+
value.every(
|
|
32
|
+
(entry: unknown) =>
|
|
33
|
+
Array.isArray(entry) &&
|
|
34
|
+
entry.every(
|
|
35
|
+
(match: unknown) =>
|
|
36
|
+
typeof match === "object" &&
|
|
37
|
+
match !== null &&
|
|
38
|
+
"index" in match &&
|
|
39
|
+
typeof match.index === "number" &&
|
|
40
|
+
"text" in match &&
|
|
41
|
+
typeof match.text === "string",
|
|
42
|
+
),
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
/** Every match of the pattern (flags without g) in each text, or PatternTimeout when the whole run takes longer than budgetMs. */
|
|
46
|
+
export const boundedMatches = (source: string, flags: string, texts: readonly string[], budgetMs: number = PATTERN_BUDGET_MS): TextMatches => {
|
|
47
|
+
const context = createContext({ texts: [...texts], source, flags: `g${flags}` });
|
|
48
|
+
try {
|
|
49
|
+
const result: unknown = SCRIPT.runInContext(context, { timeout: budgetMs });
|
|
50
|
+
// The result is built in another context; copy it through JSON so it holds plain values of this one.
|
|
51
|
+
const plain: unknown = JSON.parse(JSON.stringify(result));
|
|
52
|
+
if (!isMatches(plain)) throw new Error("chaff: the pattern's matches came back in an unexpected shape");
|
|
53
|
+
return plain;
|
|
54
|
+
} catch (error) {
|
|
55
|
+
if (isTimeout(error)) throw new PatternTimeout(budgetMs);
|
|
56
|
+
throw error;
|
|
57
|
+
}
|
|
58
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Config } from "../config/load.ts";
|
|
2
|
+
import type { RuleDefinition } from "../plugin.ts";
|
|
3
|
+
import { loadRules } from "../rule-load.ts";
|
|
4
|
+
import { loadGenres } from "../genre-load.ts";
|
|
5
|
+
import { parseCustomRules, type CustomRules } from "./parse.ts";
|
|
6
|
+
|
|
7
|
+
/** The team's custom_rules as rules, with what could not be read. A team's rule applies to every genre, like the team's words. */
|
|
8
|
+
export const customRulesOf = (config: Pick<Config, "customRules" | "baseDir">): CustomRules =>
|
|
9
|
+
parseCustomRules(config.customRules, {
|
|
10
|
+
builtIn: new Set(loadRules("en").map((rule) => rule.id)),
|
|
11
|
+
useFor: loadGenres().groups.map((group) => group.id),
|
|
12
|
+
baseDir: config.baseDir,
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Every rule a run knows for a language: chaff's own, the team's, then the plugins'. Where the team's or a plugin's
|
|
17
|
+
* cannot be read, settingProblems stops the run.
|
|
18
|
+
*/
|
|
19
|
+
export const rulesOf = (language: string, config: Pick<Config, "customRules" | "baseDir" | "extensions">): RuleDefinition[] => [
|
|
20
|
+
...loadRules(language),
|
|
21
|
+
...customRulesOf(config).rules,
|
|
22
|
+
...(config.extensions?.rules ?? []),
|
|
23
|
+
];
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { isAbsolute, relative, resolve, sep } from "node:path";
|
|
2
|
+
|
|
3
|
+
// Where a type: module rule's file is. Loading it runs its code, so a relative path may not leave the folder chaff.yaml
|
|
4
|
+
// is in: a chaff.yaml copied from elsewhere cannot reach for ../../somewhere. An absolute path is written on purpose and
|
|
5
|
+
// is used as written. Pure: no file is read.
|
|
6
|
+
|
|
7
|
+
export type ModulePathRefusal = "outside";
|
|
8
|
+
|
|
9
|
+
export type ModulePath = { readonly file: string } | { readonly refusal: ModulePathRefusal };
|
|
10
|
+
|
|
11
|
+
/** Whether file is inside dir (dir itself is not). Reads no file: the same check runs on real paths at load time. */
|
|
12
|
+
export const isInside = (dir: string, file: string): boolean => {
|
|
13
|
+
const fromDir = relative(dir, file);
|
|
14
|
+
const leaves = fromDir === ".." || fromDir.startsWith(`..${sep}`);
|
|
15
|
+
return fromDir !== "" && !leaves && !isAbsolute(fromDir);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
/** The file a module path names, relative to baseDir (where chaff.yaml is) unless it is absolute. */
|
|
19
|
+
export const modulePathOf = (written: string, baseDir: string): ModulePath => {
|
|
20
|
+
if (isAbsolute(written)) return { file: written };
|
|
21
|
+
const file = resolve(baseDir, written);
|
|
22
|
+
return isInside(baseDir, file) ? { file } : { refusal: "outside" };
|
|
23
|
+
};
|
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
import type { CustomSpec, LevelTable, Localized, RuleDefinition, Severity, TokenCondition } from "../plugin.ts";
|
|
2
|
+
import { regexRefusal, type RegexRefusal } from "./regex-safety.ts";
|
|
3
|
+
import { posTags } from "./token-pattern.ts";
|
|
4
|
+
import { modulePathOf, type ModulePathRefusal } from "./module-path.ts";
|
|
5
|
+
|
|
6
|
+
// custom_rules in chaff.yaml: a team's own deterministic rules, written without code. Each becomes a RuleDefinition like the
|
|
7
|
+
// built-in ones, so findings, explain, rules --json, stet, the baseline and SARIF treat it the same. Pure: the YAML comes in parsed.
|
|
8
|
+
|
|
9
|
+
export const CUSTOM_TYPES = ["words", "pattern", "tokens", "module"] as const;
|
|
10
|
+
|
|
11
|
+
export type CustomProblem =
|
|
12
|
+
| { readonly kind: "not-a-list" }
|
|
13
|
+
| { readonly kind: "not-a-map"; readonly at: string }
|
|
14
|
+
| { readonly kind: "bad-id"; readonly at: string }
|
|
15
|
+
| { readonly kind: "duplicate-id"; readonly at: string }
|
|
16
|
+
| { readonly kind: "built-in-id"; readonly at: string }
|
|
17
|
+
| { readonly kind: "unknown-type"; readonly at: string; readonly written: string }
|
|
18
|
+
| { readonly kind: "bad-module"; readonly at: string; readonly written: string; readonly refusal: ModulePathRefusal }
|
|
19
|
+
| { readonly kind: "bad-requires"; readonly at: string; readonly written: string }
|
|
20
|
+
| { readonly kind: "bad-word-list"; readonly at: string; readonly written: string }
|
|
21
|
+
| { readonly kind: "missing"; readonly at: string; readonly field: string }
|
|
22
|
+
| { readonly kind: "unpaired-example"; readonly at: string }
|
|
23
|
+
| { readonly kind: "bad-level"; readonly at: string; readonly written: string }
|
|
24
|
+
| { readonly kind: "bad-languages"; readonly at: string }
|
|
25
|
+
| { readonly kind: "no-words"; readonly at: string }
|
|
26
|
+
| { readonly kind: "bad-pattern"; readonly at: string; readonly refusal: RegexRefusal }
|
|
27
|
+
| { readonly kind: "no-tokens"; readonly at: string }
|
|
28
|
+
| { readonly kind: "bad-token"; readonly at: string; readonly index: number }
|
|
29
|
+
| { readonly kind: "unknown-pos"; readonly at: string; readonly written: string };
|
|
30
|
+
|
|
31
|
+
export type CustomRules = { readonly rules: readonly RuleDefinition[]; readonly problems: readonly CustomProblem[] };
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* What parsing needs to know: the built-in rule ids (a team's rule may not take one), the genres a rule applies to, and
|
|
35
|
+
* the folder a module's path is relative to (where chaff.yaml is).
|
|
36
|
+
*/
|
|
37
|
+
export type CustomContext = { readonly builtIn: ReadonlySet<string>; readonly useFor: readonly string[]; readonly baseDir: string };
|
|
38
|
+
|
|
39
|
+
const RULE_ID = /^[a-z][a-z0-9-]*$/u;
|
|
40
|
+
const SEVERITIES: readonly Severity[] = ["info", "warning", "error"];
|
|
41
|
+
|
|
42
|
+
const isRecord = (value: unknown): value is Record<string, unknown> => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
43
|
+
|
|
44
|
+
const nonEmpty = (value: unknown): value is string => typeof value === "string" && value.trim() !== "";
|
|
45
|
+
|
|
46
|
+
/** Texts by language ({ ja, en } or any language's id). undefined when there is none. */
|
|
47
|
+
const byLanguageOf = (value: unknown): Localized | undefined => {
|
|
48
|
+
if (!isRecord(value)) return undefined;
|
|
49
|
+
const entries = Object.entries(value).filter((entry): entry is [string, string] => nonEmpty(entry[1]));
|
|
50
|
+
return entries.length === 0 ? undefined : Object.fromEntries(entries.map(([language, text]) => [language, text.trim()]));
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
/** A text by language, or one string for ja and en (and, through the "en" fallback, for any other language). */
|
|
54
|
+
const localizedOf = (value: unknown): Localized | undefined => (nonEmpty(value) ? { ja: value.trim(), en: value.trim() } : byLanguageOf(value));
|
|
55
|
+
|
|
56
|
+
/** The key an example side written as one string is kept under: it reads the same in every language. */
|
|
57
|
+
const EVERY_LANGUAGE = "*";
|
|
58
|
+
|
|
59
|
+
const exampleSideOf = (value: unknown): Localized | undefined => (nonEmpty(value) ? { [EVERY_LANGUAGE]: value.trim() } : byLanguageOf(value));
|
|
60
|
+
|
|
61
|
+
/** One rule's own problems, with the rule's id (or its place in the list) as where. */
|
|
62
|
+
type Checked<T> = { readonly value: T | undefined; readonly problems: readonly CustomProblem[] };
|
|
63
|
+
|
|
64
|
+
const ok = <T>(value: T): Checked<T> => ({ value, problems: [] });
|
|
65
|
+
const failed = <T>(...problems: CustomProblem[]): Checked<T> => ({ value: undefined, problems });
|
|
66
|
+
|
|
67
|
+
type Pair = { readonly avoid: string; readonly use: string };
|
|
68
|
+
|
|
69
|
+
/** words as a map (avoid: use) or a list (words to point at, with nothing to use instead). */
|
|
70
|
+
const pairsOf = (raw: unknown): Pair[] => {
|
|
71
|
+
if (Array.isArray(raw)) return raw.filter(nonEmpty).map((avoid) => ({ avoid: avoid.trim(), use: "" }));
|
|
72
|
+
if (!isRecord(raw)) return [];
|
|
73
|
+
return Object.entries(raw).flatMap(([avoid, use]) => (avoid.trim() === "" ? [] : [{ avoid: avoid.trim(), use: nonEmpty(use) ? use.trim() : "" }]));
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const printed = (value: unknown): string => JSON.stringify(value) ?? "undefined";
|
|
77
|
+
|
|
78
|
+
const wordsOf = (raw: unknown, at: string): Checked<CustomSpec> => {
|
|
79
|
+
const usable = pairsOf(raw).filter((pair) => pair.avoid !== pair.use);
|
|
80
|
+
return usable.length === 0 ? failed({ kind: "no-words", at }) : ok({ type: "words", words: usable });
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
const patternOf = (raw: Record<string, unknown>, at: string): Checked<CustomSpec> => {
|
|
84
|
+
const pattern = raw["pattern"];
|
|
85
|
+
if (!nonEmpty(pattern)) return failed({ kind: "missing", at, field: "pattern" });
|
|
86
|
+
const flags = raw["ignore_case"] === true ? "iu" : "u";
|
|
87
|
+
const refusal = regexRefusal(pattern, flags);
|
|
88
|
+
return refusal === undefined ? ok({ type: "pattern", pattern, flags }) : failed({ kind: "bad-pattern", at, refusal });
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
const posOf = (raw: unknown, at: string): Checked<readonly string[]> => {
|
|
92
|
+
if (raw === undefined) return ok([]);
|
|
93
|
+
const written = (Array.isArray(raw) ? raw : [raw]).map((entry: unknown) => (typeof entry === "string" ? entry : printed(entry)));
|
|
94
|
+
const unknown = written.find((name) => posTags(name) === undefined);
|
|
95
|
+
if (unknown !== undefined) return failed({ kind: "unknown-pos", at, written: unknown });
|
|
96
|
+
return ok([...new Set(written.flatMap((name) => posTags(name) ?? []))]);
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
const conditionOf = (raw: unknown, index: number, at: string): Checked<TokenCondition> => {
|
|
100
|
+
if (!isRecord(raw)) return failed({ kind: "bad-token", at, index });
|
|
101
|
+
const pos = posOf(raw["pos"], at);
|
|
102
|
+
if (pos.value === undefined) return failed(...pos.problems);
|
|
103
|
+
// lemma is the linguists' word for the base form; either may be written.
|
|
104
|
+
const written = raw["base"] ?? raw["lemma"];
|
|
105
|
+
const base = nonEmpty(written) ? written.trim() : undefined;
|
|
106
|
+
const surface = nonEmpty(raw["surface"]) ? raw["surface"].trim() : undefined;
|
|
107
|
+
if (pos.value.length === 0 && base === undefined && surface === undefined) return failed({ kind: "bad-token", at, index });
|
|
108
|
+
return ok({ ...(pos.value.length === 0 ? {} : { pos: pos.value }), ...(base === undefined ? {} : { base }), ...(surface === undefined ? {} : { surface }) });
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
const tokensOf = (raw: unknown, at: string): Checked<CustomSpec> => {
|
|
112
|
+
if (!Array.isArray(raw) || raw.length === 0) return failed({ kind: "no-tokens", at });
|
|
113
|
+
const checked = raw.map((entry: unknown, index) => conditionOf(entry, index + 1, at));
|
|
114
|
+
const problems = checked.flatMap((entry) => entry.problems);
|
|
115
|
+
const tokens = checked.flatMap((entry) => (entry.value === undefined ? [] : [entry.value]));
|
|
116
|
+
return problems.length > 0 ? failed(...problems) : ok({ type: "tokens", tokens });
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
const moduleOf = (raw: Record<string, unknown>, at: string, baseDir: string): Checked<CustomSpec> => {
|
|
120
|
+
const written = raw["module"];
|
|
121
|
+
if (!nonEmpty(written)) return failed({ kind: "missing", at, field: "module" });
|
|
122
|
+
const path = modulePathOf(written.trim(), baseDir);
|
|
123
|
+
if ("refusal" in path) return failed({ kind: "bad-module", at, written, refusal: path.refusal });
|
|
124
|
+
return ok({ type: "module", module: written.trim(), file: path.file });
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
const specOf = (raw: Record<string, unknown>, type: string, at: string, baseDir: string): Checked<CustomSpec> => {
|
|
128
|
+
if (type === "words") return wordsOf(raw["words"], at);
|
|
129
|
+
if (type === "pattern") return patternOf(raw, at);
|
|
130
|
+
if (type === "module") return moduleOf(raw, at, baseDir);
|
|
131
|
+
return tokensOf(raw["tokens"], at);
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
const typeOf = (raw: Record<string, unknown>, at: string): Checked<string> => {
|
|
135
|
+
const type = raw["type"];
|
|
136
|
+
if (!nonEmpty(type)) return failed({ kind: "missing", at, field: "type" });
|
|
137
|
+
return CUSTOM_TYPES.some((known) => known === type) ? ok(type) : failed({ kind: "unknown-type", at, written: type });
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
const severityOf = (raw: unknown, at: string): Checked<Severity> => {
|
|
141
|
+
if (raw === undefined) return ok("warning");
|
|
142
|
+
const severity = SEVERITIES.find((entry) => entry === raw);
|
|
143
|
+
return severity === undefined ? failed({ kind: "bad-level", at, written: typeof raw === "string" ? raw : printed(raw) }) : ok(severity);
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
/** The four words as severities: normal is the rule's own level, relaxed one lower, strict one higher, where there is one. */
|
|
147
|
+
const levelsFor = (severity: Severity): LevelTable => {
|
|
148
|
+
const rank = SEVERITIES.indexOf(severity) + 1;
|
|
149
|
+
return { ...(rank < SEVERITIES.length ? { strict: rank + 1 } : {}), normal: rank, ...(rank > 1 ? { relaxed: rank - 1 } : {}) };
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
type Texts = { readonly name: Localized; readonly why: Localized; readonly how_to_fix: Localized; readonly before: Localized; readonly after: Localized };
|
|
153
|
+
|
|
154
|
+
const textsOf = (raw: Record<string, unknown>, at: string): Checked<Texts> => {
|
|
155
|
+
const example = isRecord(raw["example"]) ? raw["example"] : {};
|
|
156
|
+
const found = {
|
|
157
|
+
name: localizedOf(raw["name"]),
|
|
158
|
+
why: localizedOf(raw["why"]),
|
|
159
|
+
how_to_fix: localizedOf(raw["how_to_fix"]),
|
|
160
|
+
before: exampleSideOf(example["before"]),
|
|
161
|
+
after: exampleSideOf(example["after"]),
|
|
162
|
+
};
|
|
163
|
+
const missing = Object.entries(found).flatMap(([field, text]) =>
|
|
164
|
+
text === undefined ? [{ kind: "missing" as const, at, field: field === "before" || field === "after" ? `example.${field}` : field }] : [],
|
|
165
|
+
);
|
|
166
|
+
const { name, why, how_to_fix: howToFix, before, after } = found;
|
|
167
|
+
if (name === undefined || why === undefined || howToFix === undefined || before === undefined || after === undefined) return failed(...missing);
|
|
168
|
+
return ok({ name, why, how_to_fix: howToFix, before, after });
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
/** What a module's detector may ask the adapter for. Only parts of speech: without them, sentences have no tokens. */
|
|
172
|
+
const REQUIRABLE: readonly string[] = ["pos"];
|
|
173
|
+
|
|
174
|
+
const requiresOf = (raw: unknown, type: string, at: string): Checked<readonly string[]> => {
|
|
175
|
+
if (type === "tokens") return ok(["pos"]);
|
|
176
|
+
if (raw === undefined || type !== "module") return ok([]);
|
|
177
|
+
const written = (Array.isArray(raw) ? raw : [raw]).map((entry: unknown) => (typeof entry === "string" ? entry : printed(entry)));
|
|
178
|
+
const unknown = written.find((need) => !REQUIRABLE.includes(need));
|
|
179
|
+
return unknown === undefined ? ok([...new Set(written)]) : failed({ kind: "bad-requires", at, written: unknown });
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
/** A module's word list by name; its detector gets it as options.lexicon. The other types carry their words themselves. */
|
|
183
|
+
const wordListOf = (raw: unknown, type: string, at: string): Checked<string | undefined> => {
|
|
184
|
+
if (raw === undefined || type !== "module") return ok(undefined);
|
|
185
|
+
return nonEmpty(raw) ? ok(raw.trim()) : failed({ kind: "bad-word-list", at, written: printed(raw) });
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
/** What a rule's detector needs besides the document: tokens from the adapter, and a word list. */
|
|
189
|
+
type Needs = { readonly requires: readonly string[]; readonly wordList: string | undefined };
|
|
190
|
+
|
|
191
|
+
const needsOf = (raw: Record<string, unknown>, type: string, at: string): Checked<Needs> => {
|
|
192
|
+
const requires = requiresOf(raw["requires"], type, at);
|
|
193
|
+
const wordList = wordListOf(raw["word_list"], type, at);
|
|
194
|
+
if (requires.value === undefined || wordList.problems.length > 0) return failed(...requires.problems, ...wordList.problems);
|
|
195
|
+
return ok({ requires: requires.value, wordList: wordList.value });
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
const languagesOf = (raw: unknown, at: string): Checked<readonly string[] | undefined> => {
|
|
199
|
+
if (raw === undefined) return ok(undefined);
|
|
200
|
+
const list = Array.isArray(raw) ? raw : [raw];
|
|
201
|
+
return list.length > 0 && list.every(nonEmpty) ? ok(list.map((entry: string) => entry.trim())) : failed({ kind: "bad-languages", at });
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
/** The message when a rule does not write one: the replacement for a word list, else the rule's name and what was found. */
|
|
205
|
+
const defaultMessage = (spec: CustomSpec, name: Localized): Localized => {
|
|
206
|
+
if (spec.type === "words" && spec.words.every((pair) => pair.use !== ""))
|
|
207
|
+
return { ja: "「{matched}」は「{preferred}」と書きます", en: 'Write "{preferred}", not "{matched}"' };
|
|
208
|
+
return Object.fromEntries(Object.entries(name).map(([language, text]) => [language, language === "ja" ? `${text}:「{matched}」` : `${text}: "{matched}"`]));
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
const PLACEHOLDERS: Readonly<Record<string, Localized>> = {
|
|
212
|
+
matched: { ja: "見つけた語句", en: "the text found" },
|
|
213
|
+
preferred: { ja: "使う書き方", en: "the spelling to use" },
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
/** A module's detector is not in chaff's table: it is loaded from the module and found by the rule's id. */
|
|
217
|
+
const HOW_TO_FIND: Readonly<Record<CustomSpec["type"], string>> = {
|
|
218
|
+
words: "custom-words",
|
|
219
|
+
pattern: "custom-pattern",
|
|
220
|
+
tokens: "custom-tokens",
|
|
221
|
+
module: "module",
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
type Example = { readonly before: string; readonly after: string };
|
|
225
|
+
|
|
226
|
+
type Parts = {
|
|
227
|
+
readonly spec: CustomSpec;
|
|
228
|
+
readonly needs: Needs;
|
|
229
|
+
readonly severity: Severity;
|
|
230
|
+
readonly texts: Texts;
|
|
231
|
+
readonly languages: readonly string[] | undefined;
|
|
232
|
+
readonly examples: Readonly<Record<string, Example>>;
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
const READER_LANGUAGES: readonly string[] = ["ja", "en"];
|
|
236
|
+
|
|
237
|
+
/** The example in each language the rule checks, where both before and after are written in it. A string counts for both. */
|
|
238
|
+
const examplesOf = (texts: Texts, languages: readonly string[] | undefined): Record<string, Example> =>
|
|
239
|
+
Object.fromEntries(
|
|
240
|
+
(languages ?? READER_LANGUAGES).flatMap((language) => {
|
|
241
|
+
const [before, after] = [texts.before[language] ?? texts.before[EVERY_LANGUAGE], texts.after[language] ?? texts.after[EVERY_LANGUAGE]];
|
|
242
|
+
return before === undefined || after === undefined ? [] : [[language, { before, after }]];
|
|
243
|
+
}),
|
|
244
|
+
);
|
|
245
|
+
|
|
246
|
+
const definitionOf = (id: string, raw: Record<string, unknown>, parts: Parts, useFor: readonly string[]): RuleDefinition => ({
|
|
247
|
+
id,
|
|
248
|
+
layer: parts.needs.requires.includes("pos") ? "L3" : "L2",
|
|
249
|
+
status: "stable",
|
|
250
|
+
name: parts.texts.name,
|
|
251
|
+
why: parts.texts.why,
|
|
252
|
+
how_to_fix: parts.texts.how_to_fix,
|
|
253
|
+
message: localizedOf(raw["message"]) ?? defaultMessage(parts.spec, parts.texts.name),
|
|
254
|
+
messages: {},
|
|
255
|
+
placeholders: PLACEHOLDERS,
|
|
256
|
+
levels: levelsFor(parts.severity),
|
|
257
|
+
level_sets: "severity",
|
|
258
|
+
by_genre: {},
|
|
259
|
+
how_to_find: HOW_TO_FIND[parts.spec.type],
|
|
260
|
+
word_list: parts.needs.wordList,
|
|
261
|
+
extra_word_lists: [],
|
|
262
|
+
what_to_check: undefined,
|
|
263
|
+
where: undefined,
|
|
264
|
+
full_sentence: undefined,
|
|
265
|
+
requires: parts.needs.requires,
|
|
266
|
+
uses: [],
|
|
267
|
+
from: [],
|
|
268
|
+
languages: parts.languages,
|
|
269
|
+
use_for: useFor,
|
|
270
|
+
severity: parts.severity,
|
|
271
|
+
custom: parts.spec,
|
|
272
|
+
// The reference and explain read a rule's plain-language fields from guide; a team's rule is listed with the team's words.
|
|
273
|
+
guide: {
|
|
274
|
+
group: "team",
|
|
275
|
+
summary: parts.texts.name,
|
|
276
|
+
examples: parts.examples,
|
|
277
|
+
notFlagged: {},
|
|
278
|
+
levelMeaning: {},
|
|
279
|
+
sources: [],
|
|
280
|
+
rewrite: {},
|
|
281
|
+
},
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
const idOf = (raw: Record<string, unknown>, index: number, seen: ReadonlySet<string>, builtIn: ReadonlySet<string>): Checked<string> => {
|
|
285
|
+
const id = raw["id"];
|
|
286
|
+
const at = typeof id === "string" && id !== "" ? id : `#${String(index + 1)}`;
|
|
287
|
+
if (typeof id !== "string" || !RULE_ID.test(id)) return failed({ kind: "bad-id", at });
|
|
288
|
+
if (builtIn.has(id)) return failed({ kind: "built-in-id", at });
|
|
289
|
+
return seen.has(id) ? failed({ kind: "duplicate-id", at }) : ok(id);
|
|
290
|
+
};
|
|
291
|
+
|
|
292
|
+
const ruleOf = (raw: unknown, index: number, seen: ReadonlySet<string>, context: CustomContext): Checked<RuleDefinition> => {
|
|
293
|
+
if (!isRecord(raw)) return failed({ kind: "not-a-map", at: `#${String(index + 1)}` });
|
|
294
|
+
const id = idOf(raw, index, seen, context.builtIn);
|
|
295
|
+
const at = id.value ?? (nonEmpty(raw["id"]) ? raw["id"] : `#${String(index + 1)}`);
|
|
296
|
+
const type = typeOf(raw, at);
|
|
297
|
+
const spec = type.value === undefined ? failed<CustomSpec>() : specOf(raw, type.value, at, context.baseDir);
|
|
298
|
+
const needs = needsOf(raw, type.value ?? "", at);
|
|
299
|
+
const severity = severityOf(raw["level"], at);
|
|
300
|
+
const texts = textsOf(raw, at);
|
|
301
|
+
const languages = languagesOf(raw["languages"], at);
|
|
302
|
+
const examples = texts.value === undefined ? {} : examplesOf(texts.value, languages.value);
|
|
303
|
+
const unpaired: CustomProblem[] = texts.value !== undefined && Object.keys(examples).length === 0 ? [{ kind: "unpaired-example", at }] : [];
|
|
304
|
+
const problems = [...[id, type, spec, needs, severity, texts, languages].flatMap((checked) => checked.problems), ...unpaired];
|
|
305
|
+
if (problems.length > 0) return failed(...problems);
|
|
306
|
+
if (id.value === undefined || spec.value === undefined || needs.value === undefined || severity.value === undefined || texts.value === undefined)
|
|
307
|
+
return failed();
|
|
308
|
+
const parts = { spec: spec.value, needs: needs.value, severity: severity.value, texts: texts.value, languages: languages.value, examples };
|
|
309
|
+
return ok(definitionOf(id.value, raw, parts, context.useFor));
|
|
310
|
+
};
|
|
311
|
+
|
|
312
|
+
/** custom_rules as written. Every problem is reported; a rule with a problem is left out, and the run is stopped by the caller. */
|
|
313
|
+
export const parseCustomRules = (raw: unknown, context: CustomContext): CustomRules => {
|
|
314
|
+
if (raw === undefined || raw === null) return { rules: [], problems: [] };
|
|
315
|
+
if (!Array.isArray(raw)) return { rules: [], problems: [{ kind: "not-a-list" }] };
|
|
316
|
+
return raw.reduce<{ rules: RuleDefinition[]; problems: CustomProblem[] }>(
|
|
317
|
+
(acc, entry: unknown, index) => {
|
|
318
|
+
const checked = ruleOf(entry, index, new Set(acc.rules.map((rule) => rule.id)), context);
|
|
319
|
+
return { rules: checked.value === undefined ? acc.rules : [...acc.rules, checked.value], problems: [...acc.problems, ...checked.problems] };
|
|
320
|
+
},
|
|
321
|
+
{ rules: [], problems: [] },
|
|
322
|
+
);
|
|
323
|
+
};
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import type { Config } from "../config/load.ts";
|
|
2
|
+
import type { Texts, UiLanguage } from "../ui.ts";
|
|
3
|
+
import type { CustomProblem } from "./parse.ts";
|
|
4
|
+
import { customRulesOf } from "./load.ts";
|
|
5
|
+
import { MAX_PATTERN_LENGTH, MAX_REPEATS, type RegexRefusal } from "./regex-safety.ts";
|
|
6
|
+
import { POS_WRITTEN_NAMES } from "./token-pattern.ts";
|
|
7
|
+
import type { ModulePathRefusal } from "./module-path.ts";
|
|
8
|
+
|
|
9
|
+
/** Each problem's sentence, with {at}, {written}, {field}, {index}, {refusal} and {names} filled in from the problem. */
|
|
10
|
+
type Text = {
|
|
11
|
+
readonly problems: Readonly<Record<CustomProblem["kind"], string>>;
|
|
12
|
+
readonly refusal: Readonly<Record<RegexRefusal, string>>;
|
|
13
|
+
readonly modulePath: Readonly<Record<ModulePathRefusal, string>>;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const TEXT: Texts<Text> = {
|
|
17
|
+
ja: {
|
|
18
|
+
modulePath: {
|
|
19
|
+
outside: "chaff.yaml のあるフォルダの外です。読み込むとそのコードが動くので、外のファイルは絶対パスで名指ししてください",
|
|
20
|
+
},
|
|
21
|
+
refusal: {
|
|
22
|
+
"too-long": `${String(MAX_PATTERN_LENGTH)} 字を超えています。いくつかのルールに分けてください`,
|
|
23
|
+
"nested-quantifier": "繰り返しの中に繰り返しがあります((a+)+ のような形)。長い行で止まらなくなるので使えません",
|
|
24
|
+
"too-many-repeats": `回数の決まらない繰り返し(* や + や {1,9})が ${String(MAX_REPEATS)} つを超えています。長い行で止まらなくなることがあります`,
|
|
25
|
+
backreference: "後方参照(\\1)は使えません。長い行で止まらなくなることがあるためです",
|
|
26
|
+
"empty-match": "何も無い所にも当たります。すべての文で指摘が出てしまいます",
|
|
27
|
+
invalid: "正規表現として読めません",
|
|
28
|
+
},
|
|
29
|
+
problems: {
|
|
30
|
+
"not-a-list": "{scope} はルールの並び(- id: …)で書いてください",
|
|
31
|
+
"not-a-map": "{scope} の {at}: id や type を持つ項目として書いてください",
|
|
32
|
+
"bad-id": "{scope} の {at}: id は英小文字で始まり、英小文字・数字・ハイフンだけで書きます(例: team-no-tbd)",
|
|
33
|
+
"duplicate-id": "{scope} の {at}: 同じ id のルールがもう一つあります",
|
|
34
|
+
"built-in-id": "{scope} の {at}: chaff のルールと同じ id です。別の id にしてください",
|
|
35
|
+
"unknown-type": "{scope} の {at}: type: {written} は使えません(words / pattern / tokens / module)",
|
|
36
|
+
"bad-module": "{scope} の {at}: module: {written} は使えません。{refusal}",
|
|
37
|
+
"bad-requires": "{scope} の {at}: requires: {written} は求められません(求められるのは pos だけです)",
|
|
38
|
+
"bad-word-list": "{scope} の {at}: word_list: {written} は語彙表の名前として読めません",
|
|
39
|
+
missing: "{scope} の {at}: {field} がありません",
|
|
40
|
+
"unpaired-example": "{scope} の {at}: example の before と after を、ルールが見る言語の同じ言語で書いてください",
|
|
41
|
+
"bad-level": "{scope} の {at}: level: {written} は読めません(error / warning / info)",
|
|
42
|
+
"bad-languages": "{scope} の {at}: languages は言語の並びで書いてください([ja] や [ja, en])",
|
|
43
|
+
"no-words": "{scope} の {at}: words に語がありません(「使わない書き方: 使う書き方」か語の並び)",
|
|
44
|
+
"no-tokens": "{scope} の {at}: tokens に語の条件がありません(- { pos: 名詞 } のように並べます)",
|
|
45
|
+
"bad-token": "{scope} の {at}: tokens の {index} 番目に pos・base・surface のどれもありません",
|
|
46
|
+
"unknown-pos": "{scope} の {at}: 品詞 {written} は知りません({names})",
|
|
47
|
+
"bad-pattern": "{scope} の {at}: pattern を使えません。{refusal}",
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
en: {
|
|
51
|
+
modulePath: {
|
|
52
|
+
outside: "it is outside the folder chaff.yaml is in. Loading a module runs its code, so name a file outside by its absolute path",
|
|
53
|
+
},
|
|
54
|
+
refusal: {
|
|
55
|
+
"too-long": `it is longer than ${String(MAX_PATTERN_LENGTH)} characters; split it into several rules`,
|
|
56
|
+
"nested-quantifier": "it repeats something that repeats (a shape like (a+)+), which can run for minutes on a long line",
|
|
57
|
+
"too-many-repeats": `it has more than ${String(MAX_REPEATS)} repeats of varying count (*, + or {1,9}), which can run for minutes on a long line`,
|
|
58
|
+
backreference: "backreferences (\\1) are not allowed, since they can run for minutes on a long line",
|
|
59
|
+
"empty-match": "it matches an empty string, so it would report every sentence",
|
|
60
|
+
invalid: "it is not a regular expression",
|
|
61
|
+
},
|
|
62
|
+
problems: {
|
|
63
|
+
"not-a-list": "write {scope} as a list of rules (- id: …)",
|
|
64
|
+
"not-a-map": "{scope} {at}: write each rule as an entry with id and type",
|
|
65
|
+
"bad-id": "{scope} {at}: an id starts with a lowercase letter and has only lowercase letters, digits and hyphens (team-no-tbd)",
|
|
66
|
+
"duplicate-id": "{scope} {at}: another rule has the same id",
|
|
67
|
+
"built-in-id": "{scope} {at}: chaff has a rule with this id; choose another",
|
|
68
|
+
"unknown-type": "{scope} {at}: type: {written} is not a type (words / pattern / tokens / module)",
|
|
69
|
+
"bad-module": "{scope} {at}: module: {written} cannot be used: {refusal}",
|
|
70
|
+
"bad-requires": "{scope} {at}: requires: {written} cannot be asked for (only pos can)",
|
|
71
|
+
"bad-word-list": "{scope} {at}: cannot read word_list: {written} as the name of a word list",
|
|
72
|
+
missing: "{scope} {at}: {field} is missing",
|
|
73
|
+
"unpaired-example": "{scope} {at}: write example's before and after in the same language, one the rule checks",
|
|
74
|
+
"bad-level": "{scope} {at}: cannot read level: {written} (error / warning / info)",
|
|
75
|
+
"bad-languages": "{scope} {at}: write languages as a list ([en] or [ja, en])",
|
|
76
|
+
"no-words": "{scope} {at}: words has no words (avoid: use pairs, or a list)",
|
|
77
|
+
"no-tokens": "{scope} {at}: tokens has no conditions (- { pos: noun } and so on)",
|
|
78
|
+
"bad-token": "{scope} {at}: token {index} has none of pos, base and surface",
|
|
79
|
+
"unknown-pos": "{scope} {at}: unknown part of speech {written} ({names})",
|
|
80
|
+
"bad-pattern": "{scope} {at}: the pattern cannot be used: {refusal}",
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
const PLACEHOLDER = /\{(scope|at|written|field|index|refusal|names)\}/gu;
|
|
86
|
+
|
|
87
|
+
const refusalOf = (problem: CustomProblem, text: Text): string => {
|
|
88
|
+
if (problem.kind === "bad-pattern") return text.refusal[problem.refusal];
|
|
89
|
+
return problem.kind === "bad-module" ? text.modulePath[problem.refusal] : "";
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
/** The values a problem's sentence names. Each kind carries only some of them. */
|
|
93
|
+
const valuesOf = (problem: CustomProblem, text: Text, scope: string): Readonly<Record<string, string>> => ({
|
|
94
|
+
scope,
|
|
95
|
+
at: "at" in problem ? problem.at : "",
|
|
96
|
+
written: "written" in problem ? problem.written : "",
|
|
97
|
+
field: "field" in problem ? problem.field : "",
|
|
98
|
+
index: "index" in problem ? String(problem.index) : "",
|
|
99
|
+
refusal: refusalOf(problem, text),
|
|
100
|
+
names: POS_WRITTEN_NAMES.join(" / "),
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
/** One problem as a sentence. scope names the list the rule is in: custom_rules, or a plugin's rules. */
|
|
104
|
+
export const customProblemSentence = (problem: CustomProblem, ui: UiLanguage, scope = "custom_rules"): string => {
|
|
105
|
+
const values = valuesOf(problem, TEXT[ui], scope);
|
|
106
|
+
return TEXT[ui].problems[problem.kind].replace(PLACEHOLDER, (_whole, key: string) => values[key] ?? "");
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
/** What in custom_rules cannot run. Each stops the run: a team's rule that silently does not run looks like a clean document. */
|
|
110
|
+
export const customRuleProblems = (config: Pick<Config, "customRules" | "path" | "baseDir">, ui: UiLanguage): string[] =>
|
|
111
|
+
customRulesOf(config).problems.map((problem) => `chaff: ${config.path ?? "chaff.yaml"}: ${customProblemSentence(problem, ui)}`);
|