From e7fd1ac847dfed73e6031667b984e9d20b8f706c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartosz=20Dziewo=C5=84ski?= Date: Tue, 30 Oct 2018 00:19:16 +0100 Subject: [PATCH] .eslintrc: Enable and fix "max-statements-per-line": 1 I am surprised this was disabled. I investigated this after reviewing some code by a new contributor which I was certain should have failed the lint check, but passed. Change-Id: I5b3c837b8ca3292f6e268b3922443bd9587eadbe --- .eslintrc.json | 1 + .../dm/nodes/ve.dm.MWLanguageVariantNode.js | 20 ++++++++++++++----- modules/ve-mw/tests/ce/ve.ce.Surface.test.js | 4 +++- modules/ve-mw/tests/ve.test.utils.js | 4 +++- .../ve.ui.MWLanguageVariantInspector.js | 6 ++++-- 5 files changed, 26 insertions(+), 9 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index f417d1f2e7..254af69a4f 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -16,6 +16,7 @@ }, "rules": { "dot-notation": [ "error", { "allowKeywords": true } ], + "max-statements-per-line": [ "error", { "max": 1 } ], "max-len": 0, "valid-jsdoc": 0 } diff --git a/modules/ve-mw/dm/nodes/ve.dm.MWLanguageVariantNode.js b/modules/ve-mw/dm/nodes/ve.dm.MWLanguageVariantNode.js index 911b6b8177..9fd640942c 100644 --- a/modules/ve-mw/dm/nodes/ve.dm.MWLanguageVariantNode.js +++ b/modules/ve-mw/dm/nodes/ve.dm.MWLanguageVariantNode.js @@ -359,10 +359,20 @@ ve.dm.MWLanguageVariantNode.prototype.getRuleType = function () { * @return {string} */ ve.dm.MWLanguageVariantNode.static.getRuleType = function ( variantInfo ) { - if ( variantInfo.disabled ) { return 'disabled'; } - if ( variantInfo.filter ) { return 'filter'; } - if ( variantInfo.name ) { return 'name'; } - if ( variantInfo.twoway ) { return 'twoway'; } - if ( variantInfo.oneway ) { return 'oneway'; } + if ( variantInfo.disabled ) { + return 'disabled'; + } + if ( variantInfo.filter ) { + return 'filter'; + } + if ( variantInfo.name ) { + return 'name'; + } + if ( variantInfo.twoway ) { + return 'twoway'; + } + if ( variantInfo.oneway ) { + return 'oneway'; + } return 'unknown'; // should never happen }; diff --git a/modules/ve-mw/tests/ce/ve.ce.Surface.test.js b/modules/ve-mw/tests/ce/ve.ce.Surface.test.js index 29e0f03300..ac47ace426 100644 --- a/modules/ve-mw/tests/ce/ve.ce.Surface.test.js +++ b/modules/ve-mw/tests/ce/ve.ce.Surface.test.js @@ -60,7 +60,9 @@ QUnit.test( 'handleLinearDelete', function ( assert ) { } ); } ); - promise.finally( function () { done(); } ); + promise.finally( function () { + done(); + } ); } ); QUnit.test( 'beforePaste/afterPaste', function ( assert ) { diff --git a/modules/ve-mw/tests/ve.test.utils.js b/modules/ve-mw/tests/ve.test.utils.js index 17533fd061..e846e70420 100644 --- a/modules/ve-mw/tests/ve.test.utils.js +++ b/modules/ve-mw/tests/ve.test.utils.js @@ -25,7 +25,9 @@ this.imageInfoCache = null; } OO.inheritClass( MWDummyPlatform, ve.init.mw.Platform ); - MWDummyPlatform.prototype.getMessage = function () { return Array.prototype.join.call( arguments, ',' ); }; + MWDummyPlatform.prototype.getMessage = function () { + return Array.prototype.join.call( arguments, ',' ); + }; MWDummyPlatform.prototype.getHtmlMessage = function () { var $wrapper = $( '
' ); Array.prototype.forEach.call( arguments, function ( arg, i, args ) { diff --git a/modules/ve-mw/ui/inspectors/ve.ui.MWLanguageVariantInspector.js b/modules/ve-mw/ui/inspectors/ve.ui.MWLanguageVariantInspector.js index 9a68ab7ca1..3b3c90acd9 100644 --- a/modules/ve-mw/ui/inspectors/ve.ui.MWLanguageVariantInspector.js +++ b/modules/ve-mw/ui/inspectors/ve.ui.MWLanguageVariantInspector.js @@ -595,7 +595,8 @@ ve.ui.MWLanguageVariantTwoWayInspector.prototype.getDefaultVariantInfo = functio ve.ui.MWLanguageVariantTwoWayInspector.prototype.getSetupProcess = function ( data ) { return ve.ui.MWLanguageVariantTwoWayInspector.super.prototype.getSetupProcess.call( this, data ).next( function () { var variantInfo = this.variantNode.getVariantInfo(); - this.layout.clearItems(); this.items = []; + this.layout.clearItems(); + this.items = []; variantInfo.twoway.forEach( function ( tw, idx ) { this.items[ idx ] = this.createItem( tw.l, tw.t ); this.layout.addItems( [ this.items[ idx ].layout ] ); @@ -745,7 +746,8 @@ ve.ui.MWLanguageVariantOneWayInspector.prototype.getDefaultVariantInfo = functio ve.ui.MWLanguageVariantOneWayInspector.prototype.getSetupProcess = function ( data ) { return ve.ui.MWLanguageVariantOneWayInspector.super.prototype.getSetupProcess.call( this, data ).next( function () { var variantInfo = this.variantNode.getVariantInfo(); - this.layout.clearItems(); this.items = []; + this.layout.clearItems(); + this.items = []; variantInfo.oneway.forEach( function ( ow, idx ) { this.items[ idx ] = this.createItem( ow.f, ow.l, ow.t ); this.layout.addItems( [ this.items[ idx ].layout ] );