diff --git a/tasks/test-project/codemods/scenarioValueSuffix.js b/tasks/test-project/codemods/scenarioValueSuffix.js index 4d86edae1088..7a6441760819 100644 --- a/tasks/test-project/codemods/scenarioValueSuffix.js +++ b/tasks/test-project/codemods/scenarioValueSuffix.js @@ -1,16 +1,15 @@ +const stringWithSuffixRegex = /String\d+$/ + export default (file, api) => { const j = api.jscodeshift const root = j(file.source) - const endsWith6DigitsRE = /String.*\d{6,}$/ - - // Replaces the randomly generated value with consistent ones - + // Replaces the randomly generated value with a consistent one return root .find(j.Literal, { type: 'StringLiteral' }) .forEach((obj) => { const stringValue = obj.value.value - if (endsWith6DigitsRE.test(stringValue)) { + if (stringWithSuffixRegex.test(stringValue)) { obj.value.value = `String${obj.value.loc.start.line}` } })