Skip to content

Commit 1712ffa

Browse files
authored
Merge pull request #1743 from processing/chore/prettier
Add prettier configuration
2 parents 2dbad54 + b3c81ee commit 1712ffa

File tree

193 files changed

+5625
-3441
lines changed

Some content is hidden

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

193 files changed

+5625
-3441
lines changed

.eslintrc

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"extends": "airbnb",
2+
"extends": ["airbnb", "prettier"],
33
"parser": "babel-eslint",
44
"env": {
55
"browser": true,
@@ -16,12 +16,12 @@
1616
"import/no-unresolved": 0,
1717
"import/no-named-as-default": 2,
1818
"comma-dangle": 0, // not sure why airbnb turned this on. gross!
19-
"indent": [2, 2, {"SwitchCase": 1}],
19+
"indent": 0,
2020
"no-console": 0,
2121
"no-alert": 0,
2222
"no-underscore-dangle": 0,
2323
"max-len": [1, 120, 2, {"ignoreComments": true, "ignoreTemplateLiterals": true}],
24-
"quote-props": [1, "consistent-as-needed"],
24+
"quote-props": [1, "as-needed"],
2525
"no-unused-vars": [1, {"vars": "local", "args": "none"}],
2626
"consistent-return": ["error", { "treatUndefinedAsUnspecified": true }],
2727
"no-param-reassign": [2, { "props": false }],
@@ -60,10 +60,13 @@
6060
},
6161
"allowChildren": false
6262
}
63+
],
64+
"prettier/prettier": [
65+
"error"
6366
]
6467
},
6568
"plugins": [
66-
"react", "jsx-a11y", "import"
69+
"react", "jsx-a11y", "import", "prettier"
6770
],
6871
"settings": {
6972
"import/parser": "babel-eslint",

.prettierrc

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"arrowParens": "always",
3+
"bracketSpacing": true,
4+
"htmlWhitespaceSensitivity": "css",
5+
"insertPragma": false,
6+
"jsxBracketSameLine": false,
7+
"jsxSingleQuote": false,
8+
"parser": "babel",
9+
"printWidth": 80,
10+
"proseWrap": "never",
11+
"requirePragma": false,
12+
"semi": true,
13+
"singleQuote": true,
14+
"tabWidth": 2,
15+
"trailingComma": "none",
16+
"useTabs": false,
17+
"quoteProps": "as-needed"
18+
}

client/common/Button.jsx

Lines changed: 51 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { remSize, prop } from '../theme';
88
const kinds = {
99
block: 'block',
1010
icon: 'icon',
11-
inline: 'inline',
11+
inline: 'inline'
1212
};
1313

