Skip to content

test: add integration tests for sentence-length rule#31

Merged
3w36zj6 merged 17 commits intotextlint:mainfrom
r4ai:feature/add-sentence-length-tests
Mar 1, 2026
Merged

test: add integration tests for sentence-length rule#31
3w36zj6 merged 17 commits intotextlint:mainfrom
r4ai:feature/add-sentence-length-tests

Conversation

@r4ai
Copy link
Contributor

@r4ai r4ai commented Jan 4, 2026

TODO:

  • Add following test cases:
    • single line comment
    • multi line comment
    • elements immediately following a comment
    • term list
    • nested block elements (e.g., lists)
    • math
    • figure
  • Skip failing tests

Notes

The following test cases are failing because of an implementation bug:

  • should handle elements immediately below comments

    • Current Behavior: Elements placed immediately after a comment are incorrectly wrapped in a Paragraph node.
    • Expected Behavior: They should not be wrapped in a Paragraph, consistent with the behavior of elements that do not follow comments.
  • should handle nested lists

    • Current Behavior: When non-sentence elements (e.g., functions) are included as list items, they are automatically wrapped in a Paragraph. This causes them to be incorrectly targeted by sentence-length validation, leading to failures.

    • Expected Behavior: These elements should not be wrapped in a Paragraph. Their behavior should align with top-level elements (not in a list), which are not wrapped and thus exempt from sentence-length checks.

    • Example:

      Input:

      - Item 1
      
        #figure()

      Actual AST:

      Item/
        Paragraph/
          Text
          Figure
      

      Expected AST:

      Item/
        Paragraph/
          Text
        Figure
      
  • should detect violations in term lists

    • Current Behavior: Items in a term list are currently not wrapped in a Paragraph. As a result, sentence-length validation is not triggered even when an item contains a long sentence.
    • Expected Behavior: Term list items (e.g., sentences) should be wrapped in a Paragraph to ensure they are subject to the same validation rules as ordered or unordered list items.

@r4ai r4ai marked this pull request as ready for review January 5, 2026 13:56
@3w36zj6 3w36zj6 requested review from 3w36zj6 and Copilot January 5, 2026 18:47
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds comprehensive integration tests for the textlint-rule-sentence-length rule to verify that the Typst plugin correctly handles various document structures. The tests ensure that sentence length validation is properly applied to regular text while ignoring comments, math blocks, and other non-text elements.

Key changes:

  • Added 10 integration test cases covering comments, lists, math blocks, figures, and nested content
  • Created fixture files demonstrating valid and invalid scenarios for sentence length validation
  • Added textlint-rule-sentence-length (v5.2.1) as a dev dependency

Reviewed changes

Copilot reviewed 12 out of 13 changed files in this pull request and generated 1 comment.

File Description
test/integration/linting.test.ts Added new test suite with helper functions and 10 test cases for sentence-length rule validation
test/integration/fixtures/smoke/textlint-rule-sentence-length/*.typ Created fixture files for testing various scenarios (comments, lists, math, figures, nested content)
package.json Added textlint-rule-sentence-length v5.2.1 as a dev dependency
bun.lock Updated lock file with new dependency and its transitive dependencies

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@r4ai r4ai marked this pull request as draft February 18, 2026 18:29
@r4ai r4ai marked this pull request as ready for review February 19, 2026 15:41
@3w36zj6 3w36zj6 requested a review from Copilot March 1, 2026 13:52
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 12 out of 13 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@3w36zj6 3w36zj6 force-pushed the feature/add-sentence-length-tests branch from df3d760 to 29a6ed7 Compare March 1, 2026 14:17
@3w36zj6 3w36zj6 requested a review from Copilot March 1, 2026 14:21
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 12 out of 13 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Member

@3w36zj6 3w36zj6 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@3w36zj6 3w36zj6 merged commit 8e76c01 into textlint:main Mar 1, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants