-
Notifications
You must be signed in to change notification settings - Fork 528
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 allow-single-line-rule-sets option to one-declaration-per-line rule #287
Comments
Related: ticket #288 contains talk of potentially renaming |
The way the SCSS Lint rule works, it by default makes an exemption for single line rulesets, and has an option to also warn on them. I personally take the stance that single line rulesets are a code smell, doubly so when you specifically are disallowing multiple declarations per line. I would prefer this usecase be handled by a user wrapping conditional ignores around these lines once #70 lands. |
@Snugug I think using conditional ignores is fine if something is an exception to the "house style." However, when the house style explicitly allows grouping similar single line rulesets, a configuration option makes more sense. I'm perfectly happy with forbidding them by default, but I do think it needs to be configurable to adapt to existing codebases using approaches like Idiomatic CSS. |
I'm torn! I personally agree with @Snugug that they are a code smell, we have steps at compilation to minify code, original source should be as readable as possible BUT I don't think we as a linter should necessarily be dictating a style (to a point) we should be providing the tools for people to define their own by setting boundaries around best practices. I think we stick with forbidding single line by default but provide the TLDR:
|
Happy to have this forbidden by default if it does make its way in, or if not, to use the conditional ignore comments. The single-line rulesets are very much an exception to our house rules in my codebases so they're an ideal use-case for the conditional ignores for my code styling. The max properties thing was me doing a stream-of-consciousness around potential ways to codify my process of when i deem single-line rulesets to be acceptable (i.e. only when they've got one declaration inside them). Having to explicitly opt blocks into allowing single-line rulesets would also force people to be sure the single-line thing is definitely what they want so that would solve my issue equally well. |
@Snugug and @bgriffith I'm going to take your lead on this, I can't decide either way. #70 would be ideal and also if you are enabling a rule to disallow single line declarations then it does seem odd to have a way to disable this in certain cases but on the other hand are we being too dictatorial if we don't.. |
My vote is to get #70 in. I'm okay being a bit opinionated in our tool if it means our users are more explicit about exceptions in their style guides.
|
Scss-lint's Single Line Per Property (which is functionally identical to our
one-declaration-per-line
) rule has an option to allow single line rulesets such as:I think it would be a useful addition to sass-lint to add this option.
As an extension to this existing functionality I think it could be useful to add an additional configuration option
max-properties-for-single-line-ruleset
to allow users to limit the amount of properties within a single-line ruleset, defaulting to Infinity. For instance ifmax-properties-for-single-line-ruleset
was set to 1 then p { margin: 0; padding: 0; } would be invalid, but p { margin: 0; } would be acceptable. This would allow people to limit these single-line rulesets to only be used in cases where the number of properties won't affect readability.This ticket was split from #283
The text was updated successfully, but these errors were encountered: