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

Add media-feature-name-value-no-unknown #6906

Conversation

romainmenke
Copy link
Member

@romainmenke romainmenke commented Jun 6, 2023

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

Closes #6560

Is there anything in the PR that needs further explanation?

No, it's self-explanatory.


Tested this with a large monorepo containing ±50 websites and got no false positives and it tracked down a real error :

- @media (prefers-contrast: high) {
+ @media (prefers-contrast: more) {

@changeset-bot
Copy link

changeset-bot bot commented Jun 6, 2023

🦋 Changeset detected

Latest commit: 85a24c9

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
stylelint Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@romainmenke romainmenke marked this pull request as ready for review June 10, 2023 15:40
@romainmenke romainmenke force-pushed the add-media-feature-name-value-no-unknown--witty-south-china-tiger-8b25eed791 branch from da58881 to ad00a17 Compare June 10, 2023 16:02
@Mouvedia
Copy link
Contributor

Mouvedia commented Jun 11, 2023

There are probably some cases taken from this list that could be covered by additional tests .

ruleName,
config: [true],

accept: [
Copy link
Member Author

Choose a reason for hiding this comment

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

screen-spanning is an unknown media feature and those are ignored by this rule (tested with (foo: ...)).

media-feature-name-no-unknown already exists to cover those issues.

@romainmenke
Copy link
Member Author

There are probably some cases taken from in this list that could be covered by additional tests .

Good call @Mouvedia and thank you for reviewing all this 🙇

I've added all the examples from that link.
Some are partial duplicates but I personally think that is fine.

That link had an example of (grid: 0) / (grid: 1) and I had forgotten about those.
Should be good now :)

Co-authored-by: Masafumi Koba <473530+ybiquitous@users.noreply.github.com>
ybiquitous

This comment was marked as resolved.

Co-authored-by: Masafumi Koba <473530+ybiquitous@users.noreply.github.com>
Comment on lines +27 to +32
const units = new Set(require('../../reference/units').units); // a copy that is safe to mutate

// `x` as a resolution unit is very often a typo for `px`.
// By removing it from the set of known units, we can catch those typos.
// Intentional `x` units are supported by manually checking these in specific functions or properties.
units.delete('x');
Copy link
Member Author

Choose a reason for hiding this comment

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

see : #6906 (comment)

Ignoring x is very specific to this one rule.
If we want to have a re-usable reference for resolutionUnits and if resolutionUnits are included in units, then we must move the removal of x to this rule.

I think this is fine because it makes the exception local to the rule that requires it.

Copy link
Contributor

Choose a reason for hiding this comment

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

see also: #3026 (comment)

romainmenke and others added 2 commits June 13, 2023 07:56
Co-authored-by: Masafumi Koba <473530+ybiquitous@users.noreply.github.com>
Copy link
Member

@ybiquitous ybiquitous 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 great work. LGTM 👏🏼

@romainmenke
Copy link
Member Author

Thank you everyone for the extensive review! 🙇

@romainmenke romainmenke merged commit cbc0b6e into main Jun 13, 2023
15 checks passed
@romainmenke romainmenke deleted the add-media-feature-name-value-no-unknown--witty-south-china-tiger-8b25eed791 branch June 13, 2023 06:27
@ybiquitous
Copy link
Member

This new rule might be in our recommended config when the rule is mature. 😄

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.

Add media-feature-name-value-no-unknown
4 participants