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

Omit prelude requirement for SCSS @else #46

Closed
mrtnvh opened this issue Dec 29, 2021 · 1 comment
Closed

Omit prelude requirement for SCSS @else #46

mrtnvh opened this issue Dec 29, 2021 · 1 comment

Comments

@mrtnvh
Copy link

mrtnvh commented Dec 29, 2021

Problem

Snippet: https://github.com/csstree/stylelint-validator/blob/v2.0.0/lib/syntax-extension/sass/index.js

is causing the error

At-rule '@else' should contain a prelude (csstree/validator)

with code

  @if ($value == 0) {
    @return 0;
  } @else if ($value == 1) {
    @return 10;
  } @else {
    @return $delta;
  }
}

Analysis

As the else scss at-rule, doesn`t have a prelude, it looked like the simple solution would be:

// /lib/syntax-extension/sass/index.js#L56
syntaxConfig.atrules.else = {
    prelude: null
};
// /test/preprocessors.js#L80

// Add braces to ensure xxx is or is not seen as prelude
tr.ok('@else {}');
// Add missing else if
tr.ok('@else if {}');

But then the tr.ok('@else if {}'); assertion fails with At-rule '@else' should not contain a prelude (csstree/validator).

If we analyse the AST of the first code snippet (available here), the else if at-rule takes everything starting from if as prelude.

What should be the correct configuration for the else and else-if at-rule?

I've already forked the repo and tinkered with, without any success. Can you be of further assistance?

@mrtnvh mrtnvh changed the title Omit prelude requirement from @else Omit prelude requirement for SCSS @else Dec 29, 2021
@lahmatiy
Copy link
Member

Fixed in 2.1.0

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

2 participants