question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Does not work with Sass interpolation

See original GitHub issue

This plugin does not seem to support Sass interpolation.

input.scss:

/** @define ComponentName */
.ComponentName {
  $ComponentName: &;

  &--modifierName {
    color: blue;

    #{$ComponentName} {  // <- Sass interpolation
      &-decendantName {
        color: red;
      }
    }
  }
}

postcss-bem-linter result:

input.scss
 9:7  ✖  Invalid component selector                   plugin/selector-bem-pattern
         ".ComponentName--modifierName
         #{$ComponentName}-decendantName"

output.css

/** @define ComponentName */
.ComponentName--modifierName {
  color: blue;
}
.ComponentName--modifierName .ComponentName-decendantName {
  color: red;
}

postcss-bem-linter result:

No errors

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:3
  • Comments:5

github_iconTop GitHub Comments

1reaction
simonsmithcommented, Apr 16, 2018

Is it this plugin’s responsibility to process Sass string interpolation and ensure that the resulting selector is in the correct format? (And is that even possible?)

A good question and I think it would be outside of the scope of this plugin to compile the Sass and understand how to apply the linting rules to the source file.

The solution I’d be tempted to go with would be to apply the postcss-bem-linter after the Sass transformation has happened. You will get less accurate line numbers in the error console (and no editor support on the source files) but that feels like an acceptable tradeoff for these complex Sass examples.

We support nesting but mainly because that isn’t unique to Sass and also exists as an official proposal

0reactions
almogk012commented, Nov 12, 2020

@guilhermetod if i use json format, how can i do it? or you can show your js file?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Interpolation - Sass
It's almost always a bad idea to use interpolation with numbers. Interpolation returns unquoted strings that can't be used for any further math,...
Read more >
Sass interpolation doesn't work - Stack Overflow
1 Answer 1 ... The error message tells you that the background property needs to be wrapped by one of the named options....
Read more >
All You Ever Need to Know About Sass Interpolation
Interpolation, often referred to as variable interpolation or variable substitution is not something unique to Sass. Actually, you can find ...
Read more >
SASS | Interpolation - GeeksforGeeks
Interpolation allows us to interpolate sass expressions into a simple SASS or CSS code. Means, you can define ( some part or the...
Read more >
SASS Interpolation - Using #{} - Studytonight
SASS Interpolation is a technique to include the result of any SASS Script expression into the stylesheet wherever required using #{} . This...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found