ESLint improvement: Reduced need for import-globals-from when using loadSubScript

28 views
Skip to first unread message

Mark Banner

unread,
Jan 31, 2023, 3:21:10 AM1/31/23
to dev-pl...@mozilla.org, firefox-dev list

I have just landed a change that helps ESLint to automatically detect globals for loadSubScript when importing test files.

Previously you may have had to write a line to tell ESLint to import the file, e.g.

/* import-globals-from ../../../gfx/layers/apz/test/mochitest/apz_test_native_event_utils.js */

Services.scriptloader.loadSubScript(
  "chrome://mochitests/content/browser/gfx/layers/apz/test/mochitest/apz_test_utils.js",
  this
);

No more! Now you can simply call loadSubScript:

Services.scriptloader.loadSubScript(
  "chrome://mochitests/content/browser/gfx/layers/apz/test/mochitest/apz_test_utils.js",
  this
);


For urls starting with chrome://mochitests/content/browser/, our ESLint setup will now automatically find the source file and load the relevant global variables.

The patches I have just landed also clean up all (that I can find) the existing instances of import-globals-from that are now unnecessary.

Mark

Reply all
Reply to author
Forward
0 new messages