@redocly/recheck 0.1.0 → 0.2.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 +1006 -56
- package/dist/cli.js +27 -7
- package/dist/cli.js.map +1 -1
- package/dist/commands/markdoc-schema.d.ts +17 -0
- package/dist/commands/markdoc-schema.d.ts.map +1 -0
- package/dist/commands/markdoc-schema.js +127 -0
- package/dist/commands/markdoc-schema.js.map +1 -0
- package/dist/commands/run.d.ts +0 -1
- package/dist/commands/run.d.ts.map +1 -1
- package/dist/commands/run.js +68 -5
- package/dist/commands/run.js.map +1 -1
- package/dist/config/load.d.ts +11 -0
- package/dist/config/load.d.ts.map +1 -1
- package/dist/config/load.js +12 -2
- package/dist/config/load.js.map +1 -1
- package/dist/config/presets/google.d.ts +3 -0
- package/dist/config/presets/google.d.ts.map +1 -0
- package/dist/config/presets/google.js +1671 -0
- package/dist/config/presets/google.js.map +1 -0
- package/dist/config/presets/inclusive-language.d.ts +3 -0
- package/dist/config/presets/inclusive-language.d.ts.map +1 -0
- package/dist/config/presets/inclusive-language.js +321 -0
- package/dist/config/presets/inclusive-language.js.map +1 -0
- package/dist/config/presets/index.d.ts +67 -0
- package/dist/config/presets/index.d.ts.map +1 -0
- package/dist/config/presets/index.js +137 -0
- package/dist/config/presets/index.js.map +1 -0
- package/dist/config/presets/markdoc.d.ts +21 -0
- package/dist/config/presets/markdoc.d.ts.map +1 -0
- package/dist/config/presets/markdoc.js +101 -0
- package/dist/config/presets/markdoc.js.map +1 -0
- package/dist/config/presets/markdown-relaxed.d.ts +3 -0
- package/dist/config/presets/markdown-relaxed.d.ts.map +1 -0
- package/dist/config/presets/markdown-relaxed.js +98 -0
- package/dist/config/presets/markdown-relaxed.js.map +1 -0
- package/dist/config/presets/markdown.d.ts +43 -0
- package/dist/config/presets/markdown.d.ts.map +1 -0
- package/dist/config/presets/markdown.js +132 -0
- package/dist/config/presets/markdown.js.map +1 -0
- package/dist/config/presets/microsoft.d.ts +3 -0
- package/dist/config/presets/microsoft.d.ts.map +1 -0
- package/dist/config/presets/microsoft.js +2268 -0
- package/dist/config/presets/microsoft.js.map +1 -0
- package/dist/config/presets/minimal.d.ts +3 -0
- package/dist/config/presets/minimal.d.ts.map +1 -0
- package/dist/config/presets/minimal.js +21 -0
- package/dist/config/presets/minimal.js.map +1 -0
- package/dist/config/presets/plain-language.d.ts +3 -0
- package/dist/config/presets/plain-language.d.ts.map +1 -0
- package/dist/config/presets/plain-language.js +351 -0
- package/dist/config/presets/plain-language.js.map +1 -0
- package/dist/config/presets/prose.d.ts +52 -0
- package/dist/config/presets/prose.d.ts.map +1 -0
- package/dist/config/presets/prose.js +138 -0
- package/dist/config/presets/prose.js.map +1 -0
- package/dist/config/schema.d.ts +128 -22
- package/dist/config/schema.d.ts.map +1 -1
- package/dist/config/schema.js +105 -21
- package/dist/config/schema.js.map +1 -1
- package/dist/config/validate.d.ts +12 -2
- package/dist/config/validate.d.ts.map +1 -1
- package/dist/config/validate.js +1200 -44
- package/dist/config/validate.js.map +1 -1
- package/dist/core/auto-fix.d.ts +8 -13
- package/dist/core/auto-fix.d.ts.map +1 -1
- package/dist/core/auto-fix.js +94 -75
- package/dist/core/auto-fix.js.map +1 -1
- package/dist/core/case-preserve.d.ts +46 -0
- package/dist/core/case-preserve.d.ts.map +1 -0
- package/dist/core/case-preserve.js +57 -0
- package/dist/core/case-preserve.js.map +1 -0
- package/dist/core/directives.d.ts +9 -0
- package/dist/core/directives.d.ts.map +1 -0
- package/dist/core/directives.js +73 -0
- package/dist/core/directives.js.map +1 -0
- package/dist/core/files.d.ts +63 -0
- package/dist/core/files.d.ts.map +1 -1
- package/dist/core/files.js +185 -0
- package/dist/core/files.js.map +1 -1
- package/dist/core/inline-code.d.ts +87 -0
- package/dist/core/inline-code.d.ts.map +1 -0
- package/dist/core/inline-code.js +104 -0
- package/dist/core/inline-code.js.map +1 -0
- package/dist/core/line-endings.d.ts +32 -0
- package/dist/core/line-endings.d.ts.map +1 -0
- package/dist/core/line-endings.js +65 -0
- package/dist/core/line-endings.js.map +1 -0
- package/dist/core/markdoc-tags.d.ts +79 -0
- package/dist/core/markdoc-tags.d.ts.map +1 -0
- package/dist/core/markdoc-tags.js +131 -0
- package/dist/core/markdoc-tags.js.map +1 -0
- package/dist/core/runner.d.ts +92 -3
- package/dist/core/runner.d.ts.map +1 -1
- package/dist/core/runner.js +348 -110
- package/dist/core/runner.js.map +1 -1
- package/dist/core/timing.d.ts.map +1 -1
- package/dist/data/markdoc-realm-schema.d.ts +3 -0
- package/dist/data/markdoc-realm-schema.d.ts.map +1 -0
- package/dist/data/markdoc-realm-schema.js +760 -0
- package/dist/data/markdoc-realm-schema.js.map +1 -0
- package/dist/data/proper-nouns.d.ts +2 -0
- package/dist/data/proper-nouns.d.ts.map +1 -0
- package/dist/data/proper-nouns.js +208 -0
- package/dist/data/proper-nouns.js.map +1 -0
- package/dist/index.d.ts +90 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +152 -0
- package/dist/index.js.map +1 -0
- package/dist/metrics/formulas.d.ts +17 -0
- package/dist/metrics/formulas.d.ts.map +1 -0
- package/dist/metrics/formulas.js +70 -0
- package/dist/metrics/formulas.js.map +1 -0
- package/dist/metrics/index.d.ts +5 -0
- package/dist/metrics/index.d.ts.map +1 -0
- package/dist/metrics/index.js +3 -0
- package/dist/metrics/index.js.map +1 -0
- package/dist/metrics/statistics.d.ts +27 -0
- package/dist/metrics/statistics.d.ts.map +1 -0
- package/dist/metrics/statistics.js +56 -0
- package/dist/metrics/statistics.js.map +1 -0
- package/dist/parser/index.d.ts +18 -0
- package/dist/parser/index.d.ts.map +1 -0
- package/dist/parser/index.js +168 -0
- package/dist/parser/index.js.map +1 -0
- package/dist/parser/markdoc/extract-statics.d.ts +45 -0
- package/dist/parser/markdoc/extract-statics.d.ts.map +1 -0
- package/dist/parser/markdoc/extract-statics.js +139 -0
- package/dist/parser/markdoc/extract-statics.js.map +1 -0
- package/dist/parser/markdoc/pairing.d.ts +63 -0
- package/dist/parser/markdoc/pairing.d.ts.map +1 -0
- package/dist/parser/markdoc/pairing.js +94 -0
- package/dist/parser/markdoc/pairing.js.map +1 -0
- package/dist/parser/markdoc/schema.d.ts +85 -0
- package/dist/parser/markdoc/schema.d.ts.map +1 -0
- package/dist/parser/markdoc/schema.js +86 -0
- package/dist/parser/markdoc/schema.js.map +1 -0
- package/dist/parser/markdoc/span.d.ts +64 -0
- package/dist/parser/markdoc/span.d.ts.map +1 -0
- package/dist/parser/markdoc/span.js +729 -0
- package/dist/parser/markdoc/span.js.map +1 -0
- package/dist/parser/markdoc/structure.d.ts +28 -0
- package/dist/parser/markdoc/structure.d.ts.map +1 -0
- package/dist/parser/markdoc/structure.js +153 -0
- package/dist/parser/markdoc/structure.js.map +1 -0
- package/dist/parser/markdoc/syntax.d.ts +44 -0
- package/dist/parser/markdoc/syntax.d.ts.map +1 -0
- package/dist/parser/markdoc/syntax.js +317 -0
- package/dist/parser/markdoc/syntax.js.map +1 -0
- package/dist/parser/types.d.ts +18 -0
- package/dist/parser/types.d.ts.map +1 -0
- package/dist/parser/types.js.map +1 -0
- package/dist/reporter/fixes.d.ts.map +1 -1
- package/dist/reporter/fixes.js +22 -1
- package/dist/reporter/fixes.js.map +1 -1
- package/dist/reporter/statistics.d.ts +1 -8
- package/dist/reporter/statistics.d.ts.map +1 -1
- package/dist/reporter/statistics.js.map +1 -1
- package/dist/rules/registry.d.ts +15 -0
- package/dist/rules/registry.d.ts.map +1 -0
- package/dist/rules/registry.js +81 -0
- package/dist/rules/registry.js.map +1 -0
- package/dist/rules/scope/capitalization.d.ts +3 -0
- package/dist/rules/scope/capitalization.d.ts.map +1 -0
- package/dist/rules/scope/capitalization.js +161 -0
- package/dist/rules/scope/capitalization.js.map +1 -0
- package/dist/rules/scope/conditional.d.ts +3 -0
- package/dist/rules/scope/conditional.d.ts.map +1 -0
- package/dist/rules/scope/conditional.js +112 -0
- package/dist/rules/scope/conditional.js.map +1 -0
- package/dist/rules/scope/consistency.d.ts +3 -0
- package/dist/rules/scope/consistency.d.ts.map +1 -0
- package/dist/rules/scope/consistency.js +178 -0
- package/dist/rules/scope/consistency.js.map +1 -0
- package/dist/rules/scope/length.d.ts +3 -0
- package/dist/rules/scope/length.d.ts.map +1 -0
- package/dist/rules/scope/length.js +69 -0
- package/dist/rules/scope/length.js.map +1 -0
- package/dist/rules/scope/max-image-size.d.ts +3 -0
- package/dist/rules/scope/max-image-size.d.ts.map +1 -0
- package/dist/rules/scope/max-image-size.js +65 -0
- package/dist/rules/scope/max-image-size.js.map +1 -0
- package/dist/rules/scope/metric.d.ts +17 -0
- package/dist/rules/scope/metric.d.ts.map +1 -0
- package/dist/rules/scope/metric.js +216 -0
- package/dist/rules/scope/metric.js.map +1 -0
- package/dist/rules/scope/occurrence.d.ts +3 -0
- package/dist/rules/scope/occurrence.d.ts.map +1 -0
- package/dist/rules/scope/occurrence.js +48 -0
- package/dist/rules/scope/occurrence.js.map +1 -0
- package/dist/rules/scope/pattern.d.ts +3 -0
- package/dist/rules/scope/pattern.d.ts.map +1 -0
- package/dist/rules/scope/pattern.js +75 -0
- package/dist/rules/scope/pattern.js.map +1 -0
- package/dist/rules/scope/repetition.d.ts +3 -0
- package/dist/rules/scope/repetition.d.ts.map +1 -0
- package/dist/rules/scope/repetition.js +139 -0
- package/dist/rules/scope/repetition.js.map +1 -0
- package/dist/rules/scope/semantic-line-breaks.d.ts +3 -0
- package/dist/rules/scope/semantic-line-breaks.d.ts.map +1 -0
- package/dist/rules/scope/semantic-line-breaks.js +213 -0
- package/dist/rules/scope/semantic-line-breaks.js.map +1 -0
- package/dist/rules/scope/spelling.d.ts +27 -0
- package/dist/rules/scope/spelling.d.ts.map +1 -0
- package/dist/rules/scope/spelling.js +227 -0
- package/dist/rules/scope/spelling.js.map +1 -0
- package/dist/rules/scope/swap.d.ts +3 -0
- package/dist/rules/scope/swap.d.ts.map +1 -0
- package/dist/rules/scope/swap.js +149 -0
- package/dist/rules/scope/swap.js.map +1 -0
- package/dist/rules/scope/title-case.d.ts +42 -0
- package/dist/rules/scope/title-case.d.ts.map +1 -0
- package/dist/rules/scope/title-case.js +264 -0
- package/dist/rules/scope/title-case.js.map +1 -0
- package/dist/rules/token/blanks-around-fences.d.ts +3 -0
- package/dist/rules/token/blanks-around-fences.d.ts.map +1 -0
- package/dist/rules/token/blanks-around-fences.js +44 -0
- package/dist/rules/token/blanks-around-fences.js.map +1 -0
- package/dist/rules/token/blanks-around-headings.d.ts +3 -0
- package/dist/rules/token/blanks-around-headings.d.ts.map +1 -0
- package/dist/rules/token/blanks-around-headings.js +108 -0
- package/dist/rules/token/blanks-around-headings.js.map +1 -0
- package/dist/rules/token/blanks-around-lists.d.ts +3 -0
- package/dist/rules/token/blanks-around-lists.d.ts.map +1 -0
- package/dist/rules/token/blanks-around-lists.js +56 -0
- package/dist/rules/token/blanks-around-lists.js.map +1 -0
- package/dist/rules/token/blanks-around-tables.d.ts +3 -0
- package/dist/rules/token/blanks-around-tables.d.ts.map +1 -0
- package/dist/rules/token/blanks-around-tables.js +42 -0
- package/dist/rules/token/blanks-around-tables.js.map +1 -0
- package/dist/rules/token/code-block-style.d.ts +3 -0
- package/dist/rules/token/code-block-style.d.ts.map +1 -0
- package/dist/rules/token/code-block-style.js +30 -0
- package/dist/rules/token/code-block-style.js.map +1 -0
- package/dist/rules/token/code-fence-style.d.ts +3 -0
- package/dist/rules/token/code-fence-style.d.ts.map +1 -0
- package/dist/rules/token/code-fence-style.js +35 -0
- package/dist/rules/token/code-fence-style.js.map +1 -0
- package/dist/rules/token/commands-show-output.d.ts +3 -0
- package/dist/rules/token/commands-show-output.d.ts.map +1 -0
- package/dist/rules/token/commands-show-output.js +38 -0
- package/dist/rules/token/commands-show-output.js.map +1 -0
- package/dist/rules/token/descriptive-link-text.d.ts +3 -0
- package/dist/rules/token/descriptive-link-text.d.ts.map +1 -0
- package/dist/rules/token/descriptive-link-text.js +53 -0
- package/dist/rules/token/descriptive-link-text.js.map +1 -0
- package/dist/rules/token/emphasis-style.d.ts +3 -0
- package/dist/rules/token/emphasis-style.d.ts.map +1 -0
- package/dist/rules/token/emphasis-style.js +51 -0
- package/dist/rules/token/emphasis-style.js.map +1 -0
- package/dist/rules/token/fenced-code-language.d.ts +3 -0
- package/dist/rules/token/fenced-code-language.d.ts.map +1 -0
- package/dist/rules/token/fenced-code-language.js +35 -0
- package/dist/rules/token/fenced-code-language.js.map +1 -0
- package/dist/rules/token/first-line-h1.d.ts +3 -0
- package/dist/rules/token/first-line-h1.d.ts.map +1 -0
- package/dist/rules/token/first-line-h1.js +107 -0
- package/dist/rules/token/first-line-h1.js.map +1 -0
- package/dist/rules/token/heading-increment.d.ts +3 -0
- package/dist/rules/token/heading-increment.d.ts.map +1 -0
- package/dist/rules/token/heading-increment.js +27 -0
- package/dist/rules/token/heading-increment.js.map +1 -0
- package/dist/rules/token/heading-start-left.d.ts +3 -0
- package/dist/rules/token/heading-start-left.d.ts.map +1 -0
- package/dist/rules/token/heading-start-left.js +31 -0
- package/dist/rules/token/heading-start-left.js.map +1 -0
- package/dist/rules/token/heading-style.d.ts +3 -0
- package/dist/rules/token/heading-style.d.ts.map +1 -0
- package/dist/rules/token/heading-style.js +41 -0
- package/dist/rules/token/heading-style.js.map +1 -0
- package/dist/rules/token/helpers.d.ts +313 -0
- package/dist/rules/token/helpers.d.ts.map +1 -0
- package/dist/rules/token/helpers.js +746 -0
- package/dist/rules/token/helpers.js.map +1 -0
- package/dist/rules/token/hr-style.d.ts +3 -0
- package/dist/rules/token/hr-style.d.ts.map +1 -0
- package/dist/rules/token/hr-style.js +28 -0
- package/dist/rules/token/hr-style.js.map +1 -0
- package/dist/rules/token/index.d.ts +75 -0
- package/dist/rules/token/index.d.ts.map +1 -0
- package/dist/rules/token/index.js +226 -0
- package/dist/rules/token/index.js.map +1 -0
- package/dist/rules/token/line-length.d.ts +3 -0
- package/dist/rules/token/line-length.d.ts.map +1 -0
- package/dist/rules/token/line-length.js +120 -0
- package/dist/rules/token/line-length.js.map +1 -0
- package/dist/rules/token/link-fragments.d.ts +3 -0
- package/dist/rules/token/link-fragments.d.ts.map +1 -0
- package/dist/rules/token/link-fragments.js +145 -0
- package/dist/rules/token/link-fragments.js.map +1 -0
- package/dist/rules/token/link-image-reference-definitions.d.ts +3 -0
- package/dist/rules/token/link-image-reference-definitions.d.ts.map +1 -0
- package/dist/rules/token/link-image-reference-definitions.js +50 -0
- package/dist/rules/token/link-image-reference-definitions.js.map +1 -0
- package/dist/rules/token/link-image-style.d.ts +3 -0
- package/dist/rules/token/link-image-style.d.ts.map +1 -0
- package/dist/rules/token/link-image-style.js +131 -0
- package/dist/rules/token/link-image-style.js.map +1 -0
- package/dist/rules/token/list-indent.d.ts +3 -0
- package/dist/rules/token/list-indent.d.ts.map +1 -0
- package/dist/rules/token/list-indent.js +60 -0
- package/dist/rules/token/list-indent.js.map +1 -0
- package/dist/rules/token/list-length.d.ts +3 -0
- package/dist/rules/token/list-length.d.ts.map +1 -0
- package/dist/rules/token/list-length.js +55 -0
- package/dist/rules/token/list-length.js.map +1 -0
- package/dist/rules/token/list-marker-space.d.ts +3 -0
- package/dist/rules/token/list-marker-space.d.ts.map +1 -0
- package/dist/rules/token/list-marker-space.js +52 -0
- package/dist/rules/token/list-marker-space.js.map +1 -0
- package/dist/rules/token/markdoc-attributes.d.ts +3 -0
- package/dist/rules/token/markdoc-attributes.d.ts.map +1 -0
- package/dist/rules/token/markdoc-attributes.js +269 -0
- package/dist/rules/token/markdoc-attributes.js.map +1 -0
- package/dist/rules/token/markdoc-pairing.d.ts +3 -0
- package/dist/rules/token/markdoc-pairing.d.ts.map +1 -0
- package/dist/rules/token/markdoc-pairing.js +73 -0
- package/dist/rules/token/markdoc-pairing.js.map +1 -0
- package/dist/rules/token/markdoc-syntax.d.ts +3 -0
- package/dist/rules/token/markdoc-syntax.d.ts.map +1 -0
- package/dist/rules/token/markdoc-syntax.js +119 -0
- package/dist/rules/token/markdoc-syntax.js.map +1 -0
- package/dist/rules/token/markdoc-unknown-tag.d.ts +3 -0
- package/dist/rules/token/markdoc-unknown-tag.d.ts.map +1 -0
- package/dist/rules/token/markdoc-unknown-tag.js +64 -0
- package/dist/rules/token/markdoc-unknown-tag.js.map +1 -0
- package/dist/rules/token/messages.d.ts +4 -0
- package/dist/rules/token/messages.d.ts.map +1 -0
- package/dist/rules/token/messages.js +20 -0
- package/dist/rules/token/messages.js.map +1 -0
- package/dist/rules/token/no-alt-text.d.ts +3 -0
- package/dist/rules/token/no-alt-text.d.ts.map +1 -0
- package/dist/rules/token/no-alt-text.js +47 -0
- package/dist/rules/token/no-alt-text.js.map +1 -0
- package/dist/rules/token/no-bare-urls.d.ts +3 -0
- package/dist/rules/token/no-bare-urls.d.ts.map +1 -0
- package/dist/rules/token/no-bare-urls.js +88 -0
- package/dist/rules/token/no-bare-urls.js.map +1 -0
- package/dist/rules/token/no-blanks-blockquote.d.ts +3 -0
- package/dist/rules/token/no-blanks-blockquote.d.ts.map +1 -0
- package/dist/rules/token/no-blanks-blockquote.js +39 -0
- package/dist/rules/token/no-blanks-blockquote.js.map +1 -0
- package/dist/rules/token/no-duplicate-heading.d.ts +3 -0
- package/dist/rules/token/no-duplicate-heading.d.ts.map +1 -0
- package/dist/rules/token/no-duplicate-heading.js +101 -0
- package/dist/rules/token/no-duplicate-heading.js.map +1 -0
- package/dist/rules/token/no-duplicate-link-destinations.d.ts +3 -0
- package/dist/rules/token/no-duplicate-link-destinations.d.ts.map +1 -0
- package/dist/rules/token/no-duplicate-link-destinations.js +65 -0
- package/dist/rules/token/no-duplicate-link-destinations.js.map +1 -0
- package/dist/rules/token/no-emphasis-as-heading.d.ts +3 -0
- package/dist/rules/token/no-emphasis-as-heading.d.ts.map +1 -0
- package/dist/rules/token/no-emphasis-as-heading.js +44 -0
- package/dist/rules/token/no-emphasis-as-heading.js.map +1 -0
- package/dist/rules/token/no-empty-headings.d.ts +3 -0
- package/dist/rules/token/no-empty-headings.d.ts.map +1 -0
- package/dist/rules/token/no-empty-headings.js +28 -0
- package/dist/rules/token/no-empty-headings.js.map +1 -0
- package/dist/rules/token/no-empty-links.d.ts +3 -0
- package/dist/rules/token/no-empty-links.d.ts.map +1 -0
- package/dist/rules/token/no-empty-links.js +67 -0
- package/dist/rules/token/no-empty-links.js.map +1 -0
- package/dist/rules/token/no-hard-tabs.d.ts +3 -0
- package/dist/rules/token/no-hard-tabs.d.ts.map +1 -0
- package/dist/rules/token/no-hard-tabs.js +76 -0
- package/dist/rules/token/no-hard-tabs.js.map +1 -0
- package/dist/rules/token/no-inline-html.d.ts +3 -0
- package/dist/rules/token/no-inline-html.d.ts.map +1 -0
- package/dist/rules/token/no-inline-html.js +45 -0
- package/dist/rules/token/no-inline-html.js.map +1 -0
- package/dist/rules/token/no-missing-space-atx.d.ts +3 -0
- package/dist/rules/token/no-missing-space-atx.d.ts.map +1 -0
- package/dist/rules/token/no-missing-space-atx.js +36 -0
- package/dist/rules/token/no-missing-space-atx.js.map +1 -0
- package/dist/rules/token/no-missing-space-closed-atx.d.ts +3 -0
- package/dist/rules/token/no-missing-space-closed-atx.d.ts.map +1 -0
- package/dist/rules/token/no-missing-space-closed-atx.js +45 -0
- package/dist/rules/token/no-missing-space-closed-atx.js.map +1 -0
- package/dist/rules/token/no-multiple-blanks.d.ts +3 -0
- package/dist/rules/token/no-multiple-blanks.d.ts.map +1 -0
- package/dist/rules/token/no-multiple-blanks.js +35 -0
- package/dist/rules/token/no-multiple-blanks.js.map +1 -0
- package/dist/rules/token/no-multiple-space-atx.d.ts +13 -0
- package/dist/rules/token/no-multiple-space-atx.d.ts.map +1 -0
- package/dist/rules/token/no-multiple-space-atx.js +50 -0
- package/dist/rules/token/no-multiple-space-atx.js.map +1 -0
- package/dist/rules/token/no-multiple-space-blockquote.d.ts +3 -0
- package/dist/rules/token/no-multiple-space-blockquote.d.ts.map +1 -0
- package/dist/rules/token/no-multiple-space-blockquote.js +43 -0
- package/dist/rules/token/no-multiple-space-blockquote.js.map +1 -0
- package/dist/rules/token/no-multiple-space-closed-atx.d.ts +3 -0
- package/dist/rules/token/no-multiple-space-closed-atx.d.ts.map +1 -0
- package/dist/rules/token/no-multiple-space-closed-atx.js +19 -0
- package/dist/rules/token/no-multiple-space-closed-atx.js.map +1 -0
- package/dist/rules/token/no-reversed-links.d.ts +3 -0
- package/dist/rules/token/no-reversed-links.d.ts.map +1 -0
- package/dist/rules/token/no-reversed-links.js +52 -0
- package/dist/rules/token/no-reversed-links.js.map +1 -0
- package/dist/rules/token/no-space-in-code.d.ts +3 -0
- package/dist/rules/token/no-space-in-code.d.ts.map +1 -0
- package/dist/rules/token/no-space-in-code.js +75 -0
- package/dist/rules/token/no-space-in-code.js.map +1 -0
- package/dist/rules/token/no-space-in-emphasis.d.ts +3 -0
- package/dist/rules/token/no-space-in-emphasis.d.ts.map +1 -0
- package/dist/rules/token/no-space-in-emphasis.js +79 -0
- package/dist/rules/token/no-space-in-emphasis.js.map +1 -0
- package/dist/rules/token/no-space-in-links.d.ts +3 -0
- package/dist/rules/token/no-space-in-links.d.ts.map +1 -0
- package/dist/rules/token/no-space-in-links.js +48 -0
- package/dist/rules/token/no-space-in-links.js.map +1 -0
- package/dist/rules/token/no-trailing-punctuation.d.ts +3 -0
- package/dist/rules/token/no-trailing-punctuation.d.ts.map +1 -0
- package/dist/rules/token/no-trailing-punctuation.js +38 -0
- package/dist/rules/token/no-trailing-punctuation.js.map +1 -0
- package/dist/rules/token/no-trailing-spaces.d.ts +3 -0
- package/dist/rules/token/no-trailing-spaces.d.ts.map +1 -0
- package/dist/rules/token/no-trailing-spaces.js +89 -0
- package/dist/rules/token/no-trailing-spaces.js.map +1 -0
- package/dist/rules/token/ol-prefix.d.ts +3 -0
- package/dist/rules/token/ol-prefix.d.ts.map +1 -0
- package/dist/rules/token/ol-prefix.js +70 -0
- package/dist/rules/token/ol-prefix.js.map +1 -0
- package/dist/rules/token/proper-names.d.ts +3 -0
- package/dist/rules/token/proper-names.d.ts.map +1 -0
- package/dist/rules/token/proper-names.js +93 -0
- package/dist/rules/token/proper-names.js.map +1 -0
- package/dist/rules/token/reference-links-images.d.ts +3 -0
- package/dist/rules/token/reference-links-images.d.ts.map +1 -0
- package/dist/rules/token/reference-links-images.js +36 -0
- package/dist/rules/token/reference-links-images.js.map +1 -0
- package/dist/rules/token/required-headings.d.ts +3 -0
- package/dist/rules/token/required-headings.d.ts.map +1 -0
- package/dist/rules/token/required-headings.js +83 -0
- package/dist/rules/token/required-headings.js.map +1 -0
- package/dist/rules/token/single-h1.d.ts +3 -0
- package/dist/rules/token/single-h1.d.ts.map +1 -0
- package/dist/rules/token/single-h1.js +56 -0
- package/dist/rules/token/single-h1.js.map +1 -0
- package/dist/rules/token/single-trailing-newline.d.ts +3 -0
- package/dist/rules/token/single-trailing-newline.d.ts.map +1 -0
- package/dist/rules/token/single-trailing-newline.js +25 -0
- package/dist/rules/token/single-trailing-newline.js.map +1 -0
- package/dist/rules/token/strong-style.d.ts +3 -0
- package/dist/rules/token/strong-style.d.ts.map +1 -0
- package/dist/rules/token/strong-style.js +51 -0
- package/dist/rules/token/strong-style.js.map +1 -0
- package/dist/rules/token/table-column-count.d.ts +3 -0
- package/dist/rules/token/table-column-count.d.ts.map +1 -0
- package/dist/rules/token/table-column-count.js +44 -0
- package/dist/rules/token/table-column-count.js.map +1 -0
- package/dist/rules/token/table-column-style.d.ts +3 -0
- package/dist/rules/token/table-column-style.d.ts.map +1 -0
- package/dist/rules/token/table-column-style.js +179 -0
- package/dist/rules/token/table-column-style.js.map +1 -0
- package/dist/rules/token/table-pipe-style.d.ts +3 -0
- package/dist/rules/token/table-pipe-style.d.ts.map +1 -0
- package/dist/rules/token/table-pipe-style.js +54 -0
- package/dist/rules/token/table-pipe-style.js.map +1 -0
- package/dist/rules/token/ul-indent.d.ts +3 -0
- package/dist/rules/token/ul-indent.d.ts.map +1 -0
- package/dist/rules/token/ul-indent.js +72 -0
- package/dist/rules/token/ul-indent.js.map +1 -0
- package/dist/rules/token/ul-style.d.ts +3 -0
- package/dist/rules/token/ul-style.d.ts.map +1 -0
- package/dist/rules/token/ul-style.js +80 -0
- package/dist/rules/token/ul-style.js.map +1 -0
- package/dist/rules/types.d.ts +81 -0
- package/dist/rules/types.d.ts.map +1 -0
- package/dist/rules/types.js +2 -0
- package/dist/rules/types.js.map +1 -0
- package/dist/rules/utils.d.ts +29 -0
- package/dist/rules/utils.d.ts.map +1 -0
- package/dist/{assertions → rules}/utils.js +27 -0
- package/dist/rules/utils.js.map +1 -0
- package/dist/scopes/extractor.d.ts +7 -0
- package/dist/scopes/extractor.d.ts.map +1 -0
- package/dist/scopes/extractor.js +475 -0
- package/dist/scopes/extractor.js.map +1 -0
- package/dist/scopes/selector.d.ts +51 -0
- package/dist/scopes/selector.d.ts.map +1 -0
- package/dist/scopes/selector.js +121 -0
- package/dist/scopes/selector.js.map +1 -0
- package/dist/scopes/sentences.d.ts +7 -0
- package/dist/scopes/sentences.d.ts.map +1 -0
- package/dist/scopes/sentences.js +115 -0
- package/dist/scopes/sentences.js.map +1 -0
- package/dist/scopes/types.d.ts +44 -0
- package/dist/scopes/types.d.ts.map +1 -0
- package/dist/scopes/types.js +2 -0
- package/dist/scopes/types.js.map +1 -0
- package/dist/scopes/vocabulary.d.ts +16 -0
- package/dist/scopes/vocabulary.d.ts.map +1 -0
- package/dist/scopes/vocabulary.js +70 -0
- package/dist/scopes/vocabulary.js.map +1 -0
- package/dist/types/assertions.d.ts +95 -32
- package/dist/types/assertions.d.ts.map +1 -1
- package/dist/types/problems.d.ts +4 -5
- package/dist/types/problems.d.ts.map +1 -1
- package/dist/types/rules.d.ts +4 -6
- package/dist/types/rules.d.ts.map +1 -1
- package/examples/appendices/google.appendix.yaml +91 -0
- package/examples/appendices/inclusive-language.appendix.yaml +61 -0
- package/examples/appendices/microsoft.appendix.yaml +99 -0
- package/examples/appendices/plain-language.appendix.yaml +88 -0
- package/examples/google.yaml +1525 -0
- package/examples/inclusive-language.yaml +304 -0
- package/examples/microsoft.yaml +1542 -0
- package/examples/plain-language.yaml +325 -0
- package/package.json +49 -16
- package/presets/google/PROVENANCE.md +1022 -0
- package/presets/google/sources.json +192 -0
- package/presets/inclusive-language/PROVENANCE.md +174 -0
- package/presets/inclusive-language/sources.json +107 -0
- package/presets/microsoft/PROVENANCE.md +1555 -0
- package/presets/microsoft/sources.json +494 -0
- package/presets/plain-language/PROVENANCE.md +364 -0
- package/presets/plain-language/sources.json +108 -0
- package/dist/assertions/bullet-style.d.ts +0 -3
- package/dist/assertions/bullet-style.d.ts.map +0 -1
- package/dist/assertions/bullet-style.js +0 -60
- package/dist/assertions/bullet-style.js.map +0 -1
- package/dist/assertions/index.d.ts +0 -21
- package/dist/assertions/index.d.ts.map +0 -1
- package/dist/assertions/index.js +0 -30
- package/dist/assertions/index.js.map +0 -1
- package/dist/assertions/max-image-size.d.ts +0 -3
- package/dist/assertions/max-image-size.d.ts.map +0 -1
- package/dist/assertions/max-image-size.js +0 -73
- package/dist/assertions/max-image-size.js.map +0 -1
- package/dist/assertions/max-line-length.d.ts +0 -3
- package/dist/assertions/max-line-length.d.ts.map +0 -1
- package/dist/assertions/max-line-length.js +0 -68
- package/dist/assertions/max-line-length.js.map +0 -1
- package/dist/assertions/no-broken-fragment-links.d.ts +0 -3
- package/dist/assertions/no-broken-fragment-links.d.ts.map +0 -1
- package/dist/assertions/no-broken-fragment-links.js +0 -79
- package/dist/assertions/no-broken-fragment-links.js.map +0 -1
- package/dist/assertions/no-duplicate-headings.d.ts +0 -3
- package/dist/assertions/no-duplicate-headings.d.ts.map +0 -1
- package/dist/assertions/no-duplicate-headings.js +0 -66
- package/dist/assertions/no-duplicate-headings.js.map +0 -1
- package/dist/assertions/no-hard-tabs.d.ts +0 -3
- package/dist/assertions/no-hard-tabs.d.ts.map +0 -1
- package/dist/assertions/no-hard-tabs.js +0 -63
- package/dist/assertions/no-hard-tabs.js.map +0 -1
- package/dist/assertions/no-trailing-spaces.d.ts +0 -3
- package/dist/assertions/no-trailing-spaces.d.ts.map +0 -1
- package/dist/assertions/no-trailing-spaces.js +0 -72
- package/dist/assertions/no-trailing-spaces.js.map +0 -1
- package/dist/assertions/pattern.d.ts +0 -3
- package/dist/assertions/pattern.d.ts.map +0 -1
- package/dist/assertions/pattern.js +0 -39
- package/dist/assertions/pattern.js.map +0 -1
- package/dist/assertions/semantic-line-breaks.d.ts +0 -3
- package/dist/assertions/semantic-line-breaks.d.ts.map +0 -1
- package/dist/assertions/semantic-line-breaks.js +0 -152
- package/dist/assertions/semantic-line-breaks.js.map +0 -1
- package/dist/assertions/swap.d.ts +0 -3
- package/dist/assertions/swap.d.ts.map +0 -1
- package/dist/assertions/swap.js +0 -39
- package/dist/assertions/swap.js.map +0 -1
- package/dist/assertions/utils.d.ts +0 -8
- package/dist/assertions/utils.d.ts.map +0 -1
- package/dist/assertions/utils.js.map +0 -1
- package/dist/core/scope-parser.d.ts +0 -26
- package/dist/core/scope-parser.d.ts.map +0 -1
- package/dist/core/scope-parser.js +0 -110
- package/dist/core/scope-parser.js.map +0 -1
- package/dist/files.d.ts +0 -2
- package/dist/files.d.ts.map +0 -1
- package/dist/files.js +0 -39
- package/dist/files.js.map +0 -1
- package/dist/load-config.d.ts +0 -25
- package/dist/load-config.d.ts.map +0 -1
- package/dist/load-config.js +0 -104
- package/dist/load-config.js.map +0 -1
- package/dist/load.d.ts +0 -25
- package/dist/load.d.ts.map +0 -1
- package/dist/load.js +0 -112
- package/dist/load.js.map +0 -1
- package/dist/scope.d.ts +0 -26
- package/dist/scope.d.ts.map +0 -1
- package/dist/scope.js +0 -110
- package/dist/scope.js.map +0 -1
- package/dist/types.d.ts +0 -109
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js.map +0 -1
- package/dist/validate.d.ts +0 -31
- package/dist/validate.d.ts.map +0 -1
- package/dist/validate.js +0 -154
- package/dist/validate.js.map +0 -1
- /package/dist/{types.js → parser/types.js} +0 -0
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import { formatTemplate } from '../token/messages.js';
|
|
2
|
+
import { newLineRe, offsetToLineColumn } from '../../core/line-endings.js';
|
|
3
|
+
import { applyMatchCase } from '../../core/case-preserve.js';
|
|
4
|
+
// Mechanical proxy for "is this pair a same-word normalization (safe to
|
|
5
|
+
// rewrite blindly) or a substitution that can expand ambiguously (not
|
|
6
|
+
// safe)?" -- same shape as applyMatchCase's multi-word guard in
|
|
7
|
+
// case-preserve.ts: a checkable structural property (word count) that
|
|
8
|
+
// correlates with the semantic hazard, rather than an attempt to
|
|
9
|
+
// understand the words themselves. `colour`/`color` is one word either
|
|
10
|
+
// way. `it's`/`it is` is one word vs. two -- and that word-count jump is
|
|
11
|
+
// exactly where the ambiguity lives: `it's` expands to EITHER "it is" OR
|
|
12
|
+
// "it has", so picking "it is" as the winner and rewriting every "it's" to
|
|
13
|
+
// it is flat wrong whenever the source meant "it has" (see this file's
|
|
14
|
+
// fix() doc comment and the bug this guard closes: "It is fine. ... it's
|
|
15
|
+
// been growing for hours." -> "it is been growing for hours."). Splitting
|
|
16
|
+
// on whitespace is deliberately simple -- like applyMatchCase's `/\s/`
|
|
17
|
+
// check, it does not try to be a linguistic word tokenizer, just a cheap,
|
|
18
|
+
// reliable signal for "the replacement isn't shaped like the match
|
|
19
|
+
// any more."
|
|
20
|
+
//
|
|
21
|
+
// KNOWN EDGE, not fixed here (false positive, accepted cost): this guard
|
|
22
|
+
// cannot distinguish "crosses a word boundary AND is ambiguous" (`it's` ->
|
|
23
|
+
// EITHER "it is" or "it has") from "crosses a word boundary but has only
|
|
24
|
+
// ONE possible expansion" (`don't` -> always "do not", never anything
|
|
25
|
+
// else). `microsoft/contraction-consistency` ships exactly this shape
|
|
26
|
+
// alongside `it's`/`it is`: `don't`/`do not`, `won't`/`will not`, and
|
|
27
|
+
// `isn't`/`is not` are each a single, unambiguous contraction/expansion
|
|
28
|
+
// pair (1 word vs. 2), and this guard blocks fixing all three, same as it
|
|
29
|
+
// blocks `it's`/`it is` -- even though, unlike `it's`, none of them has a
|
|
30
|
+
// second meaning a blind rewrite could pick wrong. `can't`/`cannot` is the
|
|
31
|
+
// one pair in that same rule the guard does NOT block, only because
|
|
32
|
+
// "cannot" happens to be written as one word rather than two ("can not"
|
|
33
|
+
// would trip the guard identically, despite being just as unambiguous as
|
|
34
|
+
// "do not"). Word count is a proxy for "may be ambiguous," not a test of
|
|
35
|
+
// ambiguity itself, so it necessarily also catches unambiguous pairs that
|
|
36
|
+
// merely happen to differ in word count -- the same shape as
|
|
37
|
+
// applyMatchCase's own accepted edge (a hyphen-only replacement counts as
|
|
38
|
+
// "one word" and still gets shouted). Narrowing further (e.g. a hand-listed
|
|
39
|
+
// exception for "known-unambiguous" contractions) would repeat the exact
|
|
40
|
+
// per-pair-criterion pattern this whole change retires elsewhere in this
|
|
41
|
+
// package -- so the false positive is accepted, not patched, and recorded
|
|
42
|
+
// here so it is a known trade-off rather than an undocumented side effect.
|
|
43
|
+
function wordCount(text) {
|
|
44
|
+
return text.trim().split(/\s+/).filter(Boolean).length;
|
|
45
|
+
}
|
|
46
|
+
// On the segment's first line, segment.content starts mid-source-line (e.g.
|
|
47
|
+
// a heading's content excludes the '## ' marker), so segment.startColumn
|
|
48
|
+
// must be added -- see pattern.ts's toSourceColumn.
|
|
49
|
+
function toSourceColumn(segment, localLine, localColumn) {
|
|
50
|
+
return localLine === 1 ? segment.startColumn + (localColumn - 1) : localColumn;
|
|
51
|
+
}
|
|
52
|
+
// Fallback when a programmatically-built rule has no `message` (validate()
|
|
53
|
+
// requires one). %s slots: matched text, then the first-seen winner.
|
|
54
|
+
const FALLBACK_MESSAGE = 'Inconsistent spelling: "%s" conflicts with first-seen "%s".';
|
|
55
|
+
// Shared by execute() and fix(). For each `either` pair, scans ALL segments
|
|
56
|
+
// for BOTH variants (regex-escaped literals with \b word boundaries, like
|
|
57
|
+
// `swap` keys), maps every match to its absolute source position, then:
|
|
58
|
+
//
|
|
59
|
+
// 1. Dedupes by `line:column:variant` BEFORE deciding the winner:
|
|
60
|
+
// overlapping scopes (e.g. `[paragraph, sentence]`) match the same
|
|
61
|
+
// source occurrence once per covering segment, double-counting it and
|
|
62
|
+
// scrambling which variant looks 'first'.
|
|
63
|
+
// 2. Sorts by (line, column): the winner is the first match in SOURCE
|
|
64
|
+
// ORDER, file-wide -- not collection order, which scans the pair's key
|
|
65
|
+
// before its value and would always crown the key.
|
|
66
|
+
//
|
|
67
|
+
// Every later match of the OTHER (losing) variant yields one site.
|
|
68
|
+
function collectMatches(rule, ctx) {
|
|
69
|
+
const options = (rule.assertions['consistency'] ?? {});
|
|
70
|
+
const flags = options.ignoreCase ? 'gi' : 'g';
|
|
71
|
+
const sites = [];
|
|
72
|
+
for (const [key, value] of Object.entries(options.either ?? {})) {
|
|
73
|
+
// Same-word-count guard, computed once per PAIR (not per occurrence):
|
|
74
|
+
// whichever variant wins first-seen, a fix is only offered when the key
|
|
75
|
+
// and value are the same number of words. See wordCount()'s doc comment
|
|
76
|
+
// above for why a word-count mismatch (e.g. `it's` vs. `it is`) is
|
|
77
|
+
// exactly where a contraction's ambiguous expansion lives.
|
|
78
|
+
const fixable = wordCount(key) === wordCount(String(value));
|
|
79
|
+
const seen = new Set();
|
|
80
|
+
const matches = [];
|
|
81
|
+
for (const variant of [key, String(value)]) {
|
|
82
|
+
// An empty variant (only reachable when a caller bypasses validate())
|
|
83
|
+
// would escape to the zero-width `\b\b`, matching nearly every
|
|
84
|
+
// position and spuriously winning as "first-seen". Skip it.
|
|
85
|
+
if (variant.length === 0)
|
|
86
|
+
continue;
|
|
87
|
+
// Same escaping as swap keys: variants are literals, so regex
|
|
88
|
+
// metacharacters (e.g. 'e.g.') must not act as syntax.
|
|
89
|
+
const escaped = variant.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
90
|
+
const regex = new RegExp(`\\b${escaped}\\b`, flags);
|
|
91
|
+
for (const segment of ctx.segments) {
|
|
92
|
+
// newLineRe, not '\n': a bare split leaves a trailing '\r' on CRLF content.
|
|
93
|
+
const contentLines = segment.content.split(newLineRe);
|
|
94
|
+
regex.lastIndex = 0;
|
|
95
|
+
let match;
|
|
96
|
+
while ((match = regex.exec(segment.content)) !== null) {
|
|
97
|
+
// No zero-width guard needed (unlike swap/conditional/repetition):
|
|
98
|
+
// the empty-variant skip above guarantees `escaped` is a non-empty
|
|
99
|
+
// literal, and \b...\b only adds zero-width assertions around it,
|
|
100
|
+
// so `match[0]` can never be empty here.
|
|
101
|
+
const local = offsetToLineColumn(segment.content, match.index);
|
|
102
|
+
const line = segment.startLine + local.line - 1;
|
|
103
|
+
const column = toSourceColumn(segment, local.line, local.column);
|
|
104
|
+
const positionKey = `${line}:${column}:${variant}`;
|
|
105
|
+
if (seen.has(positionKey))
|
|
106
|
+
continue; // overlapping segments, same source occurrence
|
|
107
|
+
seen.add(positionKey);
|
|
108
|
+
matches.push({
|
|
109
|
+
line,
|
|
110
|
+
column,
|
|
111
|
+
text: match[0],
|
|
112
|
+
lineText: contentLines[local.line - 1] ?? '',
|
|
113
|
+
variant,
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
if (matches.length === 0)
|
|
119
|
+
continue;
|
|
120
|
+
matches.sort((a, b) => a.line - b.line || a.column - b.column);
|
|
121
|
+
const winner = matches[0].variant;
|
|
122
|
+
for (const found of matches) {
|
|
123
|
+
if (found.variant !== winner) {
|
|
124
|
+
sites.push({
|
|
125
|
+
line: found.line,
|
|
126
|
+
column: found.column,
|
|
127
|
+
text: found.text,
|
|
128
|
+
lineText: found.lineText,
|
|
129
|
+
winner,
|
|
130
|
+
fixable,
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
// Pairs are processed one at a time, so multi-pair results arrive grouped
|
|
136
|
+
// by pair; re-sort so problems/fixes read in source order.
|
|
137
|
+
sites.sort((a, b) => a.line - b.line || a.column - b.column);
|
|
138
|
+
return sites;
|
|
139
|
+
}
|
|
140
|
+
const execute = async (rule, file, ctx) => {
|
|
141
|
+
return collectMatches(rule, ctx).map((site) => ({
|
|
142
|
+
file,
|
|
143
|
+
line: site.line,
|
|
144
|
+
column: site.column,
|
|
145
|
+
text: site.lineText,
|
|
146
|
+
match: site.text,
|
|
147
|
+
ruleName: rule.name,
|
|
148
|
+
severity: rule.severity,
|
|
149
|
+
message: formatTemplate(rule.message ?? FALLBACK_MESSAGE, site.text, site.winner),
|
|
150
|
+
}));
|
|
151
|
+
};
|
|
152
|
+
const fix = async (rule, file, ctx) => {
|
|
153
|
+
// Same-word-count guard (see wordCount()'s doc comment above): a
|
|
154
|
+
// different-word-count pair (e.g. `it's`/`it is`) still gets REPORTED by
|
|
155
|
+
// execute() above -- collectMatches() doesn't distinguish the two
|
|
156
|
+
// functions -- but must never be auto-fixed, so it's filtered out here,
|
|
157
|
+
// after collection, rather than skipped during collection itself.
|
|
158
|
+
return collectMatches(rule, ctx)
|
|
159
|
+
.filter((site) => site.fixable)
|
|
160
|
+
.map((site) => ({
|
|
161
|
+
file,
|
|
162
|
+
ruleName: rule.name,
|
|
163
|
+
lineNumber: site.line,
|
|
164
|
+
editColumn: site.column,
|
|
165
|
+
deleteCount: site.text.length,
|
|
166
|
+
// Apply the MATCHED text's observed casing to the winner, not the
|
|
167
|
+
// winner as authored in config: with `ignoreCase: true`, a
|
|
168
|
+
// sentence-initial 'Behaviour' would otherwise be replaced by the
|
|
169
|
+
// literal (lowercase-first) authored winner 'behavior', silently
|
|
170
|
+
// lowercasing the start of the sentence -- the exact hazard
|
|
171
|
+
// applyMatchCase exists to prevent, and swap.ts:177 already guards
|
|
172
|
+
// against for the `swap` assertion. `consistency` shares the same
|
|
173
|
+
// ignoreCase/fix shape, so it needs the same guard.
|
|
174
|
+
insertText: applyMatchCase(site.text, site.winner),
|
|
175
|
+
}));
|
|
176
|
+
};
|
|
177
|
+
export const consistency = { id: 'consistency', fixable: true, execute, fix };
|
|
178
|
+
//# sourceMappingURL=consistency.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"consistency.js","sourceRoot":"","sources":["../../../src/rules/scope/consistency.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAC3E,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAmB7D,wEAAwE;AACxE,sEAAsE;AACtE,gEAAgE;AAChE,sEAAsE;AACtE,iEAAiE;AACjE,uEAAuE;AACvE,yEAAyE;AACzE,yEAAyE;AACzE,2EAA2E;AAC3E,uEAAuE;AACvE,yEAAyE;AACzE,0EAA0E;AAC1E,uEAAuE;AACvE,0EAA0E;AAC1E,mEAAmE;AACnE,aAAa;AACb,EAAE;AACF,yEAAyE;AACzE,2EAA2E;AAC3E,yEAAyE;AACzE,sEAAsE;AACtE,sEAAsE;AACtE,sEAAsE;AACtE,wEAAwE;AACxE,0EAA0E;AAC1E,0EAA0E;AAC1E,2EAA2E;AAC3E,oEAAoE;AACpE,wEAAwE;AACxE,yEAAyE;AACzE,yEAAyE;AACzE,0EAA0E;AAC1E,6DAA6D;AAC7D,0EAA0E;AAC1E,4EAA4E;AAC5E,yEAAyE;AACzE,yEAAyE;AACzE,0EAA0E;AAC1E,2EAA2E;AAC3E,SAAS,SAAS,CAAC,IAAY;IAC7B,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC;AACzD,CAAC;AAED,4EAA4E;AAC5E,yEAAyE;AACzE,oDAAoD;AACpD,SAAS,cAAc,CAAC,OAAgC,EAAE,SAAiB,EAAE,WAAmB;IAC9F,OAAO,SAAS,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,WAAW,GAAG,CAAC,WAAW,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC;AAC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Aa,CAAC;AAsF/D,eAAO,MAAM,MAAM,EAAE,SAAqD,CAAC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { formatTemplate } from '../token/messages.js';
|
|
2
|
+
import { newLineRe } from '../../core/line-endings.js';
|
|
3
|
+
import { splitSentences } from '../../scopes/sentences.js';
|
|
4
|
+
import { tokenizeWords } from '../../metrics/statistics.js';
|
|
5
|
+
const FALLBACK_MAX = 'Segment is %s %s; at most %s allowed';
|
|
6
|
+
const FALLBACK_MIN = 'Segment is %s %s; at least %s required';
|
|
7
|
+
// Single measurement helper, used by nothing else: `sentences` delegates to
|
|
8
|
+
// the shared sentence-boundary definition (scopes/sentences.ts), and `words`
|
|
9
|
+
// delegates to the metrics module's own tokenizer (see its export-site
|
|
10
|
+
// comment for why sharing that implementation with `metric` matters).
|
|
11
|
+
//
|
|
12
|
+
// `characters` takes the whole segment, not just its content, because a masked
|
|
13
|
+
// markdoc tag's span is blanked to same-width spaces rather than removed.
|
|
14
|
+
// `tokenizeWords` and `splitSentences` already read through that mask
|
|
15
|
+
// correctly, treating a run of blanks as a gap like real whitespace, but a raw
|
|
16
|
+
// `content.length` would count those invisible characters as visible prose:
|
|
17
|
+
// `# Head text {% #averylonganchorname %}` measured 36 characters for the 10 a
|
|
18
|
+
// reader actually sees. Subtracting each masked span's width corrects the
|
|
19
|
+
// count. A segment that was never masked has no `maskedRanges`, so this is
|
|
20
|
+
// exactly `content.length`.
|
|
21
|
+
function measure(segment, unit) {
|
|
22
|
+
const { content } = segment;
|
|
23
|
+
if (unit === 'characters') {
|
|
24
|
+
const maskedWidth = (segment.maskedRanges ?? []).reduce((total, range) => total + (range.end - range.start), 0);
|
|
25
|
+
return content.length - maskedWidth;
|
|
26
|
+
}
|
|
27
|
+
if (unit === 'sentences')
|
|
28
|
+
return splitSentences(content).length;
|
|
29
|
+
return tokenizeWords(content).length;
|
|
30
|
+
}
|
|
31
|
+
// Recheck-original `length` check: measures each scoped segment's size and
|
|
32
|
+
// flags it when the measurement falls outside `[min, max]`. Detection-only
|
|
33
|
+
// -- like `occurrence`, a size violation has no single position to anchor
|
|
34
|
+
// an edit to (shrinking or growing a segment to fit is an editorial
|
|
35
|
+
// decision, not a mechanical rewrite). Unlike `metric`, this honors
|
|
36
|
+
// whichever `scope` the rule configures -- e.g. `scope: alt` to cap image
|
|
37
|
+
// alt text length, `scope: sentence` to cap sentence length in words.
|
|
38
|
+
const execute = async (rule, file, ctx) => {
|
|
39
|
+
const problems = [];
|
|
40
|
+
const o = rule.assertions['length'];
|
|
41
|
+
for (const segment of ctx.segments) {
|
|
42
|
+
const size = measure(segment, o.unit);
|
|
43
|
+
const tooSmall = o.min !== undefined && size < o.min;
|
|
44
|
+
const tooLarge = o.max !== undefined && size > o.max;
|
|
45
|
+
if (!tooSmall && !tooLarge)
|
|
46
|
+
continue;
|
|
47
|
+
// Picking `tooSmall`'s branch first is only exhaustive because
|
|
48
|
+
// validate() rejects `min > max`, so a segment can never be both
|
|
49
|
+
// tooSmall and tooLarge at once -- a hand-built rule that skips
|
|
50
|
+
// validate() must preserve that invariant itself or this silently
|
|
51
|
+
// reports the wrong bound.
|
|
52
|
+
const bound = tooSmall ? o.min : o.max;
|
|
53
|
+
problems.push({
|
|
54
|
+
file,
|
|
55
|
+
line: segment.startLine,
|
|
56
|
+
column: segment.startColumn,
|
|
57
|
+
// newLineRe, not '\n': a bare split leaves a trailing '\r' on CRLF
|
|
58
|
+
// content (see occurrence.ts).
|
|
59
|
+
text: segment.content.split(newLineRe)[0] ?? '',
|
|
60
|
+
match: String(size),
|
|
61
|
+
ruleName: rule.name,
|
|
62
|
+
severity: rule.severity,
|
|
63
|
+
message: formatTemplate(rule.message ?? (tooSmall ? FALLBACK_MIN : FALLBACK_MAX), String(size), o.unit, String(bound)),
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
return problems;
|
|
67
|
+
};
|
|
68
|
+
export const length = { id: 'length', fixable: false, execute };
|
|
69
|
+
//# sourceMappingURL=length.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,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,YAAY,CAAC,EACxD,MAAM,CAAC,IAAI,CAAC,EACZ,CAAC,CAAC,IAAI,EACN,MAAM,CAAC,KAAK,CAAC,CACd;SACF,CAAC,CAAC;IACL,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,MAAM,GAAc,EAAE,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"max-image-size.d.ts","sourceRoot":"","sources":["../../../src/rules/scope/max-image-size.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAoB,MAAM,aAAa,CAAC;AA0F/D,eAAO,MAAM,YAAY,EAAE,SAA6D,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { newLineRe } from '../../core/line-endings.js';
|
|
2
|
+
import { getImageDestinations, hasOverlap } from '../token/helpers.js';
|
|
3
|
+
function getFileExtension(filePath) {
|
|
4
|
+
const lastDot = filePath.lastIndexOf('.');
|
|
5
|
+
return lastDot === -1 ? '' : filePath.substring(lastDot + 1).toLowerCase();
|
|
6
|
+
}
|
|
7
|
+
// `ctx.segments` is a single synthetic `scope: 'all'` segment (see
|
|
8
|
+
// `wholeFileSegment` in core/runner.ts) exactly when the rule is unscoped
|
|
9
|
+
// (the default) — `extractScopes` itself never emits a segment with that
|
|
10
|
+
// scope name, so this check is an unambiguous whole-file-vs-scoped
|
|
11
|
+
// discriminator, matching the convention documented for scope rules in
|
|
12
|
+
// rules/CONTRIBUTING.md ("Unscoped rules (`scope: all`, the default):
|
|
13
|
+
// `ctx.segments` is a single whole-file segment with `scope: 'all'`").
|
|
14
|
+
function isWholeFile(segments) {
|
|
15
|
+
return segments.length === 1 && segments[0].scope === 'all';
|
|
16
|
+
}
|
|
17
|
+
const execute = async (rule, file, ctx) => {
|
|
18
|
+
const problems = [];
|
|
19
|
+
const options = rule.assertions['max-image-size'];
|
|
20
|
+
const maxSizeKB = options?.maxSizeKB ?? 100;
|
|
21
|
+
const allowedExtensions = new Set(options?.extensions ?? ['jpg', 'jpeg', 'png', 'gif', 'webp', 'svg']);
|
|
22
|
+
const maxSizeBytes = maxSizeKB * 1024;
|
|
23
|
+
// Reference-style destinations (`![alt][ref]`) resolve against
|
|
24
|
+
// definitions anywhere in the document, so resolution always runs over
|
|
25
|
+
// the whole tree; only the resulting image tokens are scope-filtered
|
|
26
|
+
// below, matching how every other scope rule narrows to `ctx.segments`
|
|
27
|
+
// without re-deriving cross-references itself.
|
|
28
|
+
const wholeFile = isWholeFile(ctx.segments);
|
|
29
|
+
const images = getImageDestinations(ctx.tree).filter(({ token }) => wholeFile || ctx.segments.some((segment) => hasOverlap(segment, token)));
|
|
30
|
+
// newLineRe (never a bare '\n'): these lines feed Problem.text, and a
|
|
31
|
+
// '\n' split of CRLF content would leave a trailing '\r' on each one.
|
|
32
|
+
const lines = ctx.content.split(newLineRe);
|
|
33
|
+
for (const { token, destination } of images) {
|
|
34
|
+
if (destination.startsWith('http://') || destination.startsWith('https://')) {
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
const extension = getFileExtension(destination);
|
|
38
|
+
if (!allowedExtensions.has(extension)) {
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
const imageMetadata = ctx.fileMetadata?.images?.get(destination);
|
|
42
|
+
if (!imageMetadata) {
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
if (!imageMetadata.exists) {
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
if (imageMetadata.size > maxSizeBytes) {
|
|
49
|
+
const actualSizeKB = Math.round(imageMetadata.size / 1024);
|
|
50
|
+
problems.push({
|
|
51
|
+
file,
|
|
52
|
+
line: token.startLine,
|
|
53
|
+
column: token.startColumn,
|
|
54
|
+
text: lines[token.startLine - 1] || '',
|
|
55
|
+
match: token.text,
|
|
56
|
+
ruleName: rule.name,
|
|
57
|
+
severity: rule.severity,
|
|
58
|
+
message: (rule.message ?? '').replace('%s', `${destination} (${actualSizeKB}KB > ${maxSizeKB}KB)`),
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return problems;
|
|
63
|
+
};
|
|
64
|
+
export const maxImageSize = { id: 'max-image-size', fixable: false, execute };
|
|
65
|
+
//# sourceMappingURL=max-image-size.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"max-image-size.js","sourceRoot":"","sources":["../../../src/rules/scope/max-image-size.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEvE,SAAS,gBAAgB,CAAC,QAAgB;IACxC,MAAM,OAAO,GAAG,QAAQ,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IAC1C,OAAO,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;AAC7E,CAAC;AAED,mEAAmE;AACnE,0EAA0E;AAC1E,yEAAyE;AACzE,mEAAmE;AACnE,uEAAuE;AACvE,sEAAsE;AACtE,uEAAuE;AACvE,SAAS,WAAW,CAAC,QAAyB;IAC5C,OAAO,QAAQ,CAAC,MAAM,KAAK,CAAC,IAAI,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,KAAK,KAAK,CAAC;AAC9D,CAAC;AAED,MAAM,OAAO,GAAG,KAAK,EACnB,IAAoB,EACpB,IAAY,EACZ,GAAqB,EACD,EAAE;IACtB,MAAM,QAAQ,GAAc,EAAE,CAAC;IAC/B,MAAM,OAAO,GAAG,IAAI,CAAC,UAAU,CAAC,gBAAgB,CAA0B,CAAC;I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aAAa,EAAE,CAAC;YACnB,SAAS;QACX,CAAC;QAED,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,CAAC;YAC1B,SAAS;QACX,CAAC;QAED,IAAI,aAAa,CAAC,IAAI,GAAG,YAAY,EAAE,CAAC;YACtC,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC;YAC3D,QAAQ,CAAC,IAAI,CAAC;gBACZ,IAAI;gBACJ,IAAI,EAAE,KAAK,CAAC,SAAS;gBACrB,MAAM,EAAE,KAAK,CAAC,WAAW;gBACzB,IAAI,EAAE,KAAK,CAAC,KAAK,CAAC,SAAS,GAAG,CAAC,CAAC,IAAI,EAAE;gBACtC,KAAK,EAAE,KAAK,CAAC,IAAI;gBACjB,QAAQ,EAAE,IAAI,CAAC,IAAI;gBACnB,QAAQ,EAAE,IAAI,CAAC,QAAQ;gBACvB,OAAO,EAAE,CAAC,IAAI,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,OAAO,CACnC,IAAI,EACJ,GAAG,WAAW,KAAK,YAAY,QAAQ,SAAS,KAAK,CACtD;aACF,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,YAAY,GAAc,EAAE,EAAE,EAAE,gBAAgB,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ScopeRule } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Strips markup that is never readable prose (Markdoc tag markers, inline
|
|
4
|
+
* code spans) from RAW segment text -- i.e. text that has not already been
|
|
5
|
+
* structurally masked, see `MARKDOC_TAG_RE`'s comment. Inline code spans
|
|
6
|
+
* are REMOVED outright (not masked-and-restored like
|
|
7
|
+
* capitalization.ts/spelling.ts do): there is no position-sensitive rewrite
|
|
8
|
+
* downstream to keep offsets aligned for, just a word/syllable count that
|
|
9
|
+
* must never include a code span's content. BACKTICK_SPAN_RE
|
|
10
|
+
* (core/inline-code.ts) gives this the same CommonMark-correct
|
|
11
|
+
* open-run/close-run-of-equal-length span recognition capitalization.ts and
|
|
12
|
+
* spelling.ts use, including a span whose content itself contains a
|
|
13
|
+
* shorter, unpaired backtick run. Exported for direct unit testing.
|
|
14
|
+
*/
|
|
15
|
+
export declare function stripNonProse(text: string): string;
|
|
16
|
+
export declare const metric: ScopeRule;
|
|
17
|
+
//# sourceMappingURL=metric.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metric.d.ts","sourceRoot":"","sources":["../../../src/rules/scope/metric.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAoB,MAAM,aAAa,CAAC;AAwB/D;;;;;;;;;;;;GAYG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAElD;AA4MD,eAAO,MAAM,MAAM,EAAE,SAAqD,CAAC"}
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import { formatTemplate } from '../token/messages.js';
|
|
2
|
+
import { computeTextStatistics, computeReadability } from '../../metrics/index.js';
|
|
3
|
+
import { BACKTICK_SPAN_RE } from '../../core/inline-code.js';
|
|
4
|
+
/**
|
|
5
|
+
* Markdoc tag-marker spans -- `{% tag attr="x" %}`, `{% /tag %}`, and the
|
|
6
|
+
* `{%- ... -%}` whitespace-trim variant. Non-greedy (`[\s\S]*?`) so it stops
|
|
7
|
+
* at the NEAREST `%}`: back-to-back tags like `{% admonition %}` ...
|
|
8
|
+
* `{% /admonition %}` each strip as their OWN span rather than one tag's
|
|
9
|
+
* opener swallowing everything up to the other tag's closer -- which would
|
|
10
|
+
* delete the prose BETWEEN them too.
|
|
11
|
+
*
|
|
12
|
+
* Only used when markdoc parsing is off. With it on, `maskProse` in
|
|
13
|
+
* scopes/extractor.ts has already found every real `markdocTag` token and
|
|
14
|
+
* recorded its exact span in the segment's `maskedRanges`, so `extractProse`
|
|
15
|
+
* below splices those spans out instead of re-discovering tags with this
|
|
16
|
+
* regex. The regex is still needed with the flag off: the parser doesn't
|
|
17
|
+
* recognize tags at all in that mode, so `{% ... %}` is just ordinary text and
|
|
18
|
+
* nothing else keeps it out of the readability formulas.
|
|
19
|
+
*/
|
|
20
|
+
const MARKDOC_TAG_RE = /\{%-?[\s\S]*?-?%\}/g;
|
|
21
|
+
/**
|
|
22
|
+
* Strips markup that is never readable prose (Markdoc tag markers, inline
|
|
23
|
+
* code spans) from RAW segment text -- i.e. text that has not already been
|
|
24
|
+
* structurally masked, see `MARKDOC_TAG_RE`'s comment. Inline code spans
|
|
25
|
+
* are REMOVED outright (not masked-and-restored like
|
|
26
|
+
* capitalization.ts/spelling.ts do): there is no position-sensitive rewrite
|
|
27
|
+
* downstream to keep offsets aligned for, just a word/syllable count that
|
|
28
|
+
* must never include a code span's content. BACKTICK_SPAN_RE
|
|
29
|
+
* (core/inline-code.ts) gives this the same CommonMark-correct
|
|
30
|
+
* open-run/close-run-of-equal-length span recognition capitalization.ts and
|
|
31
|
+
* spelling.ts use, including a span whose content itself contains a
|
|
32
|
+
* shorter, unpaired backtick run. Exported for direct unit testing.
|
|
33
|
+
*/
|
|
34
|
+
export function stripNonProse(text) {
|
|
35
|
+
return text.replace(MARKDOC_TAG_RE, '').replace(BACKTICK_SPAN_RE, '');
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Counterpart to `stripNonProse` for a masked segment: its tag spans are
|
|
39
|
+
* already known exactly (`segment.maskedRanges`, set by `maskProse` only when
|
|
40
|
+
* it actually blanked something), so this splices each span out of `content`
|
|
41
|
+
* rather than leaving the mask's same-width spaces in place.
|
|
42
|
+
*
|
|
43
|
+
* Deletion, not blanking, matters here. `length.ts`'s `measure()` only needs a
|
|
44
|
+
* width to subtract from a character count, so reading through the mask as if
|
|
45
|
+
* it were whitespace is harmless there. `metric` tokenizes words by splitting
|
|
46
|
+
* on whitespace, so mask spaces are not interchangeable with deletion whenever
|
|
47
|
+
* a tag sits flush against real text with no separating space — for example
|
|
48
|
+
* `<code>{% $optionName %}</code>`, a shape that occurs in the repo's own docs.
|
|
49
|
+
* Left as mask spaces, `<code>` and `</code>` tokenize as two separate words;
|
|
50
|
+
* deleting the span joins them back into the single adjacent run they actually
|
|
51
|
+
* are. Splicing reproduces exactly what the regex strip did on unmasked source.
|
|
52
|
+
*/
|
|
53
|
+
function spliceOutMaskedSpans(segment) {
|
|
54
|
+
const ranges = segment.maskedRanges;
|
|
55
|
+
if (ranges === undefined)
|
|
56
|
+
return segment.content;
|
|
57
|
+
let result = '';
|
|
58
|
+
let cursor = 0;
|
|
59
|
+
for (const range of ranges) {
|
|
60
|
+
// `maskedRanges` is produced ascending and non-overlapping (maskProse
|
|
61
|
+
// sorts and clamps; shiftRanges preserves order). The clamp here mirrors
|
|
62
|
+
// maskProse's own defense: an out-of-order range would otherwise move
|
|
63
|
+
// `cursor` backward and re-emit already-copied characters.
|
|
64
|
+
result += segment.content.slice(cursor, Math.max(range.start, cursor));
|
|
65
|
+
cursor = Math.max(range.end, cursor);
|
|
66
|
+
}
|
|
67
|
+
return result + segment.content.slice(cursor);
|
|
68
|
+
}
|
|
69
|
+
const FALLBACK_MESSAGE = 'Readability (%s) is %s; expected between %s and %s.';
|
|
70
|
+
// Compares two (line, column) source positions the way source order does:
|
|
71
|
+
// earlier line first, then earlier column on the same line.
|
|
72
|
+
function comparePosition(aLine, aColumn, bLine, bColumn) {
|
|
73
|
+
return aLine - bLine || aColumn - bColumn;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Whether `outer`'s span fully contains `inner`'s -- `outer` starts at or
|
|
77
|
+
* before `inner` and ends at or after it. `startLine`/`startColumn`/
|
|
78
|
+
* `endLine`/`endColumn` are already the exact verbatim source span each
|
|
79
|
+
* segment's `content` covers (see extractor.ts's `segmentFromToken` and the
|
|
80
|
+
* `tableRow` case's explicit anchor/trim arithmetic), so containment can be
|
|
81
|
+
* decided directly from those four numbers -- no separate span needs
|
|
82
|
+
* re-deriving from `content` (e.g. via counting newlines) here.
|
|
83
|
+
*/
|
|
84
|
+
function spanContains(outer, inner) {
|
|
85
|
+
return (comparePosition(outer.startLine, outer.startColumn, inner.startLine, inner.startColumn) <= 0 &&
|
|
86
|
+
comparePosition(outer.endLine, outer.endColumn, inner.endLine, inner.endColumn) >= 0);
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Dedupes prose segments whose source span is fully nested inside another
|
|
90
|
+
* kept segment's span. A list nested inside a blockquote emits BOTH the
|
|
91
|
+
* blockquote segment (its whole raw body, list markup and all) AND each
|
|
92
|
+
* list-item segment (the same words again, just the item's own subspan);
|
|
93
|
+
* a blockquote nested inside another blockquote is the same shape one
|
|
94
|
+
* level up. Left uncaught, the nested words are scored twice and
|
|
95
|
+
* readability drifts. The old dedup only matched IDENTICAL start
|
|
96
|
+
* positions, which misses every one of these cases (the nested segment
|
|
97
|
+
* starts later than its container).
|
|
98
|
+
*
|
|
99
|
+
* Segments are sorted by (startLine, startColumn) ascending so a container
|
|
100
|
+
* is always visited before anything nested inside it; ties (a container
|
|
101
|
+
* and its first child starting at the exact same position, e.g. a
|
|
102
|
+
* blockquote and its very first list item) are broken by span
|
|
103
|
+
* DESCENDING -- the later-ending segment first -- so the outer container is
|
|
104
|
+
* always the one considered "already kept" when its nested sibling is
|
|
105
|
+
* checked, never the other way around.
|
|
106
|
+
*
|
|
107
|
+
* `stack` holds the chain of still-open containers, innermost last. Only
|
|
108
|
+
* the top is ever checked against a new candidate: markdown block spans
|
|
109
|
+
* form a laminar family (any two are either disjoint or one fully
|
|
110
|
+
* contains the other, never a partial "crossing" overlap), so once
|
|
111
|
+
* containers whose span has already ended (`end < candidate.start`) are
|
|
112
|
+
* popped off, the remaining top is the ONLY still-open span the next
|
|
113
|
+
* candidate could possibly nest inside. This is what keeps same-line
|
|
114
|
+
* SIBLINGS with disjoint spans (e.g. two table cells on one row) safe:
|
|
115
|
+
* each one's span ends before the next one's begins, so it is popped
|
|
116
|
+
* before the next is checked, and neither is ever mistaken for containing
|
|
117
|
+
* the other.
|
|
118
|
+
*/
|
|
119
|
+
function dedupeBySpanContainment(segments) {
|
|
120
|
+
const ordered = [...segments].sort((a, b) => {
|
|
121
|
+
const byStart = comparePosition(a.startLine, a.startColumn, b.startLine, b.startColumn);
|
|
122
|
+
if (byStart !== 0)
|
|
123
|
+
return byStart;
|
|
124
|
+
return comparePosition(b.endLine, b.endColumn, a.endLine, a.endColumn);
|
|
125
|
+
});
|
|
126
|
+
const stack = [];
|
|
127
|
+
const kept = [];
|
|
128
|
+
for (const segment of ordered) {
|
|
129
|
+
while (stack.length > 0) {
|
|
130
|
+
const top = stack[stack.length - 1];
|
|
131
|
+
if (comparePosition(top.endLine, top.endColumn, segment.startLine, segment.startColumn) < 0) {
|
|
132
|
+
stack.pop();
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
break;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
const container = stack[stack.length - 1];
|
|
139
|
+
if (container && spanContains(container, segment))
|
|
140
|
+
continue;
|
|
141
|
+
kept.push(segment);
|
|
142
|
+
stack.push(segment);
|
|
143
|
+
}
|
|
144
|
+
return kept;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Builds the whole-document prose string `metric` scores against, from
|
|
148
|
+
* `ctx.segments`.
|
|
149
|
+
*
|
|
150
|
+
* `metric` rules are always summary-scoped: config normalization
|
|
151
|
+
* (config/validate.ts, normalizeMetricScope) forces `scope: 'summary'` on
|
|
152
|
+
* every rule with a `metric` assertion — readability is a whole-document
|
|
153
|
+
* score over the document's prose, exactly what the extractor's `summary`
|
|
154
|
+
* segments carry — so `ctx.segments` arrives as those summary segments and
|
|
155
|
+
* no scope re-extraction happens here. See the README's `metric` entry.
|
|
156
|
+
*/
|
|
157
|
+
function extractProse(ctx) {
|
|
158
|
+
// Span-containment dedup: a segment fully nested inside another kept
|
|
159
|
+
// segment's source span must not have its text counted a second time --
|
|
160
|
+
// see dedupeBySpanContainment. The extractor already avoids the most
|
|
161
|
+
// common case on its own (see its `isNestedContainerParagraph`), but
|
|
162
|
+
// this catches every other overlap among the summary segments too
|
|
163
|
+
// (e.g. a list nested inside a blockquote).
|
|
164
|
+
const deduped = dedupeBySpanContainment(ctx.segments);
|
|
165
|
+
// Re-sort explicitly so the joined prose's sentence order can never
|
|
166
|
+
// depend on the extractor's traversal order (or dedupeBySpanContainment's
|
|
167
|
+
// own tie-breaking order, which favors span DESC, not source order).
|
|
168
|
+
deduped.sort((a, b) => a.startLine - b.startLine || a.startColumn - b.startColumn);
|
|
169
|
+
return deduped
|
|
170
|
+
.map((segment) => segment.maskedRanges !== undefined
|
|
171
|
+
? // This segment's tag spans are already known exactly, so splice them
|
|
172
|
+
// out directly instead of re-discovering them with MARKDOC_TAG_RE,
|
|
173
|
+
// which couldn't match them anyway now that their `{`/`%` characters
|
|
174
|
+
// are mask spaces. Backtick stripping still runs: masking never
|
|
175
|
+
// touches inline code spans.
|
|
176
|
+
spliceOutMaskedSpans(segment).replace(BACKTICK_SPAN_RE, '')
|
|
177
|
+
: // Markdoc parsing off, or a tag the extractor never recognized as one
|
|
178
|
+
// (e.g. written inside an inline code span): content still carries
|
|
179
|
+
// whatever raw markup it always did, so fall back to the regex-based
|
|
180
|
+
// strip.
|
|
181
|
+
stripNonProse(segment.content))
|
|
182
|
+
.join('\n');
|
|
183
|
+
}
|
|
184
|
+
const execute = async (rule, file, ctx) => {
|
|
185
|
+
const options = rule.assertions['metric'];
|
|
186
|
+
const prose = extractProse(ctx);
|
|
187
|
+
const stats = computeTextStatistics(prose);
|
|
188
|
+
// computeReadability returns 0 for zero words/sentences as a "not enough
|
|
189
|
+
// text to score" placeholder (see metrics/formulas.ts), not a genuine
|
|
190
|
+
// score -- a file with no prose must never be flagged as "too low", so
|
|
191
|
+
// skip the bounds check entirely.
|
|
192
|
+
if (stats.words === 0 || stats.sentences === 0)
|
|
193
|
+
return [];
|
|
194
|
+
const score = computeReadability(options.formula, stats);
|
|
195
|
+
const tooLow = options.min !== undefined && score < options.min;
|
|
196
|
+
const tooHigh = options.max !== undefined && score > options.max;
|
|
197
|
+
if (!tooLow && !tooHigh)
|
|
198
|
+
return [];
|
|
199
|
+
// Detection-only, whole-document: always exactly one problem, always at
|
|
200
|
+
// line 1 column 1 -- there is no single source position a readability
|
|
201
|
+
// score "belongs" to.
|
|
202
|
+
return [
|
|
203
|
+
{
|
|
204
|
+
file,
|
|
205
|
+
line: 1,
|
|
206
|
+
column: 1,
|
|
207
|
+
text: '',
|
|
208
|
+
match: '',
|
|
209
|
+
ruleName: rule.name,
|
|
210
|
+
severity: rule.severity,
|
|
211
|
+
message: formatTemplate(rule.message ?? FALLBACK_MESSAGE, options.formula, String(score), options.min !== undefined ? String(options.min) : '-∞', options.max !== undefined ? String(options.max) : '∞'),
|
|
212
|
+
},
|
|
213
|
+
];
|
|
214
|
+
};
|
|
215
|
+
export const metric = { id: 'metric', fixable: false, execute };
|
|
216
|
+
//# sourceMappingURL=metric.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metric.js","sourceRoot":"","sources":["../../../src/rules/scope/metric.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AACnF,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAE7D;;;;;;;;;;;;;;;GAeG;AACH,MAAM,cAAc,GAAG,qBAAqB,CAAC;AAE7C;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,aAAa,CAAC,IAAY;IACxC,OAAO,IAAI,CAAC,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,gBAAgB,EAAE,EAAE,CAAC,CAAC;AACxE,CAAC;AAED;;;;;;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