Skip to content

Conversation

@Splines
Copy link
Owner

@Splines Splines commented Jan 23, 2025

Fixes #15. We now use the replacement to {} only if the ERB tag starts with <%=. For all other tags (including <% and <%#), we replace them by a simple comment, without any actual remaining JS-syntax (i.e. no {}).

A respective test was added.

@Splines Splines added the bug Something isn't working label Jan 23, 2025
@Splines Splines self-assigned this Jan 23, 2025
@Splines Splines merged commit df96a45 into main Jan 23, 2025
4 checks passed
@Splines Splines deleted the fix/no-output-erb-tags branch January 23, 2025 18:16
Comment on lines +90 to +99
function wrapInEslintDisable(text) {
return `/* eslint-disable */${text}/* eslint-enable */`;
}
return preprocess(text, filename, dummyString);

function toDummyString(id, matchText) {
if (matchText.startsWith("<%=")) {
return wrapInEslintDisable(`{}/* eslint-plugin-erb ${HASH} ${id} */`);
}
return wrapInEslintDisable(`/* eslint-plugin-erb ${HASH} ${id} */`);
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm just gonna leave this idea here, I don't feel like forking this repo today:

Suggested change
function wrapInEslintDisable(text) {
return `/* eslint-disable */${text}/* eslint-enable */`;
}
return preprocess(text, filename, dummyString);
function toDummyString(id, matchText) {
if (matchText.startsWith("<%=")) {
return wrapInEslintDisable(`{}/* eslint-plugin-erb ${HASH} ${id} */`);
}
return wrapInEslintDisable(`/* eslint-plugin-erb ${HASH} ${id} */`);
}
function toDummyString(id, matchText) {
let replacement = "";
if (matchText.startsWith("<%=")) replacement = "{}";
const tagged = `${replacement}/* eslint-plugin-erb ${HASH} ${id} */`;
const wrapped = `/* eslint-disable */${tagged}/* eslint-enable */`;
return wrapped;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Parsing Error when using no-output erb tags in certain contexts

3 participants