Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"type": "prerelease",
"comment": "Get flow clean, and turn on flow check during build",
"packageName": "react-native-windows",
"email": "[email protected]",
"commit": "52941d364d05f4608f9b0266c287e53cd904522f",
"date": "2019-12-06T01:31:34.909Z"
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"build": "lerna run build --stream -- --color",
"buildci": "lerna run build --stream -- --ci",
"change": "beachball change",
"clean": "lerna run clean --stream",
"clean": "lerna run clean --stream -- --color",
"format": "node packages/scripts/formatFiles.js -i -style=file -assume-filename=../.clang-format",
"format:verify": "node packages/scripts/formatFiles.js -i -style=file -assume-filename=../.clang-format -verify"
},
Expand Down
1 change: 1 addition & 0 deletions vnext/.eslintignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/dist
/flow
/lib
/Libraries
/local-cli/generator-windows/templates/index.windows.js
Expand Down
158 changes: 158 additions & 0 deletions vnext/.flowconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
[ignore]
; We fork some components by platform - ignore all platforms except windows
.*/*[.]android.js
.*/*[.]ios.js
.*/*[.]macos.js
.*/*[.]windesktop.js

; These modules have base components and windows versions.
; Ideally we'd delete the base versions of files that had .windows overrides as part of the
; initRNLibraries build step
<PROJECT_ROOT>/Libraries/Alert/Alert.js
<PROJECT_ROOT>/Libraries/AppTheme/AppTheme.js
<PROJECT_ROOT>/Libraries/Components/Button.js
<PROJECT_ROOT>/Libraries/Components/DatePicker/DatePicker.js
<PROJECT_ROOT>/Libraries/Components/Flyout/Flyout.js
<PROJECT_ROOT>/Libraries/Components/Glyph/Glyph.js
<PROJECT_ROOT>/Libraries/Components/Keyboard/KeyboardExt.js
<PROJECT_ROOT>/Libraries/Components/Picker/Picker.js
<PROJECT_ROOT>/Libraries/Components/Picker/PickerWindows.js
<PROJECT_ROOT>/Libraries/Components/Popup/Popup.js
<PROJECT_ROOT>/Libraries/Components/RefreshControl/RefreshControl.js
<PROJECT_ROOT>/Libraries/Components/SafeAreaView/SafeAreaView.js
<PROJECT_ROOT>/Libraries/Components/ScrollView/ScrollView.js
<PROJECT_ROOT>/Libraries/Components/Switch/Switch.js
<PROJECT_ROOT>/Libraries/Components/TextInput/TextInput.js
<PROJECT_ROOT>/Libraries/Components/TextInput/TextInputState.js
<PROJECT_ROOT>/Libraries/Components/Touchable/TouchableHighlight.js
<PROJECT_ROOT>/Libraries/Components/Touchable/TouchableNativeFeedback.js
<PROJECT_ROOT>/Libraries/Components/Touchable/TouchableOpacity.js
<PROJECT_ROOT>/Libraries/Components/Touchable/TouchableWithoutFeedback.js
<PROJECT_ROOT>/Libraries/Components/View/ViewAccessibility.js
<PROJECT_ROOT>/Libraries/Components/View/ViewPropTypes.js
<PROJECT_ROOT>/Libraries/DeprecatedPropTypes/DeprecatedViewAccessibility.js
<PROJECT_ROOT>/Libraries/Image/Image.js
<PROJECT_ROOT>/Libraries/Linking/NativeLinking.js
<PROJECT_ROOT>/Libraries/Network/RCTNetworking.js
<PROJECT_ROOT>/Libraries/NewAppScreen/components/DebugInstructions.js
<PROJECT_ROOT>/Libraries/NewAppScreen/components/ReloadInstructions.js
<PROJECT_ROOT>/Libraries/Utilities/Dimensions.js



; Ignore react-native files in node_modules since they are copied into project root
.*/node_modules/react-native/.*

; Ignore templates for 'react-native init'
<PROJECT_ROOT>/template/.*

; Ignore the Dangerfile
<PROJECT_ROOT>/bots/dangerfile.js

; Ignore "BUCK" generated dirs
<PROJECT_ROOT>/\.buckd/

; Ignore unexpected extra "@providesModule"
.*/node_modules/.*/node_modules/fbjs/.*

; Ignore duplicate module providers
; For RN Apps installed via npm, "Libraries" folder is inside
; "node_modules/react-native" but in the source repo it is in the root
.*/Libraries/react-native/React.js

; Ignore polyfills
.*/Libraries/polyfills/.*

