Skip to content

Comments

Fix no-duplicate-selectors false positives with Less syntax#7888

Merged
ybiquitous merged 4 commits intomainfrom
fix-no-duplicate-selectors--reliable-wildebeest-a99e43d009
Jul 30, 2024
Merged

Fix no-duplicate-selectors false positives with Less syntax#7888
ybiquitous merged 4 commits intomainfrom
fix-no-duplicate-selectors--reliable-wildebeest-a99e43d009

Conversation

@romainmenke
Copy link
Member

@romainmenke romainmenke commented Jul 29, 2024

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

Closes #7887

Is there anything in the PR that needs further explanation?

flattenNestedSelectorsForRule can return an empty list on invalid syntax.
This forgiving behavior is intended as it also allows us to lint partially standard selector lists.

However in no-duplicate-selectors we also use these lists (after normalizing) to detect duplicates. And when the entire list is non-standard the resulting selector will be an empty string.

Each empty string is equal to any other empty string, so in turn each non-standard selector list is considered a duplicate of every other non-standard selector list.

Adding a check that flattenNestedSelectorsForRule did return at least one selector resolves any issues with non-standard syntaxes.

@changeset-bot
Copy link

changeset-bot bot commented Jul 29, 2024

🦋 Changeset detected

Latest commit: 51b267c

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

description: 'Non standard Less nested interpolation (3',
},
{
code: '.foo() { .bar > & { color: #000; } &.readonly { color: #fff; } }',
Copy link
Member

Choose a reason for hiding this comment

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

I suppose the mixin is being ignored in its entirety.
i.e. if there are duplicates in .foo() { /* here */ }, they won't be detected

@Mouvedia
Copy link
Member

@ybiquitous Should we release 16.8.1 ?
Or wait for more PRs?
By we, I mean you :)

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, LGTM 👍🏼

I'll release 16.8.1 soon.

@ybiquitous ybiquitous merged commit 133b4cc into main Jul 30, 2024
@ybiquitous ybiquitous deleted the fix-no-duplicate-selectors--reliable-wildebeest-a99e43d009 branch July 30, 2024 00:35
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 no-duplicate-selectors false positives with Less syntax

3 participants