Skip to content

usePackageJsonValidCpu (JSON)

Language JSON (and super languages)
biome.json
{
"linter": {
"rules": {
"nursery": {
"usePackageJsonValidCpu": "error"
}
}
}
}

Require the cpu field in package.json to be a valid list of processor types.

The cpu field lists the processor types that a package can run on, such as x64 or arm64. Package managers compare the field with the processor type of the machine to decide whether the package can be installed there. A value that isn’t a processor type never matches, so the package may be installed on, or refused by, the wrong machines.

This rule checks the cpu field of the outermost object in a package.json file. It reports the field when its value isn’t an array. It also reports each entry of the array that isn’t one of the following processor types, written as a string:

  • arm
  • arm64
  • ia32
  • loong64
  • mips
  • mipsel
  • ppc64
  • riscv64
  • s390
  • s390x
  • x64

An entry can start with ! to exclude a processor type. For example, "!arm" means that the package can’t run on arm processors. The rule accepts these entries.

The rule doesn’t report a package.json file that has no cpu field.

The value of the cpu field must be an array:

package.json
{
"cpu": "x64"
}
/package.json:2:12 lint/nursery/usePackageJsonValidCpu ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

⚠ The value of the cpu field isn't an array.

1 │ {
> 2 │ "cpu": "x64"
│ ^^^^^
3 │ }
4 │

ℹ Package managers expect a list of the processor types that the package supports. They compare the list with the processor type of the machine to decide whether the package can be installed there.

ℹ List the supported processor types in an array, 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.

Every entry must be a string:

package.json
{
"cpu": ["x64", 64]
}
/package.json:2:20 lint/nursery/usePackageJsonValidCpu ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

⚠ This entry of the cpu field isn't a string.

1 │ {
> 2 │ "cpu": ["x64", 64]
│ ^^
3 │ }
4 │

ℹ Package managers compare each entry with the processor type of the machine to decide whether the package can be installed there. An entry that isn't a processor type never matches, so the package may be installed on, or refused by, the wrong machines.

ℹ 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.

ℹ Replace the entry with one of the following processor types, in quotes. To exclude a processor type instead, add ! before its name.

- arm
- arm64
- ia32
- loong64
- mips
- mipsel
- ppc64
- riscv64
- s390
- s390x
- x64

An entry can’t be empty or contain only spaces:

package.json
{
"cpu": ["x64", ""]
}
/package.json:2:20 lint/nursery/usePackageJsonValidCpu ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

⚠ This entry of the cpu field is empty or contains only spaces.

1 │ {
> 2 │ "cpu": ["x64", ""]
│ ^^
3 │ }
4 │

ℹ Package managers compare each entry with the processor type of the machine to decide whether the package can be installed there. An entry that isn't a processor type never matches, so the package may be installed on, or refused by, the wrong machines.

ℹ 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.

ℹ Replace the entry with one of the following processor types, in quotes. To exclude a processor type instead, add ! before its name.

- arm
- arm64
- ia32
- loong64
- mips
- mipsel
- ppc64
- riscv64
- s390
- s390x
- x64

Every entry must be one of the processor types listed above:

package.json
{
"cpu": ["x86"]
}
/package.json:2:13 lint/nursery/usePackageJsonValidCpu ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

⚠ This entry of the cpu field isn't a known processor type.

1 │ {
> 2 │ "cpu": ["x86"]
│ ^^^^^
3 │ }
4 │

ℹ Package managers compare each entry with the processor type of the machine to decide whether the package can be installed there. An entry that isn't a processor type never matches, so the package may be installed on, or refused by, the wrong machines.

ℹ 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.

ℹ Replace the entry with one of the following processor types, in quotes. To exclude a processor type instead, add ! before its name.

- arm
- arm64
- ia32
- loong64
- mips
- mipsel
- ppc64
- riscv64
- s390
- s390x
- x64

package.json
{
"cpu": ["x64", "arm64"]
}