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

12 views
Skip to first unread message

Mark Banner

unread,
Jan 31, 2023, 3:21:11 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

--
You received this message because you are subscribed to the Google Groups "firef...@mozilla.org" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firefox-dev...@mozilla.org.
To view this discussion on the web visit https://groups.google.com/a/mozilla.org/d/msgid/firefox-dev/614bef4e-7cb6-1da2-2da5-252cf7f8db71%40mozilla.com.
Reply all
Reply to author
Forward
0 new messages