UNPKG

react-native-ui-lib

Version:

<p align="center"> <img src="https://user-images.githubusercontent.com/1780255/105469025-56759000-5ca0-11eb-993d-3568c1fd54f4.png" height="250px" style="display:block"/> </p> <p align="center">UI Toolset & Components Library for React Native</p> <p a

23 lines (19 loc) 852 B
const {findValueNodeOfIdentifier} = require('./generalUtils'); function _isLiteral(type) { return (type === 'Literal' || type === 'TemplateLiteral'); } function findAndReportHardCodedValues(value, reporter, context, depthOfSearch = 4) { if (depthOfSearch === 0) return; if (value === undefined || value === false) return; if (_isLiteral(value.type)) { reporter(value); } else if (value.type === 'ConditionalExpression') { findAndReportHardCodedValues(value.consequent, reporter, context, depthOfSearch - 1); findAndReportHardCodedValues(value.alternate, reporter, context, depthOfSearch - 1); } else if (value.type === 'Identifier') { findAndReportHardCodedValues(findValueNodeOfIdentifier(value.name, context.getScope()), reporter, context, depthOfSearch - 1); } } module.exports = { findAndReportHardCodedValues };