This is a python implementation of the official npm/validate-npm-package-name package
for validating npm package names.
$ pip install npm_package_validator$ npm_package_validator my-packageValidate 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.
The official javascript implementation npm/validate-npm-package-name.
All of this happens when you run invoke pre-commit.