Commit aa2344be authored by Mickaël Bourgier's avatar Mickaël Bourgier
Browse files

Upgrade prettier

parent 05aade4d
......@@ -6,14 +6,14 @@ const customizationPrefix = '/customization';
export const customization = {
_prefix: customizationPrefix,
themes: `${customizationPrefix}/themes`,
defaultTheme: `${customizationPrefix}/default-theme`
defaultTheme: `${customizationPrefix}/default-theme`,
};
export const components = { _prefix: '/components' };
require
.context('@webalt/react', true, /^\.\/[A-Z][^/]+$/)
.keys()
.forEach(key => {
.forEach((key) => {
const componentName = key.replace(/^\.\//, '');
components[componentName] = `${components._prefix}/${componentName
.replace(/([a-z])([A-Z])/g, '$1-$2')
......@@ -24,5 +24,5 @@ export default {
home,
contributing,
customization,
components
components,
};
......@@ -10,12 +10,12 @@ import Router, { Topbar, Sidemenu } from './Router';
class App extends Component {
state = {
customTheme: {}
customTheme: {},
};
setCustomTheme = customTheme => {
setCustomTheme = (customTheme) => {
this.setState({
customTheme
customTheme,
});
};
......
......@@ -8,11 +8,11 @@ import Home, { HomeTopbar } from './scenes/Home';
import Contributing, { ContributingTopbar } from './scenes/Contributing';
import Customization, {
CustomizationTopbar,
CustomizationSidemenu
CustomizationSidemenu,
} from './scenes/Customization';
import Components, {
ComponentsTopbar,
ComponentsSidemenu
ComponentsSidemenu,
} from './scenes/Components';
class Router extends Component {
......
......@@ -2,14 +2,14 @@ import React, { createContext } from 'react';
const { Provider: CustomThemeProvider, Consumer } = createContext({
customTheme: {},
setCustomTheme: () => {}
setCustomTheme: () => {},
});
const withCustomTheme = InnerComponent =>
const withCustomTheme = (InnerComponent) =>
function WithCustomTheme(props) {
return (
<Consumer>
{context => <InnerComponent {...context} {...props} />}
{(context) => <InnerComponent {...context} {...props} />}
</Consumer>
);
};
......
......@@ -13,7 +13,7 @@ const RouterLink = ({ href, children }) =>
RouterLink.propTypes = {
children: PropTypes.node,
href: PropTypes.string.isRequired
href: PropTypes.string.isRequired,
};
const Markdown = ({ renderers = {}, ...props }) => (
......@@ -21,13 +21,13 @@ const Markdown = ({ renderers = {}, ...props }) => (
{...props}
renderers={{
link: RouterLink,
...renderers
...renderers,
}}
/>
);
Markdown.propTypes = {
renderers: PropTypes.object
renderers: PropTypes.object,
};
export default Markdown;
......@@ -9,13 +9,13 @@ import ComponentDoc from '__src/scenes/Components/components/ComponentDoc';
const components = require
.context('@webalt/react', true, /^\.\/[A-Z][^/]+$/)
.keys()
.map(key => key.replace(/^\.\//, ''));
.map((key) => key.replace(/^\.\//, ''));
class ComponentsRouter extends Component {
render() {
return (
<Switch>
{components.map(component => (
{components.map((component) => (
<Route
key={component}
path={routes[component]}
......@@ -31,7 +31,7 @@ class ComponentsRouter extends Component {
export const ComponentsTopbar = () => (
<Switch>
{components.map(component => (
{components.map((component) => (
<Route
key={component}
path={routes[component]}
......@@ -48,7 +48,7 @@ export const ComponentsTopbar = () => (
export const ComponentsSidemenu = withCloseSidemenu(({ closeSidemenu }) => (
<List component='div'>
{components.map(component => (
{components.map((component) => (
<ListItem
key={component}
component={Link}
......
......@@ -19,7 +19,7 @@ ComponentDemo.propTypes = {
/**
* Composant à afficher
*/
component: PropTypes.any.isRequired
component: PropTypes.any.isRequired,
};
export default ComponentDemo;
......@@ -20,11 +20,11 @@ class ComponentDoc extends Component {
const demos = demosContext
.keys()
.filter(key => key.match(new RegExp(`\\./${name}/demos/.+\\.js$`)));
.filter((key) => key.match(new RegExp(`\\./${name}/demos/.+\\.js$`)));
const {
description = '',
props = {}
props = {},
} = require(`!!react-docgen!@webalt/react/${name}/${name}`);
const longDescription = description.replace(/^@summary .+$/m, '');
......@@ -39,7 +39,7 @@ class ComponentDoc extends Component {
</div>
)}
{demos.map(demo => (
{demos.map((demo) => (
<div key={demo} className='mb-4'>
<ComponentDemo component={demosContext(demo).default} />
</div>
......@@ -60,7 +60,7 @@ ComponentDoc.propTypes = {
/**
* Nom du composant à documenter
*/
name: PropTypes.string.isRequired
name: PropTypes.string.isRequired,
};
export default ComponentDoc;
......@@ -26,11 +26,11 @@ class ComponentPropsTable extends Component {
{Object.keys(props)
// Exclue les props ayant une description commençant pas "@ignore"
.filter(
propName =>
(propName) =>
'description' in props[propName] &&
!props[propName].description.startsWith('@ignore')
)
.map(propName => {
.map((propName) => {
const { defaultValue, description, required, type } = props[
propName
];
......@@ -69,7 +69,7 @@ ComponentPropsTable.propTypes = {
/**
* Tableau des props fournies par react-docgen
*/
props: PropTypes.object.isRequired
props: PropTypes.object.isRequired,
};
export default withStyles(styles)(ComponentPropsTable);
export default theme => ({
export default (theme) => ({
table: {
'& p, & ul': {
marginBottom: theme.spacing.spacers[1]
}
}
marginBottom: theme.spacing.spacers[1],
},
},
});
export {
default,
ComponentsTopbar,
ComponentsSidemenu
ComponentsSidemenu,
} from './ComponentsRouter';
export {
default,
CustomizationTopbar,
CustomizationSidemenu
CustomizationSidemenu,
} from './CustomizationRouter';
......@@ -11,17 +11,17 @@ import { withCustomTheme } from '__src/components/CustomThemeContext';
import styles from './CustomThemeEditor.styles';
const codeMirrorExtraKeys = {
Tab: cm => {
Tab: (cm) => {
const spaces = Array(cm.getOption('indentUnit') + 1).join(' ');
cm.replaceSelection(spaces);
}
},
};
class CustomThemeEditor extends Component {
state = {
dirty: false,
valid: true,
value: ''
value: '',
};
getValue = () => {
......@@ -48,7 +48,7 @@ class CustomThemeEditor extends Component {
this.setState({
dirty: false,
valid: true,
value: JSON.stringify(customTheme, null, 2)
value: JSON.stringify(customTheme, null, 2),
});
};
......@@ -77,7 +77,7 @@ class CustomThemeEditor extends Component {
mode: { name: 'javascript', json: true },
viewportMargin: Infinity,
indentUnit: 2,
extraKeys: codeMirrorExtraKeys
extraKeys: codeMirrorExtraKeys,
}}
/>
{dirty && (
......@@ -105,7 +105,7 @@ CustomThemeEditor.propTypes = {
customTheme: PropTypes.object.isRequired,
setCustomTheme: PropTypes.func.isRequired
setCustomTheme: PropTypes.func.isRequired,
};
export default withStyles(styles)(withCustomTheme(CustomThemeEditor));
export default theme => ({
export default (theme) => ({
codeMirror: {
...theme.typography.mono,
'& .CodeMirror': {
height: 'auto'
}
height: 'auto',
},
},
footer: {
display: 'flex',
justifyContent: 'space-between',
marginTop: theme.spacing.spacers[3]
}
marginTop: theme.spacing.spacers[3],
},
});
......@@ -9,11 +9,11 @@ import { withCustomTheme } from '__src/components/CustomThemeContext';
class ThemeCustomizable extends Component {
handleEdit = ({ namespace, name, new_value: value }) => {
const {
customTheme: { ...customTheme }
customTheme: { ...customTheme },
} = this.props;
let sentinel = customTheme;
namespace.forEach(attr => {
namespace.forEach((attr) => {
if (!(attr in sentinel)) {
sentinel[attr] = {};
}
......@@ -49,7 +49,7 @@ ThemeCustomizable.propTypes = {
setCustomTheme: PropTypes.func.isRequired,
theme: PropTypes.object.isRequired
theme: PropTypes.object.isRequired,
};
export default withTheme(withCustomTheme(ThemeCustomizable));
......@@ -11,7 +11,7 @@ import styles from './Home.styles';
const components = require
.context('@webalt/react', true, /^\.\/[A-Z][^/]+$/)
.keys()
.map(key => key.replace(/^\.\//, ''));
.map((key) => key.replace(/^\.\//, ''));
class Home extends Component {
render() {
......@@ -19,9 +19,9 @@ class Home extends Component {
const descriptions = Object.assign(
{},
...components.map(name => {
...components.map((name) => {
const {
description
description,
} = require(`!!react-docgen!@webalt/react/${name}/${name}`);
let shortDescription = '';
......@@ -31,7 +31,7 @@ class Home extends Component {
}
return {
[name]: shortDescription
[name]: shortDescription,
};
})
);
......@@ -120,8 +120,8 @@ ReactDOM.render(<App />, document.getElementById('root'))
</Row>
</Hidden>
{Object.keys(descriptions)
.filter(name => descriptions[name] !== '')
.map(name => (
.filter((name) => descriptions[name] !== '')
.map((name) => (
<Row key={name}>
<Col lg={3} className={classes.component}>
<Link to={routes.components[name]}>{name}</Link>
......@@ -137,7 +137,7 @@ ReactDOM.render(<App />, document.getElementById('root'))
}
Home.propTypes = {
classes: PropTypes.object.isRequired
classes: PropTypes.object.isRequired,
};
export const HomeTopbar = () => (
......
export default () => ({
header: {
fontWeight: 'bold'
fontWeight: 'bold',
},
component: {
textAlign: 'right'
textAlign: 'right',
},
description: {
'& p, & ul': {
marginBottom: 0
}
}
marginBottom: 0,
},
},
});
......@@ -11,7 +11,7 @@ const formatPropType = (propType, depth = 0) => {
case 'element':
return 'Element';
case 'enum':
return propType.value.map(child => child.value).join(' | ');
return propType.value.map((child) => child.value).join(' | ');
case 'func':
return 'Function';
case 'instanceOf':
......@@ -27,7 +27,7 @@ const formatPropType = (propType, depth = 0) => {
case 'shape':
return `{\n${Object.keys(propType.value)
.map(
childName =>
(childName) =>
`${' '.repeat(depth + 1)}${childName}: ${formatPropType(
propType.value[childName],
depth + 1
......@@ -39,7 +39,7 @@ const formatPropType = (propType, depth = 0) => {
case 'symbol':
return 'Symbol';
case 'union':
return propType.value.map(child => formatPropType(child)).join(' | ');
return propType.value.map((child) => formatPropType(child)).join(' | ');
}
return '???';
......
const parse = require('react-docgen').parse;
module.exports = function(source) {
module.exports = function (source) {
this.cacheable && this.cacheable();
let value = {};
try {
value = parse(source, null, null, {
filename: this.resourcePath
filename: this.resourcePath,
});
} catch (e) {
// ignore exception
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment