Skip to content
This repository was archived by the owner on Nov 16, 2023. It is now read-only.
This repository was archived by the owner on Nov 16, 2023. It is now read-only.

TSLint test doesn't support multiline failure messages #271

@gabritto

Description

@gabritto

TSLint rule tests don't support testing rules that have failure messages that span over multiple lines.
This happens because when TSLint parses a .lint file for the expected failure messages, it always parses lines separately.
For example:

declare var foo;
~~~~~           [This is a multiline
error message]

TSLint will parse the failure message as "This is a multiline" instead of "This is a multiline error message".

ESLint
As far as I could tell, ESLint takes a different approach to rule unit tests, so this issue will be deprecated once #214 is solved.

Workaround
As a workaround, I had my rule take a "single-line" boolean argument. If this is set, the messages the rules generates get joined into a single line. The "single-line" argument is then set in the test TSLint configurations. When running the rule in "production", this boolean is not set, so the messages can preserve their line breaks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions