Skip to content

Commit

Permalink
[core] Add prettier command
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviertassinari committed Jun 23, 2020
1 parent 26cd07b commit cfb4836
Show file tree
Hide file tree
Showing 23 changed files with 201 additions and 46 deletions.
6 changes: 6 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/.git
node_modules
dist
packages/grid/lib/lodash
packages/grid/x-grid-modules/lib/autosizer
packages/grid/x-grid-modules/lib/lodash
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"eslint-plugin-react": "^7.18.3",
"eslint-plugin-react-hooks": "^2.5.0",
"eslint-plugin-unused-imports": "^0.1.2",
"glob-gitignore": "^1.0.14",
"jest": "^25.1.0",
"jest-cli": "^25.1.0",
"jest-transform-stub": "^2.0.0",
Expand All @@ -46,6 +47,7 @@
"bootstrap": "lerna bootstrap",
"build": "lerna run build --stream",
"start": "lerna run start --parallel",
"prettier": "node ./scripts/prettier.js",
"test": "lerna run test --parallel",
"lint": "lerna run lint --parallel"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { useTheme } from '../../theme/useTheme';
import KeyboardArrowRightIcon from '@material-ui/icons/KeyboardArrowRight';

export interface SettingsPanelProps {
onApply: (settings: { size: number; type: string; selectedTheme: string, pagesize: number }) => void;
onApply: (settings: { size: number; type: string; selectedTheme: string; pagesize: number }) => void;
type: string;
size: number;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useEffect, useState } from 'react';
import { AppBreadcrumbs } from '../../app-breadcrumbs';
import { Grid, LicenseInfo, RowModel, Columns, GridOptions} from '@material-ui/x-grid';
import { Grid, LicenseInfo, RowModel, Columns, GridOptions } from '@material-ui/x-grid';
import pkg from '@material-ui/x-grid/package.json';
import { MainContainer } from './components/main-container';
import { SettingsPanel } from './components/settings-panel';
Expand Down
2 changes: 1 addition & 1 deletion packages/grid/x-grid-data-generator/bin/data-gen-script.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ require = require('esm')(module /*, options*/);

// eslint-disable-next-line @typescript-eslint/no-var-requires

require('../dist/index-cjs').datagenCli(process.argv);
require('../dist/index-cjs').datagenCli(process.argv);
4 changes: 2 additions & 2 deletions packages/grid/x-grid-modules/src/components/autosizer.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import AutoSizer from '../../lib/autosizer';

export const AutoSizerWrapper: React.FC<any> = p => (
<AutoSizer {...p}>{(size: any) => p.children(size)}</AutoSizer>
export const AutoSizerWrapper: React.FC<any> = props => (
<AutoSizer {...props}>{(size: any) => props.children(size)}</AutoSizer>
);
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ export const RootStyle = styled.div<GridRootProps>`
flex-direction: row;
padding: 0 16px;
}
.row-count, .selected-row-count {
.row-count,
.selected-row-count {
display: flex;
align-items: center;
font-size: 0.875rem;
Expand All @@ -57,7 +58,8 @@ export const RootStyle = styled.div<GridRootProps>`
min-height: 48px;
}
@media (max-width: 650px) {
.row-count, .selected-row-count {
.row-count,
.selected-row-count {
display: none;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ export const useContainerProps = (windowRef: React.RefObject<HTMLDivElement>): R
const renderingZoneHeight = rzPageSize * rowHeight + rowHeight + scrollBarSize.x;
const dataContainerWidth = columnsTotalWidth - scrollBarSize.y;
const totalHeight =
(options.paginationAutoPageSize ? 1 : rowsCount / viewportPageSize) * viewportSize.height + rowHeight +
(options.paginationAutoPageSize ? 1 : rowsCount / viewportPageSize) * viewportSize.height +
rowHeight +
(hasScrollY ? scrollBarSize.x : 0);

const indexes: ContainerProps = {
Expand Down
2 changes: 1 addition & 1 deletion packages/grid/x-grid-modules/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ export * from './models';
export * from './utils';

export * from './gridComponentProps';
export * from './gridComponent';
export * from './gridComponent';
2 changes: 1 addition & 1 deletion packages/grid/x-grid/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,5 @@ export default [
{ exitOnFail: true, wait: true },
),
],
}
},
];
2 changes: 1 addition & 1 deletion packages/license/bin/license-gen-script.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ require = require('esm')(module /*, options*/);

