Skip to content

Conversation

stevespringett
Copy link
Contributor

Closes #655

@bakkot
Copy link
Member

bakkot commented Sep 15, 2025

Thanks for the contribution. This seems like something which should be opt-in, and also should generate a warning since you'll often want manual remediation. I've pushed up commits doing both (+ a test). If this still works for you I'll land.

@stevespringett
Copy link
Contributor Author

@bakkot opt-in sounds reasonable as does displaying a warning.

@michaelficarra
Copy link
Member

So we're just flattening the numbering and not the actual structure of the emu-clauses? That seems bad for doing things like targeting exactly-N-times nested emu-clauses in CSS.

@bakkot
Copy link
Member

bakkot commented Sep 16, 2025

I don't see why it would be? From what I understand the ISO standards only specify a limit on the numbers themselves, not on the presentation of clauses. Changing how we number clauses doesn't seem to me like it ought to interact with CSS or anything else.

@michaelficarra
Copy link
Member

I really don't like the auto-collapsing in this PR. I would strongly advise against it. The computer doesn't know, when collapsing a 6-time-nested clause, whether it's more appropriate to collapse the leaf into its parent or any one of the other 5 parent nodes along the way into their parent instead. That's a decision that the author should make. If it were up to me, I would make this a warning only, which could be caused to fail the build using --strict and corrected by a human.

@michaelficarra
Copy link
Member

I don't see why it would be? From what I understand the ISO standards only specify a limit on the numbers themselves, not on the presentation of clauses.

The clause numbering should always coincide with the nesting of emu-clauses.

@bakkot
Copy link
Member

bakkot commented Sep 16, 2025

This PR does not do any auto-collapsing. (I originally thought it did but I was misreading.) It only touches the numbering.

The clause numbering should always coincide with the nesting of emu-clauses.

That's a valid preference but unless you intend to use this feature I would prefer to defer to the preferences of the people who are actually going to use this. The warning is still emitted and enforceable with --strict, it just also makes the numbering compliant with ISO for people who are not enforcing the warning.

@michaelficarra
Copy link
Member

I prefer not to include features that I think are both broken in implementation and footguns, but as you point out, I have no plans to use the feature myself, so I'm not going to get in your way.

@bakkot bakkot merged commit f7d2f4c into tc39:main Sep 16, 2025
2 checks passed
@bakkot bakkot mentioned this pull request Sep 16, 2025
@bakkot
Copy link
Member

bakkot commented Sep 16, 2025

Version 21.4.0 is out including the new --max-clause-depth flag.

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

Successfully merging this pull request may close these issues.

Limit clause numbers to five levels
3 participants