mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-14 12:11:47 +08:00
Summary: There were approximately 350 unused suppressions in xplat/js when checking with .flowconfig.android The flow team is partially responsible for this, since our release process hasn't changed since we added the flowconfig. In the diff beneath this one, I added the functionality necessary for us to not add any more unused suppressions. To test it, I made this diff. The steps were: 1. Start iOS server 2. Start android server 3. remove unused ios suppressions 4. remove unused android suppressions 5. add ios suppressions with site=react_native_ios_fb 6. add android suppressions with site=react_native_android_fb 7. remove unused ios suppressions. The ones that are unused are ones where an android comment was inserted as well, since the ios comment no longer is next to the error 8. add suppressions using ios flowconfig with site=react_native_fb 9. remove unused android suppressions. The unused ones are ones that were moved up when the cross-platform suppressions were inserted. I'm going to make this into a script to make sure we don't contribute anymore unused suppressions from our side. The controller you requested could not be found. nolint Reviewed By: TheSavior Differential Revision: D10053893 fbshipit-source-id: 7bee212062f8b2153c6ba906a30cf40df2224019
149 lines
3.9 KiB
JavaScript
149 lines
3.9 KiB
JavaScript
/**
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
* @format
|
|
* @flow
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
const BoxInspector = require('BoxInspector');
|
|
const React = require('React');
|
|
const StyleInspector = require('StyleInspector');
|
|
const StyleSheet = require('StyleSheet');
|
|
const Text = require('Text');
|
|
const TouchableHighlight = require('TouchableHighlight');
|
|
const TouchableWithoutFeedback = require('TouchableWithoutFeedback');
|
|
const View = require('View');
|
|
|
|
const flattenStyle = require('flattenStyle');
|
|
const mapWithSeparator = require('mapWithSeparator');
|
|
const openFileInEditor = require('openFileInEditor');
|
|
|
|
import type {ViewStyleProp} from 'StyleSheet';
|
|
|
|
type Props = $ReadOnly<{|
|
|
hierarchy: Array<$FlowFixMe>,
|
|
style?: ?ViewStyleProp,
|
|
source?: ?{
|
|
fileName?: string,
|
|
lineNumber?: number,
|
|
},
|
|
frame?: ?Object,
|
|
selection?: ?number,
|
|
setSelection?: (number) => mixed,
|
|
|}>;
|
|
|
|
class ElementProperties extends React.Component<Props> {
|
|
render() {
|
|
const style = flattenStyle(this.props.style);
|
|
const selection = this.props.selection;
|
|
let openFileButton;
|
|
const source = this.props.source;
|
|
const {fileName, lineNumber} = source || {};
|
|
if (fileName && lineNumber) {
|
|
const parts = fileName.split('/');
|
|
const fileNameShort = parts[parts.length - 1];
|
|
openFileButton = (
|
|
<TouchableHighlight
|
|
style={styles.openButton}
|
|
onPress={openFileInEditor.bind(null, fileName, lineNumber)}>
|
|
<Text style={styles.openButtonTitle} numberOfLines={1}>
|
|
{fileNameShort}:{lineNumber}
|
|
</Text>
|
|
</TouchableHighlight>
|
|
);
|
|
}
|
|
// Without the `TouchableWithoutFeedback`, taps on this inspector pane
|
|
// would change the inspected element to whatever is under the inspector
|
|
return (
|
|
<TouchableWithoutFeedback>
|
|
<View style={styles.info}>
|
|
<View style={styles.breadcrumb}>
|
|
{mapWithSeparator(
|
|
this.props.hierarchy,
|
|
(hierarchyItem, i) => (
|
|
<TouchableHighlight
|
|
key={'item-' + i}
|
|
style={[styles.breadItem, i === selection && styles.selected]}
|
|
// $FlowFixMe found when converting React.createClass to ES6
|
|
onPress={() => this.props.setSelection(i)}>
|
|
<Text style={styles.breadItemText}>{hierarchyItem.name}</Text>
|
|
</TouchableHighlight>
|
|
),
|
|
i => (
|
|
<Text key={'sep-' + i} style={styles.breadSep}>
|
|
▸
|
|
</Text>
|
|
),
|
|
)}
|
|
</View>
|
|
<View style={styles.row}>
|
|
<View style={styles.col}>
|
|
<StyleInspector style={style} />
|
|
{openFileButton}
|
|
</View>
|
|
{
|
|
<BoxInspector style={style} frame={this.props.frame} />
|
|
}
|
|
</View>
|
|
</View>
|
|
</TouchableWithoutFeedback>
|
|
);
|
|
}
|
|
}
|
|
|
|
const styles = StyleSheet.create({
|
|
breadSep: {
|
|
fontSize: 8,
|
|
color: 'white',
|
|
},
|
|
breadcrumb: {
|
|
flexDirection: 'row',
|
|
flexWrap: 'wrap',
|
|
alignItems: 'flex-start',
|
|
marginBottom: 5,
|
|
},
|
|
selected: {
|
|
borderColor: 'white',
|
|
borderRadius: 5,
|
|
},
|
|
breadItem: {
|
|
borderWidth: 1,
|
|
borderColor: 'transparent',
|
|
marginHorizontal: 2,
|
|
},
|
|
breadItemText: {
|
|
fontSize: 10,
|
|
color: 'white',
|
|
marginHorizontal: 5,
|
|
},
|
|
row: {
|
|
flexDirection: 'row',
|
|
alignItems: 'center',
|
|
justifyContent: 'space-between',
|
|
},
|
|
col: {
|
|
flex: 1,
|
|
},
|
|
info: {
|
|
padding: 10,
|
|
},
|
|
openButton: {
|
|
padding: 10,
|
|
backgroundColor: '#000',
|
|
marginVertical: 5,
|
|
marginRight: 5,
|
|
borderRadius: 2,
|
|
},
|
|
openButtonTitle: {
|
|
color: 'white',
|
|
fontSize: 8,
|
|
},
|
|
});
|
|
|
|
module.exports = ElementProperties;
|