check-rule-repetition.js 522 B

12345678910111213141516171819202122
  1. /**
  2. * @typedef {import('../types.js').Options} Options
  3. * @typedef {import('../types.js').State} State
  4. */
  5. /**
  6. * @param {State} state
  7. * @returns {Exclude<Options['ruleRepetition'], null | undefined>}
  8. */
  9. export function checkRuleRepetition(state) {
  10. const repetition = state.options.ruleRepetition || 3
  11. if (repetition < 3) {
  12. throw new Error(
  13. 'Cannot serialize rules with repetition `' +
  14. repetition +
  15. '` for `options.ruleRepetition`, expected `3` or more'
  16. )
  17. }
  18. return repetition
  19. }