1414
// The '&&&' will increase the specificity of the
@@ -34,7 +34,7 @@ const StyledButton = styled.button`
3434
svg * {
3535
fill: ${prop('Button.default.foreground')};
3636
}
37-
37+
3838
&:hover:not(:disabled) {
3939
color: ${prop('Button.hover.foreground')};
4040
background-color: ${prop('Button.hover.background')};
@@ -115,7 +115,7 @@ const StyledIconButton = styled.button`
115115
border-radius: 50%;
116116
padding: ${remSize(8)} ${remSize(25)};
117117
line-height: 1;
118-
118+
119119
&:hover:not(:disabled) {
120120
color: ${prop('Button.hover.foreground')};
121121
background-color: ${prop('Button.hover.background')};
@@ -150,10 +150,24 @@ const StyledIconButton = styled.button`
150150
* A Button performs an primary action
151151
*/
152152
const Button = ({
153-
children, href, kind, iconBefore, iconAfter, 'aria-label': ariaLabel, to, type, ...props
153+
children,
154+
href,
155+
kind,
156+
iconBefore,
157+
iconAfter,
158+
'aria-label': ariaLabel,
159+
to,
160+
type,
161+
...props
154162
}) => {
155163
const hasChildren = React.Children.count(children) > 0;
156-
const content = <>{iconBefore}{hasChildren && <span>{children}</span>}{iconAfter}</>;
164+
const content = (
165+
<>
166+
{iconBefore}
167+
{hasChildren && <span>{children}</span>}
168+
{iconAfter}
169+
</>
170+
);
157171
let StyledComponent = StyledButton;
158172

159173
if (kind === kinds.inline) {
@@ -177,22 +191,36 @@ const Button = ({
177191
}
178192

179193
if (to) {
180-
return <StyledComponent kind={kind} as={Link} aria-label={ariaLabel} to={to} {...props}>{content}</StyledComponent>;
194+
return (
195+
<StyledComponent
196+
kind={kind}
197+
as={Link}
198+
aria-label={ariaLabel}
199+
to={to}
200+
{...props}
201+
>
202+
{content}
203+
</StyledComponent>
204+
);
181205
}
182206

183-
return <StyledComponent kind={kind} aria-label={ariaLabel} type={type} {...props}>{content}</StyledComponent>;
207+
return (
208+
<StyledComponent kind={kind} aria-label={ariaLabel} type={type} {...props}>
209+
{content}
210+
</StyledComponent>
211+
);
184212
};
185213

186214
Button.defaultProps = {
187-
'children': null,
188-
'disabled': false,
189-
'iconAfter': null,
190-
'iconBefore': null,
191-
'kind': kinds.block,
192-
'href': null,
215+
children: null,
216+
disabled: false,
217+
iconAfter: null,
218+
iconBefore: null,
219+
kind: kinds.block,
220+
href: null,
193221
'aria-label': null,
194-
'to': null,
195-
'type': 'button',
222+
to: null,
223+
type: 'button'
196224
};
197225

198226
Button.kinds = kinds;
@@ -202,39 +230,39 @@ Button.propTypes = {
202230
* The visible part of the button, telling the user what
203231
* the action is
204232
*/
205-
'children': PropTypes.element,
233+
children: PropTypes.element,
206234
/**
207235
If the button can be activated or not
208236
*/
209-
'disabled': PropTypes.bool,
237+
disabled: PropTypes.bool,
210238
/**
211239
* SVG icon to place after child content
212240
*/
213-
'iconAfter': PropTypes.element,
241+
iconAfter: PropTypes.element,
214242
/**
215243
* SVG icon to place before child content
216244
*/
217-
'iconBefore': PropTypes.element,
245+
iconBefore: PropTypes.element,
218246
/**
219247
* The kind of button - determines how it appears visually
220248
*/
221-
'kind': PropTypes.oneOf(Object.values(kinds)),
249+
kind: PropTypes.oneOf(Object.values(kinds)),
222250
/**
223251
* Specifying an href will use an <a> to link to the URL
224252
*/
225-
'href': PropTypes.string,
253+
href: PropTypes.string,
226254
/*
227255
* An ARIA Label used for accessibility
228256
*/
229257
'aria-label': PropTypes.string,
230258
/**
231259
* Specifying a to URL will use a react-router Link
232260
*/
233-
'to': PropTypes.string,
261+
to: PropTypes.string,
234262
/**
235263
* If using a button, then type is defines the type of button
236264
*/
237-
'type': PropTypes.oneOf(['button', 'submit']),
265+
type: PropTypes.oneOf(['button', 'submit'])
238266
};
239267

240268
export default Button;

client/common/Button.stories.jsx

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,42 +21,45 @@ export const AllFeatures = () => (
2121
);
2222

2323
export const SubmitButton = () => (
24-
<Button type="submit" label="submit">This is a submit button</Button>
24+
<Button type="submit" label="submit">
25+
This is a submit button
26+
</Button>
2527
);
2628

27-
export const DefaultTypeButton = () => <Button label="login" onClick={action('onClick')}>Log In</Button>;
29+
export const DefaultTypeButton = () => (
30+
<Button label="login" onClick={action('onClick')}>
31+
Log In
32+
</Button>
33+
);
2834

29-
export const DisabledButton = () => <Button disabled label="login" onClick={action('onClick')}>Log In</Button>;
35+
export const DisabledButton = () => (
36+
<Button disabled label="login" onClick={action('onClick')}>
37+
Log In
38+
</Button>
39+
);
3040

3141
export const AnchorButton = () => (
32-
<Button href="http://p5js.org" label="submit">Actually an anchor</Button>
42+
<Button href="http://p5js.org" label="submit">
43+
Actually an anchor
44+
</Button>
3345
);
3446

3547
export const ReactRouterLink = () => (
36-
<Button to="./somewhere" label="submit">Actually a Link</Button>
48+
<Button to="./somewhere" label="submit">
49+
Actually a Link
50+
</Button>
3751
);
3852

3953
export const ButtonWithIconBefore = () => (
40-
<Button
41-
iconBefore={<GithubIcon aria-label="Github logo" />}
42-
>
43-
Create
44-
</Button>
54+
<Button iconBefore={<GithubIcon aria-label="Github logo" />}>Create</Button>
4555
);
4656

4757
export const ButtonWithIconAfter = () => (
48-
<Button
49-
iconAfter={<GithubIcon aria-label="Github logo" />}
50-
>
51-
Create
52-
</Button>
58+
<Button iconAfter={<GithubIcon aria-label="Github logo" />}>Create</Button>
5359
);
5460

5561
export const InlineButtonWithIconAfter = () => (
56-
<Button
57-
iconAfter={<DropdownArrowIcon />}
58-
kind={Button.kinds.inline}
59-
>
62+
<Button iconAfter={<DropdownArrowIcon />} kind={Button.kinds.inline}>
6063
File name
6164
</Button>
6265
);

client/common/icons.jsx

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import CircleTerminal from '../images/circle-terminal.svg';
2323
import CircleFolder from '../images/circle-folder.svg';
2424
import CircleInfo from '../images/circle-info.svg';
2525

26-
2726
// HOC that adds the right web accessibility props
2827
// https://www.scottohara.me/blog/2019/05/22/contextual-images-svgs-and-a11y.html
2928

@@ -34,13 +33,17 @@ function withLabel(SvgComponent) {
3433
const StyledIcon = styled(SvgComponent)`
3534
&&& {
3635
color: ${prop('Icon.default')};
37-
& g, & path, & polygon {
36+
& g,
37+
& path,
38+
& polygon {
3839
opacity: 1;
3940
fill: ${prop('Icon.default')};
4041
}
4142
&:hover {
4243
color: ${prop('Icon.hover')};
43-
& g, & path, & polygon {
44+
& g,
45+
& path,
46+
& polygon {
4447
opacity: 1;
4548
fill: ${prop('Icon.hover')};
4649
}
@@ -50,18 +53,16 @@ function withLabel(SvgComponent) {
5053

5154
const { 'aria-label': ariaLabel } = props;
5255
if (ariaLabel) {
53-
return (<StyledIcon
54-
{...props}
55-
aria-label={ariaLabel}
56-
role="img"
57-
focusable="false"
58-
/>);
56+
return (
57+
<StyledIcon
58+
{...props}
59+
aria-label={ariaLabel}
60+
role="img"
61+
focusable="false"
62+
/>
63+
);
5964
}
60-
return (<StyledIcon
61-
{...props}
62-
aria-hidden
63-
focusable="false"
64-
/>);
65+
return <StyledIcon {...props} aria-hidden focusable="false" />;
6566
};
6667

6768
Icon.propTypes = {

client/common/icons.stories.jsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,5 @@ export const AllIcons = () => {
1212
const names = Object.keys(icons);
1313

1414
const SelectedIcon = icons[select('name', names, names[0])];
15-
return (
16-
<SelectedIcon />
17-
);
15+
return <SelectedIcon />;
1816
};

client/components/AddRemoveButton.jsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@ import React from 'react';
22
import PropTypes from 'prop-types';
33
import { withTranslation } from 'react-i18next';
44

5-
65
import AddIcon from '../images/plus.svg';
76
import RemoveIcon from '../images/minus.svg';
87

98
const AddRemoveButton = ({ type, onClick, t }) => {
10-
const alt = type === 'add' ? t('AddRemoveButton.AltAddARIA') : t('AddRemoveButton.AltRemoveARIA');
9+
const alt =
10+
type === 'add'
11+
? t('AddRemoveButton.AltAddARIA')
12+
: t('AddRemoveButton.AltRemoveARIA');
1113
const Icon = type === 'add' ? AddIcon : RemoveIcon;
1214

1315
return (

0 commit comments

Comments
 (0)