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

Bump prettier to 2.0.0 #20211

Merged
merged 8 commits into from
Mar 22, 2020
Merged
Show file tree
Hide file tree
Changes from 5 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
3 changes: 0 additions & 3 deletions .dependabot/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ update_configs:
- match:
# These should be grouped once a PR for `jss` is opened
dependency_name: 'jss-*'
- match:
# 1.18 started adding trailing commas only compatible with typescript ^3.4
dependency_name: 'prettier'
- match:
# 2.0 started using ES modules instead of CommonJS modules
dependency_name: 'raw-loader'
Expand Down
9 changes: 9 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
eps1lon marked this conversation as resolved.
Show resolved Hide resolved
"bracketSpacing": true,
eps1lon marked this conversation as resolved.
Show resolved Hide resolved
"jsxBracketSameLine": false,
eps1lon marked this conversation as resolved.
Show resolved Hide resolved
"printWidth": 100,
"semi": true,
eps1lon marked this conversation as resolved.
Show resolved Hide resolved
"singleQuote": true,
"trailingComma": "all",
"arrowParens": "avoid"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Default in 2.0.0 is always. This would introduce 600 changed filed. I guess we already agreed to not follow it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would be in favor of using the default

Suggested change
"arrowParens": "avoid"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes me so happy :D Let's do this and get rid of the explicit defaults.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, singleQuote and trailingComma seems the only two we need to keep? https://github.com/facebook/react/blob/master/.prettierrc.js

Copy link
Member

