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

Property: name #3

Merged
merged 10 commits into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions research/name.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Name

Analysis of the `name` property

## Analysis

- The `name` and `version` together form an identifier that is assumed to be completely unique.
Ethan-Arrowood marked this conversation as resolved.
Show resolved Hide resolved
- The `name` property is optional if the package will not be published.
Ethan-Arrowood marked this conversation as resolved.
Show resolved Hide resolved
- It must be less than or equal to 214 characters (including scope)
Ethan-Arrowood marked this conversation as resolved.
Show resolved Hide resolved
- The names of scoped packages can begin with a dot or an underscore. This is not permitted without a scope.
- It cannot contain uppercase letters
- Historically, uppercase characters were allowed, but npm enforces all new packages are lowercase only
- It must contain only URL-safe characters
- > [TODO: What are "URL-safe characters"?](https://github.com/openjs-foundation/package-json-research/issues/4)
> - Is this based on the WHATWG URL specification or something else?
> - Relevant stackoverflow: https://stackoverflow.com/questions/695438/what-are-the-safe-characters-for-making-urls
> - Is the validation for this in the npm cli open-source?
Ethan-Arrowood marked this conversation as resolved.
Show resolved Hide resolved

### Scope

- While all packages have a name, some also have a scope.
- A scope follows the same rules as a name (URL-safe characters, no leading dots or underscores).
- When used in package names, scopes are preceded by an `@` and followed by a `/`.
- Example: `@scope/pkg`

## Sources
- npm's official documentation for the `name` field: https://docs.npmjs.com/cli/configuring-npm/package-json#name
- npm's documentation for Scope: https://docs.npmjs.com/cli/using-npm/scope

[github-packages]: <https://docs.github.com/en/packages>
4 changes: 3 additions & 1 deletion research/package-json.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@
- [`"dependencies"`][dependencies]
- [`"devDependencies"`][dependencies]
- [`"peerDependencies"`][dependencies]
- [`"name"`][name]

[dependencies]: <./dependencies.md> "Dependencies"
[dependencies]: <./dependencies.md> "Dependencies"
[name]: <./name.md> "Name Property"