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

Inconsistent type mixin and atrule for SCSS parser #312

Open
lmeysel opened this issue Jul 14, 2021 · 1 comment
Open

Inconsistent type mixin and atrule for SCSS parser #312

lmeysel opened this issue Jul 14, 2021 · 1 comment

Comments

@lmeysel
Copy link

lmeysel commented Jul 14, 2021

Hi, i came accross an inconsitency while parsing SCSS.

To reproduce:

import gonzales from 'gonzales-pe';
const tree = gonzales.parse('@mixin foo() {}\n@function bar() {}', { syntax: 'scss' });

This example produces the following output (I removed the unnecessary information). The mixin produces a node with type mixin whereas the function produces an atrule containing a function.

Imho the mixin should also produce an atrule containing a mixin.

{
  "type": "stylesheet",
  "content": [
    {
      "type": "mixin", // <--- top-level mixin
      "content": [
        {
          "type": "atkeyword",
          "content": [
            {
              "type": "ident",
              "content": "mixin",
            }
          ],
        },
        {
          "type": "ident",
          "content": "foo",
        },
       // ...
      ]
    },
    {
      "type": "atrule",  // <--- top-level atrule
      "content": [
        {
          "type": "atkeyword",
          "content": [
            {
              "type": "ident",
              "content": "function",
            }
          ],
        },
        {
          "type": "function", // <--- ... containing a function
          "content": [
            {
              "type": "ident",
              "content": "bar",
            },
          ],
        },
        // ...
      ],
    }
  ],
}
@lmeysel
Copy link
Author

lmeysel commented Aug 26, 2021

Not sure whether this should be a new issue, but another inconsitency occurs when parsing @each and @for loops.
While @for is wrapped in a loop/atkeyword/ident=for, whereas @each is atrule/atkeyword/ident=each

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