Skip to content
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

border none: explanation #69

Closed
paceaux opened this issue Mar 31, 2020 · 3 comments
Closed

border none: explanation #69

paceaux opened this issue Mar 31, 2020 · 3 comments

Comments

@paceaux
Copy link

paceaux commented Mar 31, 2020

Howdy, I'm trying to get to the bottom of why border:none is specifically disallowed:
https://github.com/bjankord/stylelint-config-sass-guidelines/blob/master/src/.stylelintrc.json#L21

I see that this is based on sass guidelines, but the Sass Guidelines never recommend border: 0 over border: none explicitly.

The Sass Guidelines are based on CSS Guidelines, but Harry Roberts never recommends this rule.

The Sass Guidelines are also following SCSS lint, and SCSS Lint has this rule for border:0, but it, too, never explains why.

SCSS-Lint has multiple examples of specifically surfacing an error for border: none but without explanation.

So I'm making the rounds trying to determine why this rule exists and what benefit it serves. Could you provide an explanation?

@sarahdayan
Copy link

I believe this is why.

If you set a border-style to an element with border: none in a ruleset which selector has higher specificity, it overrides the fact that you set it to none. This breaks the open/closed principle .

@paceaux
Copy link
Author

paceaux commented Apr 20, 2020

@sarahdayan I ended up publicly ranting about this issue on twitter where my conclusion similar to yours. It seems to lie within a use-case where, in the case of wanting to return border to an element, more work must be done with border: none than border-style: none or border-width: 0;

I think my chief complaint here is that in all of my investigation, this isn't explained. I think if this rule persists in the guidelines, it should have a proper error message that explains why.

@bjankord
Copy link
Owner

@paceaux This lint rule came from SCSS-Lint. From their docs, "border: 0 and border: none are fundamentally different, as they are both shorthands. The intent of this linter is to enforce consistency, rather than define which is "better.""

That's how I view this lint rule as well, it primarily drives consistency, but it also helps with some more nuanced use-cases around border styling. I don't really have a good answer beyond that but I really like demo and explanation with regards to the open/close principle from @sarahdayan.

I can updated the readme section on this rule to indicate that this rule is primarily about consistency.

@bjankord bjankord closed this as completed Jun 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants