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

New rules: no-universal-selector, no-attribute-selector & no-combinators #694

Closed
bgriffith opened this issue May 10, 2016 · 3 comments
Closed
Labels

Comments

@bgriffith
Copy link
Member

bgriffith commented May 10, 2016

Got a few basic new rules I'd like to add to Sass-lint and I think all would probably be disabled by default a la no-extends. Be great to get your thoughts @sasstools/sass-lint-contributors esp. on ...-selector vs ...-selectors

  • no-universal-selector
  • no-attribute-selector
  • no-combinators

If it's all good, I'll push up the PR 🎉

No Universal Selector

Rule no-universal-selector will enforce that the * (universal) selector is not allowed to be used.

Examples

When enabled, the following are disallowed:

* {
  content: 'foo';
}

* [lang^=en] {
  content: 'bar';
}

*.warning {
  content: 'baz';
}

*#maincontent {
  content: 'qux';
}

*:before,
*:after {
  content: 'norf';
}

No Attribute Selector

Rule no-attribute-selector will enforce that the attribute selector is not allowed to be used.

Examples

When enabled, the following are disallowed:

[autoplay] {
  content: 'foo';
}

[lang=en] {
  content: 'bar';
}

[lang~=en-us] {
  content: 'baz';
}

[lang|=us] {
  content: 'qux';
}

[href^="#"] {
  content: 'norf';
}

[href$=".com"] {
  content: 'foo';
}

[href*=news] {
  content: 'bar';
}

No Combinators

Rule no-combinators will enforce that the combinators are not allowed to be used.

Examples

When enabled, the following are disallowed:

.foo > .bar {
  content: 'foo';
}

.foo ~ .bar {
  content: 'bar';
}

.foo + .bar {
  content: 'baz';
}

.foo .bar {
  content: 'qux';
}
@bgriffith bgriffith added the rule label May 10, 2016
@DanPurdy
Copy link
Member

DanPurdy commented May 10, 2016

I would make them plural in name to follow what we already do. i.e. no-meregeable-selectors, no-color-keywords but apart from that I think they're ok, i'll have a closer look though. I would have them disabled in our config by default though maybe?

With no-combinators have you checked with interpolated values?

@bgriffith
Copy link
Member Author

Ok plural it is! I also agree with disabling them by default (like no-extends).

I think I've got it covered but will add some more tests just to be safe.

@DanPurdy
Copy link
Member

These will all be available with sass-lint 1.8.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants