build: Update eslint config and apply newer conventions

* Remove redundant closure passings.
* Enforce use of "$" (not 'jQuery').
* Enforce use of "mw" (not 'mediaWiki').
* Use blacklist instead of whitelist for ESLint config.
  This means ESLint is now enabled on test/, which was previously
  missing (by accident?).
* Add eslintrc for test/ as needed to disable two style rules
  currently violated.
* Fix violations of 'qunit/no-negated-ok'.

Bug: T208951
Change-Id: Ib995090804a98dda71b8574609e84561371c8c0c
这个提交包含在:
Timo Tijhof 2019-03-20 00:45:13 +00:00
父节点 5c3a8014c6
当前提交 44b7d9f9ed
共有 14 个文件被更改,包括 40 次插入29 次删除

1
.eslintignore 普通文件
查看文件

@ -0,0 +1 @@
vendor/**

查看文件

@ -2,11 +2,11 @@
"root": true,
"extends": "wikimedia",
"env": {
"browser": true,
"jquery": true
"browser": true
},
"globals": {
"mediaWiki": false,
"mw": false,
"$": false,
"OO": false
},
"rules": {

查看文件

@ -25,10 +25,7 @@ module.exports = function ( grunt ) {
]
},
eslint: {
all: [
'*.js',
'modules/**/*.js'
]
all: '.'
}
} );

查看文件

@ -1,4 +1,4 @@
( function ( mw, $ ) {
( function () {
var
hasOwnProperty = Object.prototype.hasOwnProperty,
@ -211,4 +211,4 @@
// Expose
mw.ForeignApi = CentralAuthForeignApi;
}( mediaWiki, jQuery ) );
}() );

查看文件

@ -1,4 +1,4 @@
( function ( mw ) {
( function () {
if ( mw.config.get( 'wgUserName' ) !== null ) {
try {
localStorage.removeItem( 'CentralAuthAnon' );
@ -7,4 +7,4 @@
document.cookie = 'CentralAuthAnon=0; expires=Thu, 01 Jan 1970 00:00:01 GMT; path=/';
}
}
}( mediaWiki ) );
}() );

查看文件

@ -1,4 +1,4 @@
( function ( mw ) {
( function () {
var url, params, len, param, i;
// Are we already logged in?
if ( mw.config.get( 'wgUserName' ) !== null ) {
@ -45,4 +45,4 @@
}
mw.loader.load( url );
}
}( mediaWiki ) );
}() );

查看文件

@ -1,4 +1,4 @@
( function ( mw, $ ) {
( function () {
'use strict';
$( function () {
// Confirm renames
@ -13,4 +13,4 @@
return confirm( mw.msg( 'centralauth-rename-deny' ) );
} );
} );
}( mediaWiki, jQuery ) );
}() );

查看文件

@ -1,4 +1,4 @@
( function ( mw, $ ) {
( function () {
$( function () {
// Confirm renames
mw.util.$content.find( 'form' ).first().on( 'submit', function () {
@ -14,4 +14,4 @@
} );
} );
}( mediaWiki, jQuery ) );
}() );

查看文件

@ -2,7 +2,7 @@
* Add autocomplete suggestions for names of global accounts.
* Lovingly stolen from core mediawiki.userSuggest
*/
( function ( mw, $ ) {
( function () {
var api, config;
config = {
@ -40,4 +40,4 @@
$( function () {
$( '.mw-autocomplete-global-user' ).suggestions( config );
} );
}( mediaWiki, jQuery ) );
}() );

查看文件

@ -1,4 +1,4 @@
( function ( mw, $ ) {
( function () {
var $methodHint;
function showMethodHint( methodName, e ) {
@ -64,4 +64,4 @@
return confirm( mw.msg( 'centralauth-admin-delete-confirm' ) );
} );
} );
}( mediaWiki, jQuery ) );
}() );

查看文件

@ -4,7 +4,7 @@
* @copyright 2011-2015 MediaWiki Widgets Team and others; see AUTHORS.txt
* @license The MIT License (MIT); see LICENSE.txt
*/
( function ( mw ) {
( function () {
/**
* Creates a mw.widgets.GlobalUserInputWidget object.
@ -117,4 +117,4 @@
return items;
};
}( mediaWiki ) );
}() );

查看文件

@ -1,4 +1,4 @@
( function ( mw, $ ) {
( function () {
mw.loader.using( 'mediawiki.Uri', function () {
var current, login;
@ -49,4 +49,4 @@
);
} );
} );
}( mediaWiki, jQuery ) );
}() );

13
tests/.eslintrc.json 普通文件
查看文件

@ -0,0 +1,13 @@
{
"extends": [
"../.eslintrc.json",
"wikimedia/qunit"
],
"env": {
"qunit": true
},
"rules": {
"vars-on-top": 0,
"one-var": 0
}
}

查看文件

@ -1,4 +1,4 @@
( function ( mw, $ ) {
( function () {
QUnit.module( 'ext.centralauth.ForeignApi', QUnit.newMwEnvironment( {
setup: function () {
this.server = this.sandbox.useFakeServer();
@ -21,7 +21,7 @@
var spy = this.sandbox.spy( api, 'getCentralAuthToken' );
return api.get( {} ).then( function () {
assert.ok( !spy.called, 'Anonymous users do not ask for centralauthtoken' );
assert.notOk( spy.called, 'Anonymous users do not ask for centralauthtoken' );
} );
} );
@ -65,8 +65,8 @@
);
return api.get( {} ).then( function () {
assert.ok( !spy.called, 'Called' );
assert.notOk( spy.called, 'Called' );
} );
} );
}( mediaWiki, jQuery ) );
}() );