private _generateRules()

in tools/tslint-rules/validateDecoratorsRule.ts [123:147]


  private _generateRules(config: {[key: string]: {[key: string]: string}}): DecoratorRules {
    const output: DecoratorRules = {};

    if (config) {
      Object.keys(config)
        .filter(decoratorName => Object.keys(config[decoratorName]).length > 0)
        .forEach(decoratorName => {
          output[decoratorName] = Object.keys(config[decoratorName]).reduce((accumulator, prop) => {
            const isForbidden = prop.startsWith('!');
            const cleanName = isForbidden ? prop.slice(1) : prop;
            const pattern = new RegExp(config[decoratorName][prop]);

            if (isForbidden) {
              accumulator.forbidden[cleanName] = pattern;
            } else {
              accumulator.required[cleanName] = pattern;
            }

            return accumulator;
          }, {required: {}, forbidden: {}} as DecoratorRuleSet);
        });
    }

    return output;
  }