; These should not be required directly
; require from fbjs/lib instead: require('fbjs/lib/warning')
.*/node_modules/warning/.*

; Flow doesn't support platforms
.*/Libraries/Utilities/HMRLoadingView.js

; Ignore the src folder - flow files are combined with ones from react-native into the root Libraries folder
.*/vnext/src/.*

[untyped]
.*/node_modules/@react-native-community/cli/.*/.*

[include]
; Need to include hoisted modules
../node_modules/

[libs]
Libraries/react-native/react-native-interface.js
flow/

[options]
emoji=true

esproposal.optional_chaining=enable
esproposal.nullish_coalescing=enable

module.file_ext=.js
module.file_ext=.json
module.file_ext=.windows.js

module.system=haste
module.system.haste.use_name_reducers=true
# keep the following in sync with server/haste/hasteImpl.js
# get basename
module.system.haste.name_reducers='^.*/\([a-zA-Z0-9$_.-]+\.js\(\.flow\)?\)$' -> '\1'
# strip .js or .js.flow suffix
module.system.haste.name_reducers='^\(.*\)\.js\(\.flow\)?$' -> '\1'
# strip .ios suffix
module.system.haste.name_reducers='^\(.*\)\.ios$' -> '\1'
module.system.haste.name_reducers='^\(.*\)\.macos$' -> '\1'
module.system.haste.name_reducers='^\(.*\)\.android$' -> '\1'
module.system.haste.name_reducers='^\(.*\)\.windows$' -> '\1'
module.system.haste.name_reducers='^\(.*\)\.windesktop$' -> '\1'
module.system.haste.name_reducers='^\(.*\)\.native$' -> '\1'
module.system.haste.paths.blacklist=<PROJECT_ROOT>/src/.*
module.system.haste.paths.blacklist=.*/__tests__/.*
module.system.haste.paths.blacklist=.*/__mocks__/.*
module.system.haste.paths.whitelist=<PROJECT_ROOT>/Libraries/.*
module.system.haste.paths.whitelist=<PROJECT_ROOT>/RNTester/.*
module.system.haste.paths.whitelist=<PROJECT_ROOT>/IntegrationTests/.*
module.system.haste.paths.blacklist=<PROJECT_ROOT>/Libraries/react-native/react-native-implementation.js
module.system.haste.paths.blacklist=<PROJECT_ROOT>/Libraries/Animated/src/polyfills/.*

munge_underscores=true

module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub'
module.name_mapper='react-native$' -> '<PROJECT_ROOT>/Libraries/react-native/react-native-implementation.js'
module.name_mapper='react-native/\(.*\)' -> '<PROJECT_ROOT>/\1'

suppress_type=$FlowIssue
suppress_type=$FlowFixMe
suppress_type=$FlowFixMeProps
suppress_type=$FlowFixMeState

suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\)
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\)?:? #[0-9]+
suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError

[lints]
sketchy-null-number=warn
sketchy-null-mixed=warn
sketchy-number=warn
untyped-type-import=warn
nonstrict-import=warn
deprecated-type=warn
unsafe-getters-setters=warn
inexact-spread=warn
unnecessary-invariant=warn
signature-verification-failure=warn
deprecated-utility=error

[strict]
deprecated-type
nonstrict-import
sketchy-null
unclear-type
unsafe-getters-setters
untyped-import
untyped-type-import

[version]
^0.98.0
2 changes: 2 additions & 0 deletions vnext/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ node_modules
.nvm
/bots/node_modules/

/flow
/flow-typed
/dist
/IntegrationTests/*.js
/IntegrationTests/*.png
Expand Down
4 changes: 2 additions & 2 deletions vnext/CHANGELOG.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
{
"comment": "fix TextInput and Switch component colors",
"author": "[email protected]",
"commit": "ab50b2508092d9faa2b796821dfbbf0f0847ed
"commit": "ab50b2508092d9faa2b796821dfbbf0f0847ed"
}
]
}
Expand Down Expand Up @@ -2734,4 +2734,4 @@
}
}
]
}
}
4 changes: 0 additions & 4 deletions vnext/IntegrationTests/XHRTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,6 @@ class XHRTest extends React.Component<{}, Object> {
}
xhr.onload = () => {
this.setState({downloading: false});
if (this.cancelled) {
this.cancelled = false;
return;
}
if (xhr.status === 200) {
let responseType = `Response is a string, ${
xhr.response.length
Expand Down
31 changes: 31 additions & 0 deletions vnext/Scripts/copyRNLibraries.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ function copyJSFolderRecursiveSync(source, target) {
exports.copyRNLibraries = () => {
const rnPath = path.dirname(require.resolve('react-native/package.json'));

const rnCodeGenDest = path.resolve(
__dirname,
'../packages/react-native-codegen',
);
if (fs.existsSync(rnCodeGenDest)) {
rimraf.sync(rnCodeGenDest);
}
const integrationTestsDest = path.resolve(__dirname, '../IntegrationTests');
if (fs.existsSync(integrationTestsDest)) {
rimraf.sync(integrationTestsDest + path.sep + '*.js');
Expand All @@ -59,6 +66,14 @@ exports.copyRNLibraries = () => {
if (fs.existsSync(librariesDest)) {
rimraf.sync(librariesDest);
}
const flowDest = path.resolve(__dirname, '../flow');
if (fs.existsSync(flowDest)) {
rimraf.sync(flowDest);
}
const flowTypedDest = path.resolve(__dirname, '../flow-typed');
if (fs.existsSync(flowTypedDest)) {
rimraf.sync(flowTypedDest);
}
const jestDest = path.resolve(__dirname, '../jest');
if (fs.existsSync(jestDest)) {
rimraf.sync(jestDest);
Expand All @@ -74,6 +89,22 @@ exports.copyRNLibraries = () => {
baseDir,
);
}

if (!fs.existsSync(path.resolve(__dirname, '../packages'))) {
fs.mkdirSync(path.resolve(__dirname, '../packages'));
}
if (
!fs.existsSync(path.resolve(__dirname, '../packages/react-native-codegen'))
) {
fs.mkdirSync(path.resolve(__dirname, '../packages/react-native-codegen'));
}

copyJSFolderRecursiveSync(
path.resolve(rnPath, 'packages/react-native-codegen/src'),
path.resolve(baseDir, 'packages/react-native-codegen'),
);
copyJSFolderRecursiveSync(path.resolve(rnPath, 'flow'), baseDir);
copyJSFolderRecursiveSync(path.resolve(rnPath, 'flow-typed'), baseDir);
copyJSFolderRecursiveSync(path.resolve(rnPath, 'Libraries'), baseDir);
copyJSFolderRecursiveSync(path.resolve(rnPath, 'jest'), baseDir);
copyJSFolderRecursiveSync(path.resolve(baseDir, 'src/jest'), baseDir); // Copy js files from src/jest to jest
Expand Down
9 changes: 7 additions & 2 deletions vnext/just-task.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ task('apiDocumenter', () => {
);
});

task('flow-check', () => {
require('child_process').execSync('npx flow check', {stdio: 'inherit'});
});

task('eslint', () => {
return eslintTask();
});
Expand All @@ -59,8 +63,8 @@ task('ts', () => {
});
task('clean', () => {
return cleanTask(
['jest', 'Libraries', 'RNTester', 'lib'].map(p =>
path.join(process.cwd(), p),
['dist', 'flow', 'flow-typed', 'jest', 'Libraries', 'RNTester', 'lib'].map(
p => path.join(process.cwd(), p),
),
);
});
Expand All @@ -73,6 +77,7 @@ task(
'initRNLibraries',
'copyFlowFiles',
'ts',
'flow-check',
condition('apiExtractorVerify', () => argv().ci),
'apiExtractorUpdate',
'apiDocumenter',
Expand Down
3 changes: 3 additions & 0 deletions vnext/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"build": "just-scripts build",
"change": "beachball change",
"clean": "just-scripts clean",
"flow-check": "flow check",
"start": "react-native start",
"lint": "just-scripts eslint",
"lint:fix": "eslint ./**/*.js ./**/*.ts? --fix",
Expand Down Expand Up @@ -46,6 +47,8 @@
"@types/react": "16.8.15",
"eslint-plugin-prettier": "2.6.2",
"eslint": "5.1.0",
"flow-bin": "^0.98.0",
"jscodeshift": "^0.6.2",
"just-scripts": "^0.24.2",
"prettier": "1.17.0",
"react-native": "https://github.com/microsoft/react-native/archive/v0.60.0-microsoft.24.tar.gz",
Expand Down
4 changes: 0 additions & 4 deletions vnext/src/IntegrationTests/XHRTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,6 @@ class XHRTest extends React.Component<{}, Object> {
}
xhr.onload = () => {
this.setState({downloading: false});
if (this.cancelled) {
this.cancelled = false;
return;
}
if (xhr.status === 200) {
let responseType = `Response is a string, ${
xhr.response.length
Expand Down
Loading