From c7a37397e78abb754280552429b43e07af156122 Mon Sep 17 00:00:00 2001 From: Sebastian Silbermann Date: Wed, 25 Aug 2021 15:45:00 +0200 Subject: [PATCH] [core] Enforce curly braces for block statements (#27946) --- .eslintrc.js | 1 + docs/src/components/header/HeaderNavBar.tsx | 8 +++-- docs/src/components/home/DesignKits.tsx | 4 ++- docs/src/components/home/ElementPointer.tsx | 4 ++- .../components/home/StoreTemplatesBanner.tsx | 8 +++-- docs/src/components/showcase/FolderTable.tsx | 8 +++-- docs/src/modules/utils/find.js | 8 +++-- .../pages/components/tables/EnhancedTable.js | 4 ++- .../pages/components/tables/EnhancedTable.tsx | 4 ++- .../pages/discover-more/showcase/Showcase.js | 4 ++- .../material-ui-codemod/src/util/memoize.js | 4 ++- .../src/v4.0.0/optimal-imports.js | 32 ++++++++++++++----- .../src/v4.0.0/top-level-imports.js | 32 ++++++++++++++----- .../src/v5.0.0/optimal-imports.js | 32 ++++++++++++++----- .../src/PickersDay/PickersDay.tsx | 4 ++- .../src/TabContext/TabContext.test.js | 12 +++++-- .../src/GlobalStyles/GlobalStyles.test.js | 20 +++++++++--- .../src/GlobalStyles/GlobalStyles.test.js | 20 +++++++++--- .../src/styleFunctionSx/styleFunctionSx.js | 4 ++- .../src/GlobalStyles/GlobalStyles.test.js | 8 +++-- packages/material-ui/src/Grid/Grid.js | 4 ++- packages/material-ui/src/Grid/Grid.test.js | 4 ++- .../src/TablePagination/TablePagination.js | 4 ++- packages/material-ui/src/locale/index.ts | 8 +++-- .../typescript-to-proptypes/src/injector.ts | 28 ++++++++++++---- .../typescript-to-proptypes/src/loadConfig.ts | 8 +++-- .../typescript-to-proptypes/src/parser.ts | 8 +++-- 27 files changed, 214 insertions(+), 71 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index c19451023ad781..dca9596bd05ed5 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -46,6 +46,7 @@ module.exports = { */ rules: { 'consistent-this': ['error', 'self'], + curly: ['error', 'all'], // Just as bad as "max components per file" 'max-classes-per-file': 'off', // Too interruptive diff --git a/docs/src/components/header/HeaderNavBar.tsx b/docs/src/components/header/HeaderNavBar.tsx index 076f9d5abeff6f..2867e06d884c16 100644 --- a/docs/src/components/header/HeaderNavBar.tsx +++ b/docs/src/components/header/HeaderNavBar.tsx @@ -121,7 +121,9 @@ export default function HeaderNavBar() { setSubMenuOpen(true); } setSubMenuIndex((prevValue) => { - if (prevValue === null) return 0; + if (prevValue === null) { + return 0; + } if (prevValue === PRODUCT_IDS.length - 1) { return 0; } @@ -131,7 +133,9 @@ export default function HeaderNavBar() { if (event.key === 'ArrowUp') { event.preventDefault(); setSubMenuIndex((prevValue) => { - if (prevValue === null) return 0; + if (prevValue === null) { + return 0; + } if (prevValue === 0) { return PRODUCT_IDS.length - 1; } diff --git a/docs/src/components/home/DesignKits.tsx b/docs/src/components/home/DesignKits.tsx index 392753808cd38d..247a54aab3f5c2 100644 --- a/docs/src/components/home/DesignKits.tsx +++ b/docs/src/components/home/DesignKits.tsx @@ -160,7 +160,9 @@ export function DesignKitImagesSet2({ export function DesignKitTools({ disableLink, ...props }: { disableLink?: boolean } & BoxProps) { function renderTool(brand: 'figma' | 'sketch' | 'xd') { - if (disableLink) return ; + if (disableLink) { + return ; + } return ( diff --git a/docs/src/components/home/ElementPointer.tsx b/docs/src/components/home/ElementPointer.tsx index 000180d05d8f9f..fdf6d20f9d7d28 100644 --- a/docs/src/components/home/ElementPointer.tsx +++ b/docs/src/components/home/ElementPointer.tsx @@ -56,7 +56,9 @@ export default function PointerContainer({ [], ); React.useEffect(() => { - if (onElementChange) onElementChange(data); + if (onElementChange) { + onElementChange(data); + } }, [data, onElementChange]); return ( diff --git a/docs/src/components/home/StoreTemplatesBanner.tsx b/docs/src/components/home/StoreTemplatesBanner.tsx index 725eb909619f05..3d8ac54175c0ce 100644 --- a/docs/src/components/home/StoreTemplatesBanner.tsx +++ b/docs/src/components/home/StoreTemplatesBanner.tsx @@ -155,7 +155,9 @@ export function StoreTemplatesSet1({ ...props }: { disableLink?: boolean; keyframes?: Record } & BoxProps) { function renderTemplate(brand: TemplateBrand) { - if (disableLink) return ; + if (disableLink) { + return ; + } return ( @@ -185,7 +187,9 @@ export function StoreTemplatesSet2({ ...props }: { disableLink?: boolean; keyframes?: Record } & BoxProps) { function renderTemplate(brand: TemplateBrand) { - if (disableLink) return ; + if (disableLink) { + return ; + } return ( diff --git a/docs/src/components/showcase/FolderTable.tsx b/docs/src/components/showcase/FolderTable.tsx index be87f4cc43f63b..a711b7b0eb79d8 100644 --- a/docs/src/components/showcase/FolderTable.tsx +++ b/docs/src/components/showcase/FolderTable.tsx @@ -48,7 +48,9 @@ function stableSort(array: readonly T[], comparator: (a: T, b: T) => number) const stabilizedThis = array.map((el, index) => [el, index] as [T, number]); stabilizedThis.sort((a, b) => { const order = comparator(a[0], b[0]); - if (order !== 0) return order; + if (order !== 0) { + return order; + } return a[1] - b[1]; }); return stabilizedThis.map((el) => el[0]); @@ -56,7 +58,9 @@ function stableSort(array: readonly T[], comparator: (a: T, b: T) => number) function formatSize(size: number) { const kb = size / 1000; - if (kb < 1000) return `${kb.toFixed(1)} KB`; + if (kb < 1000) { + return `${kb.toFixed(1)} KB`; + } return `${(kb / 1000).toFixed(0)} MB`; } diff --git a/docs/src/modules/utils/find.js b/docs/src/modules/utils/find.js index 7a79092ed9b399..57c8b548d6ece5 100644 --- a/docs/src/modules/utils/find.js +++ b/docs/src/modules/utils/find.js @@ -144,8 +144,12 @@ function findPages( pages.sort((a, b) => { const pathnameA = a.pathname.replace(/-/g, ''); const pathnameB = b.pathname.replace(/-/g, ''); - if (pathnameA < pathnameB) return -1; - if (pathnameA > pathnameB) return 1; + if (pathnameA < pathnameB) { + return -1; + } + if (pathnameA > pathnameB) { + return 1; + } return 0; }); diff --git a/docs/src/pages/components/tables/EnhancedTable.js b/docs/src/pages/components/tables/EnhancedTable.js index fbfde830815ff3..561d2c7e7e55ad 100644 --- a/docs/src/pages/components/tables/EnhancedTable.js +++ b/docs/src/pages/components/tables/EnhancedTable.js @@ -70,7 +70,9 @@ function stableSort(array, comparator) { const stabilizedThis = array.map((el, index) => [el, index]); stabilizedThis.sort((a, b) => { const order = comparator(a[0], b[0]); - if (order !== 0) return order; + if (order !== 0) { + return order; + } return a[1] - b[1]; }); return stabilizedThis.map((el) => el[0]); diff --git a/docs/src/pages/components/tables/EnhancedTable.tsx b/docs/src/pages/components/tables/EnhancedTable.tsx index be668cb0332a9d..be51cb58940d22 100644 --- a/docs/src/pages/components/tables/EnhancedTable.tsx +++ b/docs/src/pages/components/tables/EnhancedTable.tsx @@ -91,7 +91,9 @@ function stableSort(array: readonly T[], comparator: (a: T, b: T) => number) const stabilizedThis = array.map((el, index) => [el, index] as [T, number]); stabilizedThis.sort((a, b) => { const order = comparator(a[0], b[0]); - if (order !== 0) return order; + if (order !== 0) { + return order; + } return a[1] - b[1]; }); return stabilizedThis.map((el) => el[0]); diff --git a/docs/src/pages/discover-more/showcase/Showcase.js b/docs/src/pages/discover-more/showcase/Showcase.js index 3573bb2b01cd9e..2ac67f2d2b430d 100644 --- a/docs/src/pages/discover-more/showcase/Showcase.js +++ b/docs/src/pages/discover-more/showcase/Showcase.js @@ -17,7 +17,9 @@ function stableSort(array, cmp) { const stabilizedThis = array.map((el, index) => [el, index]); stabilizedThis.sort((a, b) => { const order = cmp(a[0], b[0]); - if (order !== 0) return order; + if (order !== 0) { + return order; + } return a[1] - b[1]; }); return stabilizedThis.map((el) => el[0]); diff --git a/packages/material-ui-codemod/src/util/memoize.js b/packages/material-ui-codemod/src/util/memoize.js index 452e853ab891c1..835ac03926bae9 100644 --- a/packages/material-ui-codemod/src/util/memoize.js +++ b/packages/material-ui-codemod/src/util/memoize.js @@ -2,7 +2,9 @@ const memoize = (func, resolver = (a) => a) => { const cache = new Map(); return (...args) => { const key = resolver(...args); - if (cache.has(key)) return cache.get(key); + if (cache.has(key)) { + return cache.get(key); + } const value = func(...args); cache.set(key, value); return value; diff --git a/packages/material-ui-codemod/src/v4.0.0/optimal-imports.js b/packages/material-ui-codemod/src/v4.0.0/optimal-imports.js index cc952915499e70..c465ece494457d 100644 --- a/packages/material-ui-codemod/src/v4.0.0/optimal-imports.js +++ b/packages/material-ui-codemod/src/v4.0.0/optimal-imports.js @@ -31,14 +31,20 @@ export default function transformer(fileInfo, api, options) { }; root.find(j.ImportDeclaration).forEach((path) => { - if (path.value.importKind && path.value.importKind !== 'value') return; + if (path.value.importKind && path.value.importKind !== 'value') { + return; + } const importPath = path.value.source.value.replace(/(index)?(\.js)?$/, ''); const match = importPath.match(importRegExp); - if (!match) return; + if (!match) { + return; + } const subpath = match[1].replace(/\/$/, ''); - if (/^(internal)/.test(subpath)) return; + if (/^(internal)/.test(subpath)) { + return; + } const targetImportPath = `${targetModule}/${subpath}`; const whitelist = getJSExports( @@ -48,10 +54,16 @@ export default function transformer(fileInfo, api, options) { ); path.node.specifiers.forEach((specifier, index) => { - if (!path.node.specifiers.length) return; + if (!path.node.specifiers.length) { + return; + } - if (specifier.importKind && specifier.importKind !== 'value') return; - if (specifier.type === 'ImportNamespaceSpecifier') return; + if (specifier.importKind && specifier.importKind !== 'value') { + return; + } + if (specifier.type === 'ImportNamespaceSpecifier') { + return; + } const localName = specifier.local.name; switch (specifier.type) { case 'ImportNamespaceSpecifier': @@ -69,7 +81,9 @@ export default function transformer(fileInfo, api, options) { break; } case 'ImportSpecifier': - if (!whitelist.has(specifier.imported.name)) return; + if (!whitelist.has(specifier.imported.name)) { + return; + } addSpecifier(targetImportPath, specifier); path.get('specifiers', index).prune(); break; @@ -78,7 +92,9 @@ export default function transformer(fileInfo, api, options) { } }); - if (!path.node.specifiers.length) path.prune(); + if (!path.node.specifiers.length) { + path.prune(); + } }); addImports( diff --git a/packages/material-ui-codemod/src/v4.0.0/top-level-imports.js b/packages/material-ui-codemod/src/v4.0.0/top-level-imports.js index 905de2aebc789a..f1b5d84ee2c8ad 100644 --- a/packages/material-ui-codemod/src/v4.0.0/top-level-imports.js +++ b/packages/material-ui-codemod/src/v4.0.0/top-level-imports.js @@ -25,24 +25,38 @@ export default function transformer(fileInfo, api, options) { const resultSpecifiers = []; root.find(j.ImportDeclaration).forEach((path) => { - if (!path.node.specifiers.length) return; + if (!path.node.specifiers.length) { + return; + } - if (path.value.importKind && path.value.importKind !== 'value') return; + if (path.value.importKind && path.value.importKind !== 'value') { + return; + } const importPath = path.value.source.value; const match = importPath.match(importRegExp); - if (!match) return; + if (!match) { + return; + } - if (importPath.includes('internal/')) return; + if (importPath.includes('internal/')) { + return; + } path.node.specifiers.forEach((specifier, index) => { - if (specifier.importKind && specifier.importKind !== 'value') return; - if (specifier.type === 'ImportNamespaceSpecifier') return; + if (specifier.importKind && specifier.importKind !== 'value') { + return; + } + if (specifier.type === 'ImportNamespaceSpecifier') { + return; + } switch (specifier.type) { case 'ImportDefaultSpecifier': { const localName = specifier.local.name; const moduleName = match[1]; - if (whitelist[moduleName] == null) return; + if (whitelist[moduleName] == null) { + return; + } resultSpecifiers.push( j.importSpecifier(j.identifier(moduleName), j.identifier(localName)), ); @@ -64,7 +78,9 @@ export default function transformer(fileInfo, api, options) { } }); - if (!path.node.specifiers.length) path.prune(); + if (!path.node.specifiers.length) { + path.prune(); + } }); if (resultSpecifiers.length) { diff --git a/packages/material-ui-codemod/src/v5.0.0/optimal-imports.js b/packages/material-ui-codemod/src/v5.0.0/optimal-imports.js index 257e523126541c..da401252d3dc67 100644 --- a/packages/material-ui-codemod/src/v5.0.0/optimal-imports.js +++ b/packages/material-ui-codemod/src/v5.0.0/optimal-imports.js @@ -31,14 +31,20 @@ export default function transformer(fileInfo, api, options) { }; root.find(j.ImportDeclaration).forEach((path) => { - if (path.value.importKind && path.value.importKind !== 'value') return; + if (path.value.importKind && path.value.importKind !== 'value') { + return; + } const importPath = path.value.source.value.replace(/(index)?(\.js)?$/, ''); const match = importPath.match(importRegExp); - if (!match) return; + if (!match) { + return; + } const subpath = match[1].replace(/\/$/, ''); - if (/^(internal)/.test(subpath)) return; + if (/^(internal)/.test(subpath)) { + return; + } const targetImportPath = `${targetModule}/${subpath}`; const whitelist = getJSExports( @@ -48,10 +54,16 @@ export default function transformer(fileInfo, api, options) { ); path.node.specifiers.forEach((specifier, index) => { - if (!path.node.specifiers.length) return; + if (!path.node.specifiers.length) { + return; + } - if (specifier.importKind && specifier.importKind !== 'value') return; - if (specifier.type === 'ImportNamespaceSpecifier') return; + if (specifier.importKind && specifier.importKind !== 'value') { + return; + } + if (specifier.type === 'ImportNamespaceSpecifier') { + return; + } const localName = specifier.local.name; switch (specifier.type) { case 'ImportNamespaceSpecifier': @@ -69,7 +81,9 @@ export default function transformer(fileInfo, api, options) { break; } case 'ImportSpecifier': - if (!whitelist.has(specifier.imported.name)) return; + if (!whitelist.has(specifier.imported.name)) { + return; + } addSpecifier(targetImportPath, specifier); path.get('specifiers', index).prune(); break; @@ -78,7 +92,9 @@ export default function transformer(fileInfo, api, options) { } }); - if (!path.node.specifiers.length) path.prune(); + if (!path.node.specifiers.length) { + path.prune(); + } }); addImports( diff --git a/packages/material-ui-lab/src/PickersDay/PickersDay.tsx b/packages/material-ui-lab/src/PickersDay/PickersDay.tsx index 6de3de4b415d67..9a0ebeadd7ffac 100644 --- a/packages/material-ui-lab/src/PickersDay/PickersDay.tsx +++ b/packages/material-ui-lab/src/PickersDay/PickersDay.tsx @@ -285,7 +285,9 @@ const PickersDay = React.forwardRef(function PickersDay( }; const handleClick = (event: React.MouseEvent) => { - if (!allowSameDateSelection && selected) return; + if (!allowSameDateSelection && selected) { + return; + } if (!disabled) { onDaySelect(day, 'finish'); diff --git a/packages/material-ui-lab/src/TabContext/TabContext.test.js b/packages/material-ui-lab/src/TabContext/TabContext.test.js index 927c32eededbd7..fccf482efafe30 100644 --- a/packages/material-ui-lab/src/TabContext/TabContext.test.js +++ b/packages/material-ui-lab/src/TabContext/TabContext.test.js @@ -27,7 +27,9 @@ describe('', () => { */ function Tabs({ value }) { const context = useTabContext(); - if (context === null) throw new TypeError(); + if (context === null) { + throw new TypeError(); + } return ( @@ -59,7 +61,9 @@ describe('', () => { */ function Tabs({ value }) { const context = useTabContext(); - if (context === null) throw new TypeError(); + if (context === null) { + throw new TypeError(); + } return ( @@ -87,7 +91,9 @@ describe('', () => { */ function Tabs({ value }) { const context = useTabContext(); - if (context === null) throw new TypeError(); + if (context === null) { + throw new TypeError(); + } return ( diff --git a/packages/material-ui-styled-engine-sc/src/GlobalStyles/GlobalStyles.test.js b/packages/material-ui-styled-engine-sc/src/GlobalStyles/GlobalStyles.test.js index c888b012b42aa2..cf877f19877098 100644 --- a/packages/material-ui-styled-engine-sc/src/GlobalStyles/GlobalStyles.test.js +++ b/packages/material-ui-styled-engine-sc/src/GlobalStyles/GlobalStyles.test.js @@ -9,7 +9,9 @@ describe('GlobalStyles', () => { const render = createClientRender(); it('should add global styles', function test() { - if (/jsdom/.test(window.navigator.userAgent)) this.skip(); + if (/jsdom/.test(window.navigator.userAgent)) { + this.skip(); + } const { container } = render(
@@ -24,7 +26,9 @@ describe('GlobalStyles', () => { }); it('should add global styles using JS syntax', function test() { - if (/jsdom/.test(window.navigator.userAgent)) this.skip(); + if (/jsdom/.test(window.navigator.userAgent)) { + this.skip(); + } const { container } = render(
@@ -39,7 +43,9 @@ describe('GlobalStyles', () => { }); it('should add global styles using function', function test() { - if (/jsdom/.test(window.navigator.userAgent)) this.skip(); + if (/jsdom/.test(window.navigator.userAgent)) { + this.skip(); + } const { container } = render( @@ -65,7 +71,9 @@ describe('GlobalStyles', () => { }); it('should give presedence to styled()', function test() { - if (/jsdom/.test(window.navigator.userAgent)) this.skip(); + if (/jsdom/.test(window.navigator.userAgent)) { + this.skip(); + } const Span = styled('span')` color: rgb(255, 0, 0); @@ -84,7 +92,9 @@ describe('GlobalStyles', () => { }); it('should give presedence to styled() using JS syntax', function test() { - if (/jsdom/.test(window.navigator.userAgent)) this.skip(); + if (/jsdom/.test(window.navigator.userAgent)) { + this.skip(); + } const Span = styled('span')({ color: 'rgb(255, 0, 0)', diff --git a/packages/material-ui-styled-engine/src/GlobalStyles/GlobalStyles.test.js b/packages/material-ui-styled-engine/src/GlobalStyles/GlobalStyles.test.js index 8e510f93eba8e7..f72b2e96dae639 100644 --- a/packages/material-ui-styled-engine/src/GlobalStyles/GlobalStyles.test.js +++ b/packages/material-ui-styled-engine/src/GlobalStyles/GlobalStyles.test.js @@ -9,7 +9,9 @@ describe('GlobalStyles', () => { const render = createClientRender(); it('should add global styles', function test() { - if (/jsdom/.test(window.navigator.userAgent)) this.skip(); + if (/jsdom/.test(window.navigator.userAgent)) { + this.skip(); + } const { container } = render(
@@ -24,7 +26,9 @@ describe('GlobalStyles', () => { }); it('should add global styles using JS syntax', function test() { - if (/jsdom/.test(window.navigator.userAgent)) this.skip(); + if (/jsdom/.test(window.navigator.userAgent)) { + this.skip(); + } const { container } = render(
@@ -39,7 +43,9 @@ describe('GlobalStyles', () => { }); it('should add global styles using function', function test() { - if (/jsdom/.test(window.navigator.userAgent)) this.skip(); + if (/jsdom/.test(window.navigator.userAgent)) { + this.skip(); + } const { container } = render( @@ -65,7 +71,9 @@ describe('GlobalStyles', () => { }); it('should give presedence to styled()', function test() { - if (/jsdom/.test(window.navigator.userAgent)) this.skip(); + if (/jsdom/.test(window.navigator.userAgent)) { + this.skip(); + } const Span = styled('span')` color: rgb(255, 0, 0); @@ -84,7 +92,9 @@ describe('GlobalStyles', () => { }); it('should give presedence to styled() using JS syntax', function test() { - if (/jsdom/.test(window.navigator.userAgent)) this.skip(); + if (/jsdom/.test(window.navigator.userAgent)) { + this.skip(); + } const Span = styled('span')({ color: 'rgb(255, 0, 0)', diff --git a/packages/material-ui-system/src/styleFunctionSx/styleFunctionSx.js b/packages/material-ui-system/src/styleFunctionSx/styleFunctionSx.js index 8794c1f237628e..fd88923ba5e31c 100644 --- a/packages/material-ui-system/src/styleFunctionSx/styleFunctionSx.js +++ b/packages/material-ui-system/src/styleFunctionSx/styleFunctionSx.js @@ -18,7 +18,9 @@ function callIfFn(maybeFn, arg) { function styleFunctionSx(props) { const { sx: styles, theme = {} } = props || {}; - if (!styles) return null; + if (!styles) { + return null; + } if (typeof styles === 'function') { return styles(theme); diff --git a/packages/material-ui/src/GlobalStyles/GlobalStyles.test.js b/packages/material-ui/src/GlobalStyles/GlobalStyles.test.js index 1cd229ac4bb78c..c16ae85a067b69 100644 --- a/packages/material-ui/src/GlobalStyles/GlobalStyles.test.js +++ b/packages/material-ui/src/GlobalStyles/GlobalStyles.test.js @@ -12,7 +12,9 @@ describe('Global', () => { const render = createClientRender(); it('should provide default theme', function test() { - if (/jsdom/.test(window.navigator.userAgent)) this.skip(); + if (/jsdom/.test(window.navigator.userAgent)) { + this.skip(); + } const { container } = render(
@@ -27,7 +29,9 @@ describe('Global', () => { }); it('should respect context theme if available', function test() { - if (/jsdom/.test(window.navigator.userAgent)) this.skip(); + if (/jsdom/.test(window.navigator.userAgent)) { + this.skip(); + } const { container } = render( diff --git a/packages/material-ui/src/Grid/Grid.js b/packages/material-ui/src/Grid/Grid.js index c8ca466ae313a6..cd6bcf3baca728 100644 --- a/packages/material-ui/src/Grid/Grid.js +++ b/packages/material-ui/src/Grid/Grid.js @@ -32,7 +32,9 @@ function getOffset(val) { function generateGrid(globalStyles, theme, breakpoint, ownerState) { const size = ownerState[breakpoint]; - if (!size) return; + if (!size) { + return; + } let styles = {}; diff --git a/packages/material-ui/src/Grid/Grid.test.js b/packages/material-ui/src/Grid/Grid.test.js index 861c78b5794909..84a6fa346d31e4 100644 --- a/packages/material-ui/src/Grid/Grid.test.js +++ b/packages/material-ui/src/Grid/Grid.test.js @@ -147,7 +147,9 @@ describe('', () => { describe('spacing', () => { it('should generate the right values', function test() { - if (/jsdom/.test(window.navigator.userAgent)) this.skip(); + if (/jsdom/.test(window.navigator.userAgent)) { + this.skip(); + } const parentWidth = 500; const remValue = 16; diff --git a/packages/material-ui/src/TablePagination/TablePagination.js b/packages/material-ui/src/TablePagination/TablePagination.js index cd2d3177d5f759..817222bc0c6b36 100644 --- a/packages/material-ui/src/TablePagination/TablePagination.js +++ b/packages/material-ui/src/TablePagination/TablePagination.js @@ -173,7 +173,9 @@ const TablePagination = React.forwardRef(function TablePagination(inProps, ref) const labelId = useId(SelectProps.labelId); const getLabelDisplayedRowsTo = () => { - if (count === -1) return (page + 1) * rowsPerPage; + if (count === -1) { + return (page + 1) * rowsPerPage; + } return rowsPerPage === -1 ? count : Math.min(count, (page + 1) * rowsPerPage); }; diff --git a/packages/material-ui/src/locale/index.ts b/packages/material-ui/src/locale/index.ts index 00a7e1045ba14a..ad0a540ce1bd64 100644 --- a/packages/material-ui/src/locale/index.ts +++ b/packages/material-ui/src/locale/index.ts @@ -1871,7 +1871,9 @@ export const kzKZ: Localization = { 'aria-label': 'Беттерді шарлау', getItemAriaLabel: (type, page, selected) => { if (type === 'page') { - if (selected) return `${page} — бет`; + if (selected) { + return `${page} — бет`; + } return `${page} — бетке өту`; } if (type === 'first') { @@ -2320,7 +2322,9 @@ export const ruRU: Localization = { 'aria-label': 'Навигация по страницам', getItemAriaLabel: (type, page, selected) => { if (type === 'page') { - if (selected) return `${page} страница`; + if (selected) { + return `${page} страница`; + } return `Перейти на ${page} страницу`; } if (type === 'first') { diff --git a/packages/typescript-to-proptypes/src/injector.ts b/packages/typescript-to-proptypes/src/injector.ts index a79d9d9e4cd19c..dd4d83abfe7481 100644 --- a/packages/typescript-to-proptypes/src/injector.ts +++ b/packages/typescript-to-proptypes/src/injector.ts @@ -280,7 +280,9 @@ function plugin( }); }, exit(path) { - if (alreadyImported || !needImport) return; + if (alreadyImported || !needImport) { + return; + } const propTypesImport = babel.template.ast( `import ${importName} from 'prop-types'`, @@ -307,9 +309,13 @@ function plugin( return; } - if (!node.id) return; + if (!node.id) { + return; + } const props = propTypes.body.find((prop) => prop.name === node.id!.name); - if (!props) return; + if (!props) { + return; + } // Prevent visiting again (node as any).hasBeenVisited = true; @@ -335,11 +341,15 @@ function plugin( return; } - if (!babelTypes.isIdentifier(node.id)) return; + if (!babelTypes.isIdentifier(node.id)) { + return; + } const nodeName = node.id.name; const props = propTypes.body.find((prop) => prop.name === nodeName); - if (!props) return; + if (!props) { + return; + } function getFromProp(propsNode: babelTypes.Node) { // Prevent visiting again @@ -381,11 +391,15 @@ function plugin( return; } - if (!babelTypes.isIdentifier(node.id)) return; + if (!babelTypes.isIdentifier(node.id)) { + return; + } const nodeName = node.id.name; const props = propTypes.body.find((prop) => prop.name === nodeName); - if (!props) return; + if (!props) { + return; + } // Prevent visiting again (node as any).hasBeenVisited = true; diff --git a/packages/typescript-to-proptypes/src/loadConfig.ts b/packages/typescript-to-proptypes/src/loadConfig.ts index 0bd840a407696f..2ba650e742d1a8 100644 --- a/packages/typescript-to-proptypes/src/loadConfig.ts +++ b/packages/typescript-to-proptypes/src/loadConfig.ts @@ -11,7 +11,9 @@ export default function loadConfig(tsConfigPath: string) { fs.readFileSync(filePath).toString(), ); - if (error) throw error; + if (error) { + throw error; + } const { options, errors } = ts.parseJsonConfigFileContent( config, @@ -19,7 +21,9 @@ export default function loadConfig(tsConfigPath: string) { path.dirname(tsConfigPath), ); - if (errors.length > 0) throw errors[0]; + if (errors.length > 0) { + throw errors[0]; + } return options; } diff --git a/packages/typescript-to-proptypes/src/parser.ts b/packages/typescript-to-proptypes/src/parser.ts index 7763636a754f47..c1ba18b609426c 100644 --- a/packages/typescript-to-proptypes/src/parser.ts +++ b/packages/typescript-to-proptypes/src/parser.ts @@ -674,10 +674,14 @@ export function parseFromProgram( node.heritageClauses.length === 1 ) { const heritage = node.heritageClauses[0]; - if (heritage.types.length !== 1) return; + if (heritage.types.length !== 1) { + return; + } const arg = heritage.types[0]; - if (!arg.typeArguments) return; + if (!arg.typeArguments) { + return; + } if (reactImports.includes(arg.expression.getText())) { parsePropsSymbol(