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

feat(mdlint): add rule TOP009 to ensure lesson overview items start with a capital letter and end with a period #27977

Open
wants to merge 43 commits into
base: main
Choose a base branch
from

Conversation

nikitarevenco
Copy link
Contributor

@nikitarevenco nikitarevenco commented May 15, 2024

Adds a new rule to markdown lint.

Lesson overview items should end with a period and start with a capital letter

Issue

Closes #27625 (comment)

Additional Information

Pull Request Requirements

  • I have thoroughly read and understand The Odin Project curriculum contributing guide
  • The title of this PR follows the location of change: brief description of change format, e.g. Intro to HTML and CSS lesson: Fix link text
  • The Because section summarizes the reason for this PR
  • The This PR section has a bullet point list describing the changes in this PR
  • If this PR addresses an open issue, it is linked in the Issue section
  • If any lesson files are included in this PR, they have been previewed with the Markdown preview tool to ensure it is formatted correctly
  • If any lesson files are included in this PR, they follow the Layout Style Guide

Copy link
Contributor

@MaoShizhong MaoShizhong left a comment

Choose a reason for hiding this comment

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

The checks aren't running due to a merge conflict.
You'll need to rename your rule and relevant files/dirs to use TOP009 (including the markdownlint config) because #27915 added what's now TOP008. That PR also adjusted the markdownlint config, so that should be resolved once you resolve the merge conflicts.

In terms of testing your rule, you'll need to make sure your test files include all of the different scenarios to test, and you can run the lint script on it locally.
Once you're happy with that, then a new push to here (after resolving conflicts) will trigger the actions with your local linting files.

@nikitarevenco
Copy link
Contributor Author

The checks aren't running due to a merge conflict. You'll need to rename your rule and relevant files/dirs to use TOP009 (including the markdownlint config) because #27915 added what's now TOP008. That PR also adjusted the markdownlint config, so that should be resolved once you resolve the merge conflicts.

In terms of testing your rule, you'll need to make sure your test files include all of the different scenarios to test, and you can run the lint script on it locally. Once you're happy with that, then a new push to here (after resolving conflicts) will trigger the actions with your local linting files.

Thanks for letting me know! I've fixed the merge conflicts. Now I just need to fix the code so that it works

@MaoShizhong
Copy link
Contributor

A heads up that the merge has wiped out your original doc file, so you'll want to restore it but under the TOP009 name of course

@nikitarevenco
Copy link
Contributor Author

A heads up that the merge has wiped out your original doc file, so you'll want to restore it but under the TOP009 name of course

Yay! I got it working

@nikitarevenco
Copy link
Contributor Author

A heads up that the merge has wiped out your original doc file, so you'll want to restore it but under the TOP009 name of course

Thankfully we have git for that :D

@nikitarevenco nikitarevenco marked this pull request as ready for review May 15, 2024 15:56
@MaoShizhong
Copy link
Contributor

MaoShizhong commented May 15, 2024

Question - my understanding from the original issue was that this rule was meant to prevent LO items being questions, as they instead should be statements of what the lesson will cover. But this rule tries to enforce the opposite - is this intended? I see that the doc file implies the rule is supposed to prevent questions (LO items must begin capitalised and end with a .)

@nikitarevenco
Copy link
Contributor Author

Question - my understanding from the original issue was that this rule was meant to prevent LO items being questions, as they instead should be statements of what the lesson will cover. But this rule tries to enforce the opposite - is this intended?

Oh, this was just a mistake on my part. I just fixed it!

@nikitarevenco
Copy link
Contributor Author

Actually, seems like there are still some mistakes. Sorry let me test it a bit more.

@nikitarevenco nikitarevenco marked this pull request as draft May 15, 2024 16:01
@nikitarevenco nikitarevenco marked this pull request as ready for review May 15, 2024 16:05
@nikitarevenco
Copy link
Contributor Author

Not sure what's going on here, I've removed the comment but that didn't seem to work

image

used to work just fine before

@MaoShizhong MaoShizhong self-requested a review June 30, 2024 13:29
Co-authored-by: MaoShizhong <122839503+MaoShizhong@users.noreply.github.com>
@nikitarevenco
Copy link
Contributor Author

