Configuring global functions #14210
-
I have a ESLint was complaining about undefined functions ( "globals": {
"getCookieValue": "readonly",
"setCookie": "readonly"
}, The problem now, is that ESLint thinks I'm re-declaring those functions within the
Any idea how I can tell it where the source of those functions is? Or should I just suppress the error in the source file? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Hi @Atulin! I think the correct solution would be to set the globals to That can be done either directly in the file, using the /* global getCookieValue: off, setCookie: off */ or in the config file, using "globals": {
"getCookieValue": "readonly",
"setCookie": "readonly"
},
"overrides": [
{
"files": ["path/to/site.js"],
"globals": {
"getCookieValue": "off",
"setCookie": "off"
}
}
] |
Beta Was this translation helpful? Give feedback.
-
That seems to have worked, thanks! Feels like a bit of a hacky solution though. Perhaps something like "globals-sources": [
"path/to/file.js"
] that registers stuff from that file as globals and prevents it from being considered a re-declaration would be nice to have. |
Beta Was this translation helpful? Give feedback.
Hi @Atulin!
I think the correct solution would be to set the globals to
"off"
for the file where they're declared, as they are not already declared before that script executes.That can be done either directly in the file, using the
/* global */
configuration comment:/* global getCookieValue: off, setCookie: off */
or in the config file, using
overrides
: