Skip to content

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

Closed

Description

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

Activity

  1. marcoms commented on Mar 4, 2024

    @marcoms

    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;
    	}
    }
  2. Jethus commented on Mar 8, 2024

    @Jethus

    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).

  3. changed the title [-]SCSS @container rule being flagged as "unknownAtRules"[/-] [+]@container rule being flagged as "unknownAtRules" when nested in SCSS[/+] on Mar 9, 2024
  4. mdmoreau commented on Apr 6, 2024

    @mdmoreau

    Martin Aeschlimann (@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] */
      }
    }
  5. aeschli commented on Apr 8, 2024

    @aeschli
    Collaborator

    Nested containers are only allowed in LESS and SCSS.

  6. mdmoreau commented on Apr 8, 2024

    @mdmoreau

    Martin Aeschlimann (@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

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

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions