瀏覽代碼

Merge branch 'eslint'

Code style: Switched to ESLint.
Piotrek Koszuliński 8 年之前
父節點
當前提交
416beb24f8
共有 41 個文件被更改,包括 158 次插入253 次删除
  1. 12 0
      packages/ckeditor5-ui/.eslintrc.js
  2. 0 89
      packages/ckeditor5-ui/.jscsrc
  3. 0 11
      packages/ckeditor5-ui/.jshintrc
  4. 6 5
      packages/ckeditor5-ui/gulpfile.js
  5. 2 1
      packages/ckeditor5-ui/package.json
  6. 1 1
      packages/ckeditor5-ui/src/componentfactory.js
  7. 3 1
      packages/ckeditor5-ui/src/dropdown/dropdownview.js
  8. 1 1
      packages/ckeditor5-ui/src/editableui/inline/inlineeditableuiview.js
  9. 4 4
      packages/ckeditor5-ui/src/focuscycler.js
  10. 3 1
      packages/ckeditor5-ui/src/inputtext/inputtextview.js
  11. 4 4
      packages/ckeditor5-ui/src/notification/notification.js
  12. 2 2
      packages/ckeditor5-ui/src/panel/balloon/balloonpanelview.js
  13. 23 18
      packages/ckeditor5-ui/src/template.js
  14. 1 1
      packages/ckeditor5-ui/src/toolbar/contextual/contextualtoolbar.js
  15. 3 3
      packages/ckeditor5-ui/src/toolbar/sticky/stickytoolbarview.js
  16. 2 2
      packages/ckeditor5-ui/src/view.js
  17. 7 6
      packages/ckeditor5-ui/src/viewcollection.js
  18. 0 22
      packages/ckeditor5-ui/tests/.jshintrc
  19. 2 3
      packages/ckeditor5-ui/tests/_utils/utils.js
  20. 6 6
      packages/ckeditor5-ui/tests/bindings/clickoutsidehandler.js
  21. 6 6
      packages/ckeditor5-ui/tests/bindings/escpresshandler.js
  22. 1 1
      packages/ckeditor5-ui/tests/bindings/submithandler.js
  23. 3 3
      packages/ckeditor5-ui/tests/dropdown/list/createlistdropdown.js
  24. 1 1
      packages/ckeditor5-ui/tests/dropdown/manual/dropdown.js
  25. 1 3
      packages/ckeditor5-ui/tests/editorui/boxed/boxededitoruiview.js
  26. 2 2
      packages/ckeditor5-ui/tests/focuscycler.js
  27. 1 1
      packages/ckeditor5-ui/tests/iframe/iframeview.js
  28. 1 1
      packages/ckeditor5-ui/tests/inputtext/inputtextview.js
  29. 1 1
      packages/ckeditor5-ui/tests/manual/contextualballoon/contextualballoon.js
  30. 1 1
      packages/ckeditor5-ui/tests/manual/tickets/126/1.js
  31. 4 4
      packages/ckeditor5-ui/tests/manual/tickets/198/1.js
  32. 1 1
      packages/ckeditor5-ui/tests/model.js
  33. 6 4
      packages/ckeditor5-ui/tests/panel/balloon/balloonpanelview.js
  34. 8 8
      packages/ckeditor5-ui/tests/panel/balloon/contextualballoon.js
  35. 12 9
      packages/ckeditor5-ui/tests/template.js
  36. 5 3
      packages/ckeditor5-ui/tests/toolbar/contextual/contextualtoolbar.js
  37. 5 5
      packages/ckeditor5-ui/tests/toolbar/enabletoolbarkeyboardfocus.js
  38. 1 2
      packages/ckeditor5-ui/tests/toolbar/toolbarseparatorview.js
  39. 1 1
      packages/ckeditor5-ui/tests/toolbar/toolbarview.js
  40. 3 3
      packages/ckeditor5-ui/tests/view.js
  41. 12 12
      packages/ckeditor5-ui/tests/viewcollection.js

+ 12 - 0
packages/ckeditor5-ui/.eslintrc.js

@@ -0,0 +1,12 @@
+/**
+ * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md.
+ */
+
+/* eslint-env node */
+
+'use strict';
+
+module.exports = {
+	extends: 'ckeditor5'
+};

+ 0 - 89
packages/ckeditor5-ui/.jscsrc

@@ -1,89 +0,0 @@
-{
-  "requireCurlyBraces": [
-    "if",
-    "else",
-    "for",
-    "while",
-    "do",
-    "switch",
-    "try",
-    "catch"
-  ],
-  "requireSpaceBeforeKeywords": true,
-  "requireSpaceAfterKeywords": [
-    "do",
-    "for",
-    "if",
-    "else",
-    "switch",
-    "case",
-    "try",
-    "catch",
-    "void",
-    "while",
-    "with",
-    "return",
-    "typeof"
-  ],
-  "requireSpaceBeforeBlockStatements": true,
-  "requireParenthesesAroundIIFE": true,
-  "requireSpacesInConditionalExpression": {
-    "afterTest": true,
-    "beforeConsequent": true,
-    "afterConsequent": true,
-    "beforeAlternate": true
-  },
-  "requireSpacesInFunction": {
-    "beforeOpeningCurlyBrace": true
-  },
-  "disallowSpacesInFunction": {
-    "beforeOpeningRoundBrace": true
-  },
-  "disallowSpacesInCallExpression": true,
-  "disallowMultipleVarDecl": "exceptUndefined",
-  "requireBlocksOnNewline": true,
-  "disallowPaddingNewlinesInBlocks": true,
-  "requirePaddingNewlinesBeforeKeywords": [
-    "do",
-    "for",
-    "if",
-    "switch",
-    "case",
-    "try",
-    "while",
-    "with",
-    "return"
-  ],
-  "requireSpacesInsideObjectBrackets": "all",
-  "requireSpacesInsideArrayBrackets": "all",
-  "requireSpacesInsideParentheses": "all",
-  "disallowSpaceAfterObjectKeys": true,
-  "requireSpaceBeforeObjectValues": true,
-  "requireCommaBeforeLineBreak": true,
-  "requireOperatorBeforeLineBreak": true,
-  "disallowSpaceAfterPrefixUnaryOperators": true,
-  "disallowSpaceBeforePostfixUnaryOperators": true,
-  "requireSpaceBeforeBinaryOperators": true,
-  "disallowImplicitTypeConversion": [
-    "numeric",
-    "binary",
-    "string"
-  ],
-  "requireCamelCaseOrUpperCaseIdentifiers": true,
-  "requireSpaceAfterBinaryOperators": true,
-  "disallowKeywords": [
-    "with"
-  ],
-  "disallowMultipleLineStrings": true,
-  "disallowMultipleLineBreaks": true,
-  "disallowMixedSpacesAndTabs": true,
-  "disallowTrailingWhitespace": true,
-  "maximumLineLength": 140,
-  "requireCapitalizedConstructors": true,
-  "requireDotNotation": true,
-  "disallowYodaConditions": true,
-  "disallowNewlineBeforeBlockStatements": true,
-  "validateLineBreaks": "LF",
-  "validateQuoteMarks": "'",
-  "validateIndentation": "\t"
-}

