Skip to content

Commit 99ea4af

Browse files
committed
Fix linting issues in docs.
1 parent d18c0bc commit 99ea4af

File tree

8 files changed

+98
-56
lines changed

8 files changed

+98
-56
lines changed
Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
import React from 'react';
22
import Typography from '@material-ui/core/Typography';
33

4-
export default () =>
5-
<Typography>
6-
This is a custom component.
7-
</Typography>;
4+
export default () => <Typography>This is a custom component.</Typography>;
Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
import React from 'react';
22
import Pf4 from '@docs/doc-components/pf4-dual-list.md';
3+
import PropTypes from 'prop-types';
34

4-
export default ({ activeMapper }) => activeMapper === 'pf4' ? <Pf4 /> : 'Not implemented yet';
5+
const DualListSelect = ({ activeMapper }) => (activeMapper === 'pf4' ? <Pf4 /> : 'Not implemented yet');
6+
7+
DualListSelect.propTypes = {
8+
activeMapper: PropTypes.string
9+
};
10+
11+
export default DualListSelect;

packages/react-renderer-demo/src/app/src/components/navigation/examples-texts/generic-mui-component.js

Lines changed: 36 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
import React from 'react';
22
import Typography from '@material-ui/core/Typography';
33

4+
import PropTypes from 'prop-types';
5+
46
export const docsLinks = {
57
mui: 'https://material-ui.com/api/',
68
pf4: 'http://patternfly-react.surge.sh/patternfly-4/components/',
7-
pf3: 'http://patternfly-react.surge.sh/patternfly-3/index.html',
9+
pf3: 'http://patternfly-react.surge.sh/patternfly-3/index.html'
810
};
911

