Skip to content
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

Fix: ignore examples in check-indentation #388

Merged

Conversation

ahwayakchih
Copy link
Contributor

@ahwayakchih ahwayakchih commented Sep 30, 2019

This should fix #334 by making check-indentation rule ignore whole @example blocks.

UPDATE: actually it does not fix #334, but it fixes similar issue with example code blocks.

It could be improved to allow to pass which tags should be ignored as an option, instead of rather specific excludeExamples i added.

This adds an `excludeExamples` option, defaulting to `true`.
When enabled (or not configured) it will mask all `@example` tags
and their content before testing indentation.
That prevents errors about indentation inside example code
blocks and keeps correct line numbers when reporting indentation error
found elsewhere.

It should fix gajus#334.
Ideally this would default to `true`, but that could break existing setups.
@ahwayakchih ahwayakchih changed the title Fix: ignore examples in check indentation Fix: ignore examples in check-indentation Sep 30, 2019
README.md Outdated Show resolved Hide resolved
test/rules/assertions/checkIndentation.js Show resolved Hide resolved
Instead of rather specific `excludeExamples` option, we now have more
generic `excludeTags` option. It takes an array of tag names to exclude
from `check-indentation`, and defaults to `['example']`.

Added test suggested by @golopot:
gajus#388 (comment)
Copy link
Contributor Author

@ahwayakchih ahwayakchih left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed from excludeExamples option to excludeTags option, and made it default to ['example'].
I also added suggested tests.

@ahwayakchih
Copy link
Contributor Author

ahwayakchih commented Oct 1, 2019

@brettz9, @golopot i could also add an option to ignore "code blocks" in description, which would fix #334, but i'm not sure if you'd be willing to accept such change, and if it's ok for this PR or better to add it separately. Or if "code blocks" should be kept in @example tags instead of introducing "support" for additional syntax.

@golopot
Copy link
Collaborator

golopot commented Oct 2, 2019

Another pr to handling code blocks (three ticks) would be great and it does not need to be under an option. It looks like that three ticks is recognized by jsdoc doc generator through the markdown plugin. And VS code recognized it.

@ahwayakchih
Copy link
Contributor Author

Another pr to handling code blocks (three ticks) would be great and it does not need to be under an option.

OK, i prepared #391, but it has to wait because it builds on top of this PR (so i don't have to solve merge conflicts later).

Copy link
Collaborator

@golopot golopot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@golopot golopot merged commit 756520a into gajus:master Oct 2, 2019
golopot pushed a commit that referenced this pull request Oct 2, 2019
Instead of rather specific `excludeExamples` option, we now have more
generic `excludeTags` option. It takes an array of tag names to exclude
from `check-indentation`, and defaults to `['example']`.

Added test suggested by @golopot:
#388 (comment)
@gajus
Copy link
Owner

gajus commented Oct 2, 2019

🎉 This PR is included in version 15.9.6 🎉

The release is available on:

Your semantic-release bot 📦🚀

@gajus gajus added the released label Oct 2, 2019
@ahwayakchih ahwayakchih deleted the fix/ignore-examples-in-check-indentation branch October 2, 2019 13:17
ahwayakchih added a commit to ahwayakchih/eslint-plugin-jsdoc that referenced this pull request Oct 2, 2019
ahwayakchih added a commit to ahwayakchih/eslint-plugin-jsdoc that referenced this pull request Oct 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Don't check indentation within code blocks
4 participants