Curtail use of mw.mobileFrontend in Minerva

The MobileFrontend dependency in Minerva is problematic.
Code that Minerva needs should live in core.
MobileFrontend should load code on all skins when they operate on
a mobile domain.
This eslint check reminds developers of this in a hope it encourages
more upstreaming to core when possible.
Of course disabling is also an option, but this check will at least
make us aware of when we are moving further away from the goal.

Change-Id: I62183c9aefc81053e4ad81fb746decef2dd24b44
This commit is contained in:
jdlrobson 2019-09-27 11:53:01 -07:00 committed by Jdlrobson
parent d0be74ac0f
commit ef5003f310
23 changed files with 36 additions and 2 deletions

View file

@ -15,6 +15,10 @@
"rules": {
"no-restricted-properties": [
"error",
{
"property": "mobileFrontend",
"message": "Minerva should only make use of core code. Any code using mobileFrontend should be placed inside the MobileFrontend extension"
},
{
"property": "define",
"message": "The method `define` if used with mw.mobileFrontend is deprecated. Please use `module.exports`."

View file

@ -55,4 +55,5 @@
module.exports = BackToTopOverlay;
// eslint-disable-next-line no-restricted-properties
}( mw.mobileFrontend ) );

View file

@ -2,6 +2,7 @@ module.exports = function () {
var BackToTopOverlay = require( './BackToTopOverlay.js' ),
backtotop = new BackToTopOverlay(),
features = mw.config.get( 'wgMinervaFeatures', {} ),
// eslint-disable-next-line no-restricted-properties
M = mw.mobileFrontend,
mobile = M.require( 'mobile.startup' ),
browser = mobile.Browser.getSingleton(),

View file

@ -1,5 +1,6 @@
module.exports = function () {
var
// eslint-disable-next-line no-restricted-properties
M = mw.mobileFrontend,
mobile = M.require( 'mobile.startup' ),
loader = mobile.rlModuleLoader,

View file

@ -43,4 +43,6 @@
}
module.exports = shareIcon;
// eslint-disable-next-line no-restricted-properties
}( mw.mobileFrontend, mw.msg, mw.config ) );

View file

@ -4,7 +4,7 @@
* Given a test name, sampling rate, and session ID, provides a class that buckets a user into
* a predefined bucket ("unsampled", "control", or "treatment") and starts an AB-test.
*/
( function ( M, mwExperiments ) {
( function ( mwExperiments ) {
var bucket = {
UNSAMPLED: 'unsampled', // Old treatment: not sampled and not instrumented.
CONTROL: 'control', // Old treatment: sampled and instrumented.
@ -74,4 +74,5 @@
}
module.exports = AB;
}( mw.mobileFrontend, mw.experiments ) );
}( mw.experiments ) );

View file

@ -89,4 +89,6 @@
} );
module.exports = NotificationBadge;
// eslint-disable-next-line no-restricted-properties
}( mw.mobileFrontend ) );

View file

@ -104,4 +104,6 @@
bind: bind,
render: render
};
// eslint-disable-next-line no-restricted-properties
}( mw.mobileFrontend ) );

View file

@ -166,4 +166,6 @@
getOnClickHandler: getOnClickHandler
}
};
// eslint-disable-next-line no-restricted-properties
}( mw.mobileFrontend, mw.track, mw.msg ) );

View file

@ -63,6 +63,7 @@
} );
};
}(
// eslint-disable-next-line no-restricted-properties
mw.mobileFrontend,
mw.track,
mw.config,

View file

@ -373,4 +373,6 @@
require( './watchstar.js' )( mobile );
}
} );
// eslint-disable-next-line no-restricted-properties
}( mw.mobileFrontend ) );

View file

@ -116,4 +116,5 @@
module.exports = MainMenu;
// eslint-disable-next-line no-restricted-properties
}( mw.mobileFrontend ) );

View file

@ -4,6 +4,7 @@
*/
module.exports = function () {
var badge,
// eslint-disable-next-line no-restricted-properties
M = mw.mobileFrontend,
mainMenu = require( './menu.js' ),
router = require( 'mediawiki.router' ),

View file

@ -201,4 +201,5 @@
}
};
// eslint-disable-next-line no-restricted-properties
}( mw.mobileFrontend ) );

View file

@ -30,4 +30,6 @@
} );
module.exports = IssueList;
// eslint-disable-next-line no-restricted-properties
}( mw.mobileFrontend ) );

View file

@ -23,4 +23,6 @@
}
} );
module.exports = IssueNotice;
// eslint-disable-next-line no-restricted-properties
}( mw.mobileFrontend ) );

View file

@ -54,4 +54,6 @@
}
module.exports = pageIssuesOverlay;
// eslint-disable-next-line no-restricted-properties
}( mw.mobileFrontend, mw.msg ) );

View file

@ -227,4 +227,5 @@
}
};
// eslint-disable-next-line no-restricted-properties
}( mw.mobileFrontend ) );

View file

@ -6,6 +6,7 @@
* @singleton
*/
module.exports = function () {
// eslint-disable-next-line no-restricted-properties
var M = mw.mobileFrontend,
mobile = M.require( 'mobile.startup' ),
skin = mobile.Skin.getSingleton(),

View file

@ -1,4 +1,5 @@
module.exports = function () {
// eslint-disable-next-line no-restricted-properties
var M = mw.mobileFrontend,
mobile = M.require( 'mobile.startup' ),
references = mobile.references,

View file

@ -1,5 +1,6 @@
module.exports = function () {
var
// eslint-disable-next-line no-restricted-properties
M = mw.mobileFrontend,
mobile = M.require( 'mobile.startup' ),
SearchOverlay = mobile.search.SearchOverlay,

View file

@ -54,6 +54,7 @@ module.exports = function ( mobile ) {
* @return {Overlay}
*/
function talkSectionOverlay( id, talkOptions ) {
// eslint-disable-next-line no-restricted-properties
var M = mw.mobileFrontend;
if ( id === 'new' ) {
return new ( M.require( 'mobile.talk.overlays/TalkSectionAddOverlay' ) )( talkOptions );

View file

@ -4,6 +4,7 @@
"../../.eslintrc.json"
],
"rules": {
"no-restricted-properties": "off",
"no-jquery/no-parse-html-literal": "off"
}
}