diff --git a/packages/jsts/src/rules/S5843/unit.test.ts b/packages/jsts/src/rules/S5843/unit.test.ts index 507d548a699..fdc1009c455 100644 --- a/packages/jsts/src/rules/S5843/unit.test.ts +++ b/packages/jsts/src/rules/S5843/unit.test.ts @@ -110,6 +110,42 @@ ruleTesterThreshold0.run( ], options: [0], }, + { + code: `RegExp('\\r?');`, + errors: [ + { + message: JSON.stringify({ + message: `Simplify this regular expression to reduce its complexity from 1 to the 0 allowed.`, + cost: 1, + secondaryLocations: [], // Secondary location removed when invalid (start===end) + }), + line: 1, + endLine: 1, + column: 8, + endColumn: 13, + }, + ], + options: [0], + }, + { + code: `RegExp('\\\\r?');`, + errors: [ + { + message: JSON.stringify({ + message: `Simplify this regular expression to reduce its complexity from 1 to the 0 allowed.`, + cost: 1, + secondaryLocations: [ + { message: '+1', column: 11, line: 1, endColumn: 12, endLine: 1 }, + ], + }), + line: 1, + endLine: 1, + column: 8, + endColumn: 14, + }, + ], + options: [0], + }, { code: `/(?<=abc)/`, errors: [ diff --git a/packages/jsts/src/rules/S5860/rule.ts b/packages/jsts/src/rules/S5860/rule.ts index 7ac1c230392..f55aab4d8cc 100644 --- a/packages/jsts/src/rules/S5860/rule.ts +++ b/packages/jsts/src/rules/S5860/rule.ts @@ -294,12 +294,7 @@ function prepareSecondaries( function checkIndexedGroups(intellisense: RegexIntelliSense) { intellisense.getKnowledge().forEach(regex => { regex.groups.forEach(group => { - const { locations, messages } = prepareSecondaries( - regex, - [group], - intellisense, - 'Named group', - ); + const { locations, messages } = prepareSecondaries(regex, [group], intellisense, 'Group'); group.node.references.forEach(reference => { const loc = getRegexpLocation(regex.node, reference, intellisense.context);