microsoft / vscode-css-languageservice

CSS, LESS & SCSS language service extracted from VSCode to be reused, e.g in the Monaco editor.
MIT License
312 stars 176 forks source link

@container rule being flagged as "unknownAtRules" when nested in SCSS #381

Closed dladeira closed 5 months ago

dladeira commented 6 months ago

I have the following code snippet in a NUXT project:

.item-icon {
    height: 1.6rem;

    &-sm {
        height: 1rem;
    }

    @container (max-height: 100px) {
        display: none;
    }
}
</style>

And @container is being flagged with Unknown at rule @containerscss(unknownAtRules). The expected behavior is nothing being flagged, as the code runs as expected.

This problem only applies when the rule is nested

marcoms commented 5 months ago

This also applies when using native nested CSS which is now gaining adoption

.childEl {
    /* Unknown at rule @containercss(unknownAtRules) */
    @container parentContainer (min-width: 8rem) {
        background: red;
    }
}

/* No error */
@container parentContainer (min-width: 8rem) {
    .childEl {
        background: red;
    }
}
Jethus commented 5 months ago

Just commenting to say that I'm experiencing the same issue.

@mixin container-query($size) {
  $query: map-get($breakpoints, $size);

  @container (min-width: #{$query}) {
    @content;
  }
}

image

The code works as intended, just VS Code is flagging @container with Unknown at rule @containerscss(unknownAtRules).

mdmoreau commented 4 months ago

@aeschli should those updates be applied to the CSS parser as well? Getting some odd inconsistencies while using standard CSS:

@media (width > 64em) {
  .test {
    /* [full intellisense] */
  }
}

@container (width > 64em) {
  .test {
    /* [full intellisense] */
  }
}

.test {
  @media (width > 64em) {
    /* [full intellisense] */
  }
}

.test {
  @container (width > 64em) {
    /* [no intellisense, unknown at rule] */
  }
}
aeschli commented 4 months ago

Nested containers are only allowed in LESS and SCSS.

mdmoreau commented 4 months ago

@aeschli is that in regard to the current state of nesting in VS Code or the actual spec? Everything I can find reads that @container can be nested similar to other at rules. It also works in each browser I've tested that supports nesting.

https://www.w3.org/TR/css-nesting-1/#conditionals https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_nesting/Nesting_at-rules