Changeset 0c6b92a for imaps-frontend/node_modules/eslint-plugin-react/lib/rules/boolean-prop-naming.js
Legend:
- Unmodified
- Added
- Removed
-
imaps-frontend/node_modules/eslint-plugin-react/lib/rules/boolean-prop-naming.js
rd565449 r0c6b92a 11 11 const Components = require('../util/Components'); 12 12 const propsUtil = require('../util/props'); 13 const astUtil = require('../util/ast'); 13 14 const docsUrl = require('../util/docsUrl'); 14 15 const propWrapperUtil = require('../util/propWrapper'); … … 18 19 const getSourceCode = eslintUtil.getSourceCode; 19 20 const getText = eslintUtil.getText; 21 22 /** 23 * Checks if prop is nested 24 * @param {Object} prop Property object, single prop type declaration 25 * @returns {boolean} 26 */ 27 function nestedPropTypes(prop) { 28 return ( 29 prop.type === 'Property' 30 && astUtil.isCallExpression(prop.value) 31 ); 32 } 20 33 21 34 // ------------------------------------------------------------------------------ … … 129 142 * Checks if prop is declared in flow way 130 143 * @param {Object} prop Property object, single prop type declaration 131 * @returns { Boolean}144 * @returns {boolean} 132 145 */ 133 146 function flowCheck(prop) { … … 142 155 * Checks if prop is declared in regular way 143 156 * @param {Object} prop Property object, single prop type declaration 144 * @returns { Boolean}157 * @returns {boolean} 145 158 */ 146 159 function regularCheck(prop) { … … 164 177 165 178 /** 166 * Checks if prop is nested167 * @param {Object} prop Property object, single prop type declaration168 * @returns {Boolean}169 */170 function nestedPropTypes(prop) {171 return (172 prop.type === 'Property'173 && prop.value.type === 'CallExpression'174 );175 }176 177 /**178 179 * Runs recursive check on all proptypes 179 180 * @param {Array} proptypes A list of Property object (for each proptype defined) … … 181 182 */ 182 183 function runCheck(proptypes, addInvalidProp) { 183 (proptypes || []).forEach((prop) => { 184 if (config.validateNested && nestedPropTypes(prop)) { 185 runCheck(prop.value.arguments[0].properties, addInvalidProp); 186 return; 187 } 188 if (flowCheck(prop) || regularCheck(prop) || tsCheck(prop)) { 189 addInvalidProp(prop); 190 } 191 }); 184 if (proptypes) { 185 proptypes.forEach((prop) => { 186 if (config.validateNested && nestedPropTypes(prop)) { 187 runCheck(prop.value.arguments[0].properties, addInvalidProp); 188 return; 189 } 190 if (flowCheck(prop) || regularCheck(prop) || tsCheck(prop)) { 191 addInvalidProp(prop); 192 } 193 }); 194 } 192 195 } 193 196 … … 257 260 } 258 261 259 const annotationTypeParams = component.node.parent.id.typeAnnotation.typeAnnotation.typeParameters; 262 const annotationTypeArguments = propsUtil.getTypeArguments( 263 component.node.parent.id.typeAnnotation.typeAnnotation 264 ); 260 265 if ( 261 annotationType Params && (262 annotationType Params.type === 'TSTypeParameterInstantiation'263 || annotationType Params.type === 'TypeParameterInstantiation'266 annotationTypeArguments && ( 267 annotationTypeArguments.type === 'TSTypeParameterInstantiation' 268 || annotationTypeArguments.type === 'TypeParameterInstantiation' 264 269 ) 265 270 ) { 266 return annotationType Params.params.find(271 return annotationTypeArguments.params.find( 267 272 (param) => param.type === 'TSTypeReference' || param.type === 'GenericTypeAnnotation' 268 273 ); … … 310 315 if ( 311 316 node.value 312 && node.value.type === 'CallExpression'317 && astUtil.isCallExpression(node.value) 313 318 && propWrapperUtil.isPropWrapperFunction( 314 319 context, … … 336 341 const right = node.parent.right; 337 342 if ( 338 right.type === 'CallExpression'343 astUtil.isCallExpression(right) 339 344 && propWrapperUtil.isPropWrapperFunction( 340 345 context,
Note:
See TracChangeset
for help on using the changeset viewer.