Skip to content

Commit

Permalink
fixups
Browse files Browse the repository at this point in the history
  • Loading branch information
bmeck committed Oct 7, 2024
1 parent 3f35f97 commit fd0ac0b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/rules/no-unsafe-values.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default {

messages: {
unsafeNumber: "Number outside safe range found.",
loneSurrogate: "Lone surrogate found.",
loneSurrogate: "Lone surrogate '{{ surrogate }}' found.",
},
},

Expand Down Expand Up @@ -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);
Expand Down
9 changes: 8 additions & 1 deletion tests/rules/no-unsafe-values.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit fd0ac0b

Please sign in to comment.