+ 0 - 11
packages/ckeditor5-ui/.jshintrc

@@ -1,11 +0,0 @@
-{
-  "esnext": true,
-  "immed": true,
-  "loopfunc": true,
-  "noarg": true,
-  "nonbsp": true,
-  "undef": true,
-  "unused": true,
-  "strict": "implied",
-  "varstmt": true
-}

+ 6 - 5
packages/ckeditor5-ui/gulpfile.js

@@ -3,19 +3,20 @@
  * For licensing, see LICENSE.md.
  */
 
-/* jshint browser: false, node: true, strict: true */
+/* eslint-env node */
 
 'use strict';
 
 const gulp = require( 'gulp' );
-const ckeditor5Lint = require( '@ckeditor/ckeditor5-dev-lint' )( {
+const ckeditor5Lint = require( '@ckeditor/ckeditor5-dev-lint' );
+const options = {
 	// Files ignored by `gulp lint` task.
 	// Files from .gitignore will be added automatically during task execution.
 	ignoredFiles: [
 		'src/lib/**'
 	]
-} );
+};
 
-gulp.task( 'lint', ckeditor5Lint.lint );
-gulp.task( 'lint-staged', ckeditor5Lint.lintStaged );
+gulp.task( 'lint', () => ckeditor5Lint.lint( options ) );
+gulp.task( 'lint-staged', () => ckeditor5Lint.lintStaged( options ) );
 gulp.task( 'pre-commit', [ 'lint-staged' ] );

+ 2 - 1
packages/ckeditor5-ui/package.json

