UNPKG

eslint-plugin-perfectionist

Version:

ESLint plugin for sorting various data such as objects, imports, types, enums, JSX props, etc.

23 lines (22 loc) 770 B
'use strict' Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }) const isNewlinesBetweenOption = require('./is-newlines-between-option.js') let validateNoDuplicatedGroups = ({ groups }) => { let flattenGroups = groups.flat() let seenGroups = /* @__PURE__ */ new Set() let duplicatedGroups = /* @__PURE__ */ new Set() for (let group of flattenGroups) { if (isNewlinesBetweenOption.isNewlinesBetweenOption(group)) { continue } if (seenGroups.has(group)) { duplicatedGroups.add(group) } else { seenGroups.add(group) } } if (duplicatedGroups.size > 0) { throw new Error(`Duplicated group(s): ${[...duplicatedGroups].join(', ')}`) } } exports.validateNoDuplicatedGroups = validateNoDuplicatedGroups