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

Harmonize list item indent literals #281

Closed
wants to merge 2 commits into from
Closed

Conversation

jablko
Copy link
Contributor

@jablko jablko commented Feb 22, 2022

Initial checklist

  • I read the support docs
  • I read the contributing guide
  • I agree to follow the code of conduct
  • I searched issues and couldn’t find anything (or linked relevant results below)
  • If applicable, I’ve added docs and tests

Description of changes

Whereas remark-stringify and mdast-util-to-markdown accept only 'one', 'tab', or 'mixed', remark-lint-list-item-indent accepts only 'space', 'tab-size', or 'mixed'.

What do you think about allowing them to accept either the current or the preferred literals (whichever those are), and maybe dropping support for all but the preferred literals at some future point?

@github-actions github-actions bot added the 👋 phase/new Post is being triaged automatically label Feb 22, 2022
@github-actions

This comment has been minimized.

@ChristianMurphy ChristianMurphy added 💬 type/discussion This is a request for comments 🧑 semver/major This is a change labels Feb 22, 2022
@github-actions github-actions bot added 🤞 phase/open Post is being triaged manually and removed 👋 phase/new Post is being triaged automatically labels Feb 22, 2022
@codecov-commenter

This comment was marked as resolved.

@ChristianMurphy ChristianMurphy requested a review from a team February 22, 2022 21:12
@wooorm
Copy link
Member

wooorm commented Feb 25, 2022

This is a breaking change, which I’d rather not do, especially if there’s no good reason for it.

These options are also affected by the proposal (which is a breaking change) of syntax-tree/mdast-util-to-markdown#48, syntax-tree/mdast-util-to-markdown#50, and syntax-tree/mdast-util-to-markdown#51.

@jablko
Copy link
Contributor Author

jablko commented Feb 25, 2022

@wooorm Is it a breaking change? 'one' are 'tab' are unused values, currently. Tolerating them seems like it might avoid some mistakes, by users configuring both remark-stringify and remark-lint?

@wooorm
Copy link
Member

wooorm commented Feb 25, 2022

You commit is removing the existing values (tab-size, space), not just adding new values?

Comment on lines 172 to 173
option =
{'tab-size': 'tab', space: 'one'}[/** @type {never} */ (option)] || option
Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, should be backwards compatible. Maybe support for all but the preferred literals could be dropped at some future point ... Or not.

Copy link
Member

Choose a reason for hiding this comment

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

Hmm, I guess I missed this line?

Your object is nice but it’s a) a bit hard to read, and b) it’s vulnerable to things like toString or constructor being passed (which here doesn’t seem to result in actual problems, but it’s often good to steer clear of it anyway):
How about:

// To do in major: remove legacy fallbacks.
if (option === 'tab-size') {
  option = 'tab'
} else if (option === 'space') {
  option === 'one'
}

Copy link
Contributor Author

@jablko jablko Mar 30, 2022

Choose a reason for hiding this comment

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

  • I didn't think of that (other properties of "empty" objects), thanks! I've replaced it with:
    option =
      option === 'tab-size' ? 'tab'
        : option === 'space' ? 'one'
        : option

@wooorm
Copy link
Member

wooorm commented Mar 8, 2022

For some reason one comment in the review didn’t come through (I think?):

I think I prefer the existing (this rule’s) values instead of the remark-stringify ones. They’re more about that this rule checks for a size, instead of an actual tab character or so. What do you think?

@jablko
Copy link
Contributor Author

jablko commented Mar 30, 2022

I see your point about tab-size vs. tab. I was motivated by the inconsistency, not the actual values --- this PR doesn't make sense if the values aren't preferred, especially in view of syntax-tree/mdast-util-to-markdown#51.

I'll close this and subscribe to syntax-tree/mdast-util-to-markdown#51 instead. Thanks!

@jablko jablko closed this Mar 30, 2022
@github-actions
Copy link

Hi! This was closed. Team: If this was merged, please describe when this is likely to be released. Otherwise, please add one of the no/* labels.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤞 phase/open Post is being triaged manually 🧑 semver/major This is a change 💬 type/discussion This is a request for comments
Development

Successfully merging this pull request may close these issues.

None yet

4 participants