Skip to content

Commit 8983d64

Browse files
author
Joachim Seminck
committed
Duplicate the test cases with the default parser.
1 parent ebc6778 commit 8983d64

File tree

1 file changed

+165
-0
lines changed

1 file changed

+165
-0
lines changed

tests/lib/rules/no-unused-prop-types.js

Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1504,6 +1504,24 @@ ruleTester.run('no-unused-prop-types', rule, {
15041504
'}'
15051505
].join('\n'),
15061506
parser: 'babel-eslint'
1507+
}, {
1508+
code: [
1509+
'class Hello extends Component {',
1510+
' shouldComponentUpdate (props) {',
1511+
' if (props.foo) {',
1512+
' return true;',
1513+
' }',
1514+
' }',
1515+
'',
1516+
' render() {',
1517+
' return (<div>{this.props.bar}</div>);',
1518+
' }',
1519+
'}',
1520+
'Hello.propTypes = {',
1521+
' foo: PropTypes.string,',
1522+
' bar: PropTypes.string,',
1523+
'};'
1524+
].join('\n')
15071525
}, {
15081526
code: [
15091527
'class Hello extends Component {',
@@ -1524,6 +1542,24 @@ ruleTester.run('no-unused-prop-types', rule, {
15241542
'}'
15251543
].join('\n'),
15261544
parser: 'babel-eslint'
1545+
}, {
1546+
code: [
1547+
'class Hello extends Component {',
1548+
' componentWillUpdate (props) {',
1549+
' if (props.foo) {',
1550+
' return true;',
1551+
' }',
1552+
' }',
1553+
'',
1554+
' render() {',
1555+
' return (<div>{this.props.bar}</div>);',
1556+
' }',
1557+
'}',
1558+
'Hello.propTypes = {',
1559+
' foo: PropTypes.string,',
1560+
' bar: PropTypes.string,',
1561+
'};'
1562+
].join('\n')
15271563
}, {
15281564
code: [
15291565
'class Hello extends Component {',
@@ -1545,6 +1581,24 @@ ruleTester.run('no-unused-prop-types', rule, {
15451581
'}'
15461582
].join('\n'),
15471583
parser: 'babel-eslint'
1584+
}, {
1585+
code: [
1586+
'class Hello extends Component {',
1587+
' componentWillReceiveProps (props) {',
1588+
' if (props.foo) {',
1589+
' return true;',
1590+
' }',
1591+
' }',
1592+
'',
1593+
' render() {',
1594+
' return (<div>{this.props.bar}</div>);',
1595+
' }',
1596+
'}',
1597+
'Hello.propTypes = {',
1598+
' foo: PropTypes.string,',
1599+
' bar: PropTypes.string,',
1600+
'};'
1601+
].join('\n')
15481602
}, {
15491603
code: [
15501604
'class Hello extends Component {',
@@ -1565,6 +1619,24 @@ ruleTester.run('no-unused-prop-types', rule, {
15651619
'}'
15661620
].join('\n'),
15671621
parser: 'babel-eslint'
1622+
}, {
1623+
code: [
1624+
'class Hello extends Component {',
1625+
' shouldComponentUpdate (nextProps) {',
1626+
' if (nextProps.foo) {',
1627+
' return true;',
1628+
' }',
1629+
' }',
1630+
'',
1631+
' render() {',
1632+
' return (<div>{this.props.bar}</div>);',
1633+
' }',
1634+
'}',
1635+
'Hello.propTypes = {',
1636+
' foo: PropTypes.string,',
1637+
' bar: PropTypes.string,',
1638+
'};'
1639+
].join('\n')
15681640
}, {
15691641
code: [
15701642
'class Hello extends Component {',
@@ -1585,6 +1657,24 @@ ruleTester.run('no-unused-prop-types', rule, {
15851657
'}'
15861658
].join('\n'),
15871659
parser: 'babel-eslint'
1660+
}, {
1661+
code: [
1662+
'class Hello extends Component {',
1663+
' componentWillUpdate (nextProps) {',
1664+
' if (nextProps.foo) {',
1665+
' return true;',
1666+
' }',
1667+
' }',
1668+
'',
1669+
' render() {',
1670+
' return (<div>{this.props.bar}</div>);',
1671+
' }',
1672+
'}',
1673+
'Hello.propTypes = {',
1674+
' foo: PropTypes.string,',
1675+
' bar: PropTypes.string,',
1676+
'};'
1677+
].join('\n')
15881678
}, {
15891679
code: [
15901680
'class Hello extends Component {',
@@ -1605,6 +1695,24 @@ ruleTester.run('no-unused-prop-types', rule, {
16051695
'}'
16061696
].join('\n'),
16071697
parser: 'babel-eslint'
1698+
}, {
1699+
code: [
1700+
'class Hello extends Component {',
1701+
' componentDidUpdate (prevProps) {',
1702+
' if (prevProps.foo) {',
1703+
' return true;',
1704+
' }',
1705+
' }',
1706+
'',
1707+
' render() {',
1708+
' return (<div>{this.props.bar}</div>);',
1709+
' }',
1710+
'}',
1711+
'Hello.propTypes = {',
1712+
' foo: PropTypes.string,',
1713+
' bar: PropTypes.string,',
1714+
'};'
1715+
].join('\n')
16081716
}
16091717
],
16101718

@@ -2572,6 +2680,25 @@ ruleTester.run('no-unused-prop-types', rule, {
25722680
line: 4,
25732681
column: 10
25742682
}]
2683+
}, {
2684+
code: [
2685+
'class Hello extends Component {',
2686+
' componentWillUpdate (nextProps) {',
2687+
' if (nextProps.foo) {',
2688+
' return true;',
2689+
' }',
2690+
' }',
2691+
'}',
2692+
'Hello.propTypes = {',
2693+
' foo: PropTypes.string,',
2694+
' bar: PropTypes.string,',
2695+
'};'
2696+
].join('\n'),
2697+
errors: [{
2698+
message: '\'bar\' PropType is defined but prop is never used',
2699+
line: 19,
2700+
column: 10
2701+
}]
25752702
}, {
25762703
code: [
25772704
'class Hello extends Component {',
@@ -2593,6 +2720,25 @@ ruleTester.run('no-unused-prop-types', rule, {
25932720
line: 4,
25942721
column: 10
25952722
}]
2723+
}, {
2724+
code: [
2725+
'class Hello extends Component {',
2726+
' shouldComponentUpdate (nextProps) {',
2727+
' if (nextProps.foo) {',
2728+
' return true;',
2729+
' }',
2730+
' }',
2731+
'}',
2732+
'Hello.propTypes = {',
2733+
' foo: PropTypes.string,',
2734+
' bar: PropTypes.string,',
2735+
'};'
2736+
].join('\n'),
2737+
errors: [{
2738+
message: '\'bar\' PropType is defined but prop is never used',
2739+
line: 19,
2740+
column: 10
2741+
}]
25962742
}, {
25972743
code: [
25982744
'class Hello extends Component {',
@@ -2614,6 +2760,25 @@ ruleTester.run('no-unused-prop-types', rule, {
26142760
line: 4,
26152761
column: 10
26162762
}]
2763+
}, {
2764+
code: [
2765+
'class Hello extends Component {',
2766+
' componentDidUpdate (nextProps) {',
2767+
' if (nextProps.foo) {',
2768+
' return true;',
2769+
' }',
2770+
' }',
2771+
'}',
2772+
'Hello.propTypes = {',
2773+
' foo: PropTypes.string,',
2774+
' bar: PropTypes.string,',
2775+
'};'
2776+
].join('\n'),
2777+
errors: [{
2778+
message: '\'bar\' PropType is defined but prop is never used',
2779+
line: 19,
2780+
column: 10
2781+
}]
26172782
}
26182783
/* , {
26192784
// Enable this when the following issue is fixed

0 commit comments

Comments
 (0)