Enable the regexp/no-super-linear-move ESLint rule

It flags the regexes whose search is quadratic in the input length, like
the autolinker and XFA-path ones fixed recently.

The three existing offenders: `\s*` matched the CSS indentation but also
the line terminators that make `^` match with the `m` flag (the
preprocessed CSS is unchanged), `(\d+)` made every digit of a number a
candidate start position, and `/T.*$/` could fail on the `$` and
backtrack since `.` doesn't match a line terminator.
This commit is contained in:
calixteman 2026-08-04 18:27:23 +02:00
parent e57a46436f
commit fc01f7d033
No known key found for this signature in database
GPG Key ID: 0C5442631EE0691F
4 changed files with 5 additions and 4 deletions

View File

@ -62,6 +62,7 @@ export default [
rules: {
...regexpPlugin.configs["flat/recommended"].rules,
"regexp/no-legacy-features": "off",
"regexp/no-super-linear-move": "error",
},
},
{

View File

@ -53,7 +53,7 @@ function preprocess(inFilename, outFilename, defines) {
}
return content.replaceAll(
/^\s*@import\s+url\(([^)]+)\);\s*$/gm,
/^[ \t]*@import\s+url\(([^)]+)\);[ \t]*$/gm,
function (all, url) {
const file = path.join(path.dirname(baseUrl), url);
const imported = fs.readFileSync(file, "utf8").toString();

View File

@ -37,7 +37,7 @@ function parseAdobeCMap(content) {
result.usecmap = m[1];
}
const re =
/(\d+)\s+(begincodespacerange|beginnotdefrange|begincidchar|begincidrange|beginbfchar|beginbfrange)\n([\s\S]*?)\n(?:endcodespacerange|endnotdefrange|endcidchar|endcidrange|endbfchar|endbfrange)/g;
/\b(\d+)\s+(begincodespacerange|beginnotdefrange|begincidchar|begincidrange|beginbfchar|beginbfrange)\n([\s\S]*?)\n(?:endcodespacerange|endnotdefrange|endcidchar|endcidrange|endbfchar|endbfrange)/g;
while ((m = re.exec(body))) {
const lines = m[3].toLowerCase().split("\n");

View File

@ -753,10 +753,10 @@ describe("Scripting", function () {
it("should parse a date with a format", async () => {
const check = async (date, format, expected) => {
const value = await myeval(
`AFParseDateEx("${date}", "${format}").toISOString().replace(/T.*$/, "")`
`AFParseDateEx("${date}", "${format}").toISOString().replace(/T.*/, "")`
);
expect(value).toEqual(
new Date(expected).toISOString().replace(/T.*$/, "")
new Date(expected).toISOString().replace(/T.*/, "")
);
};