10-
export default ({ activeMapper, component }) => {
12+
const GenericMuiComponent = ({ activeMapper, component }) => {
1113
const originalComponent = component;
12-
if (activeMapper === 'pf4'){
13-
switch (component){
14+
if (activeMapper === 'pf4') {
15+
switch (component) {
1416
case 'date-picker':
1517
component = 'textinput';
1618
break;
@@ -32,9 +34,11 @@ export default ({ activeMapper, component }) => {
3234
case 'checkbox-multiple':
3335
component = 'checkbox';
3436
break;
37+
default:
38+
break;
3539
}
36-
} else if (activeMapper === 'mui'){
37-
switch (component){
40+
} else if (activeMapper === 'mui') {
41+
switch (component) {
3842
case 'date-picker':
3943
component = 'text-field';
4044
break;
@@ -53,22 +57,33 @@ export default ({ activeMapper, component }) => {
5357
case 'checkbox-multiple':
5458
component = 'checkbox';
5559
break;
60+
default:
61+
break;
5662
}
5763
}
5864

59-
return <React.Fragment>
60-
<Typography variant='body1' gutterBottom>
61-
This component also accepts all other original props, please see <a
62-
href={ `${docsLinks[activeMapper]}${ activeMapper === 'pf4' || activeMapper === 'mui' ? component : '' }` }>
63-
here</a>!
64-
</Typography>
65-
66-
{ activeMapper === 'mui' ?
67-
(originalComponent === 'date-picker' || originalComponent === 'time-picker') &&
68-
<Typography variant='body1'>
69-
This component also use API from material-ui-pickers, please see <a
70-
href={ `https://material-ui-pickers.firebaseapp.com/api/${originalComponent.replace('-', '')}` }>
71-
here</a>!
65+
return (
66+
<React.Fragment>
67+
<Typography variant="body1" gutterBottom>
68+
This component also accepts all other original props, please see{' '}
69+
<a href={`${docsLinks[activeMapper]}${activeMapper === 'pf4' || activeMapper === 'mui' ? component : ''}`}>here</a>!
7270
</Typography>
73-
: '' }
74-
</React.Fragment>;};
71+
72+
{activeMapper === 'mui'
73+
? (originalComponent === 'date-picker' || originalComponent === 'time-picker') && (
74+
<Typography variant="body1">
75+
This component also use API from material-ui-pickers, please see{' '}
76+
<a href={`https://material-ui-pickers.firebaseapp.com/api/${originalComponent.replace('-', '')}`}>here</a>!
77+
</Typography>
78+
)
79+
: ''}
80+
</React.Fragment>
81+
);
82+
};
83+
84+
GenericMuiComponent.propTypes = {
85+
activeMapper: PropTypes.string,
86+
component: PropTypes.string
87+
};
88+
89+
export default GenericMuiComponent;

packages/react-renderer-demo/src/app/src/components/navigation/examples-texts/select.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,12 @@ import React from 'react';
22
import GenericComponentText from './generic-mui-component';
33
import Pf3Select from '@docs/doc-components/pf3-select.md';
44
import Pf4Select from '@docs/doc-components/pf4-select.md';
5+
import PropTypes from 'prop-types';
56

6-
export default ({ activeMapper }) => activeMapper === 'pf3' ? <Pf3Select /> : activeMapper === 'pf4' ? <Pf4Select /> : <GenericComponentText />;
7+
const Select = ({ activeMapper }) => (activeMapper === 'pf3' ? <Pf3Select /> : activeMapper === 'pf4' ? <Pf4Select /> : <GenericComponentText />);
8+
9+
Select.propTypes = {
10+
activeMapper: PropTypes.string
11+
};
12+
13+
export default Select;

packages/react-renderer-demo/src/app/src/components/navigation/examples-texts/tabs.js

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,35 @@ import React, { Fragment } from 'react';
22
import Typography from '@material-ui/core/Typography';
33
import { docsLinks } from './generic-mui-component';
44

5-
export default ({ activeMapper }) =>
5+
import PropTypes from 'prop-types';
6+
7+
const Tabs = ({ activeMapper }) => (
68
<Fragment>
7-
{ activeMapper === 'pf4' &&
8-
<Typography variant='body1' gutterBottom>
9-
This component also accepts all other original props, please see <a
10-
href={ `${docsLinks[activeMapper]}/tabs` }>
11-
here</a>!
12-
</Typography> }
9+
{activeMapper === 'pf4' && (
10+
<Typography variant="body1" gutterBottom>
11+
This component also accepts all other original props, please see <a href={`${docsLinks[activeMapper]}/tabs`}>here</a>!
12+
</Typography>
13+
)}
1314
<Typography variant="body1">
14-
For using this component, you have to append TabItem component (containing form fields) to fields property.
15-
</Typography>
16-
<Typography gutterBottom>
17-
Component constant
15+
For using this component, you have to append TabItem component (containing form fields) to fields property.
1816
</Typography>
17+
<Typography gutterBottom>Component constant</Typography>
1918
<pre>TAB_ITEM</pre> <Typography variant="body1">as an import from componentTypes</Typography>
2019
<pre>tab-item</pre> <Typography variant="body1">as a string</Typography>
21-
{ activeMapper === 'pf3' &&
22-
(
20+
{activeMapper === 'pf3' && (
2321
<Fragment>
24-
<Typography gutterBottom>
25-
Validation
26-
</Typography>
22+
<Typography gutterBottom>Validation</Typography>
2723
<Typography variant="body1">Because of schema flexibility there is no simple and efficient way to signal invalid tab content.</Typography>
2824
<Typography variant="body1">
2925
If you want to add some visual feedback for this case, please specify field names to <strong>validateFields</strong> attribute.
3026
</Typography>
3127
</Fragment>
32-
) }
33-
</Fragment>;
28+
)}
29+
</Fragment>
30+
);
31+
32+
Tabs.propTypes = {
33+
activeMapper: PropTypes.string
34+
};
35+
36+
export default Tabs;

packages/react-renderer-demo/src/app/src/components/navigation/examples-texts/wizard.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,12 @@ import Wizard from '@docs/doc-components/wizard.md';
33
import Pf3Wizard from '@docs/doc-components/pf3-wizard.md';
44
import Pf4Wizard from '@docs/doc-components/pf4-wizard.md';
55

6-
export default ({ activeMapper }) => activeMapper === 'pf3' ? <Pf3Wizard /> : activeMapper === 'pf4' ? <Pf4Wizard /> : <Wizard />;
6+
import PropTypes from 'prop-types';
7+
8+
const DocWizard = ({ activeMapper }) => (activeMapper === 'pf3' ? <Pf3Wizard /> : activeMapper === 'pf4' ? <Pf4Wizard /> : <Wizard />);
9+
10+
DocWizard.propTypes = {
11+
activeMapper: PropTypes.string
12+
};
13+
14+
export default DocWizard;

packages/react-renderer-demo/src/app/src/doc-components/custom-buttons.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,23 @@ const FormTemplate = ({ formFields, schema }) => {
4747
<Button disabled={pristine} style={{ marginRight: 8 }} onClick={onReset} variant="contained">
4848
Reset
4949
</Button>
50-
<Button variant="contained" onClick={onCancel}>Cancel</Button>
50+
<Button variant="contained" onClick={onCancel}>
51+
Cancel
52+
</Button>
5153
</div>
5254
)}
5355
</FormSpy>
5456
</Form>
5557
);
5658
};
5759

58-
const asyncSubmit = (values, api) => new Promise((resolve) => setTimeout(() => {
59-
console.log('FormValues', values);
60-
resolve('Yay');
61-
}, 1500));
60+
const asyncSubmit = (values, api) =>
61+
new Promise((resolve) =>
62+
setTimeout(() => {
63+
console.log('FormValues', values);
64+
resolve('Yay');
65+
}, 1500)
66+
);
6267

6368
const FormControls = () => (
6469
<div className="pf4">

packages/react-renderer-demo/src/app/src/doc-components/get-started/get-started.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ const schema = {
4545
const GetStartedForm = () => (
4646
<div className="pf4">
4747
<FormRender
48-
componentMapper={ componentMapper }
49-
FormTemplate={ FormTemplate }
50-
schema={ schema }
51-
onSubmit={ console.log }
52-
onCancel={ () => console.log('Cancel action') }
48+
componentMapper={componentMapper}
49+
FormTemplate={FormTemplate}
50+
schema={schema}
51+
onSubmit={console.log}
52+
onCancel={() => console.log('Cancel action')}
5353
canReset
5454
/>
5555
</div>

0 commit comments

Comments
 (0)