Skip to content

Commit

Permalink
Fix a violation and ignore false positives
Browse files Browse the repository at this point in the history
  • Loading branch information
michaldudak committed Dec 8, 2022
1 parent cd7e4e5 commit d4f6154
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 1 deletion.
2 changes: 2 additions & 0 deletions packages/mui-styles/src/styled/styled.test.js
Expand Up @@ -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,
Expand Down
5 changes: 4 additions & 1 deletion packages/mui-styles/src/withStyles/withStyles.test.js
Expand Up @@ -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',
};
Expand Down
2 changes: 2 additions & 0 deletions packages/mui-system/src/borders.js
Expand Up @@ -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');
Expand Down
2 changes: 2 additions & 0 deletions packages/mui-system/src/breakpoints.js
Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions packages/mui-system/src/compose.js
Expand Up @@ -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]) {
Expand Down
6 changes: 6 additions & 0 deletions packages/mui-system/src/cssGrid.js
Expand Up @@ -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');
Expand All @@ -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');
Expand All @@ -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');
Expand Down
2 changes: 2 additions & 0 deletions packages/mui-system/src/style.js
Expand Up @@ -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;
Expand Down

0 comments on commit d4f6154

Please sign in to comment.