useRequiredScripts
¥Summary
-
规则生效日期:
v2.3.9¥Rule available since:
v2.3.9 -
诊断类别:
lint/nursery/useRequiredScripts¥Diagnostic Category:
lint/nursery/useRequiredScripts -
此规则没有修复方案。
¥This rule doesn’t have a fix.
-
此规则的默认严重级别为 information。
¥The default severity of this rule is information.
¥How to configure
{ "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
{ "linter": { "rules": { "nursery": { "useRequiredScripts": { "options": { "requiredScripts": [ "test", "build" ] } } } } }}{ "scripts": { "test": "vitest" }}¥Valid
{ "scripts": { "test": "vitest", "build": "tsc" }}¥Options
requiredScripts
Section titled “requiredScripts”必须出现在 package.json 的 scripts 部分中的脚本名称数组。默认:[](无需脚本)
¥An array of script names that must be present in the scripts section of package.json.
Default: [] (no scripts required)
¥Related links
Biome v2.1 中文网 - 粤ICP备13048890号