Skip to content

Use node type to check for id selectors - #228

Merged
Martin Aeschlimann (aeschli) merged 1 commit into
microsoft:masterfrom
OldStarchy:master
Dec 8, 2020
Merged

Martin Aeschlimann (aeschli) merged 1 commit into
microsoft:masterfrom
OldStarchy:master

Conversation

@OldStarchy

Copy link
Copy Markdown
Contributor

Following on from the discussion in microsoft/vscode#75905 (comment).

This change replaces the check for a # character with a node type check when linting ID selectors. This is to avoid the "avoid id selectors" rule from highlighting interpolations in scss.

This also fixes a bug that the ID lint would only warn when the ID was the first selector in the rule, eg. it would detect #foo.bar but not .bar#foo.

I've added a couple more tests to cover some different id selectors and interpolations.

While this works, would it be better to add a condition on this switch to find and handle IdentifierSelectors rather than the loop through the SimpleSelector children that I have in this PR?

@ghost

Deleted user (ghost) commented Dec 8, 2020 •

Copy link
Copy Markdown

CLA assistant check
All CLA requirements met.

@aeschli

Copy link
Copy Markdown
Collaborator

Looks good! I like the suggestion to add a function visitIdentifierSelectors. It's better not to assume that an IdentifierSelectors is always the direct child of a SimpleSelector

@OldStarchy

Copy link
Copy Markdown
Contributor Author

Much simpler

@aeschli
Martin Aeschlimann (aeschli) merged commit e679422 into microsoft:master Dec 8, 2020
@aeschli

Copy link
Copy Markdown
Collaborator

Thanks @aNickzz !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants