npm-package-json-lint
npm-package-json-lint documentation
- Version in MegaLinter: 6.4.0
 - Visit Official Web Site
 - See How to configure npm-package-json-lint rules
- If custom 
.npmpackagejsonlintrc.jsonconfig file isn't found, .npmpackagejsonlintrc.json will be used 
 - If custom 
 - See How to ignore files and directories with npm-package-json-lint
- You can define a 
.npmpackagejsonlintignorefile to ignore files and folders 
 - You can define a 
 - See Index of problems detected by npm-package-json-lint
 
Configuration in MegaLinter
- Enable npm-package-json-lint by adding 
JSON_NPM_PACKAGE_JSON_LINTin ENABLE_LINTERS variable - Disable npm-package-json-lint by adding 
JSON_NPM_PACKAGE_JSON_LINTin DISABLE_LINTERS variable 
| Variable | Description | Default value | 
|---|---|---|
| JSON_NPM_PACKAGE_JSON_LINT_ARGUMENTS | User custom arguments to add in linter CLI call Ex: -s --foo "bar" | 
|
| JSON_NPM_PACKAGE_JSON_LINT_FILE_EXTENSIONS | Allowed file extensions. "*" matches any extension, "" matches empty extension. Empty list excludes all filesEx: [".py", ""] | 
[".json"] | 
| JSON_NPM_PACKAGE_JSON_LINT_FILE_NAMES_REGEX | File name regex filters. Regular expression list for filtering files by their base names using regex full match. Empty list includes all files Ex: ["Dockerfile(-.+)?", "Jenkinsfile"] | 
["package\\.json"] | 
| JSON_NPM_PACKAGE_JSON_LINT_PRE_COMMANDS | List of bash commands to run before the linter | None | 
| JSON_NPM_PACKAGE_JSON_LINT_POST_COMMANDS | List of bash commands to run after the linter | None | 
| JSON_NPM_PACKAGE_JSON_LINT_CONFIG_FILE | npm-package-json-lint configuration file nameUse LINTER_DEFAULT to let the linter find it | 
.npmpackagejsonlintrc.json | 
| JSON_NPM_PACKAGE_JSON_LINT_RULES_PATH | Path where to find linter configuration file | Workspace folder, then MegaLinter default rules | 
| JSON_NPM_PACKAGE_JSON_LINT_DISABLE_ERRORS | Run linter but consider errors as warnings | false | 
| JSON_NPM_PACKAGE_JSON_LINT_DISABLE_ERRORS_IF_LESS_THAN | Maximum number of errors allowed | 0 | 
| JSON_NPM_PACKAGE_JSON_LINT_CLI_EXECUTABLE | Override CLI executable | ['npmPkgJsonLint'] | 
MegaLinter Flavours
This linter is available in the following flavours
| Flavor | Description | Embedded linters | Info | |
|---|---|---|---|---|
![]()  | 
all | Default MegaLinter Flavor | 113 | |
| cupcake | MegaLinter for the most commonly used languages | 81 | ||
| dotnet | Optimized for C, C++, C# or VB based projects | 59 | ||
| javascript | Optimized for JAVASCRIPT or TYPESCRIPT based projects | 56 | ||
| salesforce | Optimized for Salesforce based projects | 50 | 
Behind the scenes
How are identified applicable files
- Activated only if one of these files is found: 
package.json - File extensions: 
.json - File names (regex): 
package\.json 
How the linting is performed
npm-package-json-lint is called once on the whole project directory (project CLI lint mode)
- filtering can not be done using MegaLinter configuration variables,it must be done using npm-package-json-lint configuration or ignore file (if existing)
 VALIDATE_ALL_CODEBASE: falsedoesn't make npm-package-json-lint analyze only updated files
Example calls
npmPkgJsonLint .
npmPkgJsonLint --configFile .npmpackagejsonlintrc.json .
Help content
  Configurable linter for package.json files.
  Usage
    $ npmPkgJsonLint <patterns>
  Options
    --quiet, -q Report errors only
    --noConfigFiles, -ncf Disables use of .npmpackagejsonlintrc.json files, npmpackagejsonlint.config.js files, and npmpackagejsonlint object in package.json file.
    --configFile, -c File path of .npmpackagejsonlintrc.json
    --ignorePath, -i Path to a file containing patterns that describe files to ignore. The path can be absolute or relative to process.cwd(). By default, npm-package-json-lint looks for .npmpackagejsonlintignore in process.cwd().
    --maxWarnings, -mw Maximum number of warnings that can be detected before an error is thrown.
    --allowEmptyTargets Do not throw an error when a list of targets is empty.
  Examples
    $ npmPkgJsonLint --version
    $ npmPkgJsonLint .
    $ npmPkgJsonLint ./packages
    $ npmPkgJsonLint ./package1 ./package2
    $ npmPkgJsonLint -c ./config/.npmpackagejsonlintrc.json .
    $ npmPkgJsonLint --configFile ./config/npmpackagejsonlint.config.json .
    $ npmPkgJsonLint -q .
    $ npmPkgJsonLint --quiet ./packages
    $ npmPkgJsonLint . --ignorePath .gitignore
    $ npmPkgJsonLint . -i .gitignore
    $ npmPkgJsonLint . --maxWarnings 10
    $ npmPkgJsonLint . -mw 10
Installation on mega-linter Docker image
- NPM packages (node.js):
 
