Skip to content

Commit 75d5f1a

Browse files
committed
Added custom validator check for constructing the proptypes for validation
For now will be ignored. Possible future behavior: - Import structured validator that plugs into eslint-plugin-react to validate itself and it's children
1 parent e04a31b commit 75d5f1a

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

lib/rules/prop-types.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ module.exports = function(context) {
1818

1919
var configuration = context.options[0] || {};
2020
var ignored = configuration.ignore || [];
21+
var customValidators = configuration.customValidators || [];
2122

2223
var componentList = new ComponentList();
2324

@@ -72,6 +73,15 @@ module.exports = function(context) {
7273
return ignored.indexOf(name) !== -1;
7374
}
7475

76+
/**
77+
* Checks if prop should be validated by plugin-react-proptypes
78+
* @param {String} validator Name of validator to check.
79+
* @returns {Boolean} True if validator should be checked by custom validator.
80+
*/
81+
function hasCustomValidator(validator) {
82+
return customValidators.indexOf(validator) !== -1;
83+
}
84+
7585
/**
7686
* Checks if the component must be validated
7787
* @param {Object} component The component to process
@@ -203,6 +213,15 @@ module.exports = function(context) {
203213
* the property is declared without the need for further analysis.
204214
*/
205215
function buildReactDeclarationTypes(value) {
216+
if (
217+
value &&
218+
value.callee &&
219+
value.callee.object &&
220+
hasCustomValidator(value.callee.object.name)
221+
) {
222+
return true;
223+
}
224+
206225
if (
207226
value.type === 'MemberExpression' &&
208227
value.property &&

0 commit comments

Comments
 (0)