smapiot / piral

🚀 Framework for next generation web apps using micro frontends. ⭐️ Star to support our work!
https://piral.io
MIT License
1.71k stars 127 forks source link

Add Lint Rule for CSS Conflict Detection #611

Closed FlorianRappl closed 1 year ago

FlorianRappl commented 1 year ago

New Feature Proposal

For more information, see the CONTRIBUTING guide.

Description

We should have a lint rule in the Piral CLI that can help pilet developers detect problems with their stylesheets. Quite often problems are not known and selectors are too generic to be used freely. When a selector does not only hit elements from the own micro frontend, but also from another micro frontend then we have a problem. In many cases such problems are not seen directly.

A lint rule may help.

Background

Originally, we planned to have this only in our commercial feed service (and we will have this one in there, too), but having the conflict potential also shown / indicated via the linter might be even more helpful in certain scenarios. Surely, only the feed service could detect that two selectors (independent of their complexity) are used in two different micro frontends, too.

Discussion

Right now we want to flag generic (i.e., simple - what is that?) CSS classes, element selectors, and universal selectors. Depending on how generic these are (and how they are used) they'll get a penalty point. A stylesheet with sufficient penalty points is red, otherwise it might be yellow or green (but these levels could be self-determined).