Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
class ClassComp extends React.Component {
render() {
return null;
}
}
function FuncComp() {
return null;
}
// $ExpectType Requireable
AirbnbPropTypes.and([PropTypes.number]);
// $ExpectType Requireable
AirbnbPropTypes.and([PropTypes.number, AirbnbPropTypes.nonNegativeInteger]);
// $ExpectType Validator
AirbnbPropTypes.and([PropTypes.number, AirbnbPropTypes.integer()], 'foo').isRequired;
// $ExpectType Requireable
AirbnbPropTypes.between({ lt: 1 });
// $ExpectType Requireable
AirbnbPropTypes.between({ lte: 2 });
// $ExpectType Requireable
AirbnbPropTypes.between({ gt: 3 });
// $ExpectType Requireable
AirbnbPropTypes.between({ gte: 4 });
// $ExpectType Requireable
AirbnbPropTypes.between({ lt: 1, gt: 0 });
// $ExpectType Requireable
AirbnbPropTypes.booleanSome('foo', 'bar', 'baz');
// $ExpectType Requireable
import PropTypes from 'prop-types';
import { and } from 'airbnb-prop-types';
export default and([
PropTypes.instanceOf(Set),
function modifiers(props, propName, ...rest) {
const { [propName]: propValue } = props;
let firstError;
[...propValue].some((v, i) => {
const fakePropName = `${propName}: index ${i}`;
firstError = PropTypes.string.isRequired(
{ [fakePropName]: v },
fakePropName,
...rest,
);
return firstError != null;
});
return firstError == null ? null : firstError;
},
], 'Modifiers (Set of Strings)');
import React from 'react';
import PropTypes from 'prop-types';
import { and, mutuallyExclusiveProps } from 'airbnb-prop-types';
import withStyles, { WithStylesProps } from '../../composers/withStyles';
import { styleSheet } from './styles';
const mutuallyExclusiveSizePropType = mutuallyExclusiveProps(
PropTypes.any,
'small',
'large',
'macro',
'size',
);
const namedSizePropType = and([PropTypes.bool, mutuallyExclusiveSizePropType]);
const unitSizePropType = and([PropTypes.number, mutuallyExclusiveSizePropType]);
export type Props = {
/** Fallback image if the image is broken. */
fallbackImageSrc?: string;
/** URL of the image to display. */
imageSrc: string;
/** Whether the component should be inline. */
inline?: boolean;
/** Large size (96px). */
large?: boolean;
/** Macro size (160px). */
macro?: boolean;
/** Size in units to multiply by. */
size?: number;
/** Small size (24px). */
import React from 'react';
import PropTypes from 'prop-types';
import { and, mutuallyExclusiveProps } from 'airbnb-prop-types';
import withStyles, { WithStylesProps } from '../../composers/withStyles';
import { styleSheet } from './styles';
const mutuallyExclusiveSizePropType = mutuallyExclusiveProps(
PropTypes.any,
'small',
'large',
'macro',
'size',
);
const namedSizePropType = and([PropTypes.bool, mutuallyExclusiveSizePropType]);
const unitSizePropType = and([PropTypes.number, mutuallyExclusiveSizePropType]);
export type Props = {
/** Fallback image if the image is broken. */
fallbackImageSrc?: string;
/** URL of the image to display. */
imageSrc: string;
/** Whether the component should be inline. */
inline?: boolean;
/** Large size (96px). */
large?: boolean;
/** Macro size (160px). */
macro?: boolean;
/** Size in units to multiply by. */
size?: number;
/** Small size (24px). */
small?: boolean;