Package Exports
- npm-package-json-lint
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (npm-package-json-lint) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
npm-package-json-lint
A package.json linter for Node projects
What is npm-package-json-lint?
npm-package-json-lint helps enforce standards for your package.json file. Currently it can check for:
- validity of data types in nodes. Ex:
name
should always be a string. - whether a string is a lowercase
- whether a version number is a valid
- the presence of a given module
- the presence of a pre-release version of a module
- and much more!
Please see the wiki for a list of rules.
How do I install it?
First thing first, let's make sure you have the necessary pre-requisites.
System Dependencies
Node
Use the cli
npm install npm-package-json-lint -g
Commands and configuration
Command | Alias | Description |
---|---|---|
pjl-cli --help | -h | Lists supported CLI options |
pjl-cli --version | -v | Lists the current version number |
pjl-cli --file |
-f | File path including name. Defaults to package.json |
pjl-cli --rule |
-r | Valid rule name to check. Defaults to nothing |
pjl-cli --rules-file |
-c | File path of .npmpackagejsonlintrc |
pjl-cli --ignore-warnings | -w | Ignore warnings |
Examples
Run a specific rule, require-author, on a file relative to the current working directory.
pjl-cli -f "../relative-path/package.json" -r "require-author: 'error'"
Run a specific rule, require-author, ignoring warnings on a file relative to the current working directory.
pjl-cli -f "../relative-path/package.json" -r "require-author: 'error'" --ignore-warnings
Run using the config in .npmpackagejsonlintrc
on a file relative to the current working directory.
pjl-cli -f "../relative-path/package.json" -c "./.npmpackagejsonlintrc"
Run using the default config on a file relative to the current working directory
pjl-cli -f "../relative-path/package.json"
Lint Rules
npm-package-json-lint has a configurable set of rules. Please see the wiki for a full list of available rules. By default only type checks and name/version rules are enforced. This is the bare minimum configuration.
Each rule contains the following properties:
- ID - example: require-author
- Node - example: author
- Message - example: author is required
- Rule Type - example: required
As mentioned in the "Commands and configuration" section there are two ways to specify rule sets. The first is using --rule
to specify a given rule. This will run npm-package-json-lint with just this rule. The second is using --rules-file
to specify a JSON file, named .npmpackagejsonlintrc
, to run a set of rules. If neither of the options above are specified then npm-package-json-lint looks for a global .npmpackagejsonlintrc
file in the root of your user directory. Finally, if a global .npmpackagejsonlintrc
file doesn't exist then the defaults are used.
Configuring rules
npm-package-json-lint rules can either be run as an error
or a warning
.
- "warning" - run the rule as a warning
- "error" - run the rule as an error
Ex: "require-author": "error"
Migrating from v0.x.x to 1.x.x
Please see the migration guide.
Contributing
Please see CONTRIBUTING.md.
Release History
Please see CHANGELOG.md.
Related
- grunt-npm-package-json-lint: Grunt Wrapper for npm-package-json-lint
License
Copyright (c) 2016 Thomas Lindner. Licensed under the MIT license.