I have developed a chrome extension where, in order to try and keep code managable, have broken the content script code into 5 separate js files which are injected from the serviceWorker like this if the URL matches a specific site;
chrome.scripting.executeScript({
target: { tabId },
files: [
'content/globals.js',
'content/hotkey_configs.js',
'content/element_control.js',
'content/socket-manager.js',
'content/textmanager.js',
'content/content.js',
],
});
All is good, things are working but most of these files access functions and variables through the various files.
I recently started using ESlint and it is very angry at me since I have functions spread out across the different files and it thinks it can’t find them.
For example;
file1.js
function lockTarget() {
...Some function
}
file2.js
lockTarget(); //ESlint reports that lockTarget is not defined
I have these little things all over when access data or functions in different files. I have added some global references to eslintrc like “chrome” and a few others I have defined and that addressed those.
I guess my question is: Should I should listen to ESlint and restructure my code to appease it or just add exceptions to my eslintrc file since what I’m doing is ok?