Skip to content

Commit

Permalink
Bump prettier to 2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
eps1lon committed Mar 21, 2020
1 parent 860e2d0 commit 2700af2
Show file tree
Hide file tree
Showing 45 changed files with 109 additions and 277 deletions.
9 changes: 9 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"bracketSpacing": true,
"jsxBracketSameLine": false,
"printWidth": 100,
"semi": true,
"singleQuote": true,
"trailingComma": "all",
"arrowParens": "avoid"
}
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/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
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
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.19.1",
"prettier": "^2.0.0",
"pretty-bytes": "^5.3.0",
"pretty-format-v24": "npm:pretty-format@24",
"prop-types": "^15.7.2",
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
7 changes: 2 additions & 5 deletions packages/material-ui-lab/src/SpeedDial/SpeedDial.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,10 +183,7 @@ describe('<SpeedDial />', () => {
if (actionIndex === -1) {
return getDialButton();
}
return wrapper
.find(SpeedDialAction)
.at(actionIndex)
.find(Fab);
return wrapper.find(SpeedDialAction).at(actionIndex).find(Fab);
};
/**
* @returns true if the button of the nth action is focused
Expand Down Expand Up @@ -225,7 +222,7 @@ describe('<SpeedDial />', () => {
});

// eslint-disable-next-line func-names
describe('actions navigation', function() {
describe('actions navigation', function () {
this.timeout(5000); // These tests are really slow.

/**
Expand Down
20 changes: 5 additions & 15 deletions packages/material-ui-lab/src/TreeItem/TreeItem.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,21 +70,11 @@ describe('<TreeItem />', () => {

const getIcon = testId => getByTestId(testId).querySelector(`.${classes.iconContainer} div`);

expect(getIcon('1'))
.attribute('data-test')
.to.equal('defaultCollapseIcon');
expect(getIcon('2'))
.attribute('data-test')
.to.equal('defaultEndIcon');
expect(getIcon('3'))
.attribute('data-test')
.to.equal('defaultExpandIcon');
expect(getIcon('5'))
.attribute('data-test')
.to.equal('icon');
expect(getIcon('6'))
.attribute('data-test')
.to.equal('endIcon');
expect(getIcon('1')).attribute('data-test').to.equal('defaultCollapseIcon');
expect(getIcon('2')).attribute('data-test').to.equal('defaultEndIcon');
expect(getIcon('3')).attribute('data-test').to.equal('defaultExpandIcon');
expect(getIcon('5')).attribute('data-test').to.equal('icon');
expect(getIcon('6')).attribute('data-test').to.equal('endIcon');
});

it('should treat an empty array equally to no children', () => {
Expand Down
5 changes: 3 additions & 2 deletions packages/material-ui-styles/test/styles.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,9 @@ withStyles(theme =>
// explicit not but with "Property 'children' is missing in type 'ValidationMap<Props>'".
// which is not helpful
const StatelessComponent: React.FunctionComponent<Props> = props => null;
const StatelessComponentWithStyles: React.FunctionComponent<Props &
WithStyles<typeof styles>> = props => null;
const StatelessComponentWithStyles: React.FunctionComponent<
Props & WithStyles<typeof styles>
> = props => null;
withStyles(styles)(StatelessComponent); // $ExpectError
withStyles(styles)(StatelessComponentWithStyles); // $ExpectError
}
Expand Down
25 changes: 5 additions & 20 deletions packages/material-ui/src/BottomNavigation/BottomNavigation.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,7 @@ describe('<BottomNavigation />', () => {
<BottomNavigationAction icon={icon} />
</BottomNavigation>,
);
wrapper
.find(BottomNavigationAction)
.at(1)
.simulate('click');
wrapper.find(BottomNavigationAction).at(1).simulate('click');
assert.strictEqual(handleChange.callCount, 1);
assert.strictEqual(handleChange.args[0][1], 1);
});
Expand All @@ -97,10 +94,7 @@ describe('<BottomNavigation />', () => {
<BottomNavigationAction value="second" icon={icon} />
</BottomNavigation>,
);
wrapper
.find(BottomNavigationAction)
.at(1)
.simulate('click');
wrapper.find(BottomNavigationAction).at(1).simulate('click');
assert.strictEqual(
handleChange.args[0][1],
'second',
Expand All @@ -117,20 +111,11 @@ describe('<BottomNavigation />', () => {
<BottomNavigationAction value={null} icon={icon} />
</BottomNavigation>,
);
wrapper
.find(BottomNavigationAction)
.at(0)
.simulate('click');
wrapper.find(BottomNavigationAction).at(0).simulate('click');
assert.strictEqual(handleChange.args[0][1], '');
wrapper
.find(BottomNavigationAction)
.at(1)
.simulate('click');
wrapper.find(BottomNavigationAction).at(1).simulate('click');
assert.strictEqual(handleChange.args[1][1], 1);
wrapper
.find(BottomNavigationAction)
.at(2)
.simulate('click');
wrapper.find(BottomNavigationAction).at(2).simulate('click');
assert.strictEqual(handleChange.args[2][1], null);
});
});
4 changes: 1 addition & 3 deletions packages/material-ui/src/ButtonBase/ButtonBase.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,7 @@ describe('<ButtonBase />', () => {
);
const checkbox = getByRole('checkbox');
expect(checkbox).to.have.property('nodeName', 'SPAN');
expect(checkbox)
.attribute('tabIndex')
.to.equal('0');
expect(checkbox).attribute('tabIndex').to.equal('0');
});

it('should not apply role="button" if type="button"', () => {
Expand Down
20 changes: 4 additions & 16 deletions packages/material-ui/src/Collapse/Collapse.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,7 @@ describe('<Collapse />', () => {
const wrapper = mount(<Collapse {...defaultProps}>{children}</Collapse>);
const child = wrapper.find('Transition').childAt(0);
assert.strictEqual(child.childAt(0).name(), 'div');
assert.strictEqual(
child
.childAt(0)
.childAt(0)
.children()
.type(),
'h1',
);
assert.strictEqual(child.childAt(0).childAt(0).children().type(), 'h1');
});

describe('transition lifecycle', () => {
Expand Down Expand Up @@ -215,14 +208,9 @@ describe('<Collapse />', () => {
const wrapper = mount(<Test />);

// Gets wrapper
stub(
wrapper
.find('Transition')
.childAt(0)
.childAt(0)
.instance(),
'clientHeight',
).get(() => 10);
stub(wrapper.find('Transition').childAt(0).childAt(0).instance(), 'clientHeight').get(
() => 10,
);

wrapper.setProps({
in: true,
Expand Down
16 changes: 2 additions & 14 deletions packages/material-ui/src/ExpansionPanel/ExpansionPanel.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,20 +54,8 @@ describe('<ExpansionPanel />', () => {
</ExpansionPanel>,
);

assert.strictEqual(
wrapper
.find('[aria-expanded=false]')
.hostNodes()
.text(),
'Summary',
);
assert.strictEqual(
wrapper
.find(Collapse)
.find('div#panel-content')
.text(),
'Hello',
);
assert.strictEqual(wrapper.find('[aria-expanded=false]').hostNodes().text(), 'Summary');
assert.strictEqual(wrapper.find(Collapse).find('div#panel-content').text(), 'Hello');
});

it('should be controlled', () => {
Expand Down
8 changes: 1 addition & 7 deletions packages/material-ui/src/FormGroup/FormGroup.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,6 @@ describe('<FormGroup />', () => {

assert.strictEqual(wrapper.children('span').length, 0);
assert.strictEqual(wrapper.children('div').length, 1);
assert.strictEqual(
wrapper
.children('div')
.first()
.hasClass('woofFormGroup'),
true,
);
assert.strictEqual(wrapper.children('div').first().hasClass('woofFormGroup'), true);
});
});
23 changes: 4 additions & 19 deletions packages/material-ui/src/GridList/GridList.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,7 @@ describe('<GridList />', () => {

assert.strictEqual(wrapper.find('.grid-tile').length, 2, 'should contain the children');
assert.strictEqual(
wrapper
.children()
.at(0)
.props().style.height,
wrapper.children().at(0).props().style.height,
cellHeight + 4,
'should have height to 254',
);
Expand Down Expand Up @@ -113,10 +110,7 @@ describe('<GridList />', () => {

assert.strictEqual(wrapper.find('.grid-tile').length, 2, 'should contain the children');
assert.strictEqual(
wrapper
.children()
.at(0)
.props().style.width,
wrapper.children().at(0).props().style.width,
'25%',
'should have 25% of width',
);
Expand All @@ -141,10 +135,7 @@ describe('<GridList />', () => {

assert.strictEqual(wrapper.find('.grid-tile').length, 2, 'should contain the children');
assert.strictEqual(
wrapper
.children()
.at(0)
.props().style.padding,
wrapper.children().at(0).props().style.padding,
spacing / 2,
'should have 5 of padding',
);
Expand Down Expand Up @@ -179,13 +170,7 @@ describe('<GridList />', () => {
</GridList>,
);

assert.strictEqual(
wrapper
.children()
.at(0)
.props().style.height,
'auto',
);
assert.strictEqual(wrapper.children().at(0).props().style.height, 'auto');
});
});

Expand Down
Loading

0 comments on commit 2700af2

Please sign in to comment.