diff --git a/src/rules/types.ts b/src/rules/types.ts index 0c17892..ec70b9f 100644 --- a/src/rules/types.ts +++ b/src/rules/types.ts @@ -1,6 +1,5 @@ export enum RuleTypes { Basic = "basic", - Debug = "debug", And = "and", Or = "or", AndDistinct = "and-distinct", @@ -14,12 +13,6 @@ export interface Rule { countAuthor?: boolean; } -// TODO: Delete this once we add a second type of rule -export interface DebugRule extends Rule { - type: RuleTypes.Debug; - size: number; -} - export interface BasicRule extends Rule, Reviewers { type: RuleTypes.Basic; } @@ -43,7 +36,7 @@ export interface ConfigurationFile { /** Based on the `type` parameter, Typescript converts the object to the correct type * @see {@link Rules} */ - rules: (BasicRule | DebugRule | AndRule | OrRule | AndDistinctRule)[]; + rules: (BasicRule | AndRule | OrRule | AndDistinctRule)[]; preventReviewRequests?: { teams?: string[]; users?: string[]; diff --git a/src/rules/validator.ts b/src/rules/validator.ts index 24c307f..7cc010d 100644 --- a/src/rules/validator.ts +++ b/src/rules/validator.ts @@ -2,7 +2,7 @@ import { validate } from "@eng-automation/js"; import Joi from "joi"; import { ActionLogger } from "../github/types"; -import { AndRule, BasicRule, ConfigurationFile, DebugRule, Reviewers, Rule, RuleTypes } from "./types"; +import { AndRule, BasicRule, ConfigurationFile, Reviewers, Rule, RuleTypes } from "./types"; /** For the users or team schema. Will be recycled A LOT * Remember to add `.or("users", "teams")` to force at least one of the two to be defined @@ -24,9 +24,7 @@ const ruleSchema = Joi.object().keys({ include: Joi.array().items(Joi.string()).required(), exclude: Joi.array().items(Joi.string()).optional().allow(null), }), - type: Joi.string() - .valid(RuleTypes.Basic, RuleTypes.Debug, RuleTypes.And, RuleTypes.Or, RuleTypes.AndDistinct) - .required(), + type: Joi.string().valid(RuleTypes.Basic, RuleTypes.And, RuleTypes.Or, RuleTypes.AndDistinct).required(), }); /** General Configuration schema. @@ -73,8 +71,6 @@ export const validateConfig = (config: ConfigurationFile): ConfigurationFile | n const message = `Configuration for rule '${rule.name}' is invalid`; if (type === "basic") { validatedConfig.rules[i] = validate(rule, basicRuleSchema, { message }); - } else if (type === "debug") { - validatedConfig.rules[i] = validate(rule, ruleSchema, { message }); } else if (type === "and" || type === "or" || type === "and-distinct") { // Aside from the type, every other field in this rules is identical so we can // use any of these rules to validate the other fields. diff --git a/src/test/rules/config.test.ts b/src/test/rules/config.test.ts index ee13322..3255491 100644 --- a/src/test/rules/config.test.ts +++ b/src/test/rules/config.test.ts @@ -73,7 +73,7 @@ describe("Config Parsing", () => { teams: - team-example `); - // prettifies string to [basic, debug, and, or...] + // prettifies string to [basic, and, or...] const types = JSON.stringify(Object.values(RuleTypes)).replace(/"/g, "").replace(/,/g, ", "); await expect(runner.getConfigFile("")).rejects.toThrowError( 'Configuration file is invalid: "rules[0].type" must be one of ' + types,