From d4f6154746a64a0f9e9c0ca17180eff1b8c63734 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Dudak?= Date: Thu, 8 Dec 2022 13:42:02 +0100 Subject: [PATCH] Fix a violation and ignore false positives --- packages/mui-styles/src/styled/styled.test.js | 2 ++ packages/mui-styles/src/withStyles/withStyles.test.js | 5 ++++- packages/mui-system/src/borders.js | 2 ++ packages/mui-system/src/breakpoints.js | 2 ++ packages/mui-system/src/compose.js | 2 ++ packages/mui-system/src/cssGrid.js | 6 ++++++ packages/mui-system/src/style.js | 2 ++ 7 files changed, 20 insertions(+), 1 deletion(-) diff --git a/packages/mui-styles/src/styled/styled.test.js b/packages/mui-styles/src/styled/styled.test.js index aed1323f9e7251..ba90b28075d43d 100644 --- a/packages/mui-styles/src/styled/styled.test.js +++ b/packages/mui-styles/src/styled/styled.test.js @@ -63,6 +63,8 @@ describe('styled', () => { }); it('should filter some props', () => { + // false positive + // eslint-disable-next-line react/function-component-definition const style = (props) => ({ background: props.color, borderRadius: 3, diff --git a/packages/mui-styles/src/withStyles/withStyles.test.js b/packages/mui-styles/src/withStyles/withStyles.test.js index e7835664fe2852..7dd4d0f8dc6a70 100644 --- a/packages/mui-styles/src/withStyles/withStyles.test.js +++ b/packages/mui-styles/src/withStyles/withStyles.test.js @@ -168,7 +168,10 @@ describe('withStyles', () => { }); it('should use theme.props instead of defaultProps', () => { - const MuiFoo = ({ foo }) => foo; + function MuiFoo({ foo }) { + return foo; + } + MuiFoo.defaultProps = { foo: 'foo', }; diff --git a/packages/mui-system/src/borders.js b/packages/mui-system/src/borders.js index 7ed3d41588fa1c..5673993b19acf1 100644 --- a/packages/mui-system/src/borders.js +++ b/packages/mui-system/src/borders.js @@ -67,6 +67,8 @@ export const borderLeftColor = style({ themeKey: 'palette', }); +// false positive +// eslint-disable-next-line react/function-component-definition export const borderRadius = (props) => { if (props.borderRadius !== undefined && props.borderRadius !== null) { const transformer = createUnaryUnit(props.theme, 'shape.borderRadius', 4, 'borderRadius'); diff --git a/packages/mui-system/src/breakpoints.js b/packages/mui-system/src/breakpoints.js index b2de25d4746576..44b48db750aa10 100644 --- a/packages/mui-system/src/breakpoints.js +++ b/packages/mui-system/src/breakpoints.js @@ -51,6 +51,8 @@ export function handleBreakpoints(props, propValue, styleFromPropValue) { } function breakpoints(styleFunction) { + // false positive + // eslint-disable-next-line react/function-component-definition const newStyleFunction = (props) => { const theme = props.theme || {}; const base = styleFunction(props); diff --git a/packages/mui-system/src/compose.js b/packages/mui-system/src/compose.js index 38a53eaa8fae27..0d51263b994efb 100644 --- a/packages/mui-system/src/compose.js +++ b/packages/mui-system/src/compose.js @@ -9,6 +9,8 @@ function compose(...styles) { return acc; }, {}); + // false positive + // eslint-disable-next-line react/function-component-definition const fn = (props) => { return Object.keys(props).reduce((acc, prop) => { if (handlers[prop]) { diff --git a/packages/mui-system/src/cssGrid.js b/packages/mui-system/src/cssGrid.js index d1d59ad5d4981a..3b91c00d86a3ee 100644 --- a/packages/mui-system/src/cssGrid.js +++ b/packages/mui-system/src/cssGrid.js @@ -4,6 +4,8 @@ import { createUnaryUnit, getValue } from './spacing'; import { handleBreakpoints } from './breakpoints'; import responsivePropType from './responsivePropType'; +// false positive +// eslint-disable-next-line react/function-component-definition export const gap = (props) => { if (props.gap !== undefined && props.gap !== null) { const transformer = createUnaryUnit(props.theme, 'spacing', 8, 'gap'); @@ -20,6 +22,8 @@ gap.propTypes = process.env.NODE_ENV !== 'production' ? { gap: responsivePropTyp gap.filterProps = ['gap']; +// false positive +// eslint-disable-next-line react/function-component-definition export const columnGap = (props) => { if (props.columnGap !== undefined && props.columnGap !== null) { const transformer = createUnaryUnit(props.theme, 'spacing', 8, 'columnGap'); @@ -37,6 +41,8 @@ columnGap.propTypes = columnGap.filterProps = ['columnGap']; +// false positive +// eslint-disable-next-line react/function-component-definition export const rowGap = (props) => { if (props.rowGap !== undefined && props.rowGap !== null) { const transformer = createUnaryUnit(props.theme, 'spacing', 8, 'rowGap'); diff --git a/packages/mui-system/src/style.js b/packages/mui-system/src/style.js index b88928a526909e..2767e7e306623a 100644 --- a/packages/mui-system/src/style.js +++ b/packages/mui-system/src/style.js @@ -45,6 +45,8 @@ export function getStyleValue(themeMapping, transform, propValueFinal, userValue function style(options) { const { prop, cssProperty = options.prop, themeKey, transform } = options; + // false positive + // eslint-disable-next-line react/function-component-definition const fn = (props) => { if (props[prop] == null) { return null;