Error: There is a JavaScript syntax error in your code; validation cannot continue on this file


(Cristian Serban) #1

Hello,

I am trying to upload an extension and getting this error:

Error: There is a JavaScript syntax error in your code; validation cannot continue on this file.
node_modules/popper.js/dist/popper-utils.min.js line 4 column 9049

I am using bootstrap 4 in the extension which requires https://popper.js.org/ and apparently this particular library triggers the error.

Any idea ?


(Mittineague) #2

Hi twisted1919 welcome to the forum

Well, the “min” version isn’t going to be easy to debug. I think if you try putting it together using the unminified version during development you’ll have a much better go at it.


(Cristian Serban) #3

@Mittineague - fair enough, the addons-linter says:

Code              Message                   Description                                                                                 File                                               Line   Column
JS_SYNTAX_ERROR   JavaScript syntax error   There is a JavaScript syntax error in your code; validation cannot continue on this file.   node_modules/popper.js/dist/popper-utils.js        1040   1     
JS_SYNTAX_ERROR   JavaScript syntax error   There is a JavaScript syntax error in your code; validation cannot continue on this file.   node_modules/popper.js/dist/popper.js              2371   1 

And looking at those lines, i can see things such as:

// node_modules/popper.js/dist/popper-utils.js        1040
export { computeAutoPlacement, debounce, findIndex, getBordersSize, getBoundaries, getBoundingClientRect, getClientRect, getOffsetParent, getOffsetRect, getOffsetRectRelativeToArbitraryNode, getOuterSizes, getParentNode, getPopperOffsets, getReferenceOffsets, getScroll, getScrollParent, getStyleComputedProperty, getSupportedPropertyName, getWindowSizes, isFixed, isFunction, isModifierEnabled, isModifierRequired, isNumeric, removeEventListeners, runModifiers, setAttributes, setStyles, setupEventListeners };

// node_modules/popper.js/dist/popper.js              2371
export default Popper;

I was under the impression this is valid javascript… so where do i go with this ?


(Mittineague) #4

Hmmm, I’m not seeing an obvious syntax error with line 1040. But it looks like line 2371 might need curly braces. eg.

export default Popper {}

or

export { Popper as default }; 

IMHO, hacking someone elses code is less than ideal. Have you contacted the Popper devs?


(Martin Giger) #5

This is obviously an es module (and so is the export syntax) for which support has only just landed in the linter and will take a bit of time to arrive on AMO (like a week, probably, not sure).

Further you’d have to load the file as es module in your code using import. If that’s not how you want to use it, you’d have to find a non-es module version. Though I assume the .min.js is actually a non-es module version.


(Cristian Serban) #6

@Mittineague - Thanks for the update. Popper is used by BS4 and it works just fine in dev so i highly doubt there’s an issue with it. I could contact the devs, but really, since it works just fine for bs4 i don’t think i have something to tell them…

@freaktechnik - the linter complaints about the min version too, i don’t think it’s a “usage” issue but rather the linter might not understand the syntax and it bails out.

So i guess i’d just have to wait for the linter to support this ?