eslint-plugin-markdown: New: ability to only lint for certain parts of the code block
Ref https://github.com/airbnb/javascript/issues/685
Not sure how this would work but an example would be in airbnb’s style guide.
3.1 Use the literal syntax for object creation. eslint rules: no-new-object.
// bad
const item = new Object();
// good
const item = {};
So in this case you would want to check the // good
part is linted correctly while the // bad
snippet is incorrect.
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 1
- Comments: 35 (25 by maintainers)
Commits related to this issue
- Update: Support configuration comments (fixes #46, fixes #54) — committed to eslint/eslint-plugin-markdown by btmills 8 years ago
- Update: Support configuration comments (fixes #46, fixes #54) — committed to eslint/eslint-plugin-markdown by btmills 8 years ago
- Update: Support configuration comments (fixes #46, fixes #54) — committed to eslint/eslint-plugin-markdown by btmills 8 years ago
I just added HTML comments preceding code blocks in the ESLint rule docs, and our new renderer is preserving the comments correctly! I also ran a test with the parser in this plugin. As long as there’s still a blank line preceding the code block (this is required by spec anyway), it correctly picks up the raw HTML and the code block separately.
<!--eslint-plugin-markdown ignore-->
<!--eslint-disable-block-->
<!--eslint-disable-->
/<!--eslint-enable-->
<!--eslint-plugin-markdown-disable-->
/<!--eslint-plugin-markdown-enable-->
Brainstorming a few different options there. Any preferences/other ideas?
Below, I’ve borrowed from ESLint’s eqeqeq docs and inserted comments to demonstrate what this should look like given the latest proposal. Any objections to implementing this as described?
When disabling a specific rule
<!--eslint-disable-next-block eqeqeq-->
, the plugin will alert for syntax errors and other rules but ignore errors from eqeqeq:Without any comments, the plugin will report all errors as received from ESLint:
When disabled for the entire block, the plugin won’t even bother sending the code to ESLint:
@ljharb the implementation for configuring rules in comments will be different than it will be for this, so I’ve opened #54 to track that separately. Since we still have inline config comments, I’d say #54 can build on top of this rather than blocking it.
For https://github.com/airbnb/javascript, it would be all of those. Some blocks should be skipped entirely, some blocks will have modified configs, and some blocks will be intentionally failing