Skip to content

romnn/npm-package-validator

Repository files navigation

npm-package-validator

Test Status PyPI version License Test Coverage

This is a python implementation of the official npm/validate-npm-package-name package for validating npm package names.

$ pip install npm_package_validator

CLI Usage

$ npm_package_validator my-package

Programmatic usage

Validate an npm package name like this:

import npm_package_validator
# Fails! Uppercase is not allowed for new packages
assert npm_package_validator.valid_new_package('MY-package')

However, upper case names used to be allowed and so validating as an old, existing package succeeds:

assert npm_package_validator.valid_old_package('MY-package')  # Succeeds!

When using the CLI, you can use the --old flag.

If you want to know whats wrong with a name, use:

from npm_package_validator.validate import validate_package
errors, warnings = validate_package('MY-package')
print("Errors: %s" % ", ".join(errors))
print("Warnings: %s" % ", ".join(warnings))

A valid new package name must have neither errors nor warnings. Existing packages can have warnings, as the npm validation rules have become stricter over time.

Acknowledgements

The official javascript implementation npm/validate-npm-package-name.

Development

All of this happens when you run invoke pre-commit.

About

python package for validating npm package names.

Topics

Resources

License

Stars

Watchers

Forks

Contributors 2

  •  
  •  

Languages