1

I'm trying to inject a script from rewardful in the head of my react/nextjs build. However eslint doesn't seem to like the script they've given me

<script>(function(w,r){w._rwq=r;w[r]=w[r]||function(){(w[r].q=w[r].q||[]).push(arguments)}})(window,'rewardful');</script>

It takes issue with the semicolon after the w._req=r;

Error: Parsing error: Unexpected token ;

I've tried beautifying it so it exists on each line and removing the ';' character such as:

<script>(function(w, r) {
            w._rwq = r
            w[r] = w[r] || function() {
            (w[r].q = w[r].q || []).push(arguments)
          }
          })(window, 'rewardful');</script>

However the error persists of Error: error: Expected '}', got 'w'

Any ideas?

Thanks

alienbuild
  • 246
  • 2
  • 15
  • place this above the first 1line-script: `// eslint-disable-next-line` or if u want to beautify it, add `/* eslint-disable */` and then `/* eslint-enable */` below the script. – Joel Oct 11 '22 at 11:45
  • Thanks @Joel I did try that too but the error is the same. My assumption is that it does not know what 'w' and 'r', is and that comes from another script i'm instructed to inject after this one. (that one has no issues) – alienbuild Oct 11 '22 at 11:47
  • Are you trying to put – Nikolay Oct 11 '22 at 11:48
  • @Nikolay I'm placing it into the _document.js element provided by nextjs – alienbuild Oct 11 '22 at 11:49
  • 1
    Yes, it is as good as placing it in a component, as far as I understand. You can check this out: https://stackoverflow.com/questions/34424845/adding-script-tag-to-react-jsx – Nikolay Oct 11 '22 at 11:51

0 Answers0