-
Notifications
You must be signed in to change notification settings - Fork 46
Open
Description
This proposal introduces data guidelines following the mdn/browser-compat-data approach (https://github.com/mdn/browser-compat-data/tree/main/docs/data-guidelines) to standardize how module replacement data is recorded.
Files
docs/data-guidelines/overview (or index.md).md
# Data Guidelines
This folder contains guidelines to help you record module replacement data in a consistent and understandable way. It covers the project's requirements for how module replacements should be represented, including requirements that are not coded into the linter or schema.
This file contains general guidelines that apply to all replacement types. For guidelines that apply to specific types of data, check out their respective files within this folder:
- [Micro-utility replacements](./micro-utility.md)
- [Native replacements](./native.md)
- [Preferred replacements](./preferred.md)
## Choosing a replacement type
Use replacement types to reflect the **nature of the migration path** rather than the complexity of the original module.
The replacement type system provides a clear hierarchy for categorizing module replacements based on their migration characteristics. Use the most specific applicable type for recording replacement data.
### Type precedence
When a module could potentially fit multiple types, use this precedence order:
1. **`native` (Highest Priority):** If a module's functionality can be replaced by a **single, named, built-in API**, it **must** be categorized as `native`. This applies even if the replacement could be expressed as a simple one-liner.
2. **`simple` (micro-utility):** If a module cannot be categorized as `native` but its functionality can be replaced by a **short, self-contained JavaScript expression**, it should be categorized as `simple`.
3. **`documented` (preferred) (Lowest Priority):** If a module fits neither category above because its replacement requires **refactoring, API changes, or complex migration logic**, it should be categorized as `documented`.
### Runtime support requirements
Runtime support information is required for `native` types only:
- **`simple` & `documented`**: No runtime support needed (assumed universal)
- **`native`**: Must specify `nodeVersion` for Node.js support
## Choosing runtime versions
Use version numbers to reflect which **release line** (major or minor but not patch-level releases) first supported a feature, rather than absolute version numbers.
This project does not record absolute version numbers, such as Node.js 16.14.2; instead it records significant releases (such as Node.js 16.14.0). Use the earliest applicable release line for recording support for a given feature.
### Node.js versioning
For Node.js, use the exact semantic version format (`x.y.z`) of the earliest stable release that supports the feature:
Prefer Long-Term Support (LTS) version boundaries when the feature was introduced or stabilized in one.
## Module naming
Use the exact npm package name as it appears in the registry, including scope prefixes where applicable (e.g.):
- `"lodash"`
- `"@types/node"`
- `"@babel/core"`
## Behavioral equivalence standards
### For `simple` and `native` types
The replacement must cover the **primary, most common use case** of the original module. Perfect behavioral equivalence is not required if edge cases are obscure or rarely used.
If significant edge cases exist that are commonly encountered, they should be noted in the replacement text or the module should be recategorized as `documented`.
### For `documented` types
The replacement should provide equivalent or superior functionality, but may require API changes or refactoring. Breaking changes are acceptable and expected for this type.
## Removal of irrelevant entries
Entries can be removed from the project if they are considered irrelevant. An entry can be considered irrelevant if any of these conditions are met:
- The native replacement has been available in all active Node.js LTS versions for 2+ years
- The original module is abandoned, insecure, or has negligible ecosystem usage
- The replacement strategy is no longer considered best practice by the community
</details>
Metadata
Metadata
Assignees
Labels
No labels