From fd0ac0bc87cc18acfd637bc9f4bc01e4525e4026 Mon Sep 17 00:00:00 2001 From: Bradley Meck Farias Date: Mon, 7 Oct 2024 17:45:18 -0500 Subject: [PATCH] fixups --- src/rules/no-unsafe-values.js | 8 +++++++- tests/rules/no-unsafe-values.test.js | 9 ++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/rules/no-unsafe-values.js b/src/rules/no-unsafe-values.js index 5a38394..85a21f5 100644 --- a/src/rules/no-unsafe-values.js +++ b/src/rules/no-unsafe-values.js @@ -13,7 +13,7 @@ export default { messages: { unsafeNumber: "Number outside safe range found.", - loneSurrogate: "Lone surrogate found.", + loneSurrogate: "Lone surrogate '{{ surrogate }}' found.", }, }, @@ -44,6 +44,12 @@ export default { context.report({ loc: node.loc, messageId: "loneSurrogate", + data: { + surrogate: JSON.stringify(match[0]).slice( + 1, + -1, + ), + }, }); } match = surrogatePattern.exec(node.value); diff --git a/tests/rules/no-unsafe-values.test.js b/tests/rules/no-unsafe-values.test.js index 2052b8f..4cc9426 100644 --- a/tests/rules/no-unsafe-values.test.js +++ b/tests/rules/no-unsafe-values.test.js @@ -113,7 +113,14 @@ ruleTester.run("no-unsafe-values", rule, { code: '"\ud83d\ud83d"', errors: [ { - messageId: "loneSurrogate", + message: "Lone surrogate '\\ud83d' found.", + line: 1, + column: 1, + endLine: 1, + endColumn: 5, + }, + { + message: "Lone surrogate '\\ud83d' found.", line: 1, column: 1, endLine: 1,