Skip to content

useRequiredScripts (JSON)

Language JSON (and super languages)
  • Rule available since: v2.3.9
  • Diagnostic Category: lint/suspicious/useRequiredScripts
  • This rule isn’t recommended, so you need to enable it.
  • This rule doesn’t have a fix.
  • The default severity of this rule is warning.
biome.json
{
"linter": {
"rules": {
"suspicious": {
"useRequiredScripts": "error"
}
}
}
}

Require configured scripts in package.json.

A repository can contain several packages that share commands such as test or build. Tools run from the repository’s top-level directory may expect every package to provide the same script names. The rule does nothing when requiredScripts is empty.

biome.json
{
"linter": {
"rules": {
"suspicious": {
"useRequiredScripts": {
"level": "on",
"options": {
"requiredScripts": [
"test",
"build"
]
}
}
}
}
}
}
package.json
{
"scripts": {
"test": "vitest"
}
}
/package.json:2:5 lint/suspicious/useRequiredScripts ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

⚠ The required script build is missing from package.json.

1 │ {
> 2 │ "scripts": {
│ ^^^^^^^^^^^^
> 3 │ "test": "vitest"
> 4 │ }
│ ^
5 │ }
6 │

ℹ Consistent scripts across packages ensure that each can be run reliably from the root of our project. Add the missing script to your package.json.

package.json
{
"scripts": {
"test": "vitest",
"build": "tsc"
}
}

Lists script names that must appear in the scripts object. Defaults to an empty list, which disables the rule.