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
Add except: ["inside-block"] to rule-empty-line-before #2887
Comments
@octoxan Thanks for the report and for using the template. I believe the rule is behaving correctly here as The following is an unusual style that I've not seen before: .foo {
text-align: center;
.bar {
font-style: italic;
}
} Most requests are for: .foo {
text-align: center;
.bar {
font-style: italic;
}
} However, I see no harm in adding an |
@jeddy3 |
Meybe it can help you: --- a/lib/rules/rule-empty-line-before/index.js
+++ b/lib/rules/rule-empty-line-before/index.js
@@ -34,6 +34,7 @@ const rule = function(expectation, options, context) {
ignore: ["after-comment", "inside-block"],
except: [
"after-rule",
+ "inside-block",
"after-single-line-comment",
"first-nested",
"inside-block-and-after-rule"
@@ -69,11 +70,10 @@ const rule = function(expectation, options, context) {
return;
}
+ const isNested = rule.parent.type !== "root";
+
// Optionally ignore the expectation if inside a block
- if (
- optionsMatches(options, "ignore", "inside-block") &&
- rule.parent !== root
- ) {
+ if (optionsMatches(options, "ignore", "inside-block") && isNested) {
return;
}
@@ -114,10 +114,11 @@ const rule = function(expectation, options, context) {
// Optionally reverse the expectation for single line comments
if (
+ (optionsMatches(options, "except", "inside-block") && isNested) ||
optionsMatches(options, "except", "after-single-line-comment") &&
- rule.prev() &&
- rule.prev().type === "comment" &&
- isSingleLineString(rule.prev().toString())
+ rule.prev() &&
+ rule.prev().type === "comment" &&
+ isSingleLineString(rule.prev().toString())
) {
expectEmptyLineBefore = !expectEmptyLineBefore;
} also resolves compatibility in HTML files |
Interesting. SGTM. |
@gucong3000 Let's pull that out into a separate issue and PR, and keep this one focused on just adding the new option. Feel free to create an issue about the HTML file incompatibility in the rule. |
|
@octoxan Are you still working on this? |
@jeddy3 I believe this issue is no longer matter. |
@GorwinJororis Thanks for spotting this! |
This is a bug where the rule "rule-empty-line-before" doesn't work properly, telling me something needs a new line when it should not.
"rule-empty-line-before"
e.g.
e.g.
8.1.1
With npm and inside of phpstorm.
Nesting, scss.
No warnings to be flagged. I want a warning on if there's no empty lines before non-nested rules, and if there's any empty lines on nested rules. .bar is nested, and should not throw an error.
.bar throws an error "Expected empty line before rule", but should fall under either first-nested or inside-block-and-after-rule
The text was updated successfully, but these errors were encountered: