-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Flow 0.53 support #1377
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Flow 0.53 support #1377
Changes from 5 commits
3e85c55
585b94a
f767f68
deb3b61
1a8af56
d232811
1ebfcee
a7957a1
18ad186
bb0a457
cd96ec9
6d1b7f1
a6d26d9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/** | ||
* @fileoverview Utility functions for Flow version configuration | ||
*/ | ||
'use strict'; | ||
|
||
function getFromContext(context) { | ||
let confVer = '999.999.999'; | ||
// .eslintrc shared settings (http://eslint.org/docs/user-guide/configuring#adding-shared-settings) | ||
if (context.settings.react && context.settings.react.flowVersion) { | ||
confVer = context.settings.react.flowVersion; | ||
} | ||
confVer = /^[0-9]+\.[0-9]+$/.test(confVer) ? `${confVer}.0` : confVer; | ||
return confVer.split('.').map(part => Number(part)); | ||
} | ||
|
||
function test(context, methodVer) { | ||
const confVer = getFromContext(context); | ||
methodVer = 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]; | ||
|
||
return higherMajor || higherMinor || higherOrEqualPatch; | ||
} | ||
|
||
module.exports = { | ||
test: test | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1486,6 +1486,7 @@ ruleTester.run('prop-types', rule, { | |
' }', | ||
'}' | ||
].join('\n'), | ||
settings: {react: {flowVersion: '0.52.0'}}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it better to have Or, is it better to make Or, should we leave as is -- where there is no default and users have to make a conscious choice which they want to pick? Any advice here @ljharb? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suppose it depends on the next BTW, the current default for React (and also in this PR for Flow) is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To be coherent with the React version we should default to the latest supported version. But currently a breaking change (or deprecation) in React means a new major version bump for the plugin. Are breaking changes a common thing in Flow ? (I'm afraid this will force us to bump the major version too often). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've been using Flow since around version 0.40 (about 3-4 months) and this is the first breaking change I've encountered so far. I wouldn't say that breaking changes like this are very common. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since we've checked this syntax in 0.52, it must be a breaking change to default to 0.53. My strong preference is to initially release a semver-minor with the default as 0.52, and then later release a semver-major that bumps the default to Flow latest. |
||
parser: 'babel-eslint' | ||
}, { | ||
code: [ | ||
|
@@ -1499,6 +1500,7 @@ ruleTester.run('prop-types', rule, { | |
' }', | ||
'}' | ||
].join('\n'), | ||
settings: {react: {flowVersion: '0.52.0'}}, | ||
parser: 'babel-eslint' | ||
}, { | ||
code: [ | ||
|
@@ -1514,6 +1516,7 @@ ruleTester.run('prop-types', rule, { | |
' }', | ||
'}' | ||
].join('\n'), | ||
settings: {react: {flowVersion: '0.52.0'}}, | ||
parser: 'babel-eslint' | ||
}, { | ||
code: [ | ||
|
@@ -1534,6 +1537,7 @@ ruleTester.run('prop-types', rule, { | |
' }', | ||
'}' | ||
].join('\n'), | ||
settings: {react: {flowVersion: '0.52.0'}}, | ||
parser: 'babel-eslint' | ||
}, { | ||
code: [ | ||
|
@@ -1546,6 +1550,7 @@ ruleTester.run('prop-types', rule, { | |
' }', | ||
'}' | ||
].join('\n'), | ||
settings: {react: {flowVersion: '0.52.0'}}, | ||
parser: 'babel-eslint' | ||
}, { | ||
code: [ | ||
|
@@ -1556,6 +1561,36 @@ ruleTester.run('prop-types', rule, { | |
' }', | ||
'}' | ||
].join('\n'), | ||
settings: {react: {flowVersion: '0.52.0'}}, | ||
parser: 'babel-eslint' | ||
}, | ||
{ | ||
code: ` | ||
type Props = { | ||
foo: string, | ||
}; | ||
|
||
class Bar extends React.Component<Props> { | ||
render() { | ||
return <div>{this.props.foo}</div> | ||
} | ||
} | ||
`, | ||
settings: {react: {flowVersion: '0.53.0'}}, | ||
parser: 'babel-eslint' | ||
}, { | ||
code: ` | ||
type FancyProps = { | ||
foo: string, | ||
}; | ||
|
||
class Bar extends React.Component<FancyProps> { | ||
render() { | ||
return <div>{this.props.foo}</div> | ||
} | ||
} | ||
`, | ||
settings: {react: {flowVersion: '0.53.0'}}, | ||
parser: 'babel-eslint' | ||
}, | ||
// issue #1288 | ||
|
@@ -2837,6 +2872,7 @@ ruleTester.run('prop-types', rule, { | |
column: 35, | ||
type: 'Identifier' | ||
}], | ||
settings: {react: {flowVersion: '0.52.0'}}, | ||
parser: 'babel-eslint' | ||
}, { | ||
code: [ | ||
|
@@ -2856,6 +2892,7 @@ ruleTester.run('prop-types', rule, { | |
column: 13, | ||
type: 'Property' | ||
}], | ||
settings: {react: {flowVersion: '0.52.0'}}, | ||
parser: 'babel-eslint' | ||
}, { | ||
code: [ | ||
|
@@ -2877,6 +2914,7 @@ ruleTester.run('prop-types', rule, { | |
column: 7, | ||
type: 'Property' | ||
}], | ||
settings: {react: {flowVersion: '0.52.0'}}, | ||
parser: 'babel-eslint' | ||
}, { | ||
code: [ | ||
|
@@ -2893,6 +2931,7 @@ ruleTester.run('prop-types', rule, { | |
column: 40, | ||
type: 'Identifier' | ||
}], | ||
settings: {react: {flowVersion: '0.52.0'}}, | ||
parser: 'babel-eslint' | ||
}, { | ||
code: [ | ||
|
@@ -2909,6 +2948,7 @@ ruleTester.run('prop-types', rule, { | |
column: 42, | ||
type: 'Identifier' | ||
}], | ||
settings: {react: {flowVersion: '0.52.0'}}, | ||
parser: 'babel-eslint' | ||
}, { | ||
code: [ | ||
|
@@ -2927,6 +2967,47 @@ ruleTester.run('prop-types', rule, { | |
column: 42, | ||
type: 'Identifier' | ||
}], | ||
settings: {react: {flowVersion: '0.52.0'}}, | ||
parser: 'babel-eslint' | ||
}, { | ||
code: ` | ||
type Props = { | ||
foo: string, | ||
}; | ||
|
||
class Bar extends React.Component<Props> { | ||
render() { | ||
return <div>{this.props.bar}</div> | ||
} | ||
} | ||
`, | ||
errors: [{ | ||
message: '\'bar\' is missing in props validation', | ||
line: 8, | ||
column: 37, | ||
type: 'Identifier' | ||
}], | ||
settings: {react: {flowVersion: '0.53.0'}}, | ||
parser: 'babel-eslint' | ||
}, { | ||
code: ` | ||
type FancyProps = { | ||
foo: string, | ||
}; | ||
|
||
class Bar extends React.Component<FancyProps> { | ||
render() { | ||
return <div>{this.props.bar}</div> | ||
} | ||
} | ||
`, | ||
errors: [{ | ||
message: '\'bar\' is missing in props validation', | ||
line: 8, | ||
column: 37, | ||
type: 'Identifier' | ||
}], | ||
settings: {react: {flowVersion: '0.53.0'}}, | ||
parser: 'babel-eslint' | ||
} | ||
] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please use
>= 0
here rather than relying on implicit truthiness checks