Skip to content

Commit

Permalink
refactor: update prettier to 2.0.5 and refactor the whole project for it
Browse files Browse the repository at this point in the history
  • Loading branch information
BatDroid authored and satya164 committed Jun 29, 2020
1 parent 9b74586 commit 78a33b7
Show file tree
Hide file tree
Showing 79 changed files with 200 additions and 348 deletions.
2 changes: 1 addition & 1 deletion docs/assets/snack.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function appendSnackLink() {

appendSnackLink();

var mutationObserver = new MutationObserver(mutations => {
var mutationObserver = new MutationObserver((mutations) => {
mutations.forEach(appendSnackLink);
});

Expand Down
2 changes: 1 addition & 1 deletion docs/assets/version.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ function appendVersionBanner() {

appendVersionBanner();

var mutationObserver = new MutationObserver(mutations => {
var mutationObserver = new MutationObserver((mutations) => {
mutations.forEach(appendVersionBanner);
});

Expand Down
34 changes: 10 additions & 24 deletions docs/component-docs.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,25 +39,17 @@ function getPages() {
.readFileSync(path.join(__dirname, '../src/index.tsx'))
.toString()
.split('\n')
.map(line =>
line
.split(' ')
.pop()
.replace(/('|;)/g, '')
)
.filter(line => line.startsWith('./components/'))
.map(line => {
.map((line) => line.split(' ').pop().replace(/('|;)/g, ''))
.filter((line) => line.startsWith('./components/'))
.map((line) => {
const file = require.resolve(path.join(__dirname, '../src', line));
if (/\/index\.(js|tsx?)$/.test(file)) {
const matches = fs
.readFileSync(file)
.toString()
.match(/export \{ default \} from .+/);
if (matches && matches.length) {
const name = matches[0]
.split(' ')
.pop()
.replace(/('|;)/g, '');
const name = matches[0].split(' ').pop().replace(/('|;)/g, '');
return require.resolve(path.join(__dirname, '../src', line, name));
}
}
Expand All @@ -75,18 +67,12 @@ function getPages() {
const match = content.match(/\/\/ @component (.\/\w+\.(js|tsx?))/gm);

if (match && match.length) {
const componentFiles = match.map(line => {
const componentFiles = match.map((line) => {
const fileName = line.split(' ')[2];
return {
group,
file: require.resolve(
path.join(
file
.split('/')
.slice(0, -1)
.join('/'),
fileName
)
path.join(file.split('/').slice(0, -1).join('/'), fileName)
),
};
});
Expand All @@ -98,7 +84,7 @@ function getPages() {
}, [])
.filter(
(info, index, self) =>
index === self.findIndex(other => info.file === other.file)
index === self.findIndex((other) => info.file === other.file)
)
.sort((a, b) => {
const nameA = a.file.split('/').pop();
Expand All @@ -110,12 +96,12 @@ function getPages() {
const nameB = (b.group || b.file).split('/').pop();
return nameA.localeCompare(nameB);
})
.map(info => ({ ...info, type: 'component' }));
.map((info) => ({ ...info, type: 'component' }));

const docs = fs
.readdirSync(path.join(__dirname, 'pages'))
.filter(file => file.includes('.'))
.map(file => ({
.filter((file) => file.includes('.'))
.map((file) => ({
file: path.join(__dirname, 'pages', file),
type: getType(file),
}));
Expand Down
2 changes: 1 addition & 1 deletion docs/pages/src/Showcase.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export default class Showcase extends React.Component<{}> {
to add your app to this list.
</p>
<Gallery>
{data.map(item => {
{data.map((item) => {
const tintColor = color(item.color).isLight()
? '#000000'
: '#FFFFFF';
Expand Down
4 changes: 2 additions & 2 deletions docs/pages/src/components/IconsList.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default class IconsList extends React.Component<{}, State> {
const query = this.state.query.toLowerCase();

return iconNames.filter(
item =>
(item) =>
item.includes(query.replace(/\s/g, '-')) ||
item.replace(/-/g, '').includes(query)
);
Expand Down Expand Up @@ -54,7 +54,7 @@ export default class IconsList extends React.Component<{}, State> {
/>
{searchResults.length ? (
<Results>
{searchResults.map(name => (
{searchResults.map((name) => (
<IconContainer
key={name}
type="button"
Expand Down
2 changes: 1 addition & 1 deletion example/babel.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const path = require('path');
const pak = require('../package.json');

module.exports = function(api) {
module.exports = function (api) {
api.cache(true);

return {
Expand Down
3 changes: 2 additions & 1 deletion example/metro.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ module.exports = {
resolver: {
blacklistRE: blacklist(
modules.map(
m => new RegExp(`^${escape(path.join(root, 'node_modules', m))}\\/.*$`)
(m) =>
new RegExp(`^${escape(path.join(root, 'node_modules', m))}\\/.*$`)
)
),

Expand Down
2 changes: 1 addition & 1 deletion example/src/Examples/BadgeExample.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const BadgeExample = () => {
<Paragraph style={styles.label}>Show badges</Paragraph>
<Switch
value={visible}
onValueChange={visible => setVisible(visible)}
onValueChange={(visible) => setVisible(visible)}
/>
</View>
<List.Section title="Text">
Expand Down
2 changes: 1 addition & 1 deletion example/src/Examples/BannerExample.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const BannerExample = () => {
on mobile.
</Banner>
<View style={styles.grid}>
{PHOTOS.map(uri => (
{PHOTOS.map((uri) => (
<View key={uri} style={styles.item}>
<Image source={{ uri }} style={styles.photo} />
</View>
Expand Down
2 changes: 1 addition & 1 deletion example/src/Examples/BottomNavigationExample.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const PhotoGallery = ({ route }: Route) => {

return (
<ScrollView contentContainerStyle={styles.content}>
{PHOTOS.map(uri => (
{PHOTOS.map((uri) => (
<View key={uri} style={styles.item}>
<Image source={{ uri }} style={styles.photo} />
</View>
Expand Down
2 changes: 1 addition & 1 deletion example/src/Examples/CardExample.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ const CardExample = () => {
<Card.Cover source={require('../../assets/images/city.jpg')} />
<Card.Title
title="Long Pressable City"
left={props => <Avatar.Icon {...props} icon="city" />}
left={(props) => <Avatar.Icon {...props} icon="city" />}
/>
<Card.Content>
<Paragraph>
Expand Down
8 changes: 3 additions & 5 deletions example/src/Examples/DataTableExample.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,7 @@ const DataTableExample = () => {
const sortedItems = items
.slice()
.sort((item1, item2) =>
(sortAscending
? item1.name < item2.name
: item2.name < item1.name)
(sortAscending ? item1.name < item2.name : item2.name < item1.name)
? 1
: -1
);
Expand All @@ -85,7 +83,7 @@ const DataTableExample = () => {
<DataTable.Title numeric>Fat (g)</DataTable.Title>
</DataTable.Header>

{sortedItems.slice(from, to).map(item => (
{sortedItems.slice(from, to).map((item) => (
<DataTable.Row key={item.key}>
<DataTable.Cell style={styles.first}>{item.name}</DataTable.Cell>
<DataTable.Cell numeric>{item.calories}</DataTable.Cell>
Expand All @@ -96,7 +94,7 @@ const DataTableExample = () => {
<DataTable.Pagination
page={page}
numberOfPages={Math.floor(sortedItems.length / itemsPerPage)}
onPageChange={page => setPage(page)}
onPageChange={(page) => setPage(page)}
label={`${from + 1}-${to} of ${sortedItems.length}`}
/>
</DataTable>
Expand Down
2 changes: 1 addition & 1 deletion example/src/Examples/DividerExample.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const DividerExample = () => {
<FlatList
style={{ backgroundColor: background }}
renderItem={({ item }) => <List.Item title={item} />}
keyExtractor={item => item}
keyExtractor={(item) => item}
ItemSeparatorComponent={Divider}
data={items}
/>
Expand Down
10 changes: 5 additions & 5 deletions example/src/Examples/ListAccordionExample.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ const ListAccordionExample = () => {
<ScrollView style={[styles.container, { backgroundColor: background }]}>
<List.Section title="Expandable list item">
<List.Accordion
left={props => <List.Icon {...props} icon="folder" />}
left={(props) => <List.Icon {...props} icon="folder" />}
title="Expandable list item"
>
<List.Item title="List item 1" />
<List.Item title="List item 2" />
</List.Accordion>
<List.Accordion
left={props => <List.Icon {...props} icon="folder" />}
left={(props) => <List.Icon {...props} icon="folder" />}
title="Start expanded"
expanded={expanded}
onPress={_handlePress}
Expand All @@ -45,15 +45,15 @@ const ListAccordionExample = () => {
<Divider />
<List.Section title="Expandable list with icons">
<List.Accordion
left={props => <List.Icon {...props} icon="star" />}
left={(props) => <List.Icon {...props} icon="star" />}
title="Accordion item 1"
>
<List.Item
left={props => <List.Icon {...props} icon="thumb-up" />}
left={(props) => <List.Icon {...props} icon="thumb-up" />}
title="List item 1"
/>
<List.Item
left={props => <List.Icon {...props} icon="thumb-down" />}
left={(props) => <List.Icon {...props} icon="thumb-down" />}
title="List item 2"
/>
</List.Accordion>
Expand Down
12 changes: 6 additions & 6 deletions example/src/Examples/ListAccordionGroupExample.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,22 @@ const ListAccordionGroupExample = () => {
<List.AccordionGroup>
<List.Section title="Uncontrolled Accordion Group example">
<List.Accordion
left={props => <List.Icon {...props} icon="folder" />}
left={(props) => <List.Icon {...props} icon="folder" />}
title="Expandable list item"
id="1"
>
<List.Item title="List item 1" />
<List.Item title="List item 2" />
</List.Accordion>
<List.Accordion
left={props => <List.Icon {...props} icon="folder" />}
left={(props) => <List.Icon {...props} icon="folder" />}
title="Expandable list item 2"
id="2"
>
<List.Item title="List item 1" />
</List.Accordion>
<List.Accordion
left={props => <List.Icon {...props} icon="folder" />}
left={(props) => <List.Icon {...props} icon="folder" />}
title="Expandable list item 2"
id="3"
>
Expand All @@ -50,22 +50,22 @@ const ListAccordionGroupExample = () => {
>
<List.Section title="Controlled Accordion Group example">
<List.Accordion
left={props => <List.Icon {...props} icon="folder" />}
left={(props) => <List.Icon {...props} icon="folder" />}
title="Expandable list item"
id="1"
>
<List.Item title="List item 1" />
<List.Item title="List item 2" />
</List.Accordion>
<List.Accordion
left={props => <List.Icon {...props} icon="folder" />}
left={(props) => <List.Icon {...props} icon="folder" />}
title="Expandable list item 2"
id="2"
>
<List.Item title="List item 1" />
</List.Accordion>
<List.Accordion
left={props => <List.Icon {...props} icon="folder" />}
left={(props) => <List.Icon {...props} icon="folder" />}
title="Expandable list item 2"
id="3"
>
Expand Down
14 changes: 7 additions & 7 deletions example/src/Examples/ListSectionExample.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ const ListSectionExample = () => {
<List.Section>
<List.Subheader>Single line</List.Subheader>
<List.Item
left={props => <List.Icon {...props} icon="calendar" />}
left={(props) => <List.Icon {...props} icon="calendar" />}
title="List item 1"
/>
<List.Item
left={props => <List.Icon {...props} icon="wallet-giftcard" />}
left={(props) => <List.Icon {...props} icon="wallet-giftcard" />}
title="List item 2"
/>
<List.Item
title="List item 3"
left={props => <List.Icon {...props} icon="folder" />}
right={props => <List.Icon {...props} icon="equal" />}
left={(props) => <List.Icon {...props} icon="folder" />}
right={(props) => <List.Icon {...props} icon="equal" />}
/>
</List.Section>
<Divider />
Expand All @@ -45,7 +45,7 @@ const ListSectionExample = () => {
style={styles.image}
/>
)}
right={props => <List.Icon {...props} icon="information" />}
right={(props) => <List.Icon {...props} icon="information" />}
title="List item 2"
description="Describes item 2"
/>
Expand All @@ -70,7 +70,7 @@ const ListSectionExample = () => {
style={styles.image}
/>
)}
right={props => <List.Icon {...props} icon="star-outline" />}
right={(props) => <List.Icon {...props} icon="star-outline" />}
title="List item 2"
description="Describes item 2. Example of a very very long description."
/>
Expand All @@ -85,7 +85,7 @@ const ListSectionExample = () => {
style={styles.image}
/>
)}
right={props => <List.Icon {...props} icon="star-outline" />}
right={(props) => <List.Icon {...props} icon="star-outline" />}
title="List Item 1"
description={({
ellipsizeMode,
Expand Down
2 changes: 1 addition & 1 deletion example/src/Examples/SurfaceExample.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const SurfaceExample = () => {
style={[styles.container, { backgroundColor: background }]}
contentContainerStyle={styles.content}
>
{[1, 2, 4, 6, 12].map(i => (
{[1, 2, 4, 6, 12].map((i) => (
<Surface key={i} style={[styles.surface, { elevation: i }]}>
<Text>{i}</Text>
</Surface>
Expand Down
Loading

0 comments on commit 78a33b7

Please sign in to comment.