no-empty-fields
💼 This rule is enabled in the following configs: ✅ recommended, 📦 recommended-publishable.
💡 This rule is manually fixable by editor suggestions.
This rule flags all empty Arrays and objects, as such empty expressions do nothing and are often the result of a mistake. It will report both named properties that are empty, as well as nested arrays and objects that are empty.
Examples
Section titled “Examples”{ "main": "lib/index.js", "scripts": {}, "browserslist": [], "simple-git-hooks": { "pre-commit": "pnpm exec nano-staged --allow-empty", "preserveUnused": [] }}{ "main": "lib/index.js", "simple-git-hooks": { "pre-commit": "pnpm exec nano-staged --allow-empty" }}Options
Section titled “Options”| Name | Description | Type | Default |
|---|---|---|---|
ignoreProperties |
Array of top-level properties to ignore. | String[] | [files] |
ignoreProperties
Section titled “ignoreProperties”Pass an array of top-level package properties to ignore. When provided, the rule won’t report violations for the specified properties. This can be useful if you’re using tools that take configuration from package.json and accept an empty array or object as valid non-default configuration.
{ "package-json/no-empty-fields": [ "error", { "ignoreProperties": ["browserslist"] } ]}Related Rules
Section titled “Related Rules”no-redundant-files- Reports on unnecessary or redundant elements in thefilesArray.