(ctx: ParserOptions, resultMap: ParserResultMap)
| 45 | } |
| 46 | |
| 47 | export function classifyProject(ctx: ParserOptions, resultMap: ParserResultMap): ClassifyReport { |
| 48 | const byId = new Map<PropertyReportItem['index'], PropertyReportItem>() |
| 49 | const byComponentIndex = new Map<ComponentReportItem['componentIndex'], ComponentReportItem>() |
| 50 | const byFilepath = new Map<string, Set<PropertyReportItem['index']>>() |
| 51 | const byComponentInFilepath = new Map<string, Set<ComponentReportItem['componentIndex']>>() |
| 52 | const globalMaps = createReportMaps() |
| 53 | const byFilePathMaps = new Map<string, ReportDerivedMaps>() |
| 54 | const conditions = new Map(Object.entries(ctx.conditions.values)) |
| 55 | |
| 56 | const { groupByProp } = getPropertyGroupMap(ctx) |
| 57 | |
| 58 | let id = 0 |
| 59 | let componentIndex = 0 |
| 60 | |
| 61 | const isKnownUtility = (reportItem: PropertyReportItem, componentReportItem: ComponentReportItem) => { |
| 62 | const { propName, value, tokenType } = reportItem |
| 63 | |
| 64 | const utility = ctx.utility.config[propName] |
| 65 | |
| 66 | if (utility) { |
| 67 | if (ctx.tokens.getByName(`${tokenType}.${value}`)) return true |
| 68 | if (ctx.tokens.getReferences(String(value)).length > 0) return true |
| 69 | if (ctx.utility.resolveColorMix(String(value)).color) return true |
| 70 | return false |
| 71 | } |
| 72 | |
| 73 | if (componentReportItem.reportItemType === 'pattern') { |
| 74 | const pattern = ctx.patterns.getConfig(componentReportItem.componentName.toLowerCase()) |
| 75 | const patternProp = pattern?.properties?.[propName] |
| 76 | if (!patternProp) return false |
| 77 | |
| 78 | if (patternProp.type === 'boolean' || patternProp.type === 'number') { |
| 79 | return true |
| 80 | } |
| 81 | |
| 82 | if (patternProp.type === 'property' && patternProp.value) { |
| 83 | return Boolean(ctx.utility.config[patternProp.value]) |
| 84 | } |
| 85 | |
| 86 | if (patternProp.type === 'enum' && patternProp.value) { |
| 87 | return Boolean(patternProp.value.includes(String(value))) |
| 88 | } |
| 89 | |
| 90 | if (patternProp.type === 'token') { |
| 91 | return Boolean(ctx.tokens.getByName(`${patternProp.value}.${value}`)) |
| 92 | } |
| 93 | |
| 94 | return false |
| 95 | } |
| 96 | |
| 97 | return false |
| 98 | } |
| 99 | |
| 100 | const processPattern = (opts: ProcessPatternOpts): ComponentReportItem | undefined => { |
| 101 | const { boxNode, data, item, filepath, localMaps } = opts |
| 102 | const name = item.componentName |
| 103 | const pattern = ctx.patterns.details.find((p) => p.match.test(name) || p.baseName === name) |
| 104 | if (!pattern) return |
no test coverage detected