Nixinova / LinguistJS

Analyse and list all languages used in a folder. Implementation of and powered by GitHub's Linguist.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SyntaxError: Invalid flags supplied to RegExp constructor 'x'

cw-alexcroteau opened this issue · comments

Because of a change in the upstream repo's Adblock Plus filter list, it looks like the PCRE conversion script detects a "x" flag. I am not able to produce a minimal reproduction of the issue, other than this stack trace:

(node:32624) UnhandledPromiseRejectionWarning: SyntaxError: Invalid flags supplied to RegExp constructor 'x'
    at RegExp (<anonymous>)
    at pcre (/home/alex/projects/code/node_modules/linguist-js/dist/helpers/convert-pcre.js:26:12)
    at /home/alex/projects/code/node_modules/linguist-js/dist/index.js:301:97
    at Array.some (<anonymous>)
    at analyse (/home/alex/projects/code/node_modules/linguist-js/dist/index.js:301:54)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at async /home/alex/projects/code/node_modules/linguist-js/dist/cli.js:55:22
(Use `node --trace-warnings ...` to show where the warning was created)
(node:32624) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:32624) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Thanks for the report!
Yep, that PR added this line:
https://github.com/github/linguist/blob/e78ef71af3600f96b9a40a06511ebbe3797e7401/lib/linguist/heuristics.yml#L655
The crash is due to LinguistJS not having a conversion process for the (?x) flag.
I'll fix it and have a patch release out today 👍

Should be fixed in v2.5.3 👍