Skip to content

Commit

Permalink
Remove defaultProps (#551)
Browse files Browse the repository at this point in the history
  • Loading branch information
squiaios committed May 16, 2024
1 parent 976c1ad commit 161d6ba
Showing 1 changed file with 40 additions and 48 deletions.
88 changes: 40 additions & 48 deletions src/components/FontAwesomeIcon.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,51 @@ import objectWithKey from '../utils/object-with-key'
import PropTypes from 'prop-types'
import React from 'react'

const defaultProps = {
border: false,
className: '',
mask: null,
maskId: null,
fixedWidth: false,
inverse: false,
flip: false,
icon: null,
listItem: false,
pull: null,
pulse: false,
rotation: null,
size: null,
spin: false,
spinPulse: false,
spinReverse: false,
beat: false,
fade: false,
beatFade: false,
bounce: false,
shake: false,
symbol: false,
title: '',
titleId: null,
transform: null,
swapOpacity: false
}

const FontAwesomeIcon = React.forwardRef((props, ref) => {
const {
icon: iconArgs,
mask: maskArgs,
symbol,
className,
title,
titleId,
maskId
} = props
const allProps = {...defaultProps, ...props}

Check failure on line 40 in src/components/FontAwesomeIcon.js

View workflow job for this annotation

GitHub Actions / build (14, 16.11.x, 6.x, 6.x)

A space is required after '{'

Check failure on line 40 in src/components/FontAwesomeIcon.js

View workflow job for this annotation

GitHub Actions / build (14, 16.11.x, 6.x, 6.x)

A space is required before '}'

Check failure on line 40 in src/components/FontAwesomeIcon.js

View workflow job for this annotation

GitHub Actions / build (14, 16.11.x, 1.2.x, 5.x)

A space is required after '{'

Check failure on line 40 in src/components/FontAwesomeIcon.js

View workflow job for this annotation

GitHub Actions / build (14, 16.11.x, 1.2.x, 5.x)

A space is required before '}'

Check failure on line 40 in src/components/FontAwesomeIcon.js

View workflow job for this annotation

GitHub Actions / build (14, 16.6.x, 6.x, 5.x)

A space is required after '{'

Check failure on line 40 in src/components/FontAwesomeIcon.js

View workflow job for this annotation

GitHub Actions / build (14, 16.6.x, 6.x, 5.x)

A space is required before '}'

Check failure on line 40 in src/components/FontAwesomeIcon.js

View workflow job for this annotation

GitHub Actions / build (14, 16.12.x, 1.2.x, 5.x)

A space is required after '{'

Check failure on line 40 in src/components/FontAwesomeIcon.js

View workflow job for this annotation

GitHub Actions / build (14, 16.12.x, 1.2.x, 5.x)

A space is required before '}'

Check failure on line 40 in src/components/FontAwesomeIcon.js

View workflow job for this annotation

GitHub Actions / build (14, 16.11.x, 6.x, 5.x)

A space is required after '{'

Check failure on line 40 in src/components/FontAwesomeIcon.js

View workflow job for this annotation

GitHub Actions / build (14, 16.11.x, 6.x, 5.x)

A space is required before '}'

Check failure on line 40 in src/components/FontAwesomeIcon.js

View workflow job for this annotation

GitHub Actions / build (14, 16.5.x, 6.x, 6.x)

A space is required after '{'

Check failure on line 40 in src/components/FontAwesomeIcon.js

View workflow job for this annotation

GitHub Actions / build (14, 16.5.x, 6.x, 6.x)

A space is required before '}'

Check failure on line 40 in src/components/FontAwesomeIcon.js

View workflow job for this annotation

GitHub Actions / build (14, 16.6.x, 1.2.x, 5.x)

A space is required after '{'

Check failure on line 40 in src/components/FontAwesomeIcon.js

View workflow job for this annotation

GitHub Actions / build (14, 16.6.x, 1.2.x, 5.x)

A space is required before '}'

Check failure on line 40 in src/components/FontAwesomeIcon.js

View workflow job for this annotation

GitHub Actions / build (14, 16.11.x, 1.2.x, 6.x)

A space is required after '{'

Check failure on line 40 in src/components/FontAwesomeIcon.js

View workflow job for this annotation

GitHub Actions / build (14, 16.11.x, 1.2.x, 6.x)

A space is required before '}'

Check failure on line 40 in src/components/FontAwesomeIcon.js

View workflow job for this annotation

GitHub Actions / build (14, 16.12.x, 1.2.x, 6.x)

A space is required after '{'

Check failure on line 40 in src/components/FontAwesomeIcon.js

View workflow job for this annotation

GitHub Actions / build (14, 16.12.x, 1.2.x, 6.x)

A space is required before '}'

Check failure on line 40 in src/components/FontAwesomeIcon.js

View workflow job for this annotation

GitHub Actions / build (14, 16.7.x, 6.x, 5.x)

A space is required after '{'

Check failure on line 40 in src/components/FontAwesomeIcon.js

View workflow job for this annotation

GitHub Actions / build (14, 16.7.x, 6.x, 5.x)

A space is required before '}'

Check failure on line 40 in src/components/FontAwesomeIcon.js

View workflow job for this annotation

GitHub Actions / build (14, 16.7.x, 6.x, 6.x)

A space is required after '{'

Check failure on line 40 in src/components/FontAwesomeIcon.js

View workflow job for this annotation

GitHub Actions / build (14, 16.7.x, 6.x, 6.x)

A space is required before '}'

Check failure on line 40 in src/components/FontAwesomeIcon.js

View workflow job for this annotation

GitHub Actions / build (14, 16.6.x, 6.x, 6.x)

A space is required after '{'

Check failure on line 40 in src/components/FontAwesomeIcon.js

View workflow job for this annotation

GitHub Actions / build (14, 16.6.x, 6.x, 6.x)

A space is required before '}'

Check failure on line 40 in src/components/FontAwesomeIcon.js

View workflow job for this annotation

GitHub Actions / build (14, 16.10.x, 1.2.x, 6.x)

A space is required after '{'

Check failure on line 40 in src/components/FontAwesomeIcon.js

View workflow job for this annotation

GitHub Actions / build (14, 16.10.x, 1.2.x, 6.x)

A space is required before '}'

Check failure on line 40 in src/components/FontAwesomeIcon.js

View workflow job for this annotation

GitHub Actions / build (14, 16.4.x, 1.2.x, 5.x)

A space is required after '{'

Check failure on line 40 in src/components/FontAwesomeIcon.js

View workflow job for this annotation

GitHub Actions / build (14, 16.4.x, 1.2.x, 5.x)

A space is required before '}'

Check failure on line 40 in src/components/FontAwesomeIcon.js

View workflow job for this annotation

GitHub Actions / build (14, 16.7.x, 1.2.x, 6.x)

A space is required after '{'

Check failure on line 40 in src/components/FontAwesomeIcon.js

View workflow job for this annotation

GitHub Actions / build (14, 16.7.x, 1.2.x, 6.x)

A space is required before '}'

Check failure on line 40 in src/components/FontAwesomeIcon.js

View workflow job for this annotation

GitHub Actions / build (14, 16.10.x, 6.x, 6.x)

A space is required after '{'

Check failure on line 40 in src/components/FontAwesomeIcon.js

View workflow job for this annotation

GitHub Actions / build (14, 16.10.x, 6.x, 6.x)

A space is required before '}'

Check failure on line 40 in src/components/FontAwesomeIcon.js

View workflow job for this annotation

GitHub Actions / build (14, 17.0.x, 1.2.x, 5.x)

A space is required after '{'

Check failure on line 40 in src/components/FontAwesomeIcon.js

View workflow job for this annotation

GitHub Actions / build (14, 17.0.x, 1.2.x, 5.x)

A space is required before '}'

Check failure on line 40 in src/components/FontAwesomeIcon.js

View workflow job for this annotation

GitHub Actions / build (14, 16.9.x, 6.x, 5.x)

A space is required after '{'

Check failure on line 40 in src/components/FontAwesomeIcon.js

View workflow job for this annotation

GitHub Actions / build (14, 16.12.x, 6.x, 5.x)

A space is required after '{'

Check failure on line 40 in src/components/FontAwesomeIcon.js

View workflow job for this annotation

GitHub Actions / build (14, 16.9.x, 6.x, 5.x)

A space is required before '}'

Check failure on line 40 in src/components/FontAwesomeIcon.js

View workflow job for this annotation

GitHub Actions / build (14, 16.12.x, 6.x, 5.x)

A space is required before '}'

Check failure on line 40 in src/components/FontAwesomeIcon.js

View workflow job for this annotation

GitHub Actions / build (14, 17.0.x, 1.2.x, 6.x)

A space is required after '{'

Check failure on line 40 in src/components/FontAwesomeIcon.js

View workflow job for this annotation

GitHub Actions / build (14, 17.0.x, 1.2.x, 6.x)

A space is required before '}'

Check failure on line 40 in src/components/FontAwesomeIcon.js

View workflow job for this annotation

GitHub Actions / build (14, 16.10.x, 6.x, 5.x)

A space is required after '{'

Check failure on line 40 in src/components/FontAwesomeIcon.js

View workflow job for this annotation

GitHub Actions / build (14, 16.10.x, 6.x, 5.x)

A space is required before '}'

Check failure on line 40 in src/components/FontAwesomeIcon.js

View workflow job for this annotation

GitHub Actions / build (14, 17.0.x, 6.x, 5.x)

A space is required after '{'

Check failure on line 40 in src/components/FontAwesomeIcon.js

View workflow job for this annotation

GitHub Actions / build (14, 17.0.x, 6.x, 5.x)

A space is required before '}'

Check failure on line 40 in src/components/FontAwesomeIcon.js

View workflow job for this annotation

GitHub Actions / build (14, 16.10.x, 1.2.x, 5.x)

A space is required after '{'

Check failure on line 40 in src/components/FontAwesomeIcon.js

View workflow job for this annotation

GitHub Actions / build (14, 16.10.x, 1.2.x, 5.x)

A space is required before '}'

Check failure on line 40 in src/components/FontAwesomeIcon.js

View workflow job for this annotation

GitHub Actions / build (14, 16.3.x, 6.x, 5.x)

A space is required after '{'

Check failure on line 40 in src/components/FontAwesomeIcon.js

View workflow job for this annotation

GitHub Actions / build (14, 16.3.x, 6.x, 5.x)

A space is required before '}'

Check failure on line 40 in src/components/FontAwesomeIcon.js

View workflow job for this annotation

GitHub Actions / build (14, 16.3.x, 1.2.x, 5.x)

A space is required after '{'

Check failure on line 40 in src/components/FontAwesomeIcon.js

View workflow job for this annotation

GitHub Actions / build (14, 16.3.x, 1.2.x, 5.x)

A space is required before '}'

Check failure on line 40 in src/components/FontAwesomeIcon.js

View workflow job for this annotation

GitHub Actions / build (14, 16.3.x, 6.x, 6.x)

A space is required after '{'

Check failure on line 40 in src/components/FontAwesomeIcon.js

View workflow job for this annotation

GitHub Actions / build (14, 16.3.x, 6.x, 6.x)

A space is required before '}'

Check failure on line 40 in src/components/FontAwesomeIcon.js

View workflow job for this annotation

GitHub Actions / build (14, 16.12.x, 6.x, 6.x)

A space is required after '{'

Check failure on line 40 in src/components/FontAwesomeIcon.js

View workflow job for this annotation

GitHub Actions / build (14, 16.12.x, 6.x, 6.x)

A space is required before '}'

Check failure on line 40 in src/components/FontAwesomeIcon.js

View workflow job for this annotation

GitHub Actions / build (14, 16.6.x, 1.2.x, 6.x)

A space is required after '{'

Check failure on line 40 in src/components/FontAwesomeIcon.js

View workflow job for this annotation

GitHub Actions / build (14, 16.6.x, 1.2.x, 6.x)

A space is required before '}'

Check failure on line 40 in src/components/FontAwesomeIcon.js

View workflow job for this annotation

GitHub Actions / build (14, 16.9.x, 1.2.x, 5.x)

A space is required after '{'

Check failure on line 40 in src/components/FontAwesomeIcon.js

View workflow job for this annotation

GitHub Actions / build (14, 16.9.x, 1.2.x, 5.x)

A space is required before '}'

Check failure on line 40 in src/components/FontAwesomeIcon.js

View workflow job for this annotation

GitHub Actions / build (14, 16.8.x, 1.2.x, 5.x)

A space is required after '{'

Check failure on line 40 in src/components/FontAwesomeIcon.js

View workflow job for this annotation

GitHub Actions / build (14, 16.8.x, 1.2.x, 5.x)

A space is required before '}'

Check failure on line 40 in src/components/FontAwesomeIcon.js

View workflow job for this annotation

GitHub Actions / build (14, 16.3.x, 1.2.x, 6.x)

A space is required after '{'

Check failure on line 40 in src/components/FontAwesomeIcon.js

View workflow job for this annotation

GitHub Actions / build (14, 16.3.x, 1.2.x, 6.x)

A space is required before '}'

Check failure on line 40 in src/components/FontAwesomeIcon.js

View workflow job for this annotation

GitHub Actions / build (14, 16.5.x, 1.2.x, 6.x)

A space is required after '{'

Check failure on line 40 in src/components/FontAwesomeIcon.js

View workflow job for this annotation

GitHub Actions / build (14, 16.5.x, 1.2.x, 6.x)

A space is required before '}'

Check failure on line 40 in src/components/FontAwesomeIcon.js

View workflow job for this annotation

GitHub Actions / build (14, 16.9.x, 6.x, 6.x)

A space is required after '{'

Check failure on line 40 in src/components/FontAwesomeIcon.js

View workflow job for this annotation

GitHub Actions / build (14, 16.9.x, 6.x, 6.x)

A space is required before '}'

Check failure on line 40 in src/components/FontAwesomeIcon.js

View workflow job for this annotation

GitHub Actions / build (14, 16.8.x, 1.2.x, 6.x)

A space is required after '{'

Check failure on line 40 in src/components/FontAwesomeIcon.js

View workflow job for this annotation

GitHub Actions / build (14, 16.8.x, 1.2.x, 6.x)

A space is required before '}'

Check failure on line 40 in src/components/FontAwesomeIcon.js

View workflow job for this annotation

GitHub Actions / build (14, 16.9.x, 1.2.x, 6.x)

A space is required after '{'

Check failure on line 40 in src/components/FontAwesomeIcon.js

View workflow job for this annotation

GitHub Actions / build (14, 16.9.x, 1.2.x, 6.x)

A space is required before '}'

Check failure on line 40 in src/components/FontAwesomeIcon.js

View workflow job for this annotation

GitHub Actions / build (14, 16.5.x, 6.x, 5.x)

A space is required after '{'

Check failure on line 40 in src/components/FontAwesomeIcon.js

View workflow job for this annotation

GitHub Actions / build (14, 16.5.x, 6.x, 5.x)

A space is required before '}'

Check failure on line 40 in src/components/FontAwesomeIcon.js

View workflow job for this annotation

GitHub Actions / build (14, 16.4.x, 1.2.x, 6.x)

A space is required after '{'

Check failure on line 40 in src/components/FontAwesomeIcon.js

View workflow job for this annotation

GitHub Actions / build (14, 16.4.x, 1.2.x, 6.x)

A space is required before '}'

Check failure on line 40 in src/components/FontAwesomeIcon.js

View workflow job for this annotation

GitHub Actions / build (14, 16.7.x, 1.2.x, 5.x)

A space is required after '{'

Check failure on line 40 in src/components/FontAwesomeIcon.js

View workflow job for this annotation

GitHub Actions / build (14, 16.7.x, 1.2.x, 5.x)

A space is required before '}'

Check failure on line 40 in src/components/FontAwesomeIcon.js

View workflow job for this annotation

GitHub Actions / build (14, 16.5.x, 1.2.x, 5.x)

A space is required after '{'

Check failure on line 40 in src/components/FontAwesomeIcon.js

View workflow job for this annotation

GitHub Actions / build (14, 16.5.x, 1.2.x, 5.x)

A space is required before '}'

Check failure on line 40 in src/components/FontAwesomeIcon.js

View workflow job for this annotation

GitHub Actions / build (14, 17.0.x, 6.x, 6.x)

A space is required after '{'

Check failure on line 40 in src/components/FontAwesomeIcon.js

View workflow job for this annotation

GitHub Actions / build (14, 17.0.x, 6.x, 6.x)

A space is required before '}'

Check failure on line 40 in src/components/FontAwesomeIcon.js

View workflow job for this annotation

GitHub Actions / build (14, 16.4.x, 6.x, 5.x)

A space is required after '{'

Check failure on line 40 in src/components/FontAwesomeIcon.js

View workflow job for this annotation

GitHub Actions / build (14, 16.4.x, 6.x, 5.x)

A space is required before '}'

Check failure on line 40 in src/components/FontAwesomeIcon.js

View workflow job for this annotation

GitHub Actions / build (14, 16.4.x, 6.x, 6.x)

A space is required after '{'

Check failure on line 40 in src/components/FontAwesomeIcon.js

View workflow job for this annotation

GitHub Actions / build (14, 16.4.x, 6.x, 6.x)

A space is required before '}'

Check failure on line 40 in src/components/FontAwesomeIcon.js

View workflow job for this annotation

GitHub Actions / build (14, 16.8.x, 6.x, 6.x)

A space is required after '{'

Check failure on line 40 in src/components/FontAwesomeIcon.js

View workflow job for this annotation

GitHub Actions / build (14, 16.8.x, 6.x, 6.x)

A space is required before '}'

Check failure on line 40 in src/components/FontAwesomeIcon.js

View workflow job for this annotation

GitHub Actions / build (14, 16.8.x, 6.x, 5.x)

A space is required after '{'

Check failure on line 40 in src/components/FontAwesomeIcon.js

View workflow job for this annotation

GitHub Actions / build (14, 16.8.x, 6.x, 5.x)

A space is required before '}'

const iconLookup = normalizeIconArgs(iconArgs)
const iconLookup = normalizeIconArgs(allProps.icon)

const classes = objectWithKey('classes', [
...classList(props),
...className.split(' ')
...classList(allProps),
...allProps.className.split(' ')
])
const transform = objectWithKey(
'transform',
typeof props.transform === 'string'
? parse.transform(props.transform)
: props.transform
typeof allProps.transform === 'string'
? parse.transform(allProps.transform)
: allProps.transform
)
const mask = objectWithKey('mask', normalizeIconArgs(maskArgs))
const mask = objectWithKey('mask', normalizeIconArgs(allProps.mask))

const renderedIcon = icon(iconLookup, {
...classes,
Expand All @@ -50,10 +71,10 @@ const FontAwesomeIcon = React.forwardRef((props, ref) => {
const { abstract } = renderedIcon
const extraProps = { ref }

Object.keys(props).forEach(key => {
Object.keys(allProps).forEach(key => {
// eslint-disable-next-line no-prototype-builtins
if (!FontAwesomeIcon.defaultProps.hasOwnProperty(key)) {
extraProps[key] = props[key]
if (!defaultProps.hasOwnProperty(key)) {
extraProps[key] = allProps[key]
}
})

Expand Down Expand Up @@ -143,35 +164,6 @@ FontAwesomeIcon.propTypes = {
swapOpacity: PropTypes.bool
}

FontAwesomeIcon.defaultProps = {
border: false,
className: '',
mask: null,
maskId: null,
fixedWidth: false,
inverse: false,
flip: false,
icon: null,
listItem: false,
pull: null,
pulse: false,
rotation: null,
size: null,
spin: false,
spinPulse: false,
spinReverse: false,
beat: false,
fade: false,
beatFade: false,
bounce: false,
shake: false,
symbol: false,
title: '',
titleId: null,
transform: null,
swapOpacity: false
}

export default FontAwesomeIcon

const convertCurry = convert.bind(null, React.createElement)

0 comments on commit 161d6ba

Please sign in to comment.