usePackageJsonValidCpu (JSON)
Summary
Section titled “Summary”- Rule available since:
v2.6.3 - Diagnostic Category:
lint/nursery/usePackageJsonValidCpu - This rule doesn’t have a fix.
- The default severity of this rule is warning.
- Sources:
- Same as
package-json/valid-cpu
- Same as
How to configure
Section titled “How to configure”{ "linter": { "rules": { "nursery": { "usePackageJsonValidCpu": "error" } } }}Description
Section titled “Description”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:
armarm64ia32loong64mipsmipselppc64riscv64s390s390xx64
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.
Examples
Section titled “Examples”Invalid
Section titled “Invalid”The value of the cpu field must be an array:
{ "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:
{ "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:
{ "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:
{ "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
{ "cpu": ["x64", "arm64"]}Related links
Section titled “Related links”Copyright (c) 2023-present Biome Developers and Contributors.