mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Popups
synced 2024-11-27 17:00:37 +00:00
Hygiene: restrict use of $.each and fix offenders
Bug: T190142 Change-Id: I5da7a4a1ffe14647ec70b10b3a7ab9b935c5ca84
This commit is contained in:
parent
18f5c3d060
commit
3245a2ac6e
|
@ -18,6 +18,13 @@
|
|||
"ReduxThunk": false
|
||||
},
|
||||
"rules": {
|
||||
"no-restricted-properties": [2,
|
||||
{
|
||||
"object": "$",
|
||||
"property": "each",
|
||||
"message": "Please use Array.forEach"
|
||||
}
|
||||
],
|
||||
"dot-notation": [ 2, { "allowKeywords": true } ],
|
||||
"no-use-before-define": 0,
|
||||
"no-var": 2,
|
||||
|
|
BIN
resources/dist/index.js
vendored
BIN
resources/dist/index.js
vendored
Binary file not shown.
BIN
resources/dist/index.js.json
vendored
BIN
resources/dist/index.js.json
vendored
Binary file not shown.
|
@ -57,7 +57,7 @@ function makeTitleInExtractBold( extract, title ) {
|
|||
);
|
||||
extract = extract.split( snip );
|
||||
|
||||
$.each( extract, ( index, part ) => {
|
||||
extract.forEach( part => {
|
||||
if ( part.indexOf( boldIdentifier ) === 0 ) {
|
||||
elements.push( $( '<b>' )
|
||||
.text( part.substring( boldIdentifier.length ) ) );
|
||||
|
|
|
@ -562,7 +562,7 @@ export function layoutPreview(
|
|||
export function getClosestYPosition( y, rects, isTop ) {
|
||||
let minY = null, result;
|
||||
|
||||
$.each( rects, ( i, rect ) => {
|
||||
Array.prototype.slice.call( rects ).forEach( rect => {
|
||||
const deltaY = Math.abs( y - rect.top + y - rect.bottom );
|
||||
|
||||
if ( minY === null || minY > deltaY ) {
|
||||
|
|
|
@ -130,13 +130,13 @@ QUnit.test( 'MediaWiki API gateway is correctly extracting the page data from th
|
|||
|
||||
assert.expect( errorCases.length + successCases.length );
|
||||
|
||||
$.each( errorCases, ( _, data ) => {
|
||||
errorCases.forEach( data => {
|
||||
assert.throws( () => {
|
||||
gateway.extractPageFromResponse( data );
|
||||
} );
|
||||
} );
|
||||
|
||||
$.each( successCases, ( _, data ) => {
|
||||
successCases.forEach( data => {
|
||||
assert.deepEqual(
|
||||
gateway.extractPageFromResponse( data[ 0 ] ),
|
||||
data[ 1 ]
|
||||
|
|
Loading…
Reference in a new issue