Skip to content

[BUG] Rule about spaces is already covered by rule about 'URL-friendly characters' #70

@bershanskiy

Description

@bershanskiy

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

If package name contains leading or ending spaces, two errors logged when a single error would do. Rule "name can only contain URL-friendly characters" implies "name cannot contain leading or trailing spaces" so the latter is redundant.

Expected Behavior

Error "name cannot contain leading or trailing spaces" is not logged since it is redundant.

Steps To Reproduce

Run this and observe two errors in each case:

const validate = require("validate-npm-package-name");
console.log(validate(' leading-space').errors);
// Output:
// ["name cannot contain leading or trailing spaces", "name can only contain URL-friendly characters"]
console.log(validate('trailing-space ').errors);
// The same output:
// ["name cannot contain leading or trailing spaces", "name can only contain URL-friendly characters"]

Environment

  • npm: 8.0.0
  • Node: v19.6.0
  • OS: Ubuntu 22.04
  • platform: Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions