Skip to content

useRequiredScripts

¥Summary

¥How to configure

biome.json
{
"linter": {
"rules": {
"nursery": {
"useRequiredScripts": "error"
}
}
}
}

¥Description

强制要求 package.json 中包含所需的脚本。

¥Enforce the presence of required scripts in package.json.

此规则确保指定的脚本定义在 package.json 文件的 scripts 部分中。在单体仓库环境中,工作区之间的一致性至关重要,因此此功能尤其有用。

¥This rule ensures that specified scripts are defined in the scripts section of a package.json file. It’s particularly useful in monorepo environments where consistency across workspaces is important.

如果没有配置任何必需脚本,此规则将不会执行任何操作。

¥Without required scripts configured, this rule doesn’t do anything.

¥Examples

¥Invalid

biome.json
{
"linter": {
"rules": {
"nursery": {
"useRequiredScripts": {
"options": {
"requiredScripts": [
"test",
"build"
]
}
}
}
}
}
}
{
"scripts": {
"test": "vitest"
}
}

¥Valid

{
"scripts": {
"test": "vitest",
"build": "tsc"
}
}

¥Options

必须出现在 package.jsonscripts 部分中的脚本名称数组。默认:[](无需脚本)

¥An array of script names that must be present in the scripts section of package.json. Default: [] (no scripts required)

¥Related links