usePackageJsonCpu (JSON)
Language JSON (and super languages)
Summary
Section titled “Summary”- Rule available since:
v2.6.6 - Diagnostic Category:
lint/nursery/usePackageJsonCpu - This rule doesn’t have a fix.
- The default severity of this rule is information.
- Sources:
- Same as
package-json/require-cpu
- Same as
How to configure
Section titled “How to configure”{ "linter": { "rules": { "nursery": { "usePackageJsonCpu": "error" } } }}Description
Section titled “Description”Require the cpu field in package.json.
The cpu field lists the processor types that a package can run on, such as x64 or
arm64. Package managers read it to avoid installing the package on a processor that the
package doesn’t support. Without the field, the package is installed on every processor,
and a package that can’t run there fails later, when it is used.
This rule reports a package.json file whose outermost object has no cpu field. A cpu
field inside another object doesn’t count. The rule doesn’t check the value of the field.
Examples
Section titled “Examples”Invalid
Section titled “Invalid”{ "name": "my-package", "version": "1.0.0"}/package.json:1:1 lint/nursery/usePackageJsonCpu ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ℹ This package.json file is missing the cpu field.
> 1 │ {
│ ^
2 │ "name": "my-package",
3 │ "version": "1.0.0"
ℹ Package managers read this field to avoid installing the package on a processor that the package doesn't support.
ℹ Add a cpu field that lists the processor types the package supports, for example ["x64", "arm64"].
ℹ This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.
{ "name": "my-package", "version": "1.0.0", "cpu": ["x64", "arm64"]}Related links
Section titled “Related links”Copyright (c) 2023-present Biome Developers and Contributors.