Renovate: Use automation to enforce one sentence per line

Created on 2 Nov 2020  路  9Comments  路  Source: renovatebot/renovate

What would you like Renovate to be able to do?

We need an automatic way to enforce the "one sentence per line" standard, that @HonkingGoose just implemented in PR #7625.
@JamieMagee said that we could try making our own Prettier plugin.

At the most basic level, if this is the Markdown input:

This is a sentence. This is a second sentence. This is a third sentence.

Then the Prettier plugin should fix it up like this:

This is a sentence.
This is a second sentence.
This is a third sentence.

Did you already have any implementation ideas?

I've checked for viable ways to fix this with an existing package, but I haven't found a well maintained package.
This is discussed in https://github.com/renovatebot/renovate/issues/7545 (scroll trough the issue to see mentions of alternatives that were considered).

@viceice said:

I think it should be easy doable to write a prettier plugin based on the textlint rule

Quote from @rarkins:

I'm ok with that as long as we don't end up needing too many ignore statements throughout our markdown.

I'm willing to help where I can, I can at least write input and output files that you can use to test the plugin. :smile:

priority-4-low feature

Most helpful comment

I have a prettier plugin for this working locally. Just need to deal with some edge cases where we don't want to break on every .. For example: e.g., i.e., etc., ...

All 9 comments

@JamieMagee Did you have any thoughts on how to get started with this?

I was thinking that maybe I can write some test cases, if you supply me with a "template" that I can fill in, so that I can see how the testcase works?

I've reviewed some incoming PRs that were not (yet) using the new style, and made suggestions to fix the style errors.
While I was doing this, I thought: "I don't know if we should enforce a style that we can't automate. It's a bit unfair to ask contributors to change their work when the linter says it's good to go....".
I also think this is a bit of a unfair surprise to spring on honest contributors.

Maybe we should:

  • Tell me to stop reviewing for style "issues"
  • Automate the problem with the linter plugin and then enforce the rule.

Or we could:

  • Leave it be and focus attention on something else.

I don't know what the team's thoughts are on this?

I agree, if we can't enforce and fix automatically using a linter then it's best to do the updating manually in batches instead of causing friction in PRs

I agree, if we can't enforce and fix automatically using a linter then it's best to do the updating manually in batches instead of causing friction in PRs

I'll stop reviewing for these kinds of issues then. :+1:

I have a prettier plugin for this working locally. Just need to deal with some edge cases where we don't want to break on every .. For example: e.g., i.e., etc., ...

Just keep running it on the code base and adding "if" statements until it's good :D

I'm going to park this for now. The corner cases have ended up being a lot larger than I assumed. It's things like markdown links, comments, etc.

I looked at the suggested plugins (JoshuaKGoldberg/sentences-per-line, and IQTLabs/textlint-rule-one-sentence-per-line), and they don't deal with these corner cases either.

@JamieMagee That sounds tricky to work around indeed, and the other plugins didn't find a way to deal with these corner cases as well so it seems.

Thank you for trying! I'm sorry that I can't be of more help to get this done.

so close

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jycouet picture jycouet  路  4Comments

rarkins picture rarkins  路  3Comments

ZauberNerd picture ZauberNerd  路  4Comments

Siilwyn picture Siilwyn  路  4Comments

amilajack picture amilajack  路  3Comments