Skip to content

Commit

Permalink
[code-infra] Update prettier and pretty-quick (mui#11735)
Browse files Browse the repository at this point in the history
  • Loading branch information
Janpot authored Jan 24, 2024
1 parent 014c978 commit 76dc850
Show file tree
Hide file tree
Showing 72 changed files with 292 additions and 389 deletions.
11 changes: 7 additions & 4 deletions docs/data/data-grid/editing/ValidateServerNameGrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,13 @@ function validateName(username) {
const existingUsers = rows.map((row) => row.name.toLowerCase());

return new Promise((resolve) => {
promiseTimeout = setTimeout(() => {
const exists = existingUsers.includes(username.toLowerCase());
resolve(exists ? `${username} is already taken.` : null);
}, Math.random() * 500 + 100); // simulate network latency
promiseTimeout = setTimeout(
() => {
const exists = existingUsers.includes(username.toLowerCase());
resolve(exists ? `${username} is already taken.` : null);
},
Math.random() * 500 + 100,
); // simulate network latency
});
}

Expand Down
11 changes: 7 additions & 4 deletions docs/data/data-grid/editing/ValidateServerNameGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,13 @@ function validateName(username: string): Promise<boolean> {
const existingUsers = rows.map((row) => row.name.toLowerCase());

return new Promise<any>((resolve) => {
promiseTimeout = setTimeout(() => {
const exists = existingUsers.includes(username.toLowerCase());
resolve(exists ? `${username} is already taken.` : null);
}, Math.random() * 500 + 100); // simulate network latency
promiseTimeout = setTimeout(
() => {
const exists = existingUsers.includes(username.toLowerCase());
resolve(exists ? `${username} is already taken.` : null);
},
Math.random() * 500 + 100,
); // simulate network latency
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ function CustomHeaderFilter(props: GridHeaderFilterCellProps) {

const publish = React.useCallback(
(
eventName: keyof GridHeaderFilterEventLookup,
propHandler?: React.EventHandler<any>,
) =>
eventName: keyof GridHeaderFilterEventLookup,
propHandler?: React.EventHandler<any>,
) =>
(event: React.SyntheticEvent) => {
apiRef.current.publishEvent(
eventName,
Expand Down
15 changes: 9 additions & 6 deletions docs/data/data-grid/row-ordering/RowOrderingGrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@ import { useDemoData } from '@mui/x-data-grid-generator';

function updateRowPosition(initialIndex, newIndex, rows) {
return new Promise((resolve) => {
setTimeout(() => {
const rowsClone = [...rows];
const row = rowsClone.splice(initialIndex, 1)[0];
rowsClone.splice(newIndex, 0, row);
resolve(rowsClone);
}, Math.random() * 500 + 100); // simulate network latency
setTimeout(
() => {
const rowsClone = [...rows];
const row = rowsClone.splice(initialIndex, 1)[0];
rowsClone.splice(newIndex, 0, row);
resolve(rowsClone);
},
Math.random() * 500 + 100,
); // simulate network latency
});
}

Expand Down
15 changes: 9 additions & 6 deletions docs/data/data-grid/row-ordering/RowOrderingGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,15 @@ function updateRowPosition(
rows: Array<GridRowModel>,
): Promise<any> {
return new Promise((resolve) => {
setTimeout(() => {
const rowsClone = [...rows];
const row = rowsClone.splice(initialIndex, 1)[0];
rowsClone.splice(newIndex, 0, row);
resolve(rowsClone);
}, Math.random() * 500 + 100); // simulate network latency
setTimeout(
() => {
const rowsClone = [...rows];
const row = rowsClone.splice(initialIndex, 1)[0];
rowsClone.splice(newIndex, 0, row);
resolve(rowsClone);
},
Math.random() * 500 + 100,
); // simulate network latency
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ import { useDemoData, randomInt } from '@mui/x-data-grid-generator';

function loadServerRows(page, data) {
return new Promise((resolve) => {
setTimeout(() => {
resolve(data.rows.slice(page * 5, (page + 1) * 5));
}, randomInt(100, 600)); // simulate network latency
setTimeout(
() => {
resolve(data.rows.slice(page * 5, (page + 1) * 5));
},
randomInt(100, 600),
); // simulate network latency
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ import { GridDemoData, useDemoData, randomInt } from '@mui/x-data-grid-generator

function loadServerRows(page: number, data: GridDemoData): Promise<any> {
return new Promise((resolve) => {
setTimeout(() => {
resolve(data.rows.slice(page * 5, (page + 1) * 5));
}, randomInt(100, 600)); // simulate network latency
setTimeout(
() => {
resolve(data.rows.slice(page * 5, (page + 1) * 5));
},
randomInt(100, 600),
); // simulate network latency
});
}

Expand Down
17 changes: 10 additions & 7 deletions docs/data/data-grid/tree-data/TreeDataLazyLoading.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,16 @@ const getChildren = (parentPath) => {
*/
const fakeDataFetcher = (parentPath = []) =>
new Promise((resolve) => {
setTimeout(() => {
const rows = getChildren(parentPath).map((row) => ({
...row,
descendantCount: getChildren(row.hierarchy).length,
}));
resolve(rows);
}, 500 + Math.random() * 300);
setTimeout(
() => {
const rows = getChildren(parentPath).map((row) => ({
...row,
descendantCount: getChildren(row.hierarchy).length,
}));
resolve(rows);
},
500 + Math.random() * 300,
);
});

const LoadingContainer = styled('div')({
Expand Down
17 changes: 10 additions & 7 deletions docs/data/data-grid/tree-data/TreeDataLazyLoading.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,16 @@ const getChildren = (parentPath: string[]) => {
*/
const fakeDataFetcher = (parentPath: string[] = []) =>
new Promise<GridRowModel<Row>[]>((resolve) => {
setTimeout(() => {
const rows = getChildren(parentPath).map((row) => ({
...row,
descendantCount: getChildren(row.hierarchy).length,
}));
resolve(rows);
}, 500 + Math.random() * 300);
setTimeout(
() => {
const rows = getChildren(parentPath).map((row) => ({
...row,
descendantCount: getChildren(row.hierarchy).length,
}));
resolve(rows);
},
500 + Math.random() * 300,
);
});

const LoadingContainer = styled('div')({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,13 @@ function AutocompleteDatePicker(props: AutocompleteDatePickerProps) {

const optionsLookup = React.useMemo(
() =>
options.reduce((acc, option) => {
acc[option.toISOString()] = true;
return acc;
}, {} as Record<string, boolean>),
options.reduce(
(acc, option) => {
acc[option.toISOString()] = true;
return acc;
},
{} as Record<string, boolean>,
),
[options],
);

Expand Down
2 changes: 1 addition & 1 deletion docs/data/date-pickers/date-calendar/WeekPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export default function WeekPicker() {
hoveredDay,
onPointerEnter: () => setHoveredDay(ownerState.day),
onPointerLeave: () => setHoveredDay(null),
} as any),
}) as any,
}}
/>
</LocalizationProvider>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
hoveredDay,
onPointerEnter: () => setHoveredDay(ownerState.day),
onPointerLeave: () => setHoveredDay(null),
} as any),
}) as any,
}}
/>
4 changes: 2 additions & 2 deletions docs/data/date-pickers/lifecycle/ServerInteraction.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ function DisplayEvents(props) {
value === null
? 'null'
: value.isValid()
? value.format('DD/MM/YYYY')
: 'Invalid Date'
? value.format('DD/MM/YYYY')
: 'Invalid Date'
}`,
)
.join('\n')}
Expand Down
4 changes: 2 additions & 2 deletions docs/data/date-pickers/lifecycle/ServerInteraction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ function DisplayEvents(props: DisplayEventsProps) {
value === null
? 'null'
: value.isValid()
? value.format('DD/MM/YYYY')
: 'Invalid Date'
? value.format('DD/MM/YYYY')
: 'Invalid Date'
}`,
)
.join('\n')}
Expand Down
4 changes: 1 addition & 3 deletions docs/scripts/formattedTSDemos.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,7 @@ async function getFiles(root) {

try {
await Promise.all(
(
await fse.readdir(root)
).map(async (name) => {
(await fse.readdir(root)).map(async (name) => {
const filePath = path.join(root, name);
const stat = await fse.stat(filePath);

Expand Down
4 changes: 1 addition & 3 deletions docs/scripts/populatePickersDemos.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ async function getFiles(root) {

try {
await Promise.all(
(
await fse.readdir(root)
).map(async (name) => {
(await fse.readdir(root)).map(async (name) => {
const filePath = path.join(root, name);
const stat = await fse.stat(filePath);

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@
"nyc": "^15.1.0",
"patch-package": "^7.0.2",
"postinstall-postinstall": "^2.1.0",
"prettier": "^2.8.8",
"pretty-quick": "^3.1.3",
"prettier": "^3.2.4",
"pretty-quick": "^4.0.0",
"process": "^0.11.10",
"react": "^18.2.0",
"react-dom": "^18.2.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ describe('<DataGridPremium /> - Clipboard', () => {
...column,
type: 'string',
editable: true,
} as GridColDef),
}) as GridColDef,
),
};
}, [rowLength, colLength]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ function GridRowReorderCell(params: GridRenderCellParams) {

const publish = React.useCallback(
(
eventName: keyof GridRowEventLookup,
propHandler?: React.MouseEventHandler<HTMLDivElement> | undefined,
): React.MouseEventHandler<HTMLDivElement> =>
eventName: keyof GridRowEventLookup,
propHandler?: React.MouseEventHandler<HTMLDivElement> | undefined,
): React.MouseEventHandler<HTMLDivElement> =>
(event) => {
// Ignore portal
if (isEventTargetInPortal(event)) {
Expand Down
71 changes: 35 additions & 36 deletions packages/grid/x-data-grid/src/components/GridFooter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,46 +9,45 @@ import { GridSelectedRowCount } from './GridSelectedRowCount';
import { GridFooterContainer, GridFooterContainerProps } from './containers/GridFooterContainer';
import { useGridRootProps } from '../hooks/utils/useGridRootProps';

const GridFooter = React.forwardRef<HTMLDivElement, GridFooterContainerProps>(function GridFooter(
props,
ref,
) {
const apiRef = useGridApiContext();
const rootProps = useGridRootProps();
const totalTopLevelRowCount = useGridSelector(apiRef, gridTopLevelRowCountSelector);
const selectedRowCount = useGridSelector(apiRef, selectedGridRowsCountSelector);
const visibleTopLevelRowCount = useGridSelector(apiRef, gridFilteredTopLevelRowCountSelector);
const GridFooter = React.forwardRef<HTMLDivElement, GridFooterContainerProps>(
function GridFooter(props, ref) {
const apiRef = useGridApiContext();
const rootProps = useGridRootProps();
const totalTopLevelRowCount = useGridSelector(apiRef, gridTopLevelRowCountSelector);
const selectedRowCount = useGridSelector(apiRef, selectedGridRowsCountSelector);
const visibleTopLevelRowCount = useGridSelector(apiRef, gridFilteredTopLevelRowCountSelector);

const selectedRowCountElement =
!rootProps.hideFooterSelectedRowCount && selectedRowCount > 0 ? (
<GridSelectedRowCount selectedRowCount={selectedRowCount} />
) : (
<div />
);
const selectedRowCountElement =
!rootProps.hideFooterSelectedRowCount && selectedRowCount > 0 ? (
<GridSelectedRowCount selectedRowCount={selectedRowCount} />
) : (
<div />
);

const rowCountElement =
!rootProps.hideFooterRowCount && !rootProps.pagination ? (
<rootProps.slots.footerRowCount
{...rootProps.slotProps?.footerRowCount}
rowCount={totalTopLevelRowCount}
visibleRowCount={visibleTopLevelRowCount}
/>
) : null;
const rowCountElement =
!rootProps.hideFooterRowCount && !rootProps.pagination ? (
<rootProps.slots.footerRowCount
{...rootProps.slotProps?.footerRowCount}
rowCount={totalTopLevelRowCount}
visibleRowCount={visibleTopLevelRowCount}
/>
) : null;

const paginationElement = rootProps.pagination &&
!rootProps.hideFooterPagination &&
rootProps.slots.pagination && (
<rootProps.slots.pagination {...rootProps.slotProps?.pagination} />
);
const paginationElement = rootProps.pagination &&
!rootProps.hideFooterPagination &&
rootProps.slots.pagination && (
<rootProps.slots.pagination {...rootProps.slotProps?.pagination} />
);

return (
<GridFooterContainer ref={ref} {...props}>
{selectedRowCountElement}
{rowCountElement}
{paginationElement}
</GridFooterContainer>
);
});
return (
<GridFooterContainer ref={ref} {...props}>
{selectedRowCountElement}
{rowCountElement}
{paginationElement}
</GridFooterContainer>
);
},
);

GridFooter.propTypes = {
// ----------------------------- Warning --------------------------------
Expand Down
6 changes: 3 additions & 3 deletions packages/grid/x-data-grid/src/components/GridRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,9 @@ const GridRow = React.forwardRef<HTMLDivElement, GridRowProps>(function GridRow(

const publish = React.useCallback(
(
eventName: keyof GridRowEventLookup,
propHandler: React.MouseEventHandler<HTMLDivElement> | undefined,
): React.MouseEventHandler<HTMLDivElement> =>
eventName: keyof GridRowEventLookup,
propHandler: React.MouseEventHandler<HTMLDivElement> | undefined,
): React.MouseEventHandler<HTMLDivElement> =>
(event) => {
// Ignore portal
if (isEventTargetInPortal(event)) {
Expand Down
Loading

0 comments on commit 76dc850

Please sign in to comment.