Skip to content

Commit

Permalink
[Fix] add an additional fix for jsx-eslint#1785, and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed May 11, 2018
1 parent 48f2831 commit e57ca07
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/util/version.js
Expand Up @@ -27,7 +27,7 @@ function getFlowVersionFromContext(context) {
}

function test(context, methodVer, confVer) {
methodVer = methodVer.split('.').map(part => Number(part));
methodVer = String(methodVer || '').split('.').map(part => Number(part));
const higherMajor = methodVer[0] < confVer[0];
const higherMinor = methodVer[0] === confVer[0] && methodVer[1] < confVer[1];
const higherOrEqualPatch = methodVer[0] === confVer[0] && methodVer[1] === confVer[1] && methodVer[2] <= confVer[2];
Expand Down
30 changes: 30 additions & 0 deletions tests/lib/rules/no-deprecated.js
Expand Up @@ -75,6 +75,7 @@ ruleTester.run('no-deprecated', rule, {
{
code: `
class Foo {
constructor() {}
componentWillMount() {}
componentWillReceiveProps() {}
componentWillUpdate() {}
Expand Down Expand Up @@ -379,6 +380,35 @@ ruleTester.run('no-deprecated', rule, {
)
}
]
},
{
code: `
class Foo extends React.Component {
constructor() {}
componentWillMount() {}
componentWillReceiveProps() {}
componentWillUpdate() {}
}
`,
errors: [
{
message: errorMessage(
'componentWillMount', '16.3.0', 'UNSAFE_componentWillMount',
'https://reactjs.org/docs/react-component.html#unsafe_componentwillmount'
)
},
{
message: errorMessage(
'componentWillReceiveProps', '16.3.0', 'UNSAFE_componentWillReceiveProps',
'https://reactjs.org/docs/react-component.html#unsafe_componentwillreceiveprops'
)
},
{
message: errorMessage('componentWillUpdate', '16.3.0', 'UNSAFE_componentWillUpdate',
'https://reactjs.org/docs/react-component.html#unsafe_componentwillupdate'
)
}
]
}
]
});

0 comments on commit e57ca07

Please sign in to comment.