Skip to content

Commit

Permalink
[tests] no-unescaped-entities: skip test cases that are now parsing…
Browse files Browse the repository at this point in the history
… errors in acorn-jsx@5.2.0

Co-authored-by: Chiawen Chen <golopot@gmail.com>
Co-authored-by: Jordan Harband <ljharb@gmail.com>
  • Loading branch information
golopot and ljharb committed Mar 1, 2020
1 parent 434b45f commit e231f44
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"object.values": "^1.1.1",
"prop-types": "^15.7.2",
"resolve": "^1.15.1",
"semver": "^6.3.0",
"string.prototype.matchall": "^4.0.2",
"xregexp": "^4.3.0"
},
Expand Down Expand Up @@ -69,5 +70,10 @@
"eslintplugin",
"react"
],
"license": "MIT"
"license": "MIT",
"greenkeeper": {
"ignore": [
"semver"
]
}
}
24 changes: 16 additions & 8 deletions tests/lib/rules/no-unescaped-entities.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@
// Requirements
// ------------------------------------------------------------------------------

const semver = require('semver');

let allowsInvalidJSX = false;
try {
// eslint-disable-next-line import/no-extraneous-dependencies, global-require
allowsInvalidJSX = semver.satisfies(require('acorn-jsx/package.json').version, '< 5.2');
} catch (e) { /**/ }

const RuleTester = require('eslint').RuleTester;
const rule = require('../../../lib/rules/no-unescaped-entities');

Expand Down Expand Up @@ -107,7 +115,7 @@ ruleTester.run('no-unescaped-entities', rule, {
],

invalid: [
{
(allowsInvalidJSX && {
code: `
var Hello = createReactClass({
render: function() {
Expand All @@ -116,7 +124,7 @@ ruleTester.run('no-unescaped-entities', rule, {
});
`,
errors: [{message: '`>` can be escaped with `&gt;`.'}]
}, {
}), {
code: `
var Hello = createReactClass({
render: function() {
Expand All @@ -126,7 +134,7 @@ ruleTester.run('no-unescaped-entities', rule, {
`,
parser: parsers.BABEL_ESLINT,
errors: [{message: '`>` can be escaped with `&gt;`.'}]
}, {
}, (allowsInvalidJSX && {
code: `
var Hello = createReactClass({
render: function() {
Expand All @@ -137,7 +145,7 @@ ruleTester.run('no-unescaped-entities', rule, {
});
`,
errors: [{message: '`>` can be escaped with `&gt;`.'}]
}, {
}), {
code: `
var Hello = createReactClass({
render: function() {
Expand All @@ -158,7 +166,7 @@ ruleTester.run('no-unescaped-entities', rule, {
});
`,
errors: [{message: '`\'` can be escaped with `&apos;`, `&lsquo;`, `&#39;`, `&rsquo;`.'}]
}, {
}, (allowsInvalidJSX && {
code: `
var Hello = createReactClass({
render: function() {
Expand All @@ -171,7 +179,7 @@ ruleTester.run('no-unescaped-entities', rule, {
{message: '`>` can be escaped with `&gt;`.'},
{message: '`>` can be escaped with `&gt;`.'}
]
}, {
}), (allowsInvalidJSX && {
code: `
var Hello = createReactClass({
render: function() {
Expand All @@ -180,7 +188,7 @@ ruleTester.run('no-unescaped-entities', rule, {
});
`,
errors: [{message: '`}` can be escaped with `&#125;`.'}]
}, {
}), {
code: `
var Hello = createReactClass({
render: function() {
Expand Down Expand Up @@ -231,5 +239,5 @@ ruleTester.run('no-unescaped-entities', rule, {
}]
}]
}
]
].filter(Boolean)
});

0 comments on commit e231f44

Please sign in to comment.