Trott / remark-lint-prohibited-strings

remark-lint plugin to prohibit specified strings in markdown files

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Fix regexp handling

Trott opened this issue · comments

Right now, if no strings in the configuration contain regexp-y things, they will happily be processed as a regular expression. I can't decide if this is a feature or a bug.

If a feature, then the issue is that the output will contain the regexp-y things, like:

Use "Node.js" instead of "Node\b"

That \b is a zero-width word-boundary. Not terribly friendly output. (By the way, the config requires that the backslash be escaped so it will look like no: 'Node\\b'.)

If a bug, then we should find a way to disable it and enable a more explicit "this is a regexp" way of doing things. Also, make sure the regexp-way-of-doing-things has a decent error message for output.

i got interested by this, and looks like you can input any type of regexp

new RegExp(`(\\.|@[a-z0-9/-]*)?${val.no}(\\.\\w)?`, 'g');

but there is also side effect here, if you input dot it will means any character

Easiest solution here might be to get rid of the "instead of" part of the message? "Use foo" rather than "Use foo instead of F00" and trust that the user will be able to find the prohibited string?

Slightly more robust solution would be to make the entirety of the thing a capture group and output whatever the match is?