Skip to content

Commit 5ad93b4

Browse files
committed
[Fix] forbid-prop-types: propWrapperFunctions breaks on identifiers.
1 parent 73abadb commit 5ad93b4

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

lib/rules/forbid-prop-types.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ module.exports = {
7474
* @returns {void}
7575
*/
7676
function checkForbidden(declarations) {
77-
declarations.forEach(declaration => {
77+
(declarations || []).forEach(declaration => {
7878
if (declaration.type !== 'Property') {
7979
return;
8080
}

tests/lib/rules/forbid-prop-types.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,18 @@ ruleTester.run('forbid-prop-types', rule, {
398398
settings: {
399399
propWrapperFunctions: ['forbidExtraProps']
400400
}
401+
}, {
402+
code: [
403+
'import { forbidExtraProps } from "airbnb-prop-types";',
404+
'export const propTypes = {a: PropTypes.any};',
405+
'export default function Component() {}',
406+
'Component.propTypes = forbidExtraProps(propTypes);',
407+
].join('\n'),
408+
// errors: [{message: ANY_ERROR_MESSAGE}], // TODO: make this pass
409+
errors: [],
410+
settings: {
411+
propWrapperFunctions: ['forbidExtraProps']
412+
}
401413
}, {
402414
code: [
403415
'class Component extends React.Component {',

0 commit comments

Comments
 (0)