-
-
Notifications
You must be signed in to change notification settings - Fork 163
check-examples exampleCodeRegex option with global and multiline expression flags #331
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
🤔alternatively, perhaps there is a way to lint the whole example content as markdown, using something like this: https://github.com/eslint/eslint-plugin-markdown |
Regarding linting as Markdown... With the approach of eslint in how (pre)processors work (which is what There is one other possibility outside of our plug-in. You could define the equivalent of an eslint processor for https://github.com/remarkjs/remark (they only appear to support plugins themselves, though the project they are associated with at https://github.com/unifiedjs/unified support processors, albeit focused apparently more on text, rather than code) Such a processor would find the jsdoc blocks within JavaScript files and then find the Markdown within those blocks. The advantage of this approach is that you could get linting of your Markdown within the jsdoc blocks along the way, as well as the lint JavaScript example blocks within them. The disadvantage is that it would not be integrated with your regular coding error messages, but would instead be added with any Markdown styling rules you wanted to enforce. But in any case, I think that it is not inconceivable to handle this in |
Btw, whoever might find time to work on this issue, might also knock out #211 ( |
🎉 This issue has been resolved in version 18.2.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
It would be great if the
check-examples
ruleexampleCodeRegex
option could work with global and multiline expression flags, so that multiple markdown code blocks could be linted per example. Here is a contrived example, supported byjsdoc-md
:Here is an example
/^```(?:js|javascript)\n([\s\S]*?)```$/gm
pattern for theexampleCodeRegex
option:https://regexr.com/4h9sh
Each regex result should be linted in isolation; I tried quickly adding
gm
flags to the source code here:eslint-plugin-jsdoc/src/rules/checkExamples.js
Line 70 in f0c246c
But that caused weirdness where ESLint would not allow the same named
const
in two code blocks, etc. and the errors for following code blocks were reporting in the wrong places.The text was updated successfully, but these errors were encountered: