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 ignore: ["keyframe-selectors"] to selector-disallowed-list #7417

Merged

Conversation

mattxwang
Copy link
Member

@mattxwang mattxwang commented Dec 19, 2023

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

Closes #7162.

Is there anything in the PR that needs further explanation?

Two quick questions:

  1. I used the isKeyframeSelector util (used elsewhere) to heuristically guess if the item is a keyframe selector, rather than seeing if it's actually in a keyframe. Does this make sense? Am now using isKeyframeRule instead!
  2. I assumed that there should be nothing "special" about this option's interaction with splitList; in particular, if the list is not split, given /from/ the current implementation will still flag from, to; it's only if the rule is given /from/, { splitList: true } that from, to is properly ignored. However, it'd be simple for me to reverse this behaviour - what are our thoughts? Resolved by the former :)

Copy link

changeset-bot bot commented Dec 19, 2023

🦋 Changeset detected

Latest commit: 5e3675c

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

@mattxwang mattxwang force-pushed the add-ignore-keyframe-selectors-to-selector-disallowed-list branch from 60fb3e6 to d49fdc9 Compare December 19, 2023 00:17
@mattxwang mattxwang marked this pull request as ready for review December 19, 2023 21:45
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.

@mattxwang Thanks for the pull request!

I think it's better to check if the rule node is inside @keyframes {} block rather than using isKeyframeSelector() like this:

if (ignoreKeyframeSelectors && isInsideKeyframes(ruleNode)) {
	return;
}

// ...

const keyframesPattern = /^keyframes$/i;

/**
 * @param {import('postcss').Node} node
 * @returns {boolean}
 */
function isInsideKeyframes({ parent }) {
	return Boolean(parent && isAtRule(parent) && keyframesPattern.test(parent.name));
}

If doing so, splitList is unnecessary for ignore: ['keyframe-selectors']. Any thoughts?

lib/rules/selector-disallowed-list/README.md Outdated Show resolved Hide resolved
lib/rules/selector-disallowed-list/README.md Outdated Show resolved Hide resolved
lib/rules/selector-disallowed-list/__tests__/index.mjs Outdated Show resolved Hide resolved
lib/rules/selector-disallowed-list/__tests__/index.mjs Outdated Show resolved Hide resolved
@ybiquitous ybiquitous mentioned this pull request Dec 20, 2023
9 tasks
@Mouvedia
Copy link
Member

I think it's better to check if the rule node is inside @keyframes {} block rather than using isKeyframeSelector() like this:

[]

const keyframesPattern = /^keyframes$/i;

/**
 * @param {import('postcss').Node} node
 * @returns {boolean}
 */
function isInsideKeyframes({ parent }) {
	return Boolean(parent && isAtRule(parent) && keyframesPattern.test(parent.name));
}

This looks similar to /lib/utils/isKeyframeRule.mjs.

@ybiquitous
Copy link
Member

Ah, I forgot isKeyframeRule. Nice catch! 👍🏼

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.

Looking good. I've requested some changes to align the docs and tests with our conventions.

lib/rules/selector-disallowed-list/README.md Outdated Show resolved Hide resolved
lib/rules/selector-disallowed-list/__tests__/index.mjs Outdated Show resolved Hide resolved
lib/rules/selector-disallowed-list/__tests__/index.mjs Outdated Show resolved Hide resolved
lib/rules/selector-disallowed-list/__tests__/index.mjs Outdated Show resolved Hide resolved
lib/rules/selector-disallowed-list/__tests__/index.mjs Outdated Show resolved Hide resolved
mattxwang and others added 7 commits December 21, 2023 16:54
Co-authored-by: Masafumi Koba <473530+ybiquitous@users.noreply.github.com>
Co-authored-by: Richard Hallows <jeddy3@users.noreply.github.com>
Co-authored-by: Masafumi Koba <473530+ybiquitous@users.noreply.github.com>
Co-authored-by: Masafumi Koba <473530+ybiquitous@users.noreply.github.com>
@mattxwang
Copy link
Member Author

Thanks for the feedback everyone! Have just made the requested changes - let me know what y'all think!

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.

Thank you! LGTM 👍🏼

lib/rules/selector-disallowed-list/README.md Outdated Show resolved Hide resolved
Co-authored-by: Masafumi Koba <473530+ybiquitous@users.noreply.github.com>
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.

LGTM, thank you!

@mattxwang mattxwang merged commit 8ec6748 into main Dec 22, 2023
16 checks passed
@mattxwang mattxwang deleted the add-ignore-keyframe-selectors-to-selector-disallowed-list branch December 22, 2023 08:40
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 ignore: ["keyframe-selectors"] to selector-disallowed-list
4 participants