-
Notifications
You must be signed in to change notification settings - Fork 35
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
Does not work with Sass interpolation #132
Comments
I've come across this issue as well. For now I'm simply ignoring (the few and far between) instances of selectors that contain Sass string interpolation. Not ideal, nor sustainable, but it's tiding things over until a solution is reached (hopefully in this issue). Rather than ignoring on a selector-by-selector basis, I put the bemLinter({
ignoreSelectors: /\#\{\$[a-z]+(?:-[a-z]+)*\}/,
}); The intended logic of this regex (see example) is to match any string that contains: Back to the issue at hand: 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?) Or, is it instead the responsibility of the user to configure the regex to take into account the presence of Sass string interpolation within a selector? /cc @simonsmith |
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 We support nesting but mainly because that isn't unique to Sass and also exists as an official proposal |
If anyone comes after this, I'm using the following for now: const namePattern = /([a-z0-9]+|#\{\$.*\})((-[a-z0-9]+|#\{\$.*\})+)?/;
componentSelectors: (componentName) => new RegExp(`^\\.(${componentName})(((--|__)(${namePattern.source}))+)?$`) It's been working so far. If anyone try this in another project and find any error, warn me please. |
@guilhermetod if i use json format, how can i do it? |
This plugin does not seem to support Sass interpolation.
input.scss:
postcss-bem-linter result:
output.css
postcss-bem-linter result:
No errors
The text was updated successfully, but these errors were encountered: