From 808762d3260526d74a2237f1daed4339f88175e5 Mon Sep 17 00:00:00 2001 From: Daniel Martens Date: Thu, 1 Feb 2024 15:45:43 +0100 Subject: [PATCH 1/3] fix(no-useless-mustaches): escape < in fixes --- lib/rules/no-useless-mustaches.js | 3 +- tests/lib/rules/no-useless-mustaches.js | 48 +++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/lib/rules/no-useless-mustaches.js b/lib/rules/no-useless-mustaches.js index f4f858d9e..9a382f511 100644 --- a/lib/rules/no-useless-mustaches.js +++ b/lib/rules/no-useless-mustaches.js @@ -142,8 +142,9 @@ module.exports = { // It doesn't autofix because another rule like indent or eol space might remove spaces. return null } + const escaped = text.replace(/\ + {{ '<' }} + {{ '>' }} + {{ '&' }} + {{ '—' }} + + `, + output: ` + + `, + errors: [ + 'Unexpected mustache interpolation with a string literal value.', + 'Unexpected mustache interpolation with a string literal value.', + 'Unexpected mustache interpolation with a string literal value.', + 'Unexpected mustache interpolation with a string literal value.', + ] + }, + { + code: ` + + `, + output: ` + + `, + errors: [ + 'Unexpected mustache interpolation with a string literal value.', + 'Unexpected mustache interpolation with a string literal value.', + 'Unexpected mustache interpolation with a string literal value.', + 'Unexpected mustache interpolation with a string literal value.', + ] + }, { code: `