@@ -12,7 +12,7 @@
   "devDependencies": {
     "@ckeditor/ckeditor5-basic-styles": "^0.8.1",
     "@ckeditor/ckeditor5-core": "^0.8.1",
-    "@ckeditor/ckeditor5-dev-lint": "^2.0.2",
+    "@ckeditor/ckeditor5-dev-lint": "^3.0.0",
     "@ckeditor/ckeditor5-editor-classic": "^0.7.3",
     "@ckeditor/ckeditor5-engine": "^0.10.0",
     "@ckeditor/ckeditor5-enter": "^0.9.1",
@@ -23,6 +23,7 @@
     "@ckeditor/ckeditor5-typing": "^0.9.1",
     "@ckeditor/ckeditor5-undo": "^0.8.1",
     "del": "^2.2.0",
+    "eslint-config-ckeditor5": "^1.0.0",
     "gulp": "^3.9.0",
     "guppy-pre-commit": "^0.4.0",
     "lodash-cli": "^4"

+ 1 - 1
packages/ckeditor5-ui/src/componentfactory.js

@@ -18,7 +18,7 @@ import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
  * The main use case for the component factory is the {@link module:core/editor/editorui~EditorUI#componentFactory} factory.
  */
 export default class ComponentFactory {
-	/**ś
+	/**
 	 * Creates ComponentFactory instance.
 	 *
 	 * @constructor

+ 3 - 1
packages/ckeditor5-ui/src/dropdown/dropdownview.js

@@ -92,7 +92,9 @@ export default class DropdownView extends View {
 		} );
 
 		// Toggle the the dropdown when it's button has been clicked.
-		this.listenTo( buttonView, 'execute', () => this.isOpen = !this.isOpen );
+		this.listenTo( buttonView, 'execute', () => {
+			this.isOpen = !this.isOpen;
+		} );
 
 		// Toggle the visibility of the panel when the dropdown becomes open.
 		panelView.bind( 'isVisible' ).to( this, 'isOpen' );

+ 1 - 1
packages/ckeditor5-ui/src/editableui/inline/inlineeditableuiview.js

@@ -38,7 +38,7 @@ export default class InlineEditableUIView extends EditableUIView {
 		 */
 		this.set( 'name', null );
 
-		const getLabel = ( value ) => {
+		const getLabel = value => {
 			return t( 'Rich Text Editor, %0', [ value ] );
 		};
 

+ 4 - 4
packages/ckeditor5-ui/src/focuscycler.js

@@ -101,14 +101,14 @@ export default class FocusCycler {
 		 */
 
 		if ( options.actions && options.keystrokeHandler ) {
-			for ( let methodName in options.actions ) {
+			for ( const methodName in options.actions ) {
 				let actions = options.actions[ methodName ];
 
 				if ( typeof actions == 'string' ) {
 					actions = [ actions ];
 				}
 
-				for ( let keystroke of actions ) {
+				for ( const keystroke of actions ) {
 					options.keystrokeHandler.set( keystroke, ( data, cancel ) => {
 						this[ methodName ]();
 						cancel();
@@ -241,7 +241,7 @@ export default class FocusCycler {
 	 */
 	_getFocusableItem( step ) {
 		// Cache for speed.
-		let current = this.current;
+		const current = this.current;
 		const collectionLength = this.focusables.length;
 
 		if ( !collectionLength ) {
@@ -258,7 +258,7 @@ export default class FocusCycler {
 		let index = ( current + collectionLength + step ) % collectionLength;
 
 		do {
-			let view = this.focusables.get( index );
+			const view = this.focusables.get( index );
 
 			// TODO: Check if view is visible.
 			if ( isFocusable( view ) ) {

+ 3 - 1
packages/ckeditor5-ui/src/inputtext/inputtextview.js

@@ -62,7 +62,9 @@ export default class InputTextView extends View {
 		} );
 
 		// Note: `value` cannot be an HTML attribute, because it doesn't change HTMLInputElement value once changed.
-		this.on( 'change:value', ( evt, propertyName, value ) => this.element.value = value || '' );
+		this.on( 'change:value', ( evt, propertyName, value ) => {
+			this.element.value = value || '';
+		} );
 	}
 
 	/**

+ 4 - 4
packages/ckeditor5-ui/src/notification/notification.js

@@ -37,7 +37,7 @@ export default class Notification extends Plugin {
 	init() {
 		// Each unhandled and not stopped `show:warning` event is displayed as system alert.
 		this.on( 'show:warning', ( evt, data ) => {
-			window.alert( data.message );
+			window.alert( data.message ); // eslint-disable-line no-alert
 		}, { priority: 'lowest' } );
 	}
 
@@ -59,7 +59,7 @@ export default class Notification extends Plugin {
 	 */
 	showSuccess( message, data = {} ) {
 		this._showNotification( {
-			message: message,
+			message,
 			type: 'success',
 			namespace: data.namespace
 		} );
@@ -83,7 +83,7 @@ export default class Notification extends Plugin {
 	 */
 	showInfo( message, data = {} ) {
 		this._showNotification( {
-			message: message,
+			message,
 			type: 'info',
 			namespace: data.namespace
 		} );
@@ -130,7 +130,7 @@ export default class Notification extends Plugin {
 	 */
 	showWarning( message, data = {} ) {
 		this._showNotification( {
-			message: message,
+			message,
 			type: 'warning',
 			namespace: data.namespace
 		} );

+ 2 - 2
packages/ckeditor5-ui/src/panel/balloon/balloonpanelview.js

@@ -118,7 +118,7 @@ export default class BalloonPanelView extends View {
 			attributes: {
 				class: [
 					'ck-balloon-panel',
-					bind.to( 'position', ( value ) => `ck-balloon-panel_${ value }` ),
+					bind.to( 'position', value => `ck-balloon-panel_${ value }` ),
 					bind.if( 'isVisible', 'ck-balloon-panel_visible' ),
 					bind.if( 'withArrow', 'ck-balloon-panel_with-arrow' ),
 					bind.to( 'className' )
@@ -425,7 +425,7 @@ BalloonPanelView.arrowVerticalOffset = 15;
  * @member {Object} module:ui/panel/balloon/balloonpanelview~BalloonPanelView.defaultPositions
  */
 BalloonPanelView.defaultPositions = {
-	southEastArrowNorthEast: ( targetRect ) => ( {
+	southEastArrowNorthEast: targetRect => ( {
 		top: targetRect.bottom + BalloonPanelView.arrowVerticalOffset,
 		left: targetRect.left + targetRect.width / 2 - BalloonPanelView.arrowHorizontalOffset,
 		name: 'arrow_ne'

+ 23 - 18
packages/ckeditor5-ui/src/template.js

@@ -171,7 +171,7 @@ export default class Template {
 		this._revertData = getEmptyRevertData();
 
 		this._renderNode( {
-			node: node,
+			node,
 			isApplying: true,
 			revertData: this._revertData
 		} );
@@ -324,7 +324,9 @@ export default class Template {
 			 *
 			 * @error ui-template-wrong-syntax
 			 */
-			throw new CKEditorError( 'ui-template-wrong-syntax: Node definition must have either "tag" or "text" when rendering new Node.' );
+			throw new CKEditorError(
+				'ui-template-wrong-syntax: Node definition must have either "tag" or "text" when rendering new Node.'
+			);
 		}
 
 		if ( this.text ) {
@@ -560,7 +562,7 @@ export default class Template {
 	_renderStyleAttribute( styles, data ) {
 		const node = data.node;
 
-		for ( let styleName in styles ) {
+		for ( const styleName in styles ) {
 			const styleValue = styles[ styleName ];
 
 			// Cases:
@@ -601,12 +603,12 @@ export default class Template {
 		const isApplying = data.isApplying;
 		let childIndex = 0;
 
-		for ( let child of this.children ) {
+		for ( const child of this.children ) {
 			if ( isViewCollection( child ) ) {
 				if ( !isApplying ) {
 					child.setParent( node );
 
-					for ( let view of child ) {
+					for ( const view of child ) {
 						container.appendChild( view.element );
 					}
 				}
@@ -649,7 +651,7 @@ export default class Template {
 			return;
 		}
 
-		for ( let key in this.eventListeners ) {
+		for ( const key in this.eventListeners ) {
 			const revertBindings = this.eventListeners[ key ].map( schemaItem => {
 				const [ domEvtName, domSelector ] = key.split( '@' );
 
@@ -705,7 +707,7 @@ export default class Template {
 	 * what changes have been made by {@link #apply} to the node.
 	 */
 	_revertTemplateFromNode( node, revertData ) {
-		for ( let binding of revertData.bindings ) {
+		for ( const binding of revertData.bindings ) {
 			// Each binding may consist of several observable+observable#attribute.
 			// like the following has 2:
 			//
@@ -716,7 +718,7 @@ export default class Template {
 			//			bind.to( 'bar' )
 			//		]
 			//
-			for ( let revertBinding of binding ) {
+			for ( const revertBinding of binding ) {
 				revertBinding();
 			}
 		}
@@ -727,7 +729,7 @@ export default class Template {
 			return;
 		}
 
-		for ( let attrName in revertData.attributes ) {
+		for ( const attrName in revertData.attributes ) {
 			const attrValue = revertData.attributes[ attrName ];
 
 			// When the attribute has **not** been set before #apply().
@@ -795,7 +797,8 @@ export class TemplateBinding {
 	 * {@link module:ui/template~TemplateBinding#observable}.
 	 *
 	 * @param {Node} [node] A native DOM node, passed to the custom {@link module:ui/template~TemplateBinding#callback}.
-	 * @returns {*} The value of {@link module:ui/template~TemplateBinding#attribute} in {@link module:ui/template~TemplateBinding#observable}.
+	 * @returns {*} The value of {@link module:ui/template~TemplateBinding#attribute} in
+	 * {@link module:ui/template~TemplateBinding#observable}.
 	 */
 	getValue( node ) {
 		const value = this.observable[ this.attribute ];
@@ -1084,7 +1087,7 @@ function normalize( def ) {
 			if ( isViewCollection( def.children ) ) {
 				children.add( def.children );
 			} else {
-				for ( let child of def.children ) {
+				for ( const child of def.children ) {
 					if ( isTemplate( child ) || isView( child ) ) {
 						children.add( child );
 					} else {
@@ -1122,7 +1125,7 @@ function normalize( def ) {
 //
 // @param {Object} attrs
 function normalizeAttributes( attrs ) {
-	for ( let a in attrs ) {
+	for ( const a in attrs ) {
 		if ( attrs[ a ].value ) {
 			attrs[ a ].value = [].concat( attrs[ a ].value );
 		}
@@ -1150,7 +1153,7 @@ function normalizeAttributes( attrs ) {
 // @param {Object} listeners
 // @returns {Object} Object containing normalized listeners.
 function normalizeListeners( listeners ) {
-	for ( let l in listeners ) {
+	for ( const l in listeners ) {
 		arrayify( listeners, l );
 	}
 
@@ -1225,10 +1228,10 @@ function arrayify( obj, key ) {
 function arrayValueReducer( prev, cur ) {
 	if ( isFalsy( cur ) ) {
 		return prev;
-	} else if ( isFalsy( prev ) )  {
+	} else if ( isFalsy( prev ) ) {
 		return cur;
 	} else {
-		return `${prev} ${cur}`;
+		return `${ prev } ${ cur }`;
 	}
 }
 
@@ -1247,7 +1250,7 @@ function arrayValueReducer( prev, cur ) {
 // @param {Object} ext Object extending base.
 // @returns {String}
 function extendObjectValueArray( obj, ext ) {
-	for ( let a in ext ) {
+	for ( const a in ext ) {
 		if ( obj[ a ] ) {
 			obj[ a ].push( ...ext[ a ] );
 		} else {
@@ -1289,12 +1292,14 @@ function extendTemplate( template, def ) {
 			 *
 			 * @error ui-template-extend-children-mismatch
 			 */
-			throw new CKEditorError( 'ui-template-extend-children-mismatch: The number of children in extended definition does not match.' );
+			throw new CKEditorError(
+				'ui-template-extend-children-mismatch: The number of children in extended definition does not match.'
+			);
 		}
 
 		let childIndex = 0;
 
-		for ( let childDef of def.children ) {
+		for ( const childDef of def.children ) {
 			extendTemplate( template.children.get( childIndex++ ), childDef );
 		}
 	}

+ 1 - 1
packages/ckeditor5-ui/src/toolbar/contextual/contextualtoolbar.js

@@ -157,7 +157,7 @@ export default class ContextualToolbar extends Plugin {
 			return Promise.resolve();
 		}
 
-		const showPromise = new Promise( ( resolve ) => {
+		const showPromise = new Promise( resolve => {
 			// If `beforeShow` event is not stopped by any external code then panel will be displayed.
 			this.once( 'beforeShow', () => {
 				if ( isStopped ) {

+ 3 - 3
packages/ckeditor5-ui/src/toolbar/sticky/stickytoolbarview.js

@@ -116,11 +116,11 @@ export default class StickyToolbarView extends ToolbarView {
 					bind.if( '_isStickyToTheLimiter', 'ck-toolbar_sticky_bottom-limit' ),
 				],
 				style: {
-					width: bind.to( 'isSticky', ( isSticky ) => {
+					width: bind.to( 'isSticky', isSticky => {
 						return isSticky ? toPx( this._elementPlaceholder.getBoundingClientRect().width ) : null;
 					} ),
 
-					bottom: bind.to( '_isStickyToTheLimiter', ( _isStickyToTheLimiter ) => {
+					bottom: bind.to( '_isStickyToTheLimiter', _isStickyToTheLimiter => {
 						return _isStickyToTheLimiter ? toPx( this.limiterOffset ) : null;
 					} ),
 
@@ -144,7 +144,7 @@ export default class StickyToolbarView extends ToolbarView {
 				],
 				style: {
 					display: bind.to( 'isSticky', isSticky => isSticky ? 'block' : 'none' ),
-					height: bind.to( 'isSticky', ( isSticky ) => {
+					height: bind.to( 'isSticky', isSticky => {
 						return isSticky ? toPx( this._toolbarRect.height ) : null;
 					} )
 				}

+ 2 - 2
packages/ckeditor5-ui/src/view.js

@@ -330,9 +330,9 @@ export default class View {
 	 * @protected
 	 */
 	_addTemplateChildren() {
-		const search = ( def ) => {
+		const search = def => {
 			if ( def.children ) {
-				for ( let defOrView of def.children ) {
+				for ( const defOrView of def.children ) {
 					if ( defOrView instanceof View ) {
 						this.addChildren( defOrView );
 					} else {

+ 7 - 6
packages/ckeditor5-ui/src/viewcollection.js

@@ -202,26 +202,27 @@ export default class ViewCollection extends Collection {
 			 *
 			 * @memberOf module:ui/viewcollection~ViewCollection#delegate
 			 * @function module:ui/viewcollection~ViewCollection#delegate.to
-			 * @param {module:utils/emittermixin~EmitterMixin} dest An `EmitterMixin` instance which is the destination for delegated events.
+			 * @param {module:utils/emittermixin~EmitterMixin} dest An `EmitterMixin` instance which is
+			 * the destination for delegated events.
 			 */
-			to: ( dest ) => {
+			to: dest => {
 				// Activate delegating on existing views in this collection.
-				for ( let view of this ) {
-					for ( let evtName of events ) {
+				for ( const view of this ) {
+					for ( const evtName of events ) {
 						view.delegate( evtName ).to( dest );
 					}
 				}
 
 				// Activate delegating on future views in this collection.
 				this.on( 'add', ( evt, view ) => {
-					for ( let evtName of events ) {
+					for ( const evtName of events ) {
 						view.delegate( evtName ).to( dest );
 					}
 				} );
 
 				// Deactivate delegating when view is removed from this collection.
 				this.on( 'remove', ( evt, view ) => {
-					for ( let evtName of events ) {
+					for ( const evtName of events ) {
 						view.stopDelegating( evtName, dest );
 					}
 				} );

+ 0 - 22
packages/ckeditor5-ui/tests/.jshintrc

@@ -1,22 +0,0 @@
-{
-  "esnext": true,
-  "expr": true,
-  "immed": true,
-  "loopfunc": true,
-  "noarg": true,
-  "nonbsp": true,
-  "strict": "implied",
-  "undef": true,
-  "unused": true,
-  "varstmt": true,
-  "globals": {
-    "after": false,
-    "afterEach": false,
-    "before": false,
-    "beforeEach": false,
-    "describe": false,
-    "expect": false,
-    "it": false,
-    "sinon": false
-  }
-}

+ 2 - 3
packages/ckeditor5-ui/tests/_utils/utils.js

@@ -35,14 +35,13 @@ const utils = {
 
 				this.element = document.body;
 
-				for ( let name in regions ) {
+				for ( const name in regions ) {
 					const regionCollection = this[ name ] = this.createCollection();
 					const callbackOrSelector = regions[ name ];
 
 					regionCollection.setParent(
 						typeof callbackOrSelector == 'string' ?
-								document.querySelector( callbackOrSelector )
-							:
+								document.querySelector( callbackOrSelector )							:
 								callbackOrSelector( this.element )
 					);
 				}

+ 6 - 6
packages/ckeditor5-ui/tests/bindings/clickoutsidehandler.js

@@ -25,8 +25,8 @@ describe( 'clickOutsideHandler', () => {
 
 		clickOutsideHandler( {
 			emitter: Object.create( DomEmitterMixin ),
-			activator: activator,
-			contextElement: contextElement,
+			activator,
+			contextElement,
 			callback: actionSpy
 		} );
 	} );
@@ -74,8 +74,8 @@ describe( 'clickOutsideHandler', () => {
 
 		clickOutsideHandler( {
 			emitter: Object.create( DomEmitterMixin ),
-			activator: activator,
-			contextElement: contextElement,
+			activator,
+			contextElement,
 			callback: spy
 		} );
 
@@ -91,8 +91,8 @@ describe( 'clickOutsideHandler', () => {
 
 		clickOutsideHandler( {
 			emitter: Object.create( DomEmitterMixin ),
-			activator: activator,
-			contextElement: contextElement,
+			activator,
+			contextElement,
 			callback: spy
 		} );
 

+ 6 - 6
packages/ckeditor5-ui/tests/bindings/escpresshandler.js

@@ -23,8 +23,8 @@ describe( 'escPressHandler', () => {
 		emitter = Object.create( DomEmitterMixin );
 
 		escPressHandler( {
-			emitter: emitter,
-			activator: activator,
+			emitter,
+			activator,
 			callback: actionSpy
 		} );
 	} );
@@ -73,8 +73,8 @@ describe( 'escPressHandler', () => {
 		emitter = Object.create( DomEmitterMixin );
 
 		escPressHandler( {
-			emitter: emitter,
-			activator: activator,
+			emitter,
+			activator,
 			callback: spy
 		} );
 
@@ -91,8 +91,8 @@ describe( 'escPressHandler', () => {
 		emitter = Object.create( DomEmitterMixin );
 
 		escPressHandler( {
-			emitter: emitter,
-			activator: activator,
+			emitter,
+			activator,
 			callback: spy
 		} );
 

+ 1 - 1
packages/ckeditor5-ui/tests/bindings/submithandler.js

@@ -25,7 +25,7 @@ describe( 'submitHandler', () => {
 		submitHandler( { view } );
 	} );
 
-	it( 'should fire #submit event on the view and prevent the native DOM #submit', ( done ) => {
+	it( 'should fire #submit event on the view and prevent the native DOM #submit', done => {
 		const evt = new Event( 'submit' );
 		const spy = sinon.spy( evt, 'preventDefault' );
 

+ 3 - 3
packages/ckeditor5-ui/tests/dropdown/list/createlistdropdown.js

@@ -20,7 +20,7 @@ describe( 'createListDropdown', () => {
 		items = new Collection();
 		model = new Model( {
 			isEnabled: true,
-			items: items,
+			items,
 			isOn: false,
 			label: 'foo'
 		} );
@@ -73,10 +73,10 @@ describe( 'createListDropdown', () => {
 				expect( item.baz ).to.equal( 'foo?' );
 			} );
 
-			it( 'delegates view.listView#execute to the view', ( done ) => {
+			it( 'delegates view.listView#execute to the view', done => {
 				items.add( new Model( { label: 'a', style: 'b' } ) );
 
-				view.on( 'execute', ( evt ) => {
+				view.on( 'execute', evt => {
 					expect( evt.source ).to.equal( view.listView.items.get( 0 ) );
 					expect( evt.path ).to.deep.equal( [ view.listView.items.get( 0 ), view ] );
 

+ 1 - 1
packages/ckeditor5-ui/tests/dropdown/manual/dropdown.js

@@ -52,7 +52,7 @@ function testList() {
 
 	const dropdownView = createListDropdown( model );
 
-	dropdownView.on( 'execute', ( evt ) => {
+	dropdownView.on( 'execute', evt => {
 		/* global console */
 		console.log( 'List#execute:', evt.source.label );
 	} );

+ 1 - 3
packages/ckeditor5-ui/tests/editorui/boxed/boxededitoruiview.js

@@ -3,16 +3,14 @@
  * For licensing, see LICENSE.md.
  */
 
-import Editor from '@ckeditor/ckeditor5-core/src/editor/editor';
 import BoxedEditorUIView from '../../../src/editorui/boxed/boxededitoruiview';
 import Locale from '@ckeditor/ckeditor5-utils/src/locale';
 import ViewCollection from '../../../src/viewcollection';
 
 describe( 'BoxedEditorUIView', () => {
-	let view, element, editor;
+	let view, element;
 
 	beforeEach( () => {
-		editor = new Editor();
 		view = new BoxedEditorUIView( new Locale( 'en' ) );
 		element = view.element;
 

+ 2 - 2
packages/ckeditor5-ui/tests/focuscycler.js

@@ -22,8 +22,8 @@ describe( 'FocusCycler', () => {
 			focusedElement: null
 		};
 		cycler = new FocusCycler( {
-			focusables: focusables,
-			focusTracker: focusTracker
+			focusables,
+			focusTracker
 		} );
 
 		testUtils.sinon.stub( global.window, 'getComputedStyle' );

+ 1 - 1
packages/ckeditor5-ui/tests/iframe/iframeview.js

@@ -42,7 +42,7 @@ describe( 'IframeView', () => {
 	} );
 
 	describe( 'loaded event', () => {
-		it( 'is fired when frame finished loading', ( done ) => {
+		it( 'is fired when frame finished loading', done => {
 			view = new IframeView();
 
 			view.on( 'loaded', () => done() );

+ 1 - 1
packages/ckeditor5-ui/tests/inputtext/inputtextview.js

@@ -39,7 +39,7 @@ describe( 'InputTextView', () => {
 			} );
 
 			it( 'should set to empty string when using `falsy` values', () => {
-				[ undefined, false, null ].forEach( ( value ) => {
+				[ undefined, false, null ].forEach( value => {
 					view.value = value;
 
 					expect( view.element.value ).to.equal( '' );

+ 1 - 1
packages/ckeditor5-ui/tests/manual/contextualballoon/contextualballoon.js

@@ -124,7 +124,7 @@ class PluginGeneric extends Plugin {
 			cancel();
 		} );
 
-		this.editor.ui.componentFactory.add( this.label, ( locale ) => {
+		this.editor.ui.componentFactory.add( this.label, locale => {
 			const button = new ButtonView( locale );
 
 			button.label = this.label;

+ 1 - 1
packages/ckeditor5-ui/tests/manual/tickets/126/1.js

@@ -9,7 +9,7 @@ import BalloonPanelView from '../../../../src/panel/balloon/balloonpanelview';
 
 import '@ckeditor/ckeditor5-theme-lark/theme/theme.scss';
 
-window.createPanel = ( selector ) => {
+window.createPanel = selector => {
 	const view = new BalloonPanelView();
 
 	view.element.innerHTML = `Parent of this panel has position:${ selector }.`;

+ 4 - 4
packages/ckeditor5-ui/tests/manual/tickets/198/1.js

@@ -47,7 +47,7 @@ ClassicEditor.create( document.querySelector( '#editor-delete' ), {
 .catch( err => console.error( err.stack ) );
 
 function wait( delay ) {
-	return new Promise( ( resolve ) => {
+	return new Promise( resolve => {
 		setTimeout( () => resolve(), delay );
 	} );
 }
@@ -57,7 +57,7 @@ function startExternalInsert( editor ) {
 	const bath = document.batch( 'transparent' );
 
 	function type( path, text ) {
-		return new Promise( ( resolve ) => {
+		return new Promise( resolve => {
 			let position = new Position( document.getRoot(), path );
 			let index = 0;
 
@@ -67,7 +67,7 @@ function startExternalInsert( editor ) {
 						bath.insert( position, new Text( text[ index ] ) );
 						position = position.getShiftedBy( 1 );
 
-						let nextLetter = text[ ++index ];
+						const nextLetter = text[ ++index ];
 
 						if ( nextLetter ) {
 							typing( nextLetter );
@@ -94,7 +94,7 @@ function startExternalInsert( editor ) {
 	}
 
 	wait( 3000 )
-		.then( () => type( [ 0, 36 ], `This specification defines the 5th major revision of the core language of the World Wide Web. ` ) )
+		.then( () => type( [ 0, 36 ], 'This specification defines the 5th major revision of the core language of the World Wide Web. ' ) )
 		.then( () => insertNewLine( [ 0 ] ) )
 		.then( () => type( [ 0, 0 ], 'a' ) )
 		.then( () => insertNewLine( [ 1 ] ) )

+ 1 - 1
packages/ckeditor5-ui/tests/model.js

@@ -30,7 +30,7 @@ describe( 'Model', () => {
 	} );
 
 	it( 'should add properties on creation', () => {
-		let car = new Car( null, {
+		const car = new Car( null, {
 			prop: 1
 		} );
 

+ 6 - 4
packages/ckeditor5-ui/tests/panel/balloon/balloonpanelview.js

@@ -171,7 +171,7 @@ describe( 'BalloonPanelView', () => {
 				innerHeight: 500,
 				scrollX: 0,
 				scrollY: 0,
-				getComputedStyle: ( el ) => {
+				getComputedStyle: el => {
 					return window.getComputedStyle( el );
 				}
 			};
@@ -186,7 +186,7 @@ describe( 'BalloonPanelView', () => {
 
 			sinon.assert.calledWithExactly( spy, sinon.match( {
 				element: view.element,
-				target: target,
+				target,
 				positions: [
 					BalloonPanelView.defaultPositions.southEastArrowNorthEast,
 					BalloonPanelView.defaultPositions.southWestArrowNorthEast,
@@ -223,7 +223,8 @@ describe( 'BalloonPanelView', () => {
 				expect( view.position ).to.equal( 'arrow_ne' );
 			} );
 
-			it( 'should put balloon on the `south east` side of the target element when target is on the top left side of the limiter', () => {
+			it( 'should put balloon on the `south east` side of the target element when ' +
+				'target is on the top left side of the limiter', () => {
 				mockBoundingBox( target, {
 					top: 0,
 					left: 0,
@@ -262,7 +263,8 @@ describe( 'BalloonPanelView', () => {
 				expect( view.position ).to.equal( 'arrow_se' );
 			} );
 
-			it( 'should put balloon on the `north west` side of the target element when target is on the bottom right of the limiter', () => {
+			it( 'should put balloon on the `north west` side of the target element when ' +
+				'target is on the bottom right of the limiter', () => {
 				mockBoundingBox( target, {
 					top: 450,
 					left: 450,

+ 8 - 8
packages/ckeditor5-ui/tests/panel/balloon/contextualballoon.js

@@ -104,12 +104,12 @@ describe( 'ContextualBalloon', () => {
 	} );
 
 	describe( 'add()', () => {
-		it( 'should return promise resolved when view is ready', ( done ) => {
+		it( 'should return promise resolved when view is ready', done => {
 			const clock = sinon.useFakeTimers();
 
 			const view = {
 				init: () => {
-					return new Promise( ( resolve ) => {
+					return new Promise( resolve => {
 						setTimeout( () => {
 							resolve();
 						}, 10 );
@@ -119,7 +119,7 @@ describe( 'ContextualBalloon', () => {
 			};
 
 			const result = balloon.add( {
-				view: view,
+				view,
 				position: { target: 'fake' }
 			} );
 
@@ -183,7 +183,7 @@ describe( 'ContextualBalloon', () => {
 			const view = new View();
 
 			balloon.add( {
-				view: view,
+				view,
 				position: { target: 'fake' },
 				balloonClassName: 'foo'
 			} );
@@ -245,12 +245,12 @@ describe( 'ContextualBalloon', () => {
 			expect( balloon.visibleView ).to.equal( viewA );
 		} );
 
-		it( 'should wait for init of preceding view when was is not ready', ( done ) => {
+		it( 'should wait for init of preceding view when was is not ready', done => {
 			const clock = sinon.useFakeTimers();
 
 			const view = {
 				init: () => {
-					return new Promise( ( resolve ) => {
+					return new Promise( resolve => {
 						setTimeout( () => {
 							resolve();
 						}, 10 );
@@ -260,7 +260,7 @@ describe( 'ContextualBalloon', () => {
 			};
 
 			balloon.add( {
-				view: view,
+				view,
 				position: { target: 'fake' }
 			} );
 
@@ -296,7 +296,7 @@ describe( 'ContextualBalloon', () => {
 			const view = new View();
 
 			balloon.add( {
-				view: view,
+				view,
 				position: { target: 'fake' },
 				balloonClassName: 'foo'
 			} );

+ 12 - 9
packages/ckeditor5-ui/tests/template.js

@@ -6,8 +6,7 @@
 /* globals HTMLElement, Event, document */
 
 import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils';
-import Template from '../src/template';
-import { TemplateToBinding, TemplateIfBinding } from '../src/template';
+import { default as Template, TemplateToBinding, TemplateIfBinding } from '../src/template';
 import View from '../src/view';
 import ViewCollection from '../src/viewcollection';
 import Model from '../src/model';
@@ -323,12 +322,14 @@ describe( 'Template', () => {
 							}
 						} );
 
-						expect( normalizeHtml( el.outerHTML ) ).to.equal( '<p style="width:10px;height:10px;background-color:yellow;"></p>' );
+						expect( normalizeHtml( el.outerHTML ) )
+							.to.equal( '<p style="width:10px;height:10px;background-color:yellow;"></p>' );
 
 						observable.width = '20px';
 						observable.backgroundColor = 'green';
 
-						expect( normalizeHtml( el.outerHTML ) ).to.equal( '<p style="width:20px;height:10px;background-color:green;"></p>' );
+						expect( normalizeHtml( el.outerHTML ) )
+							.to.equal( '<p style="width:20px;height:10px;background-color:green;"></p>' );
 					} );
 
 					it( 'renders with empty string attributes', () => {
@@ -811,7 +812,8 @@ describe( 'Template', () => {
 						}
 					} ).apply( el );
 
-					expect( normalizeHtml( el.outerHTML ) ).to.equal( '<p style="width:20px;height:10px;float:left;background-color:green;"></p>' );
+					expect( normalizeHtml( el.outerHTML ) )
+						.to.equal( '<p style="width:20px;height:10px;float:left;background-color:green;"></p>' );
 				} );
 
 				it( 'applies when bound to observable', () => {
@@ -1783,7 +1785,7 @@ describe( 'Template', () => {
 								'ck-class',
 								bind.to( 'foo' ),
 								bind.to( 'baz' ),
-								bind.to( 'foo', value => `foo-is-${value}` ),
+								bind.to( 'foo', value => `foo-is-${ value }` ),
 								'ck-end'
 							]
 						},
@@ -1810,7 +1812,7 @@ describe( 'Template', () => {
 									'ck-class',
 									bind.to( 'foo' ),
 									bind.to( 'baz' ),
-									bind.to( 'foo', value => `foo-is-${value}` ),
+									bind.to( 'foo', value => `foo-is-${ value }` ),
 									'ck-end'
 								]
 							}
@@ -1839,7 +1841,8 @@ describe( 'Template', () => {
 					} );
 
 					observable.foo = 'bar';
-					expect( normalizeHtml( el.outerHTML ) ).to.equal( '<p complex="bar" emptystring="bar" simple="bar" zero="0 bar">abc</p>' );
+					expect( normalizeHtml( el.outerHTML ) )
+						.to.equal( '<p complex="bar" emptystring="bar" simple="bar" zero="0 bar">abc</p>' );
 
 					observable.foo = 0;
 					expect( normalizeHtml( el.outerHTML ) ).to.equal( '<p complex="0" emptystring="0" simple="0" zero="0 0">abc</p>' );
@@ -2023,7 +2026,7 @@ describe( 'Template', () => {
 							'class': [
 								'ck-class',
 								bind.if( 'foo', 'foo-set' ),
-								bind.if( 'bar', 'bar-not-set', ( value ) => !value ),
+								bind.if( 'bar', 'bar-not-set', value => !value ),
 								'ck-end'
 							]
 						},

+ 5 - 3
packages/ckeditor5-ui/tests/toolbar/contextual/contextualtoolbar.js

@@ -69,7 +69,7 @@ describe( 'ContextualToolbar', () => {
 		expect( contextualToolbar.toolbarView.items ).to.length( 2 );
 	} );
 
-	it( 'should fire internal `_selectionChangeDebounced` event 200 ms after last selection change', ( done ) => {
+	it( 'should fire internal `_selectionChangeDebounced` event 200 ms after last selection change', done => {
 		// This test uses setTimeout to test lodash#debounce because sinon fake timers
 		// doesn't work with lodash. Lodash keeps time related stuff in a closure
 		// and sinon is not able to override it.
@@ -274,7 +274,7 @@ describe( 'ContextualToolbar', () => {
 	} );
 
 	describe( 'destroy()', () => {
-		it( 'should not fire `_selectionChangeDebounced` after plugin destroy', ( done ) => {
+		it( 'should not fire `_selectionChangeDebounced` after plugin destroy', done => {
 			const spy = sandbox.spy();
 
 			contextualToolbar.on( '_selectionChangeDebounced', spy );
@@ -430,7 +430,9 @@ describe( 'ContextualToolbar', () => {
 			sandbox.stub( domRange, 'getClientRects', () => {
 				return {
 					length: 2,
-					item: id => id === 0 ? forwardSelectionRect : backwardSelectionRect
+					item( id ) {
+						return id === 0 ? forwardSelectionRect : backwardSelectionRect;
+					}
 				};
 			} );
 

+ 5 - 5
packages/ckeditor5-ui/tests/toolbar/enabletoolbarkeyboardfocus.js

@@ -22,10 +22,10 @@ describe( 'enableToolbarKeyboardFocus()', () => {
 		toolbar = new ToolbarView();
 
 		enableToolbarKeyboardFocus( {
-			origin: origin,
-			originFocusTracker: originFocusTracker,
-			originKeystrokeHandler: originKeystrokeHandler,
-			toolbar: toolbar
+			origin,
+			originFocusTracker,
+			originKeystrokeHandler,
+			toolbar
 		} );
 
 		return toolbar.init();
@@ -87,7 +87,7 @@ describe( 'enableToolbarKeyboardFocus()', () => {
 } );
 
 function viewCreator( name ) {
-	return ( locale ) => {
+	return locale => {
 		const view = new View( locale );
 
 		view.name = name;

+ 1 - 2
packages/ckeditor5-ui/tests/toolbar/toolbarseparatorview.js

@@ -6,10 +6,9 @@
 import ToolbarSeparatorView from '../../src/toolbar/toolbarseparatorview';
 
 describe( 'ToolbarSeparatorView', () => {
-	let locale, view;
+	let view;
 
 	beforeEach( () => {
-		locale = {};
 		view = new ToolbarSeparatorView();
 
 		return view.init();

+ 1 - 1
packages/ckeditor5-ui/tests/toolbar/toolbarview.js

@@ -267,7 +267,7 @@ function nonFocusable() {
 }
 
 function namedFactory( name ) {
-	return ( locale ) => {
+	return locale => {
 		const view = new View( locale );
 
 		view.name = name;

+ 3 - 3
packages/ckeditor5-ui/tests/view.js

@@ -141,7 +141,7 @@ describe( 'View', () => {
 
 					throw new Error( 'This should not be executed.' );
 				} )
-				.catch( ( err ) => {
+				.catch( err => {
 					expect( err ).to.be.instanceof( CKEditorError );
 					expect( err.message ).to.match( /ui-view-init-re/ );
 				} );
@@ -348,8 +348,8 @@ describe( 'View', () => {
 
 				init() {
 					return new Promise( resolve => {
-							setTimeout( () => resolve(), this.delay );
-						} )
+						setTimeout( () => resolve(), this.delay );
+					} )
 						.then( () => super.init() )
 						.then( () => {
 							this.spy();

+ 12 - 12
packages/ckeditor5-ui/tests/viewcollection.js

@@ -82,7 +82,7 @@ describe( 'ViewCollection', () => {
 						tag: 'li',
 						children: [
 							{
-								text: text
+								text
 							}
 						]
 					} );
@@ -132,7 +132,7 @@ describe( 'ViewCollection', () => {
 
 			const childA = {
 				init: () => {
-					return new Promise( ( resolve ) => {
+					return new Promise( resolve => {
 						setTimeout( () => {
 							spyA();
 							resolve();
@@ -143,7 +143,7 @@ describe( 'ViewCollection', () => {
 
 			const childB = {
 				init: () => {
-					return new Promise( ( resolve ) => {
+					return new Promise( resolve => {
 						setTimeout( () => {
 							spyB();
 							resolve();
@@ -154,7 +154,7 @@ describe( 'ViewCollection', () => {
 
 			const childC = {
 				init: () => {
-					return new Promise( ( resolve ) => {
+					return new Promise( resolve => {
 						setTimeout( () => {
 							spyC();
 							resolve();
@@ -250,8 +250,8 @@ describe( 'ViewCollection', () => {
 
 				init() {
 					return new Promise( resolve => {
-							setTimeout( () => resolve(), this.delay );
-						} )
+						setTimeout( () => resolve(), this.delay );
+					} )
 						.then( () => super.init() )
 						.then( () => {
 							this.spy();
@@ -263,9 +263,9 @@ describe( 'ViewCollection', () => {
 			const viewB = new DelayedInitView( 100, spyB );
 
 			return collection.init().then( () => {
-					collection.add( viewA );
-					collection.add( viewB );
-				} )
+				collection.add( viewA );
+				collection.add( viewB );
+			} )
 				.then( () => {
 					return collection.destroy().then( () => {
 						expect( viewA.ready ).to.be.true;
@@ -362,7 +362,7 @@ describe( 'ViewCollection', () => {
 				expect( returned ).to.be.undefined;
 			} );
 
-			it( 'forwards an event to another observable – existing view', ( done ) => {
+			it( 'forwards an event to another observable – existing view', done => {
 				const target = new View();
 				const view = new View();
 
@@ -383,7 +383,7 @@ describe( 'ViewCollection', () => {
 				view.fire( 'foo' );
 			} );
 
-			it( 'forwards an event to another observable – new view', ( done ) => {
+			it( 'forwards an event to another observable – new view', done => {
 				const target = new View();
 				const view = new View();
 
@@ -512,7 +512,7 @@ describe( 'ViewCollection', () => {
 				sinon.assert.callCount( spy, 1 );
 			} );
 
-			it( 'supports deep event delegation', ( done ) => {
+			it( 'supports deep event delegation', done => {
 				const target = new View();
 				const viewA = new View();
 				const viewAA = new View();