useRequiredScripts (JSON)
Language JSON (and super languages)
Summary
Section titled “Summary”- 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.
How to configure
Section titled “How to configure”{ "linter": { "rules": { "suspicious": { "useRequiredScripts": "error" } } }}Description
Section titled “Description”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.
Examples
Section titled “Examples”Invalid
Section titled “Invalid”{ "linter": { "rules": { "suspicious": { "useRequiredScripts": { "level": "on", "options": { "requiredScripts": [ "test", "build" ] } } } } }}{ "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.
{ "scripts": { "test": "vitest", "build": "tsc" }}Options
Section titled “Options”requiredScripts
Section titled “requiredScripts”Lists script names that must appear in the scripts object. Defaults to an empty list, which
disables the rule.
Related links
Section titled “Related links”Copyright (c) 2023-present Biome Developers and Contributors.