module.exports = {
  isValidPluginName(packageName) {
    return (
      packageName &&
      /^(?:@[a-z0-9-*~][a-z0-9-*._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/.test(
        packageName,
      )
    );
  },

  toValidPluginName(packageName) {
    return packageName
      .trim()
      .toLowerCase()
      .replace(/\s+/g, "-")
      .replace(/^[._]/, "")
      .replace(/[^a-z0-9-~]+/g, "-");
  },
};
