Skip to content
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

[RFR] Upgrade prettier and apply format #2849

Merged
merged 1 commit into from
Feb 4, 2019
Merged
Show file tree
Hide file tree
Changes from all 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
17 changes: 10 additions & 7 deletions examples/data-generator/src/finalize.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,16 @@ export default function(db) {
.forEach(customer => customer.groups.push('regular'));

// add 'returns' group
db.commands.filter(command => command.returned).forEach(command => {
if (
db.customers[command.customer_id].groups.indexOf('returns') === -1
) {
db.customers[command.customer_id].groups.push('returns');
}
});
db.commands
.filter(command => command.returned)
.forEach(command => {
if (
db.customers[command.customer_id].groups.indexOf('returns') ===
-1
) {
db.customers[command.customer_id].groups.push('returns');
}
});

// add 'reviewer' group
db.reviews.forEach(review => {
Expand Down
24 changes: 14 additions & 10 deletions examples/demo/src/App.css
Original file line number Diff line number Diff line change
@@ -1,24 +1,28 @@
.App {
text-align: center;
text-align: center;
}

.App-logo {
animation: App-logo-spin infinite 20s linear;
height: 80px;
animation: App-logo-spin infinite 20s linear;
height: 80px;
}

.App-header {
background-color: #222;
height: 150px;
padding: 20px;
color: white;
background-color: #222;
height: 150px;
padding: 20px;
color: white;
}

.App-intro {
font-size: large;
font-size: large;
}

@keyframes App-logo-spin {
from { transform: rotate(0deg); }
to { transform: rotate(360deg); }
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
5 changes: 2 additions & 3 deletions examples/demo/src/categories/CategoryEdit.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ import ProductRefField from '../products/ProductRefField';

const CategoryTitle = translate(({ record, translate }) => (
<span>
{translate('resources.categories.name', { smart_count: 1 })} &quot;{
record.name
}&quot;
{translate('resources.categories.name', { smart_count: 1 })} &quot;
{record.name}&quot;
</span>
));

Expand Down
6 changes: 3 additions & 3 deletions examples/demo/src/index.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
body {
margin: 0;
padding: 0;
font-family: sans-serif;
margin: 0;
padding: 0;
font-family: sans-serif;
}
3 changes: 2 additions & 1 deletion examples/demo/src/orders/MobileGrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ const MobileGrid = ({ classes, ids, data, basePath, translate }) => (
<DateField record={data[id]} source="date" showTime />
</span>
<span className={classes.cardContentRow}>
{translate('resources.commands.fields.basket.total')}:&nbsp;
{translate('resources.commands.fields.basket.total')}
:&nbsp;
<NumberField
record={data[id]}
source="total"
Expand Down
4 changes: 3 additions & 1 deletion examples/demo/src/reviews/StarRatingField.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ const StarRatingField = ({ record }) => (
<span>
{Array(record.rating)
.fill(true)
.map((_, i) => <Icon key={i} style={style} />)}
.map((_, i) => (
<Icon key={i} style={style} />
))}
</span>
);

Expand Down
22 changes: 12 additions & 10 deletions examples/demo/src/visitors/MobileGrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ const MobileGrid = ({ classes, ids, data, basePath, translate }) => (
/>
<CardContent className={classes.cardContent}>
<div>
{translate('resources.customers.fields.last_seen_gte')}&nbsp;
{translate('resources.customers.fields.last_seen_gte')}
&nbsp;
<DateField
record={data[id]}
source="last_seen"
Expand All @@ -63,29 +64,30 @@ const MobileGrid = ({ classes, ids, data, basePath, translate }) => (
{translate(
'resources.commands.name',
parseInt(data[id].nb_commands, 10) || 1
)}&nbsp;:&nbsp;<NumberField
)}
&nbsp;:&nbsp;
<NumberField
record={data[id]}
source="nb_commands"
label="resources.customers.fields.commands"
className={classes.nb_commands}
/>
</div>
<div>
{translate('resources.customers.fields.total_spent')}&nbsp;
:{' '}
{translate('resources.customers.fields.total_spent')}
&nbsp; :{' '}
<ColoredNumberField
record={data[id]}
source="total_spent"
options={{ style: 'currency', currency: 'USD' }}
/>
</div>
</CardContent>
{data[id].groups &&
data[id].groups.length > 0 && (
<CardContent className={classes.cardContent}>
<SegmentsField record={data[id]} />
</CardContent>
)}
{data[id].groups && data[id].groups.length > 0 && (
<CardContent className={classes.cardContent}>
<SegmentsField record={data[id]} />
</CardContent>
)}
</Card>
))}
</div>
Expand Down
3 changes: 2 additions & 1 deletion examples/simple/src/comments/CommentList.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ const CommentPagination = translate(
key="prev"
onClick={() => setPage(page - 1)}
>
<ChevronLeft />&nbsp;
<ChevronLeft />
&nbsp;
{translate('ra.navigation.prev')}
</Button>
)}
Expand Down
24 changes: 14 additions & 10 deletions examples/simple/src/posts/PostEdit.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ const EditActions = ({
resource,
...rest
}) => (
<CardActions className={className} {...rest}>
<CloneButton
className="button-clone"
basePath={basePath}
record={data}
/>
{hasShow && <ShowButton basePath={basePath} record={data} />}
</CardActions>
);
<CardActions className={className} {...rest}>
<CloneButton
className="button-clone"
basePath={basePath}
record={data}
/>
{hasShow && <ShowButton basePath={basePath} record={data} />}
</CardActions>
);

const PostEdit = props => (
<Edit title={<PostTitle />} actions={<EditActions />} {...props}>
Expand Down Expand Up @@ -83,7 +83,11 @@ const PostEdit = props => (
/>
</FormTab>
<FormTab label="post.form.miscellaneous">
<ReferenceArrayInput reference="tags" source="tags" filter={{ published: true }}>
<ReferenceArrayInput
reference="tags"
source="tags"
filter={{ published: true }}
>
<AutocompleteArrayInput />
</ReferenceArrayInput>
<ArrayInput source="backlinks">
Expand Down
7 changes: 6 additions & 1 deletion examples/simple/src/users/Aside.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ const Aside = () => (
<div style={{ width: 200, margin: '1em' }}>
<Typography variant="title">App Users</Typography>
<Typography variant="body1">
Eiusmod adipisicing tempor duis qui. Ullamco aliqua tempor incididunt aliquip aliquip qui ad minim aliqua. Aute et magna quis pariatur irure sunt. Aliquip velit consequat dolore ullamco laborum voluptate cupidatat. Proident minim reprehenderit id dolore elit sit occaecat ad amet tempor esse occaecat enim. Laborum aliqua excepteur qui ipsum in dolor et cillum est.
Eiusmod adipisicing tempor duis qui. Ullamco aliqua tempor
incididunt aliquip aliquip qui ad minim aliqua. Aute et magna quis
pariatur irure sunt. Aliquip velit consequat dolore ullamco laborum
voluptate cupidatat. Proident minim reprehenderit id dolore elit sit
occaecat ad amet tempor esse occaecat enim. Laborum aliqua excepteur
qui ipsum in dolor et cillum est.
</Typography>
</div>
);
Expand Down
20 changes: 15 additions & 5 deletions examples/simple/src/users/UserShow.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,18 @@ const defaultProps = {
describe('UserShow', () => {
describe('As User', () => {
it('should display one tab', () => {
const wrapper = shallow(<UserShow {...defaultProps} permissions="user" />);
const wrapper = shallow(
<UserShow {...defaultProps} permissions="user" />
);

const tab = wrapper.find(Tab);
expect(tab.length).toBe(1);
});

it('should show the user identity in the first tab', () => {
const wrapper = shallow(<UserShow {...defaultProps} permissions="user" />);
const wrapper = shallow(
<UserShow {...defaultProps} permissions="user" />
);

const tab = wrapper.find(Tab);
const fields = tab.find(TextField);
Expand All @@ -43,14 +47,18 @@ describe('UserShow', () => {

describe('As Admin', () => {
it('should display two tabs', () => {
const wrapper = shallow(<UserShow {...defaultProps} permissions="admin" />);
const wrapper = shallow(
<UserShow {...defaultProps} permissions="admin" />
);

const tabs = wrapper.find(Tab);
expect(tabs.length).toBe(2);
});

it('should show the user identity in the first tab', () => {
const wrapper = shallow(<UserShow {...defaultProps} permissions="admin" />);
const wrapper = shallow(
<UserShow {...defaultProps} permissions="admin" />
);

const tabs = wrapper.find(Tab);
const fields = tabs.at(0).find(TextField);
Expand All @@ -60,7 +68,9 @@ describe('UserShow', () => {
});

it('should show the user role in the second tab', () => {
const wrapper = shallow(<UserShow {...defaultProps} permissions="admin" />);
const wrapper = shallow(
<UserShow {...defaultProps} permissions="admin" />
);

const tabs = wrapper.find(Tab);
const fields = tabs.at(1).find(TextField);
Expand Down
6 changes: 3 additions & 3 deletions examples/tutorial/src/index.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
body {
margin: 0;
padding: 0;
font-family: sans-serif;
margin: 0;
padding: 0;
font-family: sans-serif;
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"jest": "^23.6.0",
"lerna": "~2.9.1",
"lolex": "~2.3.2",
"prettier": "~1.13.7",
"prettier": "~1.16.4",
"raf": "~3.4.0",
"ts-jest": "^23.10.4",
"tslint": "^5.11.0",
Expand Down
3 changes: 2 additions & 1 deletion packages/ra-core/src/CoreAdminRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ export class CoreAdminRouter extends Component {
) {
return (
<div style={welcomeStyles}>
React-admin is properly configured.<br />
React-admin is properly configured.
<br />
Now you can add a first &lt;Resource&gt; as child of
&lt;Admin&gt;.
</div>
Expand Down
12 changes: 4 additions & 8 deletions packages/ra-core/src/controller/CreateController.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ export class CreateController extends Component {
state && state.record
? state.record
: search
? parse(search, { arrayFormat: 'bracket' })
: record;
? parse(search, { arrayFormat: 'bracket' })
: record;
}

defaultRedirectRoute() {
Expand Down Expand Up @@ -140,14 +140,10 @@ function mapStateToProps(state) {
}

export default compose(
checkMinimumRequiredProps('Create', [
'basePath',
'location',
'resource',
]),
checkMinimumRequiredProps('Create', ['basePath', 'location', 'resource']),
connect(
mapStateToProps,
{ crudCreate: crudCreateAction }
),
translate,
translate
)(CreateController);
4 changes: 2 additions & 2 deletions packages/ra-core/src/controller/ListController.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@ export class ListController extends Component {
Object.keys(this.props.query).length > 0
? this.props.query
: this.hasCustomParams(this.props.params)
? { ...this.props.params }
: { filter: this.props.filterDefaultValues || {} };
? { ...this.props.params }
: { filter: this.props.filterDefaultValues || {} };

if (!query.sort) {
query.sort = this.props.sort.field;
Expand Down
14 changes: 10 additions & 4 deletions packages/ra-core/src/controller/checkMinimumRequiredProps.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
import React from 'react';

const checkMinimumRequiredProps = (displayName, requiredProps) => WrappedComponent => (props) => {
const checkMinimumRequiredProps = (
displayName,
requiredProps
) => WrappedComponent => props => {
const propNames = Object.keys(props);
const missingProps = requiredProps.filter(prop => !propNames.includes(prop));
const missingProps = requiredProps.filter(
prop => !propNames.includes(prop)
);

if (missingProps.length > 0) {
throw new Error(
`<${displayName}> component is not properly configured, some essential props are missing.
`<${displayName}> component is not properly configured, some essential props are missing.
Be sure to pass the props from the parent. Example:

const My${displayName} = props => (
<${displayName} {...props}></${displayName}>
);

The missing props are: ${missingProps.join(', ')}`)
The missing props are: ${missingProps.join(', ')}`
);
}

return <WrappedComponent {...props} />;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ export class ReferenceManyFieldController extends Component {

componentWillReceiveProps(nextProps) {
if (
this.props.record.id !== nextProps.record.id ||
!isEqual(this.props.filter, nextProps.filter)
this.props.record.id !== nextProps.record.id ||
!isEqual(this.props.filter, nextProps.filter)
) {
this.fetchReferences(nextProps);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ describe('<ReferenceInputController />', () => {
it('should only call crudGetMatching when props are changed from outside', () => {
const crudGetMatchingAccumulate = jest.fn();
const crudGetManyAccumulate = jest.fn();
const ControllerWrapper = (props) => (
const ControllerWrapper = props => (
<ReferenceInputController
{...defaultProps}
allowEmpty
Expand Down
4 changes: 2 additions & 2 deletions packages/ra-core/src/controller/input/referenceDataStatus.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ export const getSelectedReferencesStatus = (input, referenceRecords) =>
!input.value || input.value.length === referenceRecords.length
? REFERENCES_STATUS_READY
: referenceRecords.length > 0
? REFERENCES_STATUS_INCOMPLETE
: REFERENCES_STATUS_EMPTY;
? REFERENCES_STATUS_INCOMPLETE
: REFERENCES_STATUS_EMPTY;

export const getStatusForArrayInput = ({
input,
Expand Down
Loading