[GH-ISSUE #135] Should shared.js' createTokenCache not recreate an existing cache? #1962

Closed
opened 2026-03-07 20:03:10 +03:00 by kerem · 1 comment
Owner

Originally created by @JoshuaKGoldberg on GitHub (Jul 15, 2018).
Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/135

Context: I'm writing a custom rule and would like to use the forEachLine method (#134). That method uses the tokenCache created by createTokenCache.

If it just so happens that a custom rule's version of markdownlint is different from the package's, then forEachLine will crash as its version of tokenCache won't exist. The solution is to manually call shared.createTokenCache() in the rule... but that seems wasteful for the general case of everyone using the same markdownlint version.

Originally created by @JoshuaKGoldberg on GitHub (Jul 15, 2018). Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/135 _Context: I'm writing a custom rule and would like to use the `forEachLine` method (#134). That method uses the `tokenCache` created by `createTokenCache`._ If it just so happens that a custom rule's version of markdownlint is different from the package's, then `forEachLine` will crash as its version of `tokenCache` won't exist. The solution is to manually call `shared.createTokenCache()` in the rule... but that seems wasteful for the general case of everyone using the same markdownlint version.
kerem closed this issue 2026-03-07 20:03:10 +03:00
Author
Owner

@DavidAnson commented on GitHub (Jul 15, 2018):

Per #134, these functions are not public at present (partly due to challenges like this), so this scenario is not one that should be encountered.

<!-- gh-comment-id:405104373 --> @DavidAnson commented on GitHub (Jul 15, 2018): Per #134, these functions are not public at present (partly due to challenges like this), so this scenario is not one that should be encountered.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/markdownlint#1962
No description provided.