Skip to content

Commit e3c3a29

Browse files
committed
Merge branch 'master' into release
2 parents 616d131 + ccee583 commit e3c3a29

File tree

75 files changed

+1891
-729
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+1891
-729
lines changed

babel.config.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
module.exports = {
22
env: {
33
test: {
4-
presets: ['module:metro-react-native-babel-preset'],
5-
retainLines: true,
6-
},
4+
presets: ['module:metro-react-native-babel-preset']
5+
}
76
},
8-
presets: ['module:metro-react-native-babel-preset'],
9-
retainLines: true,
10-
plugins: ['transform-inline-environment-variables'],
7+
presets: ['module:metro-react-native-babel-preset']
118
};

demo/src/screens/MainScreen.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ class MainScreen extends Component {
113113
const filteredMenuSection = _.filter(menuSection.screens, menuItem => {
114114
const {title, description, tags} = menuItem;
115115
return (
116-
_.includes(_.lowerCase(title), _.toLower(filterText)) ||
116+
_.includes(_.toLower(title), _.toLower(filterText)) ||
117117
_.includes(_.toLower(description), _.toLower(filterText)) ||
118118
_.includes(_.toLower(tags), _.toLower(filterText))
119119
);
@@ -137,6 +137,7 @@ class MainScreen extends Component {
137137
<TextField
138138
ref={r => (this.input = r)}
139139
value={this.state.filterText}
140+
testID="uilib.search_for_component"
140141
placeholder="Search for your component..."
141142
onChangeText={this.filterExplorerScreens}
142143
onBlur={this.onSearchBoxBlur}
@@ -242,8 +243,8 @@ class MainScreen extends Component {
242243
{showResults && this.renderSearchResults(filteredNavigationData)}
243244

244245
{showCarousel && (
245-
<TabController asCarousel>
246-
<TabController.TabBar testID={'mainScreenTabBar'} items={_.map(data, section => ({label: section.title, testID: `section.${section.title}`}))}/>
246+
<TabController asCarousel items={_.map(data, section => ({label: section.title, testID: `section.${section.title}`}))}>
247+
<TabController.TabBar testID={'mainScreenTabBar'}/>
247248
{this.renderPages(data)}
248249
</TabController>
249250
)}

demo/src/screens/PlaygroundScreen.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,26 @@
11
import _ from 'lodash';
22
import React, {Component} from 'react';
33
import {StyleSheet} from 'react-native';
4-
import {View, Text, Card,} from 'react-native-ui-lib'; //eslint-disable-line
4+
import {View, Text, Card, TextField, Button} from 'react-native-ui-lib'; //eslint-disable-line
55

66
export default class PlaygroundScreen extends Component {
77
render() {
88
return (
9-
<View center bg-dark80 flex>
9+
<View bg-dark80 flex padding-20>
10+
<View marginT-20>
11+
<TextField placeholder="Placeholder" />
12+
</View>
1013
<Card height={100} center padding-20>
1114
<Text text50>Playground Screen</Text>
1215
</Card>
16+
<View flex center>
17+
<Button marginV-20 label="Button"/>
18+
</View>
1319
</View>
1420
);
1521
}
1622
}
1723

1824
const styles = StyleSheet.create({
19-
container: {}
25+
container: {},
2026
});

demo/src/screens/componentScreens/CheckboxScreen.js renamed to demo/src/screens/componentScreens/CheckboxScreen.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class CheckboxScreen extends Component {
1010
value4: true,
1111
value5: false
1212
};
13-
13+
1414
render() {
1515
return (
1616
<View useSafeArea flex>

demo/src/screens/componentScreens/DateTimePickerScreen.js

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,42 @@
11
import React, {Component} from 'react';
22
import {DateTimePicker, View, Text} from 'react-native-ui-lib'; // eslint-disable-line
33

4-
54
export default class DateTimePickerScreen extends Component {
6-
75
render() {
86
return (
9-
<View flex padding-20>
10-
<Text text40 marginB-40>Date Time Picker</Text>
11-
12-
<DateTimePicker
13-
title={'Date'}
14-
placeholder={'Select a date'}
7+
<View flex padding-s5>
8+
<Text text40>Date Time Picker</Text>
9+
<DateTimePicker
10+
containerStyle={{marginVertical: 20}}
11+
title={'Date'}
12+
placeholder={'Select a date'}
1513
// dateFormat={'MMM D, YYYY'}
16-
// value={new Date('October 13, 2014')}
14+
// value={new Date('October 13, 2014')}
1715
/>
18-
<DateTimePicker
19-
mode={'time'}
20-
title={'Time'}
16+
<DateTimePicker
17+
mode={'time'}
18+
title={'Time'}
2119
placeholder={'Select time'}
2220
// timeFormat={'h:mm A'}
2321
// value={new Date('2015-03-25T12:00:00-06:30')}
2422
/>
23+
24+
<Text text60R marginT-40>
25+
Disabled
26+
</Text>
27+
<DateTimePicker
28+
containerStyle={{marginBottom: 20}}
29+
editable={false}
30+
title={'Date'}
31+
placeholder={'Select a date'}
32+
/>
33+
<DateTimePicker
34+
editable={false}
35+
mode={'time'}
36+
title={'Time'}
37+
placeholder={'Select time'}
38+
value={new Date('2015-03-25T12:00:00-06:30')}
39+
/>
2540
</View>
2641
);
2742
}

demo/src/screens/componentScreens/FloatingButtonScreen.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,12 @@ export default class FloatingButtonScreen extends Component {
8383
visible={this.state.showButton}
8484
button={{
8585
label: 'Approve',
86-
onPress: this.close,
87-
labelStyle: {fontWeight: '400'}
86+
onPress: this.close
8887
}}
8988
secondaryButton={{
9089
label: 'Not now',
9190
onPress: this.notNow,
92-
color: Colors.red30,
93-
labelStyle: {fontWeight: '400'}
91+
color: Colors.red30
9492
}}
9593
// bottomMargin={80}
9694
// hideBackgroundOverlay

demo/src/screens/componentScreens/SwitchScreen.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class SwitchScreen extends Component {
1515
return (
1616
<View flex bottom padding-20>
1717
<View flex center>
18-
<Switch value={this.state.value1} onValueChange={value1 => this.setState({value1})} style={{marginBottom: 20}}/>
18+
<Switch testID="switch" value={this.state.value1} onValueChange={value1 => this.setState({value1})} style={{marginBottom: 20}}/>
1919
<Switch
2020
onColor={Colors.purple30}
2121
offColor={Colors.purple60}

demo/src/screens/componentScreens/TabControllerScreen/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,11 @@ class TabControllerScreen extends Component {
109109
key={key}
110110
asCarousel={asCarousel}
111111
selectedIndex={selectedIndex}
112-
onChangeIndex={this.onChangeIndex}
112+
onChangeIndex={this.onChangeIndex}
113+
items={items}
113114
>
114115
<TabController.TabBar
115-
items={items}
116+
// items={items}
116117
// key={key}
117118
// uppercase
118119
// indicatorStyle={{backgroundColor: 'green', height: 3}}

eslint-rules/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,15 @@ module.exports = {
55
'component-deprecation': require('./lib/rules/component-deprecation'),
66
'assets-deprecation': require('./lib/rules/assets-deprecation'),
77
'typography-deprecation': require('./lib/rules/typography-deprecation'),
8+
'function-deprecation': require('./lib/rules/function-deprecation'),
89
// for duplicate rules usage
910
'component-deprecation_warn': require('./lib/rules/component-deprecation'),
1011
'assets-deprecation_warn': require('./lib/rules/assets-deprecation'),
1112
'typography-deprecation_warn': require('./lib/rules/typography-deprecation'),
13+
'function-deprecation_warn': require('./lib/rules/function-deprecation'),
1214
'component-deprecation_error': require('./lib/rules/component-deprecation'),
1315
'assets-deprecation_error': require('./lib/rules/assets-deprecation'),
1416
'typography-deprecation_error': require('./lib/rules/typography-deprecation'),
17+
'function-deprecation_error': require('./lib/rules/function-deprecation'),
1518
},
1619
};

eslint-rules/lib/rules/assets-deprecation.js

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,43 @@ module.exports = {
4343
const {deprecations, source} = context.options[0];
4444
let localImportSpecifier;
4545

46-
function setLocalImportSpecifier(node) {
46+
function setLocalImportSpecifierFromImport(node) {
4747
localImportSpecifier = utils.getLocalImportSpecifier(node, source, defaultImportName);
4848
}
4949

50+
function setLocalImportSpecifierFromRequire(node) {
51+
if (node.init && node.init.callee && node.init.callee.name === 'require') {
52+
if (node.id && node.id.properties) {
53+
_.map(node.id.properties, property => {
54+
if (property.key && property.key.name === defaultImportName) {
55+
if (property.value && property.value.name) {
56+
localImportSpecifier = property.value.name;
57+
} else {
58+
localImportSpecifier = property.key.name;
59+
}
60+
}
61+
});
62+
}
63+
}
64+
}
65+
5066
function getAssetString(node, pathString = '') {
5167
if (node) {
5268
if (node.object) {
53-
if (node.property && node.property.name) {
54-
pathString = (pathString === '') ? `${node.property.name}` : `${node.property.name}.${pathString}`;
55-
return getAssetString(node.object, pathString);
69+
if (node.property) {
70+
let name;
71+
if (node.property.type === 'Identifier' && node.property.name) {
72+
name = node.property.name;
73+
} else if (node.property.type === 'Literal' && node.property.value) {
74+
name = node.property.value;
75+
} else if (node.property.type === 'CallExpression' && node.property.callee && node.property.callee.name) {
76+
// TODO: ¯\_(ツ)_/¯
77+
}
78+
79+
if (name) {
80+
pathString = (pathString === '') ? `${name}` : `${name}.${pathString}`;
81+
return getAssetString(node.object, pathString);
82+
}
5683
}
5784
} else if (node.name === localImportSpecifier) {
5885
pathString = `${node.name}.${pathString}`;
@@ -79,11 +106,12 @@ module.exports = {
79106
}
80107

81108
return {
82-
ImportDeclaration: node => !localImportSpecifier && setLocalImportSpecifier(node),
109+
ImportDeclaration: node => !localImportSpecifier && setLocalImportSpecifierFromImport(node),
110+
VariableDeclarator: node => !localImportSpecifier && setLocalImportSpecifierFromRequire(node),
83111
MemberExpression: node => localImportSpecifier && testMemberDeprecation(node),
84112

85-
86-
// VariableDeclarator: node => testVariableDeclarator(node),
113+
// ExpressionStatement: node => testExpressionStatement(node),
114+
// AssignmentExpression: node => testAssignmentExpression(node),
87115
// JSXAttribute: node => testJSXAttribute(node),
88116
// JSXOpeningElement: node => testJSXOpeningElement(node),
89117
// JSXSpreadAttribute: node => testJSXSpreadAttribute(node),

eslint-rules/lib/rules/component-deprecation.js

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ module.exports = {
1919
recommended: true,
2020
},
2121
messages: {
22-
uiLib: 'This component is deprecated or containes deprecated props.',
22+
uiLib: 'This component is deprecated or contains deprecated props.',
2323
},
2424
fixable: 'code',
2525
schema: [MAP_SCHEMA],
@@ -48,7 +48,7 @@ module.exports = {
4848
return fixer.replaceText(node.name, fix);
4949
case FIX_TYPES.COMPONENT_NAME:
5050
if (node.type === 'ImportDeclaration') {
51-
const index = getSpecifierIndex(node, options.name);
51+
const index = utils.getSpecifierIndex(node, options.name);
5252
return fixer.replaceText(node.specifiers[index], fix);
5353
}
5454
return fixer.replaceText(node.name, fix);
@@ -63,19 +63,6 @@ module.exports = {
6363
}
6464
}
6565

66-
function getSpecifierIndex(node, name) {
67-
let matchIndex;
68-
if (node && node.specifiers) {
69-
_.forEach(node.specifiers, (s, index) => {
70-
const x = _.get(s, 'imported.name');
71-
if (x === name) {
72-
matchIndex = index;
73-
}
74-
});
75-
}
76-
return matchIndex;
77-
}
78-
7966
function checkPropDeprecation(node, propName, deprecatedPropList, componentName) {
8067
const deprecatedProp = _.find(deprecatedPropList, {prop: propName});
8168
if (deprecatedProp) {

0 commit comments

Comments
 (0)