Skip to content

Conversation

@fisker
Copy link
Member

@fisker fisker commented Oct 21, 2022

Description

Since v2.0.0, we removed version option from getSupportInfo #7620, since became useless, let's remove it.

Checklist

  • I’ve added tests to confirm my change works.
  • (If changing the API or CLI) I’ve documented the changes I’ve made (in the docs/ directory).
  • (If the change is user-facing) I’ve added my changes to changelog_unreleased/*/XXXX.md file following changelog_unreleased/TEMPLATE.md.
  • I’ve read the contributing guidelines.

Try the playground for this PR

@thorn0
Copy link
Member

thorn0 commented Oct 21, 2022

I can imagine how since could be useful for #9879

@fisker
Copy link
Member Author

fisker commented Oct 21, 2022

It can be useful, but if we do #9879 (comment), we won't need that. Even if we want run multiple version in on page, we can still hardcode there.

@thorn0
Copy link
Member

thorn0 commented Oct 21, 2022

I forgot that every version can tell us itself what it supports. So let's proceed.

@fisker
Copy link
Member Author

fisker commented Oct 21, 2022

Added old values to playground, so old link won't be broken 1ba50c7

Comment on lines 48 to 57
if (Array.isArray(option.default)) {
option.default =
option.default.length === 1
? option.default[0].value
: option.default
.filter(filterSince)
.sort((info1, info2) =>
semverCompare(info2.since, info1.since)
)[0].value;
}
Copy link
Member Author

Choose a reason for hiding this comment

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

Maybe I should keep this array thing, otherwise it will be a breaking change, plugin may use array as default value.

Copy link
Member Author

Choose a reason for hiding this comment

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

Deprecated array, introduced function for non-primitive values, it will be safer (to avoid mutate).

Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't these things be JSON-serializable?

Copy link
Member Author

Choose a reason for hiding this comment

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

Make sense, so I'll just put [{value: []}] back.

Copy link
Member Author

Choose a reason for hiding this comment

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

Wait, we get the support info from getSupportInfo function, so it will return [], then it's serializable.

Copy link
Member Author

Choose a reason for hiding this comment

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

Let's add a new defaultValue field?

Copy link
Member

Choose a reason for hiding this comment

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

How will it be different from default?

Copy link
Member Author

Choose a reason for hiding this comment

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

When they are array, defaultValue use the value directly, default use default[0].value, so we don't need ask plugin to update.

Copy link
Member Author

Choose a reason for hiding this comment

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

So I can use defaultValue: [] instead of default: [{value: []}].

Copy link
Member Author

Choose a reason for hiding this comment

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

Forget it, switched back to default: [{value: []}]

@thorn0
Copy link
Member

thorn0 commented Oct 21, 2022

Also this logic was used to hide unreleased things on the playground.

@fisker
Copy link
Member Author

fisker commented Oct 21, 2022

Also this logic was used to hide unreleased things on the playground.

I know that, but why? Only PR's playground will show unreleased, it should be shown, let people play with it.

@fisker
Copy link
Member Author

fisker commented Oct 21, 2022

And we already use showUnreleased: true,

showUnreleased: true,

@thorn0
Copy link
Member

thorn0 commented Oct 21, 2022

And we already use showUnreleased: true,

showUnreleased: true,

Doesn't this PR remove support for showUnreleased?

@fisker
Copy link
Member Author

fisker commented Oct 21, 2022

showUnreleased checks since, there is no since to check now. So unreleased will always show. The code above was in playground, it's useless now.

@fisker
Copy link
Member Author

fisker commented Oct 21, 2022

I mean we already show unreleased before this PR, so

Also this logic was used to hide unreleased things on the playground.

We are not using.

@fisker
Copy link
Member Author

fisker commented Oct 21, 2022

Don't overthink this, nobody is using it, even I thought prettier-vscode may use it to support different version of prettier, but they are not.

@fisker fisker marked this pull request as ready for review October 21, 2022 16:59
@fisker fisker marked this pull request as draft October 21, 2022 17:16
@fisker fisker marked this pull request as ready for review October 22, 2022 03:43
Copy link
Contributor

@sosukesuzuki sosukesuzuki left a comment

Choose a reason for hiding this comment

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

Good catch

@fisker fisker merged commit 2d23d33 into prettier:next Oct 23, 2022
@fisker fisker deleted the remove-since branch October 23, 2022 03:18
medikoo pushed a commit to medikoo/prettier-elastic that referenced this pull request Feb 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants