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

Refactor to improve types and docs for *-list rules #5936

Merged
merged 1 commit into from Feb 23, 2022
Merged

Conversation

ybiquitous
Copy link
Member

@ybiquitous ybiquitous commented Feb 23, 2022

Which issue, if any, is this issue related to?

Follow-up of #5934

Is there anything in the PR that needs further explanation?

When I was looking into the problem of #5933 and #5934, I felt to check the *-list rules again.

So, this pull request aims to improve the docs and type of that rules for consistency and clarity.
It doesn't change the existing behavior.

@@ -80,7 +80,7 @@ testRule({
ruleName,
skipBasicChecks: true,

config: ['keyframes'],
config: 'keyframes',
Copy link
Member Author

Choose a reason for hiding this comment

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

[note] This change aims to test a single primary option value.

const rule = (primary) => {
// To allow for just a string as a parameter (not only arrays of strings)
const primaryValues = [primary].flat();
Copy link
Member Author

Choose a reason for hiding this comment

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

[note] validateOptions allows both a single value and an array, so it's better to call .flat() after the validation.

message: messages.rejected('>'),
},
],
});
Copy link
Member Author

Choose a reason for hiding this comment

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

[note] This new test case aims to just check a single primary value.

* @param {string} value
* @param {string} comparison
*
* @param {unknown} comparison
Copy link
Member Author

Choose a reason for hiding this comment

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

[note] testAgainst() uses isString(), so it accepts the unknown argument.

@ybiquitous ybiquitous marked this pull request as ready for review February 23, 2022 13:20
Copy link
Member

@jeddy3 jeddy3 left a comment

Choose a reason for hiding this comment

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

Fantastic cleanup and refactor, thank you!

LGTM.

@ybiquitous ybiquitous merged commit ca1238d into main Feb 23, 2022
@ybiquitous ybiquitous deleted the follow-up-5934 branch February 23, 2022 23:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants