I'm trying to add pendo snippet in my react application I have included the javascript snippet and I use pendo.initialize({visitor:{id:'id'})
I validate using pendo.validateInstall()
, all works fine but I've encountered a eslint error "pendo is not defined" in pendo.initialize({visitor:{id:'id'})
which is used at my promise handler.
Asked
Active
Viewed 4,338 times
2

Filip Cordas
- 2,531
- 1
- 12
- 23

Revathy Arunachalam
- 21
- 1
- 2
-
ESLint tells you it's not defined because it *doesn't know about it*. It's not in the current file and I suspect it's some sort of global but without a visibility from the current location to the declaration *and* a thorough map of the dataflow of the application (which is beyond the scope of ESLint), it has no way of knowing that `pendo` will be declared and assigned a value by the time your code reaches the line with `pendo.initialize`. – VLAZ Mar 27 '19 at 11:48
-
Probably don't have the import of the module on top of the file. Most likely they have a proper js module so you don't have to use global variables – Filip Cordas Mar 27 '19 at 11:53
-
https://stackoverflow.com/questions/44877904/how-do-you-import-a-javascript-package-from-a-cdn-script-tag-in-react I resolved that ESLint error using this thank you all for responding. – Revathy Arunachalam Mar 27 '19 at 12:07
2 Answers
3
Instead of using
pendo.initialize({visitor:{id:'id'})
use
window.pendo.initialize({visitor:{id:'id'})

Esteban Camacho
- 31
- 1
2
You can add globals in the eslint
configuration.
"globals": {
"pendo": true
}
If you want to override the error message just in one file, you add the following on top of your javascript file.
/* global pendo */
Checkout the eslint global documentation.

Subash
- 7,098
- 7
- 44
- 70