You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Where moduleSatement is defined according to the the JS spec (1 and 2). strings would also cover the various bits of template literals. By matching identifiers explicitly we avoid the issues where an identifier ends in import or export (JS regexps are eager). Edit: more thinking is required here... Edit2: done, it should work.
The module could still be fooled by a regexp that's been designed to trick it (e.g. r = /;import {} from ''). Avoiding this would require more logic than what RegExps provide AFAICT.
Edit: assuming you decided to use compose-regexp, it can be kept as a dev-dependency.
Edit3: dealing with interpolations in template literals would also require an actual parser (though note a complex one).
The text was updated successfully, but these errors were encountered:
Beside #3, you can also trivially fool the detector with comments, strings or even regexps.
e.g. if you feed it this file, it returns true:
The current regexps are also pretty contrived. They are equivalent to
I propose we move to something like
Where
moduleSatement
is defined according to the the JS spec (1 and 2).strings
would also cover the various bits of template literals. By matching identifiers explicitly we avoid the issues where an identifier ends inimport
orexport
(JS regexps are eager).Edit: more thinking is required here...Edit2: done, it should work.The module could still be fooled by a regexp that's been designed to trick it (e.g.
r = /;import {} from ''
). Avoiding this would require more logic than what RegExps provide AFAICT.Edit: assuming you decided to use
compose-regexp
, it can be kept as a dev-dependency.Edit3: dealing with interpolations in template literals would also require an actual parser (though note a complex one).
The text was updated successfully, but these errors were encountered: