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 selector-pseudo-class-focus rule #3355
Conversation
This rule will be very good for a11y. And could show that Stylelint is not just a tool to check whitespaces but could also promote best practices. |
@YozhikM Thanks for starting this! The code is looking good. As I suggested in #2650 (comment), I think this and #3357 should first live in an Once the pack is published, you can send an PR to update the list of plugins. |
@jeddy3 what is your reason for moving it to a plugin? Here are my thoughts:
|
I would agree with @ai on this point. I would include this rule in the core, but won't include another one. Because in the current state it's for iPhone/iPad users. And very few people know about this feature. |
@hudochenkov webkit also support this (i.e. chrome also and chromium based) |
I'm going to have to dig into my memory and recall some original design decisions, so bear with me... When we first starting working on stylelint we looked to CSSLint for inspiration. We noticed that quite a few of the rules were now redundant as they were based on "best practises" that were, well, no longer best practice. As such, we made an early design decision to avoid adding such rules to stylelint, instead, we'd favour rules that could be configured to enforce whatever a team needs (or deems the best practice at the time) by applying limits to targeted constructs within the language. That's why we have rules like This design decision is captured in the VISION doc. A little later we realised that not everything a team might need could be achieved using just these configurable rules, so we added a plugin system. This allowed users to create rules which could do more than just apply limits to targeted constructs, whilst keeping the core stable and relevant. In this particular instance, it looks like there are two ways to maintain accessibility:
I don't believe this rule can account for the latter, which is why it might not meet the "Has a clear and unambiguous finished state" rule of inclusion. Anyway, I think this point is moot as this is the kind of stuff that can get experimented on (and quickly iterated on) within a plugin.
It sounds like we need to do a better job of promoting the possible errors and limiting rules. I'm writing an article at the moment that highlights the value of the limiting rules. When I get around to finishing it it will hopefully help us promote this feature of stylelint.
There are some excellent plugins that I see in regular use.
We went through the pain of doing it that way around circa 7.8.0. I thought the lesson we learnt was that it's less painful to move plugins to core than to move built-in rules out. I'm not seeing any arguments in the comments above that invalidate the original design decisions. Unless I'm missing something here? I agree there is a user education issue, though. We need to do a better job at promoting and signposting (within the docs and outside of them) the possible errors and limiting rules, as well as the plugin system (and this An It feels like this is approach will balance the user's need with the still valid original design decisions that have kept the built-in rules relevant. Thoughts? |
@jeddy3 Excellent. Work in progress. Who and where can I ask questions if they appear? |
@YozhikM thank you for starting working on this plugin! I think you can create an issue in this repository and we'll help you. |
Good stuff! Both stylelint-scss and stylelint-order are plugin packs. You can use them for inspiration if you like. |
And only 1/5 of Stylelint users use these plugins http://www.npmtrends.com/stylelint-vs-stylelint-order-vs-stylelint-scss |
I still think it will be great as official plugin |
Not everyone need these plugins :) |
I am making slides about PostCSS and want to promote Stylelint. Here is an overview of our “Possible errors” rules:
Only 2 and 3 issues are really popular. Error 1 happens sometimes. Unfortunately, it doesn’t compete with ESLint “Possible Errors” rules. This is why I still believe that a11y rules in the core will be extremely good for promotion. We need more rules to prevent errors. |
It is close, ESLint has 34 , stylelint has 24 |
Also, JavaScript is a programming language, while CSS isn't. More errors could be identified by code analysis in JavaScript, then in CSS. |
I am glad to see more possible errors rules and i have some ideas for new rules, but i think we should concentrate now on bug fixes and build-in support |
@evilebottnawi I would like to see more error targeted rules, rather stylistic, as well (we might cover all stylistic rules already :)). Please, create new issues for your rules ideas. New contributors are more willingly work on new stuff rather fixing bugs, in my opinion. |
@hudochenkov In near future 👍 |
@ntwb when we compare ESLint and Stylelint rules by the number we are making mistakes. Stylelint has 10 rules just to check syntax errors (unknown properties, selectors, etc). If you group rules by error type we will have only 4 errors, which STylelint prevents @hudochenkov we have JS in Stylelint to be smart. Simpler CSS syntax should even help us in finding real errors. |
That's fantastic! I'd suggest highlighting the limiting rules rather than focusing on the ones that check for possible errors. As @hudochenkov pointed out, CSS and JavaScript are two very different languages. They have different problems that need addressing with linters. For me personally, I find that inconsistency is the biggest hurdle to maintaining a stylesheet within a team. There are so many ways for a developer to achieve the same outcome in CSS. As such, a large proportion of stylelint rules were specifically built to help teams combat these inconsistencies. For example, a team might:
These are just three examples. Hopefully, it's clear how stylelint can help a team enforce the consistent use of any number of other methodologies. There are over 50 limiting rules in stylelint, including fine-grained ones like
I think we can close these PRs and issues now that #3364 has been merged. We can continue the discussion about how best to promote the plugin system (and plugins themselves) in #3362. @YozhikM Thanks again for your work on these rules and porting them to the |
Issue #3354
No.