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

doc: spell out condition restrictions #55187

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jkrems
Copy link
Contributor

@jkrems jkrems commented Sep 30, 2024

I never really thought about what kinds of conditions are allowed and which aren't - and it looks like the answer is mostly "anything goes". This documents the status-quo from a practical perspective from what I can gather.

Some of these restrictions (e.g. "no comma") aren't actively enforced by nodejs but maybe should be in the future.

@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/loaders

@nodejs-github-bot nodejs-github-bot added the doc Issues and PRs related to the documentations. label Sep 30, 2024
jkrems added a commit to jkrems/node that referenced this pull request Sep 30, 2024
Copy link
Contributor

@guybedford guybedford left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The numbered points seem great to me, but ideally we shouldn't encourage people to use all characters I think? So let's be a little bit more cautious in the wording perhaps.

Comment on lines 692 to 693
Conditions can be almost any string, including multi-byte characters and
whitespace. There's only a few restrictions:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer that we do not say this, and instead say something less specific, eg that special characters are permitted in condition names. We should probably ban spaces IMO.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could start this with a stronger recommendation (e.g. keep it to /^[a-z0-9:=-]+$/) and only afterwards go into the technical side of what's enforced?

I'm +1 on banning whitespace and also banning quotes and non-ASCII characters. I don't see a clear use case for those but could see many confusing bugs. Conditions usually fail silently, so debugging a "looked like character A but was actually character B" problem seems super annoying.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a more opinionated opening paragraph before delving into the technical restrictions.

jkrems added a commit to jkrems/node that referenced this pull request Sep 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc Issues and PRs related to the documentations.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants