Closed Bug 1857522 Opened 8 months ago Closed 8 months ago

Consider reducing the Stylelint-allowed maximum level of CSS nesting from 8 to... 4?

Categories

(Developer Infrastructure :: Lint and Formatting, task)

Tracking

(firefox120 fixed)

RESOLVED FIXED
Tracking Status
firefox120 --- fixed

People

(Reporter: Gijs, Assigned: emilio)

References

(Blocks 1 open bug)

Details

Attachments

(2 files)

+++ This bug was initially created as a clone of Bug #1856660 +++

The nesting level was set at 8. That seems high to me, but newtab/messaging-system uses it. It would be interesting to understand why and what people think is a "reasonable" value. Personally, a selector with 8 descendant or child selectors seems unusable to me, but perhaps I'm in the minority.

Yes when I saw 8 I was surprised. I'd go as far as suggesting that 3 would be enough but I haven't used nesting much yet myself so I don't have a great sense for it. Dão probably has better opinions than me.

Flags: needinfo?(dao+bmo)

Yeah, 8 is too high and only there because of newtab code, which overuses nesting (and the descendant selector). It's not a model I think we want to follow. We should have newtab override the limit for now, and set the global limit to 4, would be my initial guess based on the nesting we've introduced so far. I feel like urlbarView.css and tabs.css have been good test cases, and I think 4 may be the maximum I've reached, possibly only once: https://searchfox.org/mozilla-central/rev/6602bdf9fff5020fbc8e248c963ddddf09a77b1b/browser/themes/shared/tabs.css#330
Perhaps that's an argument for 3, but I think I'd err on the side of leaving some leeway here. Usability depends a lot on how large your rules are as well. If they all fit on a screen like in the above example, 4 seems okay?

Flags: needinfo?(dao+bmo)

That still doesn't trigger on the code in comment 2, so that is a bit
confusing and needs investigation.

Assignee: nobody → emilio
Status: NEW → ASSIGNED

As that allows you to get around the lint with :is() trivially.

Pushed by ealvarez@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/3a9825468499
Reduce max nesting depth to 3. r=Gijs
Pushed by ealvarez@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/38314c6dc43e
Don't ignore pseudo-classes in max-nesting-depth limit. r=Gijs
Blocks: 1878634
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: