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

Fix declaration-property-value-no-unknown false positives for descriptors #6669

Merged
merged 6 commits into from Feb 17, 2023
Merged

Fix declaration-property-value-no-unknown false positives for descriptors #6669

merged 6 commits into from Feb 17, 2023

Conversation

FloEdelmann
Copy link
Member

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

Closes #6663.

Is there anything in the PR that needs further explanation?

No, it's self-explanatory.

@changeset-bot
Copy link

changeset-bot bot commented Feb 17, 2023

🦋 Changeset detected

Latest commit: ca25f9b

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

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

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

@jeddy3 jeddy3 changed the title Fix at-rule descriptors in declaration-property-value-no-unknown Fix declaration-property-value-no-unknown false positives for descriptors Feb 17, 2023
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.

@FloEdelmann This is fantastic, thank you!

It's looking good. I've requested a couple of small changes.

lib/rules/declaration-property-value-no-unknown/index.js Outdated Show resolved Hide resolved
.changeset/cyan-kangaroos-hope.md Outdated Show resolved Hide resolved
FloEdelmann and others added 2 commits February 17, 2023 13:07
Co-authored-by: Richard Hallows <jeddy3@users.noreply.github.com>
Co-authored-by: Richard Hallows <jeddy3@users.noreply.github.com>
FloEdelmann and others added 2 commits February 17, 2023 14:33
Co-authored-by: Richard Hallows <jeddy3@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.

Cool. LGTM 👏🏼

const { error } =
decl?.parent?.type === 'atrule'
? // @ts-expect-error -- CSSTree types are not complete
forkedLexer.matchAtruleDescriptor(decl.parent.name, prop, cssTreeValueNode)
Copy link
Member

Choose a reason for hiding this comment

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

I'll send a patch to @types/css-tree. 💪🏼

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks! Note that more functions from the Lexer class are missing, so maybe you can add them all in one batch?

Also, I used @ts-expect-error instead of @ts-ignore, so that this PR can be merged first and this will throw an error once the css-tree types are fixed.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, when I added the Lexer class type to @types/css-tree with DefinitelyTyped/DefinitelyTyped#64256, I added only the minimum necessary method as Lexer really has many methods!

If you know what other methods we will need than matchAtruleDescriptor(), please let me know. For example, we need methods starting match like matchAtrulePrelude()...

I also prefer @ts-expect-error over @ts-ignore and more suitable in this situation. 👍🏼

Copy link
Member Author

Choose a reason for hiding this comment

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

matchAtrulePrelude might be needed for #6560.

Copy link
Member

Choose a reason for hiding this comment

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

I've opened PR DefinitelyTyped/DefinitelyTyped#64410. Any feedback is welcome if you have.

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.

Thanks for making the changes.

LGTM.

@jeddy3 jeddy3 merged commit 02f1f98 into stylelint:main Feb 17, 2023
@FloEdelmann FloEdelmann deleted the at-rule-descriptor branch February 17, 2023 16:07
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.

Fix declaration-property-value-no-unknown false positives for descriptors
3 participants