quit passing variables unnecessarily
MODIFY
packages/@romejs/js-parser-utils/regex.ts
packages/@romejs/js-parser-utils/regex.ts
@@ -12,10 +12,8 @@ const VALID_REGEX_FLAGS: Array<string> = 'gmsiyu'.split('');
// This is used by both rome-json and rome-js-parser to validate regex flags
export function validateRegexFlags(
flags: string,
- parserIndex: number,
onUnexpected: (
metadata: Omit<DiagnosticDescription, 'category'>,
- parserIndex: number,
index: number,
) => void,
): Set<
@@ -27,12 +25,12 @@ export function validateRegexFlags(
if (VALID_REGEX_FLAGS.includes(flag)) {
if (foundFlags.has(flag)) {
- onUnexpected(descriptions.REGEX_PARSER.DUPLICATE_FLAG, i, parserIndex);
+ onUnexpected(descriptions.REGEX_PARSER.DUPLICATE_FLAG, i);
} else {
foundFlags.add(flag);
}
} else {
- onUnexpected(descriptions.REGEX_PARSER.INVALID_FLAG, i, parserIndex);
+ onUnexpected(descriptions.REGEX_PARSER.INVALID_FLAG, i);
}
}

MODIFY
packages/@romejs/js-parser/tokenizer/index.ts
packages/@romejs/js-parser/tokenizer/index.ts
@@ -1027,13 +1027,9 @@ export function readRegexp(parser: JSParser): void {
description: descriptions.JS_PARSER.UNICODE_ESCAPE_IN_REGEX_FLAGS,
});
}
- const mods = validateRegexFlags(rawMods, getIndex(parser), (
- metadata,
- parserIndex,
- flagPosition,
- ) => {
+ const mods = validateRegexFlags(rawMods, (metadata, flagPosition) => {
parser.addDiagnostic({
- index: add(coerce0(parserIndex - rawMods.length), flagPosition),
+ index: add(coerce0(getIndex(parser) - rawMods.length), flagPosition),
description: metadata,
});
});

quit passing variables unnecessarily