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

Comments break use-nesting #21

Open
ryami333 opened this issue Nov 26, 2024 · 0 comments
Open

Comments break use-nesting #21

ryami333 opened this issue Nov 26, 2024 · 0 comments

Comments

@ryami333
Copy link

Consider the following code:

.foo {
  margin-top: 10px;
}

.foo:first-child {
  margin-top: unset;
}

If you have configured Stylelint to enable this plugin, then you'll correctly receive a linting error:

Expected ".foo:first-child" inside of ".foo". (csstools/use-nesting)

However, if you have any kind of comment between the two style declarations, then you no longer get a linting error. Eg.:

.foo {
  margin-top: 10px;
}

+/**
+ * This comment breaks the linting!
+ */
.foo:first-child {
  margin-top: unset;
}

I've read in #9 that it would be difficult to implement this plugin for non-sequential nodes, but it seems like it would be sensible to make a special exception for non-styling nodes like comments, no?

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

No branches or pull requests

1 participant