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: Add support for media conditions in require-baseline rule #49

Merged
merged 3 commits into from
Feb 19, 2025

Conversation

ryo-manba
Copy link
Contributor

Prerequisites checklist

What is the purpose of this pull request?

This pull request adds support for media conditions in the require-baseline rule.

What changes did you make? (Give an overview)

  • Added checks for media conditions in @media queries.
  • Updated baseline-data.js to include media conditions.
  • Adjusted test cases to cover media conditions.
  • Updated documentation to reflect the changes.

Related Issues

fixes #48

Is there anything you'd like reviewers to focus on?

Copy link

linux-foundation-easycla bot commented Feb 16, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

Copy link
Member

@nzakas nzakas left a comment

Choose a reason for hiding this comment

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

Thanks for the submission, this is looking really good. Just left one note about an edge case.

continue;
}

const conditionLevel = mediaConditions.get(child.name);
Copy link
Member

Choose a reason for hiding this comment

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

conditionLevel can be undefined if someone is using an unknown media condition. In that case, we should just exit early because no-invalid-at-rules should catch it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point! I've fixed it.
Add check for invalid at-rules

@ryo-manba ryo-manba requested a review from nzakas February 17, 2025 23:34
@@ -556,6 +556,11 @@ export default {
node,
) {
for (const child of node.children) {
// ignore unknown media conditions - no-invalid-at-rules already catches this
Copy link
Member

Choose a reason for hiding this comment

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

Can you also a add a test that has an invalid media condition to verify that it's ignored?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ryo-manba ryo-manba requested a review from nzakas February 19, 2025 14:10
Copy link
Member

@nzakas nzakas left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks so much!

@nzakas nzakas merged commit ad9ddd7 into eslint:main Feb 19, 2025
16 checks passed
@ryo-manba ryo-manba deleted the feat-require-baseline-media-conditions branch February 20, 2025 00:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Complete
Development

Successfully merging this pull request may close these issues.

Bug: require-baseline does not properly validate media conditions in @media rules
2 participants