Bug 1591013 - Add an eslint rule to prevent loading client modules from devtools/server r=nchevobbe

Depends on D51054

This will help catch some issues related to server files importing client files.
Note that we still don't validate:
- devtools/shared: at the moment devtools/shared still contains client only files which
  naturally import other client files, so linting here is not an option before we clean
  this up
- require calls using variables eg require(MY_MODULE_URI). Maybe we should prevent this via
  another linting rule

Differential Revision: https://phabricator.services.mozilla.com/D50466

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Julian Descottes 2019-10-30 08:28:44 +00:00
parent 0815c788fc
commit 4f668cb36e

View File

@ -82,6 +82,14 @@ module.exports = {
"rules": {
"no-unused-vars": ["error", {"args": "none", "vars": "local"}],
}
}, {
// For all server files, prevent requiring devtools/client modules.
"files": [
"server/**",
],
"rules": {
"mozilla/reject-some-requires": ["error", "^devtools/client"],
}
}, {
// Cu, Cc etc... are not available in most devtools modules loaded by require.
"files": [