id | title |
---|---|
rules |
Rules |
Rules allow npm-package-json-lint to be fully customizable. npm-package-json-lint will only run the rules supplied. As of v2.7.0, there are multiple ways to supply configuration. One of the easiest way is via a .npmpackagejsonlintrc.json file. The default configuration supplied in v1 is no longer provided in v2. Please see the new default config module, npm-package-json-lint-config-default instead.
Migrating from v2.x.x to 3.x.x?
Please see migrating-from-v2-to-v3
Migrating from v1.x.x to 2.x.x?
Please see migrating-from-v1-to-v2
Migrating from v0.x.x to 1.x.x?
Please see migrating-from-v0-to-v1
npm-package-json-lint rules can either be run as an error
, warning
, or off
.
- "warning" - run the rule as a warning
- "error" - run the rule as an error
- "off" - disables the rule
Ex: "require-author": "error"
Please see .npmpackagejsonlintrc.json file.
v2 added support for shareable npm-package-json-lint config! If you would like to use your .npmpackagejsonlintrc.json file in multiple projects you can create a npm module that exports your config.
Create a new npm module that exports the desired npm-package-json-lint configuration. The module name must start with npm-package-json-lint-config-
. Add the desired configuration to the index.js file.
const config = {
'rules': {
'require-name': 'error'
}
};
module.exports = config;
For a complete example, please see npm-package-json-lint-config-default
Follow these instructions for publishing to npm. Please add the following keywords for discoverability, npm-package-json-lint
, npm-package-json-lintconfig
, and npm-package-json-lint-config
.
Please also add a dependency on npm-package-json-lint using peerdependencies. Example
peerDependencies: {
"npm-package-json-lint": ">= 2"
}
Add the following to your .npmpackagejsonlintrc.json
file.
{
"extends": "npm-package-json-lint-config-default"
}
npm-package-json-lint-config-default
can be replaced by the name of the shared module you are using.
Generates an error if node is missing from package.json file
- require-author
- require-bin
- require-bugs
- require-bundledDependencies
- require-config
- require-contributors
- require-cpu
- require-dependencies
- require-description
- require-devDependencies
- require-directories
- require-engines
- require-files
- require-homepage
- require-keywords
- require-license
- require-main
- require-man
- require-module
- require-name
- require-optionalDependencies
- require-os
- require-peerDependencies
- require-preferGlobal
- require-private
- require-publishConfig
- require-repository-directory
- require-repository
- require-scripts
- require-types
- require-typings
- require-version
Generates an error if node's value doesn't have the correct data type
- bin-type
- bundledDependencies-type
- config-type
- cpu-type
- dependencies-type
- description-type
- devDependencies-type
- directories-type
- engines-type
- files-type
- homepage-type
- keywords-type
- license-type
- main-type
- man-type
- name-type
- optionalDependencies-type
- os-type
- peerDependencies-type
- preferGlobal-type
- private-type
- repository-type
- scripts-type
- version-type
Generates an error if node's value doesn't match one of the values in the supplied array
- valid-values-author
- valid-values-engines
- valid-values-license
- valid-values-name-scope
- valid-values-private
- valid-values-publishConfig
Generates an error if dependencies fail to meet the rules requirements
- dependencies
- devDependencies
- no-absolute-version-devDependencies
- no-caret-version-devDependencies
- no-restricted-devDependencies
- no-restricted-pre-release-devDependencies
- no-tilde-version-devDependencies
- prefer-no-version-zero-devDependencies
- prefer-absolute-version-devDependencies
- prefer-alphabetical-devDependencies
- prefer-caret-version-devDependencies
- prefer-no-version-zero-devDependencies
- prefer-tilde-version-devDependencies
- bundledDependencies
- optionalDependencies
- peerDependencies
Generates an error if node's value fails to meet the format requirements
Generates an error if the package.json properties fail to meet the desired requirements
Generates an error if the node is present