Skip to content

Commit

Permalink
this time? please?
Browse files Browse the repository at this point in the history
  • Loading branch information
StyleShit committed Sep 25, 2024
1 parent 39a7a8f commit 4d9d249
Showing 1 changed file with 111 additions and 0 deletions.
111 changes: 111 additions & 0 deletions tests/lib/rules/no-unescaped-entities.js
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,19 @@ ruleTester.run('no-unescaped-entities', rule, {
{
messageId: 'unescapedEntityAlts',
data: { entity: '>', alts: '`>`' },
suggestions: [{
messageId: 'replaceWithAlt',
data: { alt: '>' },
output: `
var Hello = createReactClass({
render: function() {
return <>first line is ok
so is second
and here are some bad entities: &gt;</>
}
});
`,
}],
},
],
},
Expand All @@ -366,6 +379,52 @@ ruleTester.run('no-unescaped-entities', rule, {
{
messageId: 'unescapedEntityAlts',
data: { entity: '\'', alts: '`&apos;`, `&lsquo;`, `&#39;`, `&rsquo;`' },
suggestions: [
{
messageId: 'replaceWithAlt',
data: { alt: '&apos;' },
output: `
var Hello = createReactClass({
render: function() {
return <div>&apos;</div>;
}
});
`,
},
{
messageId: 'replaceWithAlt',
data: { alt: '&lsquo;' },
output: `
var Hello = createReactClass({
render: function() {
return <div>&lsquo;</div>;
}
});
`,
},
{
messageId: 'replaceWithAlt',
data: { alt: '&#39;' },
output: `
var Hello = createReactClass({
render: function() {
return <div>&#39;</div>;
}
});
`,
},
{
messageId: 'replaceWithAlt',
data: { alt: '&rsquo;' },
output: `
var Hello = createReactClass({
render: function() {
return <div>&rsquo;</div>;
}
});
`,
},
],
},
],
},
Expand All @@ -382,6 +441,17 @@ ruleTester.run('no-unescaped-entities', rule, {
{
messageId: 'unescapedEntityAlts',
data: { entity: '}', alts: '`&#125;`' },
suggestions: [{
messageId: 'replaceWithAlt',
data: { alt: '&#125;' },
output: `
var Hello = createReactClass({
render: function() {
return <>{"Unbalanced braces - babel-eslint"}&#125;</>;
}
});
`,
}],
},
],
},
Expand Down Expand Up @@ -430,6 +500,17 @@ ruleTester.run('no-unescaped-entities', rule, {
{
messageId: 'unescapedEntityAlts',
data: { entity: '&', alts: '`&amp;`' },
suggestions: [{
messageId: 'replaceWithAlt',
data: { alt: '&amp;' },
output: `
var Hello = createReactClass({
render: function() {
return <span>foo &amp; bar</span>;
}
});
`,
}],
},
],
options: [
Expand Down Expand Up @@ -489,6 +570,36 @@ ruleTester.run('no-unescaped-entities', rule, {
data: { entity: '"', alts: '`&quot;`, `&ldquo;`, `&#34;`, `&rdquo;`' },
line: 2,
column: 34,
suggestions: [
{
messageId: 'replaceWithAlt',
data: { alt: '&quot;' },
output: `
<script>window.foo = "bar&quot;</script>
`,
},
{
messageId: 'replaceWithAlt',
data: { alt: '&ldquo;' },
output: `
<script>window.foo = "bar&ldquo;</script>
`,
},
{
messageId: 'replaceWithAlt',
data: { alt: '&#34;' },
output: `
<script>window.foo = "bar&#34;</script>
`,
},
{
messageId: 'replaceWithAlt',
data: { alt: '&rdquo;' },
output: `
<script>window.foo = "bar&rdquo;</script>
`,
},
],
},
],
}
Expand Down

0 comments on commit 4d9d249

Please sign in to comment.