// eslint-disable-next-line @typescript-eslint/no-var-requires

require('../dist/cjs/license-cli').licenseGenCli(process.argv);
require('../dist/cjs/license-cli').licenseGenCli(process.argv);
2 changes: 1 addition & 1 deletion packages/license/src/__tests__/verifyLicense.tests.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { generateLicence } from '../generateLicense';
import { generateReleaseInfo, verifyLicense } from '../verifyLicense';
import {LicenseStatus} from "../licenseStatus";
import { LicenseStatus } from '../licenseStatus';

const oneDayInMS = 1000 * 60 * 60 * 24;
const oneYear = oneDayInMS * 365;
Expand Down
4 changes: 2 additions & 2 deletions packages/license/src/license-cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ export function licenseGenCli(args: any) {
.option('-o, --order <order>', 'Order number id')
.option('-e, --expiry <expiry>', 'Number of days from now until expiry date', '366')
.action(function() {
if(!program.order) {
throw new Error('You forgot to pass an order number. $ > licensegen -o order_123')
if (!program.order) {
throw new Error('You forgot to pass an order number. $ > licensegen -o order_123');
}

const licenseDetails = {
Expand Down
10 changes: 5 additions & 5 deletions packages/license/src/licenseStatus.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export enum LicenseStatus {
NotFound = 'NotFound',
Invalid = 'Invalid',
Expired = 'Expired',
Valid = 'Valid',
}
NotFound = 'NotFound',
Invalid = 'Invalid',
Expired = 'Expired',
Valid = 'Valid',
}
2 changes: 1 addition & 1 deletion packages/license/src/useLicenseVerifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useEffect, useState } from 'react';
import { verifyLicense } from './verifyLicense';
import { LicenseInfo } from './licenseInfo';
import { showExpiredLicenseError, showInvalidLicenseError, showNotFoundLicenseError } from './licenseErrorMessageUtils';
import {LicenseStatus} from "./licenseStatus";
import { LicenseStatus } from './licenseStatus';

export const useLicenseVerifier = () => {
const [licenseStatus, setLicenseStatus] = useState(LicenseStatus.Invalid);
Expand Down
6 changes: 3 additions & 3 deletions packages/license/src/verifyLicense.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {base64Decode, base64Encode} from './encoding/base64';
import {md5} from './encoding/md5';
import {LicenseStatus} from "./licenseStatus";
import { base64Decode, base64Encode } from './encoding/base64';
import { md5 } from './encoding/md5';
import { LicenseStatus } from './licenseStatus';

export const generateReleaseInfo = () => {
const today = new Date();
Expand Down
6 changes: 3 additions & 3 deletions packages/panel/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ export default {
external: [...Object.keys(pkg.peerDependencies || {})],
plugins: [
production &&
cleaner({
targets: ['./dist/'],
}),
cleaner({
targets: ['./dist/'],
}),
typescript(),
!production && sourceMaps(),
production && terser(),
Expand Down
6 changes: 3 additions & 3 deletions packages/splitter/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ export default {
external: [...Object.keys(pkg.peerDependencies || {})],
plugins: [
production &&
cleaner({
targets: ['./dist/'],
}),
cleaner({
targets: ['./dist/'],
}),
typescript(),
!production && sourceMaps(),
production && terser(),
Expand Down
17 changes: 9 additions & 8 deletions packages/storybook/src/stories/grid-options.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -240,19 +240,19 @@ export const withCustomFooter = () => {
pagination: true,
paginationPageSize: 33,
hideFooterPagination: true,
footerComponent: ({paginationProps, rows, columns, options, api, gridRef}) => (
footerComponent: ({ paginationProps, rows, columns, options, api, gridRef }) => (
<Footer className={'my-custom-footer'}>
<span style={{ display: 'flex', alignItems: 'center' }}>
<span style={{ display: 'flex', alignItems: 'center' }}>
This is my custom footer and pagination here!
</span>
</span>
<Pagination
className={'my-custom-pagination'}
page={paginationProps.page}
count={paginationProps.pageCount}
onChange={(e, value) => paginationProps.setPage(value)}
/>
</Footer>
)
),
}}
/>
</div>
Expand All @@ -272,7 +272,7 @@ export const withCustomHeaderAndFooter = () => {
pagination: true,
paginationPageSize: 33,
hideFooterPagination: true,
headerComponent: ({paginationProps}) => (
headerComponent: ({ paginationProps }) => (
<div className={'custom-header'}>
<Pagination
className={'my-custom-pagination'}
Expand All @@ -282,10 +282,11 @@ export const withCustomHeaderAndFooter = () => {
/>
</div>
),
footerComponent: ({paginationProps}) => (
footerComponent: ({ paginationProps }) => (
<div className="footer my-custom-footer"> I counted {paginationProps.rowCount} row(s) </div>
)
}} />
),
}}
/>
</div>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,19 +131,19 @@ export const CustomFooter = () => {
hideFooter: true,
footerComponent: ({ paginationProps }) => (
<Footer className={'my-custom-footer'}>
<span style={{ display: 'flex', alignItems: 'center' }}>
This is my custom footer and pagination here!{' '}
</span>
<span style={{ display: 'flex', alignItems: 'center' }}>
This is my custom footer and pagination here!{' '}
</span>
<Pagination
className={'my-custom-pagination'}
page={paginationProps.page}
count={paginationProps.pageCount}
onChange={(e, value) => paginationProps.setPage(value)}
/>
</Footer>
)
),
}}
/>
/>
</div>
);
};
Expand All @@ -161,7 +161,7 @@ export const HeaderAndFooter = () => {
pagination: true,
paginationPageSize: 33,
hideFooterPagination: true,
headerComponent: ({paginationProps}) => (
headerComponent: ({ paginationProps }) => (
<div className={'custom-header'}>
<Pagination
className={'my-custom-pagination'}
Expand All @@ -171,9 +171,9 @@ export const HeaderAndFooter = () => {
/>
</div>
),
footerComponent: ({paginationProps}) => (
footerComponent: ({ paginationProps }) => (
<div className="footer my-custom-footer"> I counted {paginationProps.rowCount} row(s) </div>
)
),
}}
/>
</div>
Expand Down
2 changes: 1 addition & 1 deletion .prettierrc.js → prettier.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ module.exports = {
},
},
],
};
};
37 changes: 37 additions & 0 deletions scripts/listChangedFiles.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Based on similar script in React
// https://github.com/facebook/react/blob/b87aabdfe1b7461e7331abb3601d9e6bb27544bc/scripts/shared/listChangedFiles.js

const util = require('util');
const childProcess = require('child_process');

const execFileAsync = util.promisify(childProcess.execFile);

async function exec(command, args) {
const options = {
cwd: process.cwd(),
env: process.env,
stdio: 'pipe',
encoding: 'utf-8',
};

const results = await execFileAsync(command, args, options);
return results.stdout;
}

async function execGitCmd(args) {
const gitResults = await exec('git', args);
return gitResults
.trim()
.toString()
.split('\n');
}

async function listChangedFiles() {
const comparedBranch = process.env.CIRCLECI ? 'origin/master' : 'master';
const mergeBase = await execGitCmd(['rev-parse', comparedBranch]);
const gitDiff = await execGitCmd(['diff', '--name-only', mergeBase]);
const gitLs = await execGitCmd(['ls-files', '--others', '--exclude-standard']);
return new Set([...gitDiff, ...gitLs]);
}

module.exports = listChangedFiles;
Loading

0 comments on commit cfb4836

Please sign in to comment.