From a5c9b2fec1acd3b7c35d9c235a20077a91ae015f Mon Sep 17 00:00:00 2001 From: Sebastian Silbermann Date: Sun, 22 Mar 2020 13:55:19 +0100 Subject: [PATCH 1/2] chore: format all ts files --- .../src/defaultTheme/defaultTheme.spec.ts | 2 +- .../src/styles/createMixins.spec.ts | 48 +++++++++---------- .../test/typescript/colors.spec.ts | 27 ++++++++--- scripts/generateProptypes.ts | 15 +++--- scripts/prettier.js | 2 +- 5 files changed, 54 insertions(+), 40 deletions(-) diff --git a/packages/material-ui-styles/src/defaultTheme/defaultTheme.spec.ts b/packages/material-ui-styles/src/defaultTheme/defaultTheme.spec.ts index 96a7b2142e5237..6bc4c5ddd2eb4c 100644 --- a/packages/material-ui-styles/src/defaultTheme/defaultTheme.spec.ts +++ b/packages/material-ui-styles/src/defaultTheme/defaultTheme.spec.ts @@ -13,7 +13,7 @@ declare module '@material-ui/styles' { } { - makeStyles(theme => { + makeStyles((theme) => { // $ExpectType string const value = theme.myProperty; diff --git a/packages/material-ui/src/styles/createMixins.spec.ts b/packages/material-ui/src/styles/createMixins.spec.ts index 91e3e0292cb6fe..0564d0fdab7ae1 100644 --- a/packages/material-ui/src/styles/createMixins.spec.ts +++ b/packages/material-ui/src/styles/createMixins.spec.ts @@ -1,29 +1,29 @@ import { createMuiTheme, makeStyles } from '@material-ui/core/styles'; { - const theme = createMuiTheme({ - mixins: { - toolbar: { - background: '#fff', - minHeight: 36, - '@media (min-width:0px) and (orientation: landscape)': { - minHeight: 24 - }, - '@media (min-width:600px)': { - minHeight: 48 - } - }, - } - }); - - const useStyles = makeStyles(theme => ({ - appBarSpacer: theme.mixins.toolbar, - toolbarIcon: { - display: 'flex', - alignItems: 'center', - justifyContent: 'flex-end', - padding: '0 8px', - ...theme.mixins.toolbar, + const theme = createMuiTheme({ + mixins: { + toolbar: { + background: '#fff', + minHeight: 36, + '@media (min-width:0px) and (orientation: landscape)': { + minHeight: 24, + }, + '@media (min-width:600px)': { + minHeight: 48, }, - })); + }, + }, + }); + + const useStyles = makeStyles((theme) => ({ + appBarSpacer: theme.mixins.toolbar, + toolbarIcon: { + display: 'flex', + alignItems: 'center', + justifyContent: 'flex-end', + padding: '0 8px', + ...theme.mixins.toolbar, + }, + })); } diff --git a/packages/material-ui/test/typescript/colors.spec.ts b/packages/material-ui/test/typescript/colors.spec.ts index 8c24ba74d1c59b..45058f5bc42022 100644 --- a/packages/material-ui/test/typescript/colors.spec.ts +++ b/packages/material-ui/test/typescript/colors.spec.ts @@ -1,13 +1,26 @@ import { colors, Color } from '@material-ui/core'; const { - amber, blue, blueGrey, - brown, cyan, deepOrange, - deepPurple, green, grey, - indigo, lightBlue, lightGreen, - lime, orange, pink, - purple, red, teal, - yellow, common + amber, + blue, + blueGrey, + brown, + cyan, + deepOrange, + deepPurple, + green, + grey, + indigo, + lightBlue, + lightGreen, + lime, + orange, + pink, + purple, + red, + teal, + yellow, + common, } = colors; const colorList: Color[] = [ diff --git a/scripts/generateProptypes.ts b/scripts/generateProptypes.ts index e92ac892467e7b..f726397a0567fc 100644 --- a/scripts/generateProptypes.ts +++ b/scripts/generateProptypes.ts @@ -43,8 +43,8 @@ async function generateProptypes( return GenerateResult.NoComponent; } - proptypes.body.forEach(component => { - component.types.forEach(prop => { + proptypes.body.forEach((component) => { + component.types.forEach((prop) => { if (prop.name === 'classes' && prop.jsDoc) { prop.jsDoc += '\nSee [CSS API](#css) below for more details.'; } else if (prop.name === 'children' && !prop.jsDoc) { @@ -75,6 +75,7 @@ async function generateProptypes( prop.jsDoc = prop.jsDoc.replace(documentRegExp, ''); return true; } + console.log(prop); return undefined; }, @@ -100,7 +101,7 @@ async function run() { [ path.resolve(__dirname, '../packages/material-ui/src'), path.resolve(__dirname, '../packages/material-ui-lab/src'), - ].map(folderPath => + ].map((folderPath) => glob('+([A-Z])*/+([A-Z])*.d.ts', { absolute: true, cwd: folderPath, @@ -111,7 +112,7 @@ async function run() { const files = _.flatten(allFiles) // Filter out files where the directory name and filename doesn't match // Example: Modal/ModalManager.d.ts - .filter(filePath => { + .filter((filePath) => { const folderName = path.basename(path.dirname(filePath)); const fileName = path.basename(filePath, '.d.ts'); @@ -120,7 +121,7 @@ async function run() { const program = ttp.createProgram(files, tsconfig); - const promises = files.map>(async tsFile => { + const promises = files.map>(async (tsFile) => { const jsFile = tsFile.replace('.d.ts', '.js'); if (!ignoreCache && (await fse.stat(jsFile)).mtimeMs > (await fse.stat(tsFile)).mtimeMs) { @@ -140,7 +141,7 @@ async function run() { } console.log('--- Summary ---'); - const groups = _.groupBy(results, x => x); + const groups = _.groupBy(results, (x) => x); _.forOwn(groups, (count, key) => { console.log('%s: %d', GenerateResult[(key as unknown) as GenerateResult], count.length); @@ -149,7 +150,7 @@ async function run() { console.log('Total: %d', results.length); } -run().catch(error => { +run().catch((error) => { console.error(error); process.exit(1); }); diff --git a/scripts/prettier.js b/scripts/prettier.js index 2b38897360fe7e..37beae02144615 100644 --- a/scripts/prettier.js +++ b/scripts/prettier.js @@ -24,7 +24,7 @@ function runPrettier(options) { .filter((notEmpty) => notEmpty); const files = glob - .sync('**/*.{js,tsx,d.ts}', { ignore: ['**/node_modules/**', ...ignoredFiles] }) + .sync('**/*.{js,tsx,ts}', { ignore: ['**/node_modules/**', ...ignoredFiles] }) .filter((f) => !changedFiles || changedFiles.has(f)); if (!files.length) { From 4a5cb45fc612f8aebc006d62262a163029b38155 Mon Sep 17 00:00:00 2001 From: Sebastian Silbermann Date: Sun, 22 Mar 2020 14:22:41 +0100 Subject: [PATCH 2/2] Update scripts/generateProptypes.ts --- scripts/generateProptypes.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/generateProptypes.ts b/scripts/generateProptypes.ts index f726397a0567fc..7926bafad120c8 100644 --- a/scripts/generateProptypes.ts +++ b/scripts/generateProptypes.ts @@ -75,7 +75,6 @@ async function generateProptypes( prop.jsDoc = prop.jsDoc.replace(documentRegExp, ''); return true; } - console.log(prop); return undefined; },