-
-
Notifications
You must be signed in to change notification settings - Fork 929
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: ["after-closing-brace"] to block-closing-brace-empty-line-before #2090
Comments
Thanks for using our issue template and the detailed description @thomasjbradley 👍 p.s. Originally via this Stack Overflow issue. |
I think we can achieve this with the addition of an There is a precedence for This would be the first instance of a user defined So, the following config: "block-closing-brace-empty-line-before": ["never", { "exceptAtRules": ["media"] }] Would enforce this: @media print {
a {
color: red;
}
} Having an user defined option, rather than just the keyword one of "block-closing-brace-empty-line-before": ["never", { "exceptAtRules": ["media", "supports"] }] @media print {
a {
color: red;
}
}
@supports (display:flex) {
a {
display: flex;
}
} Unless there are objections, I'll label this up as "help wanted" and point @thomasjbradley in the direction of how to contribute this option. |
@jeddy3 What if someone wants to use the exception for all at-rules? |
Oops, I hadn't thought about that. @thomasjbradley Is your code style to have an empty line before the closing brace of just That last one makes me think that having the flexibility to specify exactly which at-rules are exceptions is desirable, but I'm 100% sure now. |
For me it would only be nested rulesets. So |
@davidtheclark So it sounds like could have an @my-custom-nesting-at-rule {
a {}
} The |
Why not? If we're just checking that the at-rule contains rules, that would apply just as much to custom at-rules as standard ones, right? |
I realised the same thing on the train. I originally thought we'd have to keep a list of standard nesting at-rules, but now, like you, I see that we can just detect if the at-rule contains rules.
|
I'll label this issue up accordingly. @thomasjbradley Would you like to contribute this option? |
In line with #1663, I'm pretty sure this option should be |
I would like to define an exception for {
"block-closing-brace-newline-after": ["always", { "exceptAtRules": ["else"] }]
} @media (width < 500) {
display: none;
} @else {
display: block;
} Citations: |
@jonathantneal It is possible now using a couple of rules from stylelint-scss (a plugin pack for SCSS-like constructs). Those guys wrote up an example on how to do it.
The request in this issue is for something different i.e. having an empty line before a closing brace if it is preceded by another closing brace. |
Maybe we need even more generic approach, which could be used almost with any Stylelint rule? For instance, we can determinate interface, which will allow to target within ignore and except any recognized by Stylelint CSS entity and whenever needed, to specify which exactly instance of entity should it be. It could look like except:
- property
- at-rule:
- media
- blockless # target blockless at-rules
- same-name # target entities with same name
- single-line # reverse behavior for any entity represented as single line
- ruleset
- whatever_else_Stylelint_recognizes
ignore:
- property
- at-rule:
- 'media'
- ruleset
- whatever_else_Stylelint_recognizes This interface can be applicable to any rule, which evaluates based on whether or not something appears before or after in AST. It will also neglect some strange situations, when some rules have specific ignores and excepts, while other no, or ignores and excepts are different not because they aren't useful, but simply because they weren't foresighted during development. |
It is kinda strange when here #2090 (comment) and here #2090 (comment) we were talking about some nicer, more generic and broad interface, and than issue suddenly closed by slightly PR, which solves some problems, but obviously doesn't work as a solution for author's original issue with enforcing empty line only in at rules, while the PR allows doing so only globally |
Possibly a bug, but most likely a feature request.
I'd like to be able to force an empty line at the end of a media query—we can do it at the top of a media query, but I can't seem to find how to do it at the bottom.
I see the rule:
rule-nested-empty-line-before
which will force a new line at the top of the media query.And I see the rule:
block-closing-brace-empty-line-before
which will force a new line at the end of the block, but that would also force a new line aftercolor: red
.This CSS should pass:
This CSS should fail:
Currently using
7.5.0
.Node API.
Nope.
I'd like to get a warning message if there isn’t an empty line at the end of a media query.
Both empty lines and non empty lines pass Stylelint tests.
I feel like an older version used to enforce this, but looking through past commits of my Stylelint config I don't see anything that jumps out at me as being “the rule” that enforced that requirement.
The text was updated successfully, but these errors were encountered: