How to disable linting in Markdown script tags.
In markdown files, often I post only a part of a javascript/typescript file to explain something.
If this part is e.g. a method of a class (without the whole class definition), I get a lot of errors.
How can I disable linting script tags in markdown?
Something like ```javascript-nolint or ```typescript lint:disable would be helpful. Or is there a config?
Please sign in to leave a comment.
What linter do you use?
Hi there,
Not answering the actual question (since I'm not familiar with the actual subject that much) .. but here I have found opposite request which is still not marked as implemented/processed or alike: https://youtrack.jetbrains.com/issue/WEB-25785 ...
But back to your issue: what linters show those errors -- IDE built-in inspections / native support ... or external linters (ESLint etc).
For external linters it's easy: just create custom Scope where you would list all such "excluded" files and then add a rule for that particular linter (in Inspections -- external linter results are integrated as separate inspection) so it is disabled (not executed) for that newly created Scope.
And just in case (so it's more clear on what's happening to everyone): could you share an example of such .md file (so it can be copy-pasted and tested locally) and the screenshot of how it looks in IDE (the errors etc)
I use eslint (for js files) and tslint (for ts files) combined. If the script tag is javascript, I guess it takes the eslint.
Have you tried these options for ESLint: https://eslint.org/docs/2.0.0/user-guide/configuring#configuring-rules and https://eslint.org/docs/2.0.0/user-guide/configuring#ignoring-files-and-directories
and those for TSLint: https://palantir.github.io/tslint/usage/rule-flags/ ?
Here the screenshot with javascript as type and **/*.md in .eslintignore:
Edit: I know, I did abuse javascript as type. But typescript as type says additionally, that the method (loadConfigFromREST) is not resolved and shows it in red. I don't want to put the whole script, only a snippet...
I don't like to have something like this in the code block:
It's showed in the rendered md page and it does not help, the errors do not disappear.
Here the same example as typescript for tslint:
example.md:
>I don't like to have something like this in the code block:
>It's showed in the rendered md page and it does not help, the errors do not disappear.
The solution I have suggested does not require this -- since it's Scope based and per-Inspection setting .. it's stored in project settings.
What @Oksana has suggested should also work -- should be pretty much the same but config is stored in actual linter config (so it should also work if running manually outside of IDE etc).