@MaoShizhong Thank you! The PR is not ready for review yet as the tests are not passing. I will let you know when they are.

@MaoShizhong MaoShizhong mentioned this pull request Jul 6, 2024
7 tasks
Copy link
Contributor

@MaoShizhong MaoShizhong left a comment

Choose a reason for hiding this comment

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

Had a think about this further.

I think we should add a non-script-fixable error if an LO item ends with a ? that reports something like "Lesson overview items must be statements, not questions."

If I wrote - What are linters? then the current code would only complain about the ? and simply fixing (script or manual) to - What are linters. will not make sense, yet the linter will be happy.

I think questions should be flagged as such and not made script-fixable, as that requires changing the sentence wording itself e.g. to - Describe what linters are.

Then in that situation, we can flag and script-fix capitalisation/end punctuation errors. Those errors must only flag if the question error doesn't.

@nikitarevenco
Copy link
Contributor Author

nikitarevenco commented Jul 9, 2024

Had a think about this further.

I think we should add a non-script-fixable error if an LO item ends with a ? that reports something like "Lesson overview items must be statements, not questions."

If I wrote - What are linters? then the current code would only complain about the ? and simply fixing (script or manual) to - What are linters. will not make sense, yet the linter will be happy.

I think questions should be flagged as such and not made script-fixable, as that requires changing the sentence wording itself e.g. to - Describe what linters are.

Then in that situation, we can flag and script-fix capitalisation/end punctuation errors. Those errors must only flag if the question error doesn't.

I agree with you. I think introducing fixers only makes sense when they are beneficial in every case.
I don't think it makes sense for there to be a punctuation auto fixer in the first place. For example, while Describe what linters are -> Describe what linters are. makes sense, What are linters -> What are linters. would not make as much sense because the sentence itself is phrased as a question, only proper capitalisation fixer makes sense to me describe what linters are -> Describe what linters are, what do you think

@MaoShizhong
Copy link
Contributor

I think I'm with you on that, where the nuances and complexity of a fixer catching all cases isn't really that beneficial given the example you provided.

I would probably think then we just need the one general error reporting something like
"Lesson overview items must be statements, not questions, and must begin with a capital letter and end with a period."
No need for actual/expected, just provide the LO item itself in the context property.

That should flag for questions (ends in ?), as well as uncapitalised/un-period-ended LO items. Then we leave it to the user to manually fix, since it's context-dependent.

@MaoShizhong MaoShizhong added the Content: Markdownlint Involves anything related to the curriculum repo linter label Jul 10, 2024
@nikitarevenco
Copy link
Contributor Author

I think I'm with you on that, where the nuances and complexity of a fixer catching all cases isn't really that beneficial given the example you provided.

I would probably think then we just need the one general error reporting something like "Lesson overview items must be statements, not questions, and must begin with a capital letter and end with a period." No need for actual/expected, just provide the LO item itself in the context property.

That should flag for questions (ends in ?), as well as uncapitalised/un-period-ended LO items. Then we leave it to the user to manually fix, since it's context-dependent.

I made the lint rules behave like your suggestions:

  • Single warning message Lesson overview items must be statements, not questions, and must begin with a capital letter and end with a period.

Copy link
Contributor

@MaoShizhong MaoShizhong left a comment

Choose a reason for hiding this comment

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

Just two little nits but otherwise I'm happy with this 🔥 Seems to work great!

markdownlint/docs/TOP008.md Show resolved Hide resolved
markdownlint/docs/TOP009.md Outdated Show resolved Hide resolved
nikitarevenco and others added 2 commits July 15, 2024 17:15
Co-authored-by: MaoShizhong <122839503+MaoShizhong@users.noreply.github.com>
For consistency

Co-authored-by: MaoShizhong <122839503+MaoShizhong@users.noreply.github.com>
Co-authored-by: MaoShizhong <122839503+MaoShizhong@users.noreply.github.com>
Copy link
Contributor

@MaoShizhong MaoShizhong left a comment

Choose a reason for hiding this comment

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

I'm happy with this now - let's see if @thatblindgeye has anything further to add.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Content: Markdownlint Involves anything related to the curriculum repo linter
Projects
None yet
Development

Successfully merging this pull request may close these issues.

New lint rule: Lesson overview items should not be questions.
3 participants