@oliviertassinari oliviertassinari Mar 21, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As long as it matches (more or less) the format of the demos in https://reactjs.org/, we should be fine.

}
2 changes: 1 addition & 1 deletion docs/scripts/formattedTSDemos.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const babelConfig = {
const workspaceRoot = path.join(__dirname, '../../');

const prettierConfig = prettier.resolveConfig.sync(process.cwd(), {
config: path.join(workspaceRoot, 'prettier.config.js'),
config: path.join(workspaceRoot, '.prettierrc'),
});

async function getFiles(root) {
Expand Down
6 changes: 3 additions & 3 deletions docs/src/modules/components/AdCarbon.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ const styles = theme => ({
display: 'block',
overflow: 'hidden',
backgroundColor: theme.palette.background.level2,
padding: `${theme.spacing(1.5)}px ${theme.spacing(1.5)}px ${theme.spacing(
1.5,
)}px ${theme.spacing(1.5) + 130}px`,
padding: `${theme.spacing(1.5)}px ${theme.spacing(1.5)}px ${theme.spacing(1.5)}px ${
theme.spacing(1.5) + 130
}px`,
borderRadius: theme.shape.borderRadius,
'& .carbon-img': {
float: 'left',
Expand Down
6 changes: 3 additions & 3 deletions docs/src/modules/components/AdCodeFund.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ const styles = theme => ({
display: 'block',
overflow: 'hidden',
backgroundColor: theme.palette.background.level2,
padding: `${theme.spacing(1.5)}px ${theme.spacing(1.5)}px ${theme.spacing(
1.5,
)}px ${theme.spacing(1.5) + 130}px`,
padding: `${theme.spacing(1.5)}px ${theme.spacing(1.5)}px ${theme.spacing(1.5)}px ${
theme.spacing(1.5) + 130
}px`,
borderRadius: theme.shape.borderRadius,
'& .cf-img-wrapper.cf-img-wrapper': {
float: 'left',
Expand Down
6 changes: 3 additions & 3 deletions docs/src/modules/components/AdInHouse.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ const useStyles = makeStyles(theme => ({
display: 'block',
overflow: 'hidden',
backgroundColor: theme.palette.background.level2,
padding: `${theme.spacing(1.5)}px ${theme.spacing(1.5)}px ${theme.spacing(
1.5,
)}px ${theme.spacing(1.5) + 130}px`,
padding: `${theme.spacing(1.5)}px ${theme.spacing(1.5)}px ${theme.spacing(1.5)}px ${
theme.spacing(1.5) + 130
}px`,
borderRadius: theme.shape.borderRadius,
'& $imageWrapper': {
float: 'left',
Expand Down
6 changes: 1 addition & 5 deletions docs/src/modules/components/Demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,7 @@ function useUniqueId(prefix) {
// useOpaqueReference
const [id, setDemoId] = React.useState(null);
React.useEffect(() => {
setDemoId(
Math.random()
.toString(36)
.slice(2),
);
setDemoId(Math.random().toString(36).slice(2));
}, []);

return `${prefix}${id}`;
Expand Down
5 changes: 1 addition & 4 deletions docs/src/modules/redux/initRedux.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,7 @@ function create(initialState) {
options: optionsReducer,
}),
initialState, // Hydrate the store with server-side data
compose(
applyMiddleware(...middleware),
devtools,
),
compose(applyMiddleware(...middleware), devtools),
);
}

Expand Down
5 changes: 1 addition & 4 deletions docs/src/modules/utils/find.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,7 @@ function findPagesMarkdown(
.replace('.md', '');

// Remove the last pathname segment.
pathname = pathname
.split('/')
.slice(0, 3)
.join('/');
pathname = pathname.split('/').slice(0, 3).join('/');

pagesMarkdown.push({
// Relative location in the path (URL) system.
Expand Down
5 changes: 1 addition & 4 deletions docs/src/modules/utils/generateMarkdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,7 @@ function getChained(type) {

function escapeCell(value) {
// As the pipe is use for the table structure
return value
.replace(/</g, '&lt;')
.replace(/`&lt;/g, '`<')
.replace(/\|/g, '\\|');
return value.replace(/</g, '&lt;').replace(/`&lt;/g, '`<').replace(/\|/g, '\\|');
}

function isElementTypeAcceptingRefProp(type) {
Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/components/autocomplete/GoogleMaps.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ interface PlaceType {
{
offset: number;
length: number;
}
},
];
};
}
Expand Down
4 changes: 1 addition & 3 deletions docs/src/pages/components/material-icons/SearchIcons.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,7 @@ let DialogDetails = props => {
<MarkdownElement
className={classes.markdown}
onClick={handleClick}
text={`\`\`\`js\nimport ${selectedIcon.key}Icon from '@material-ui/icons/${
selectedIcon.key
}';\n\`\`\``}
text={`\`\`\`js\nimport ${selectedIcon.key}Icon from '@material-ui/icons/${selectedIcon.key}';\n\`\`\``}
/>
<Link
className={classes.import}
Expand Down
95 changes: 48 additions & 47 deletions docs/src/pages/discover-more/showcase/Showcase.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,56 +87,57 @@ function Showcase(props) {
<MenuItem value="stars">{t('stars')}</MenuItem>
</Select>
</FormControl>
{stableSort(appList.filter(item => item[sortFunctionName] !== undefined), sortFunction).map(
app => (
<div key={app.title}>
<Typography component="h2" variant="h4" gutterBottom className={classes.title}>
<span>{app.title}</span>
{app.source ? (
<IconButton
href={app.source}
target="_blank"
aria-label={`${app.title} ${t('sourceCode')}`}
>
<GitHubIcon />
</IconButton>
) : null}
</Typography>
{app.image ? (
<Card className={classes.card}>
<CardMedia
component="a"
href={app.link}
rel="noopener"
target="_blank"
className={classes.cardMedia}
image={`/static/images/showcase/${app.image}`}
title={app.title}
/>
</Card>
) : (
<Link
variant="body2"
{stableSort(
appList.filter(item => item[sortFunctionName] !== undefined),
sortFunction,
).map(app => (
<div key={app.title}>
<Typography component="h2" variant="h4" gutterBottom className={classes.title}>
<span>{app.title}</span>
{app.source ? (
<IconButton
href={app.source}
target="_blank"
rel="noopener nofollow"
href={app.link}
gutterBottom
aria-label={`${app.title} ${t('sourceCode')}`}
>
{t('visit')}
</Link>
)}
<Typography gutterBottom>{app.description}</Typography>
<Typography
variant="caption"
display="block"
color="textSecondary"
className={classes.description}
<GitHubIcon />
</IconButton>
) : null}
</Typography>
{app.image ? (
<Card className={classes.card}>
<CardMedia
component="a"
href={app.link}
rel="noopener"
target="_blank"
className={classes.cardMedia}
image={`/static/images/showcase/${app.image}`}
title={app.title}
/>
</Card>
) : (
<Link
variant="body2"
target="_blank"
rel="noopener nofollow"
href={app.link}
gutterBottom
>
{app.dateAdded}
</Typography>
</div>
),
)}
{t('visit')}
</Link>
)}
<Typography gutterBottom>{app.description}</Typography>
<Typography
variant="caption"
display="block"
color="textSecondary"
className={classes.description}
>
{app.dateAdded}
</Typography>
</div>
))}
</div>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ const options = {
h1: { component: props => <Typography gutterBottom variant="h4" {...props} /> },
h2: { component: props => <Typography gutterBottom variant="h6" {...props} /> },
h3: { component: props => <Typography gutterBottom variant="subtitle1" {...props} /> },
h4: { component: props => <Typography gutterBottom variant="caption" paragraph {...props} /> },
h4: {
component: props => <Typography gutterBottom variant="caption" paragraph {...props} />,
},
p: { component: props => <Typography paragraph {...props} /> },
a: { component: Link },
li: {
Expand Down
7 changes: 1 addition & 6 deletions docs/src/pages/system/basics/CssProp.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,7 @@ import { createMuiTheme } from '@material-ui/core/styles';
import { compose, spacing, palette, css } from '@material-ui/system';

const Box = styled.div`
${css(
compose(
spacing,
palette,
),
)}
${css(compose(spacing, palette))}
`;

const theme = createMuiTheme();
Expand Down
7 changes: 1 addition & 6 deletions docs/src/pages/system/basics/CssProp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,7 @@ import { createMuiTheme } from '@material-ui/core/styles';
import { compose, spacing, palette, css } from '@material-ui/system';

const Box = styled.div`
${css(
compose(
spacing,
palette,
),
)}
${css(compose(spacing, palette))}
`;

const theme = createMuiTheme();
Expand Down
7 changes: 1 addition & 6 deletions docs/src/pages/system/basics/JSS.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@ import React from 'react';
import { styled } from '@material-ui/core/styles';
import { compose, spacing, palette } from '@material-ui/system';

const Box = styled('div')(
compose(
spacing,
palette,
),
);
const Box = styled('div')(compose(spacing, palette));

export default function JSS() {
return (
Expand Down
7 changes: 1 addition & 6 deletions docs/src/pages/system/basics/JSS.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@ import React from 'react';
import { styled } from '@material-ui/core/styles';
import { compose, spacing, palette } from '@material-ui/system';

const Box = styled('div')(
compose(
spacing,
palette,
),
);
const Box = styled('div')(compose(spacing, palette));

export default function JSS() {
return (
Expand Down
4 changes: 1 addition & 3 deletions framer/Material-UI.framerfx/code/Chip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,7 @@ export const Chip: React.SFC<Props> = (props: Props) => {
avatar={
avatarImageFile || avatarImageUrl ? (
<Avatar imageFile={avatarImageFile} imageUrl={avatarImageUrl} />
) : (
undefined
)
) : undefined
}
icon={<Icon icon={icon} theme={iconTheme} />}
onDelete={deletable ? () => {} : undefined}
Expand Down
4 changes: 1 addition & 3 deletions framer/Material-UI.framerfx/code/SnackbarContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ export const SnackbarContent: React.SFC<Props> = (props: Props) => {
<MuiButton color="secondary" size="small">
{label}
</MuiButton>
) : (
undefined
);
) : undefined;

return <MuiSnackbarContent action={action} {...other} />;
};
Expand Down
2 changes: 1 addition & 1 deletion framer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@
"build": "yarn build:core && yarn build:styles && yarn prettier",
"build:core": "cross-env BABEL_ENV=test babel-node --config-file ../babel.config.js ./scripts/buildFramer.js ../packages/material-ui/src ./Material-UI.framerfx/code",
"build:styles": "cross-env BABEL_ENV=test babel-node --config-file ../babel.config.js ./scripts/buildFramer.js ../packages/material-ui-styles/src ./Material-UI.framerfx/code",
"prettier": "prettier --write --config ../prettier.config.js './**/*.{js,tsx}'"
"prettier": "prettier --write --config ../.prettierrc' './**/*.{js,tsx}'"
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
"mocha": "^7.0.0",
"node-fetch": "^ 2.6.0",
"nyc": "^15.0.0",
"prettier": "1.17.0",
"prettier": "^2.0.0",
"pretty-bytes": "^5.3.0",
"pretty-format-v24": "npm:pretty-format@24",
"prop-types": "^15.7.2",
Expand Down
6 changes: 1 addition & 5 deletions packages/material-ui-benchmark/src/system.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,7 @@ const suite = new Benchmark.Suite('system', {
});
Benchmark.options.minSamples = 100;

const materialSystem = compose(
palette,
spacing,
typography,
);
const materialSystem = compose(palette, spacing, typography);
const styledSystem = compose2(color, space, fontFamily, fontSize);

const BoxStyles = styled('div')(styleFunction);
Expand Down
5 changes: 1 addition & 4 deletions packages/material-ui-codemod/src/v1.0.0/svg-icon-imports.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@ function capitalize(string) {
* @param {string} iconName
*/
function pascalize(iconName) {
return iconName
.split('-')
.map(capitalize)
.join('');
return iconName.split('-').map(capitalize).join('');
}

/**
Expand Down
4 changes: 1 addition & 3 deletions packages/material-ui-icons/scripts/download.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ function downloadIcon(icon) {
Object.keys(themeMap).map(async theme => {
const formattedTheme = themeMap[theme].split('_').join('');
const response = await fetch(
`https://fonts.gstatic.com/s/i/materialicons${formattedTheme}/${icon.name}/v${
icon.version
}/24px.svg`,
`https://fonts.gstatic.com/s/i/materialicons${formattedTheme}/${icon.name}/v${icon.version}/24px.svg`,
);
if (response.status !== 200) {
throw new Error(`status ${response.status}`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -806,7 +806,10 @@ describe('<Autocomplete />', () => {
});

it('warn if getOptionSelected match multiple values for a given option', () => {
const value = [{ id: '10', text: 'One' }, { id: '20', text: 'Two' }];
const value = [
{ id: '10', text: 'One' },
{ id: '20', text: 'Two' },
];
const options = [
{ id: '10', text: 'One' },
{ id: '20', text: 'Two' },
Expand Down
Loading