eslint-plugin-perfectionist
Version:
ESLint plugin for sorting various data such as objects, imports, types, enums, JSX props, etc.
18 lines (17 loc) • 673 B
JavaScript
/**
* Checks if the given AST selector matches the expected AST selector.
*
* @param params - The parameters object.
* @param params.matchesAstSelector - The AST selector to match against, or
* undefined if no selector is specified.
* @param params.matchedAstSelectors - The matched AST selectors for a node.
* @returns True if the given AST selector matches the expected AST selector, or
* if no selector is specified; otherwise, false.
*/
function passesAstSelectorFilter({ matchedAstSelectors, matchesAstSelector }) {
if (!matchesAstSelector) {
return true
}
return matchedAstSelectors.has(matchesAstSelector)
}
export { passesAstSelectorFilter }