eslint-plugin-perfectionist
Version:
ESLint plugin for sorting various data such as objects, imports, types, enums, JSX props, etc.
50 lines (49 loc) • 1.32 kB
JavaScript
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' })
const matches = require('../../utils/matches.js')
let doesCustomGroupMatch = props => {
if ('anyOf' in props.customGroup) {
return props.customGroup.anyOf.some(subgroup =>
doesCustomGroupMatch({ ...props, customGroup: subgroup }),
)
}
if (
props.customGroup.selector &&
!props.selectors.includes(props.customGroup.selector)
) {
return false
}
if (props.customGroup.modifiers) {
for (let modifier of props.customGroup.modifiers) {
if (!props.modifiers.includes(modifier)) {
return false
}
}
}
if (
'elementNamePattern' in props.customGroup &&
props.customGroup.elementNamePattern
) {
let matchesElementNamePattern = matches.matches(
props.elementName,
props.customGroup.elementNamePattern,
)
if (!matchesElementNamePattern) {
return false
}
}
if (
'elementValuePattern' in props.customGroup &&
props.customGroup.elementValuePattern
) {
let matchesElementNamePattern = matches.matches(
props.elementValue ?? '',
props.customGroup.elementValuePattern,
)
if (!matchesElementNamePattern) {
return false
}
}
return true
}
exports.doesCustomGroupMatch = doesCustomGroupMatch