putout
Version:
🐊 Pluggable and configurable code transformer with built-in ESLint, Babel and support of js, jsx, typescript, flow, markdown, yaml and json
34 lines (25 loc) • 620 B
JavaScript
;
const picomatch = require('picomatch');
const {keys, assign} = Object;
module.exports.parseMatch = (name, match) => {
if (!match || !name)
return {};
const rules = {};
const globs = keys(match);
for (const glob of globs) {
const paths = [
glob,
`**/${glob}`,
`${glob}/**`,
`**/${glob}/**`,
];
const isMatch = picomatch(paths, {
dot: true,
});
if (isMatch(name))
assign(rules, match[glob]);
}
return {
rules,
};
};