Skip to main content

No description has been added so far.

Project description

Build Status PyPI version License Test Coverage

This python package allows you to validate npm package names. It is a python implementation of the official npm/validate-npm-package-name package for javascript.

$ 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 once has been allowed and you can also validate old, existing packages:

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.

Credits

This package is a port from the official npm/validate-npm-package-name

Development

For detailed instructions see CONTRIBUTING.

Tests

You can run tests with

$ invoke test
$ invoke test --min-coverage=90     # Fail when code coverage is below 90%
$ invoke type-check                 # Run mypy type checks

Linting and formatting

Lint and format the code with

$ invoke format
$ invoke lint

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

Note

This project is still in the alpha stage and should not be considered production ready.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for npm-package-validator, version 1.0.1
Filename, size File type Python version Upload date Hashes
Filename, size npm_package_validator-1.0.1.tar.gz (7.4 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page