Fix eslint error @typescript-eslint/no-base-to-string causing test failures #6113
Labels
Status: Triage
Needs to be verified, categorized, etc
Type: Bug / Error
Something isn't working or is incorrect
Description
When running
pnpm test
, the eslint checker flags the following error, preventing all tests from running:'DOMPurify.sanitize(sanitizeMore(text, config), config.dompurifyConfig)' may use Object's default stringification format ('[object Object]') when stringified @typescript-eslint/no-base-to-string
This issue occurs in the file:
/packages/mermaid/src/diagrams/common/common.ts
on line 86.The error is caused because the
toString
method may stringify an object using the default[object Object]
format.Steps to reproduce
pnpm test
@typescript-eslint/no-base-to-string
Screenshots
Code Sample
Setup
Suggested Solutions
The issue can be fixed by explicitly converting the output of
DOMPurify.sanitize
to a string using theString()
method instead of relying ontoString()
. For example:text = String(DOMPurify.sanitize(sanitizeMore(text, config), config.dompurifyConfig));
This resolves the eslint error:
@typescript-eslint/no-base-to-string
.Additional Context
This fix ensures compatibility with the eslint rule
@typescript-eslint/no-base-to-string
, allowing tests to run successfully usingpnpm test
.The text was updated successfully, but these errors were encountered: