Skip to content

Commit

Permalink
fix(ruleset-migrator): avoid positive lookbehinds (#2349)
Browse files Browse the repository at this point in the history
P0lip authored Nov 23, 2022

Verified

This commit was signed with the committer’s verified signature. The key has expired.
gjbkz Kei Ito
1 parent fe3bbbf commit 455c324
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions packages/ruleset-migrator/src/transformers/formats.ts
Original file line number Diff line number Diff line change
@@ -26,18 +26,11 @@ const FORMATS = [

function safeFormat(format: string): string {
return format
.replace(/\.|(?<=[0-9])-(?=[0-9])/g, '_')
.replace(/\.|([0-9])-(?=[0-9])/g, '$1_')
.replace(/-([0-9a-z])/g, (match, char) => String(char).toUpperCase());
}

const REPLACEMENTS = Object.fromEntries(
FORMATS.map(format => [
format,
(ALIASES[format] ?? format)
.replace(/\.|(?<=[0-9])-(?=[0-9])/g, '_')
.replace(/-([0-9a-z])/g, (match, char) => String(char).toUpperCase()),
]),
);
const REPLACEMENTS = Object.fromEntries(FORMATS.map(format => [format, safeFormat(ALIASES[format] ?? format)]));

function transform(input: unknown, ctx: TransformerCtx): namedTypes.ArrayExpression {
assertArray(input);

0 comments on commit 455c324

Please sign in to comment.