Skip to content

Commit 598477f

Browse files
committed
fix: Print an empty string if the source location isn't available.
1 parent f2824a5 commit 598477f

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

packages/@css-blocks/core/src/Analyzer/validations/property-conflict-validator.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -125,14 +125,14 @@ function recursivelyPruneConflicts(prop: string, conflicts: ConflictMap): Rulese
125125
* @param prop The property we're printing on this Ruleset.
126126
* @param rule The Ruleset we're printing.
127127
*/
128-
function printRulesetConflict(prop: string, rules: Ruleset<Style>[]) {
128+
function formatRulesetConflicts(prop: string, rules: Ruleset<Style>[]) {
129129
const out = new Set();
130130
for (let rule of rules) {
131131
let decl = rule.declarations.get(prop);
132132
let nodes: postcss.Rule[] | postcss.Declaration[] = decl ? decl.map((d) => d.node) : [rule.node];
133133
for (let node of nodes) {
134-
let line = node.source.start && `:${node.source.start.line}`;
135-
let column = node.source.start && `:${node.source.start.column}`;
134+
let line = node.source.start && `:${node.source.start.line}` || "";
135+
let column = node.source.start && `:${node.source.start.column}` || "";
136136
out.add(` ${rule.style.asSource(true)} (${rule.file}${line}${column})`);
137137
}
138138
}
@@ -236,7 +236,7 @@ export const propertyConflictValidator: Validator = (elAnalysis, _templateAnalys
236236
let details = "\n";
237237
for (let [prop, matches] of conflicts.entries()) {
238238
if (!prop || !matches.length) { return; }
239-
details += ` ${prop}:\n${printRulesetConflict(prop, matches)}\n\n`;
239+
details += ` ${prop}:\n${formatRulesetConflicts(prop, matches)}\n\n`;
240240
}
241241
err(msg, null, details);
242242
}

0 commit comments

Comments
 (0)