Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mixing of semi-colon styles can cause errors #338

Closed
tombye opened this issue Oct 11, 2016 · 1 comment
Closed

Mixing of semi-colon styles can cause errors #338

tombye opened this issue Oct 11, 2016 · 1 comment

Comments

@tombye
Copy link
Contributor

tombye commented Oct 11, 2016

The Show/Hide content module was written with the standardJS style of semicolon use. All our other GOVUK modules use the JSLint style and combining the two can cause errors.

For example, if you have the Show/Hide content module followed by the Stick-at-top-when-scrolling module, you get this:

End of Show/Hide content module:

  GOVUK.ShowHideContent = ShowHideContent
  global.GOVUK = GOVUK
})(window)

Start of Stick-at-top-when-scrolling module:

(function (global) {
  "use strict";

...which causes this error:

Uncaught TypeError: (intermediate value)(intermediate value)(intermediate value)(...) is not a function

I think the parser is seeing only line breaks between })(window) and (function (global) { so assumes you mean:

(function () { ... })(window)(function (global) { ... })

(function () { ... })(window) doesn't return a function so it breaks.

We've solved this on Digital Marketplace by adding a semicolon after the Show/Hide content module block but having a project-specific fix for this isn't ideal.

@robinwhittleton
Copy link
Contributor

#334 (that @tvararu referenced) lints every JS file with Standard. This fixes this issue. Looking at the original example, both show-hide-content
and stick-at-top-when-scrolling start with the same ;(function (global) {.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants