Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
patricklx committed May 10, 2023
1 parent 0aab5dc commit 7939052
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions lib/preprocessors/glimmer.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,26 @@ function mapRange(messages, filename) {
const original = TEXT_CACHE.get(filename);
const flattened = messages.flat();

if (!transformed) {
return flattened;
}

// if there are no instances of the placeholder value, then this template
// did not contain a <template> tag, so preprocessed === postprocessed
if (!transformed.includes(util.TEMPLATE_TAG_PLACEHOLDER)) {
return flattened;
}

const lines = transformed.split('\n');
const originalLines = original.split('\n');

// get template ranges to remove eslint messages that are inside the templates
const templateRanges = [];
let isInsideTemplate = false;
for (const [index, line] of transformed.split('\n').entries()) {
for (const [index, line] of lines.entries()) {
const lineHasOpeningTag = openingTemplateTagRegex.test(line);
const lineHasClosingTag = closingTemplateTagRegex.test(line);

if (lineHasOpeningTag) {
isInsideTemplate = true;
templateRanges.push({
Expand All @@ -125,7 +138,7 @@ function mapRange(messages, filename) {
startColumn: line.search(openingTemplateTagRegex) + 1,
});
}

if (lineHasClosingTag && isInsideTemplate) {
isInsideTemplate = false;
const match = line.match(closingTemplateTagRegex);
Expand All @@ -134,19 +147,6 @@ function mapRange(messages, filename) {
}
}

if (!transformed) {
return flattened;
}

// if there are no instances of the placeholder value, then this template
// did not contain a <template> tag, so preprocessed === postprocessed
if (!transformed.includes(util.TEMPLATE_TAG_PLACEHOLDER)) {
return flattened;
}

const lines = transformed.split('\n');
const originalLines = original.split('\n');

// this function assumes the original output and transformed output
// are identical, minus the changes to transform `<template>` into the
// placeholder `[__GLIMMER_TEMPLATE()]
Expand Down

0 comments on commit 7939052

Please sign in to comment.