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 ignore: [single-declaration] to declaration-block-trailing-semicolon #5165
Conversation
b286c0e
to
225d39e
Compare
Thanks for the pull request.
I can't think of one. If it's exclusive, then we've merged it into primary option. For example, Primary options and @keyframes bugfix { from { padding: 0 } to { padding: 0; } } The
I think we support it for consistency, when catering to your use case. And, just so I'm clear, you always want trailing semis except (i.e. never) when the declaration block as one declaration regardless of whether the block spans multiple lines? Like so: a { background: pink; color: red; }
a {
background: pink;
color: red;
}
a { color: red }
a {
color: red
} Or do your single declaration blocks always appear within single-line blocks?, e.g.: a { color: red } |
Good point. Ill fix that.
If you check the examples in the README you will see that it works for multi-line blocks as well.
What about |
225d39e
to
cb9741f
Compare
cb9741f
to
06f3694
Compare
Thanks for the answers and for updating the pull request. I'd like to get a clear picture of your use case so that I'm sure we're going down the right path. Would disallowing trailing semicolons inside single-line blocks cater to your use case, e.g: a { color: red }
a { background: pink; color: red }
a {
color: red;
} This would also apply to the example you gave: @keyframes bugfix { from { padding: 0 } to { padding: 0 } } If so, then an |
My personal use-case, would be single-line-block / ignore / for always only. That's not exactly what I have PRd though. I added the consistent version which always require not having a trailing semicolon as
Like I said I didn't bother with single/multi line blocks for my second PR. It might be easier than I think; Ill have to check.
That would require
"
Ignore behaviour is desirable because sometimes you do know that this block may be expanded. |
Thanks, I think I understand now. You don't add trailing semicolons when you're sure the block won't expand. For example, in the case of: @-webkit-keyframes bugfix { from { padding: 0 } to { padding: 0 } } In that case, I think an If there are particular patterns for when a block won't ever be expanded, you can write a plugin to enforce the correct use of the trailing semicolon inside single-line blocks. |
I am alright with this but how do I convey that it's exclusive to
There's another problem: it doesn't convey that it only matches if there's just one declaration. |
It won't be exclusive to
Yes, it is also valid.
It will ignore single-line blocks regardless of how many declarations there are. This will work for your use case, right? The |
Actually, it's not. In my experience most of these once-set never-touch block declarations have a single declaration. Please check the README and tests and tell me what's wrong with it. I think what Iv come up with is a good compromise—even though it doesn't cater for single or multi line blocks. |
I think your original
To keep the codebase sustainable, we tend to avoid adding code for idiosyncratic patterns. Instead, we add |
3ff9292
to
bead6f3
Compare
@jeddy3 done. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Mouvedia Thanks for reverting to the ignore
option. The code looks good.
I've requested some minor changes to the docs and tests to align them with our conventions and to be consistent with the rule's other examples and tests. The conventions help:
- us maintain the test code
- users when looking through lots of rules
lib/rules/declaration-block-trailing-semicolon/__tests__/index.js
Outdated
Show resolved
Hide resolved
lib/rules/declaration-block-trailing-semicolon/__tests__/index.js
Outdated
Show resolved
Hide resolved
lib/rules/declaration-block-trailing-semicolon/__tests__/index.js
Outdated
Show resolved
Hide resolved
lib/rules/declaration-block-trailing-semicolon/__tests__/index.js
Outdated
Show resolved
Hide resolved
lib/rules/declaration-block-trailing-semicolon/__tests__/index.js
Outdated
Show resolved
Hide resolved
lib/rules/declaration-block-trailing-semicolon/__tests__/index.js
Outdated
Show resolved
Hide resolved
a5b6010
to
5af0f16
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! LGTM.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've left minor comments about the document, but this PR looks good to me. 👍
Closes #5159
It cannot be named
"except"
because it would requirefoo { property: value; }
to be valid for"never"
which is useless/stupid. Or do you imagine a use case for it that would warrant it?Should it be supported just for consistency?
Can an option be exclusive to
"always"
? If so do you have an example?