Explorar el Código

Merge branch 'eslint'

Code style: Switched to ESLint.
Piotrek Koszuliński hace 8 años
padre
commit
0cb6425a07
Se han modificado 48 ficheros con 317 adiciones y 433 borrados
  1. 12 0
      packages/ckeditor5-utils/.eslintrc.js
  2. 0 89
      packages/ckeditor5-utils/.jscsrc
  3. 0 11
      packages/ckeditor5-utils/.jshintrc
  4. 0 12
      packages/ckeditor5-utils/dev/.jshintrc
  5. 7 2
      packages/ckeditor5-utils/dev/tasks/lodash/tasks.js
  6. 6 5
      packages/ckeditor5-utils/gulpfile.js
  7. 2 1
      packages/ckeditor5-utils/package.json
  8. 3 3
      packages/ckeditor5-utils/src/collection.js
  9. 2 2
      packages/ckeditor5-utils/src/config.js
  10. 1 1
      packages/ckeditor5-utils/src/count.js
  11. 3 3
      packages/ckeditor5-utils/src/diff.js
  12. 2 2
      packages/ckeditor5-utils/src/difftochanges.js
  13. 1 1
      packages/ckeditor5-utils/src/dom/createelement.js
  14. 5 6
      packages/ckeditor5-utils/src/dom/emittermixin.js
  15. 1 1
      packages/ckeditor5-utils/src/dom/tounit.js
  16. 17 17
      packages/ckeditor5-utils/src/emittermixin.js
  17. 1 1
      packages/ckeditor5-utils/src/keystrokehandler.js
  18. 1 1
      packages/ckeditor5-utils/src/locale.js
  19. 3 3
      packages/ckeditor5-utils/src/mapsequal.js
  20. 2 2
      packages/ckeditor5-utils/src/mix.js
  21. 1 1
      packages/ckeditor5-utils/src/objecttomap.js
  22. 3 4
      packages/ckeditor5-utils/src/observablemixin.js
  23. 1 1
      packages/ckeditor5-utils/src/translation-service.js
  24. 0 22
      packages/ckeditor5-utils/tests/.jshintrc
  25. 1 1
      packages/ckeditor5-utils/tests/_utils-tests/utils.js
  26. 1 1
      packages/ckeditor5-utils/tests/_utils/locale-mock.js
  27. 9 9
      packages/ckeditor5-utils/tests/ckeditorerror.js
  28. 58 58
      packages/ckeditor5-utils/tests/collection.js
  29. 12 12
      packages/ckeditor5-utils/tests/comparearrays.js
  30. 1 1
      packages/ckeditor5-utils/tests/config.js
  31. 1 1
      packages/ckeditor5-utils/tests/dom/getdatafromelement.js
  32. 40 40
      packages/ckeditor5-utils/tests/dom/position.js
  33. 1 1
      packages/ckeditor5-utils/tests/dom/setdatainelement.js
  34. 75 76
      packages/ckeditor5-utils/tests/emittermixin.js
  35. 2 2
      packages/ckeditor5-utils/tests/eventinfo.js
  36. 4 4
      packages/ckeditor5-utils/tests/isIterable.js
  37. 1 1
      packages/ckeditor5-utils/tests/keyboard.js
  38. 1 1
      packages/ckeditor5-utils/tests/keystrokehandler.js
  39. 3 3
      packages/ckeditor5-utils/tests/lodash.js
  40. 4 4
      packages/ckeditor5-utils/tests/log.js
  41. 4 4
      packages/ckeditor5-utils/tests/manual/position/position.js
  42. 3 3
      packages/ckeditor5-utils/tests/manual/tickets/148/1.js
  43. 1 3
      packages/ckeditor5-utils/tests/mix.js
  44. 12 9
      packages/ckeditor5-utils/tests/observablemixin.js
  45. 1 1
      packages/ckeditor5-utils/tests/priorities.js
  46. 3 3
      packages/ckeditor5-utils/tests/spy.js
  47. 2 1
      packages/ckeditor5-utils/tests/translation-service.js
  48. 3 3
      packages/ckeditor5-utils/tests/uid.js

+ 12 - 0
packages/ckeditor5-utils/.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-utils/.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-utils/.jshintrc

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

+ 0 - 12
packages/ckeditor5-utils/dev/.jshintrc

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

+ 7 - 2
packages/ckeditor5-utils/dev/tasks/lodash/tasks.js

@@ -1,4 +1,9 @@
-/* jshint node: true, esnext: true */
+/**
+ * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md.
+ */
+
+/* eslint-env node */
 
 'use strict';
 
@@ -28,7 +33,7 @@ function buildLodash() {
 			'exports=es',
 			'--development',
 			'--output', DEST_PATH
-		], ( err ) => {
+		], err => {
 			if ( err instanceof Error ) {
 				reject( err );
 			} else {

+ 6 - 5
packages/ckeditor5-utils/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-utils/package.json

@@ -6,10 +6,11 @@
     "CKEditor"
   ],
   "devDependencies": {
-    "@ckeditor/ckeditor5-dev-lint": "^2.0.2",
+    "@ckeditor/ckeditor5-dev-lint": "^3.0.0",
     "@ckeditor/ckeditor5-core": "^0.8.1",
     "@ckeditor/ckeditor5-engine": "^0.10.0",
     "del": "^2.2.0",
+    "eslint-config-ckeditor5": "^1.0.0",
     "gulp": "^3.9.0",
     "guppy-pre-commit": "^0.4.0",
     "lodash-cli": "^4"

+ 3 - 3
packages/ckeditor5-utils/src/collection.js

@@ -410,7 +410,7 @@ export default class Collection {
 			 * @static
 			 * @param {Function} Class Specifies which class factory is to be initialized.
 			 */
-			as: ( Class ) => {
+			as: Class => {
 				this._setUpBindToBinding( item => new Class( item ) );
 			},
 
@@ -422,7 +422,7 @@ export default class Collection {
 			 * produce the items. When the string is provided, the property value is used to create
 			 * the bound collection items.
 			 */
-			using: ( callbackOrProperty ) => {
+			using: callbackOrProperty => {
 				if ( typeof callbackOrProperty == 'function' ) {
 					this._setUpBindToBinding( item => callbackOrProperty( item ) );
 				} else {
@@ -466,7 +466,7 @@ export default class Collection {
 		};
 
 		// Load the initial content of the collection.
-		for ( let externalItem of externalCollection ) {
+		for ( const externalItem of externalCollection ) {
 			addItem( null, externalItem );
 		}
 

+ 2 - 2
packages/ckeditor5-utils/src/config.js

@@ -138,7 +138,7 @@ export default class Config {
 		name = parts.pop();
 
 		// Iterate over parts to check if currently stored configuration has proper structure.
-		for ( let part of parts ) {
+		for ( const part of parts ) {
 			// If there is no object for specified part then create one.
 			if ( !isPlainObject( target[ part ] ) ) {
 				target[ part ] = {};
@@ -187,7 +187,7 @@ export default class Config {
 		name = parts.pop();
 
 		// Iterate over parts to check if currently stored configuration has proper structure.
-		for ( let part of parts ) {
+		for ( const part of parts ) {
 			if ( !isPlainObject( source[ part ] ) ) {
 				source = null;
 				break;

+ 1 - 1
packages/ckeditor5-utils/src/count.js

@@ -18,7 +18,7 @@
 export default function count( iterator ) {
 	let count = 0;
 
-	for ( let _ of iterator ) { // jshint ignore:line
+	for ( const _ of iterator ) { // eslint-disable-line no-unused-vars
 		count++;
 	}
 

+ 3 - 3
packages/ckeditor5-utils/src/diff.js

@@ -24,15 +24,15 @@
 export default function diff( a, b, cmp ) {
 	// Set the comparator function.
 	cmp = cmp || function( a, b ) {
-			return a === b;
-		};
+		return a === b;
+	};
 
 	// Temporary action type statics.
 	let _insert, _delete;
 
 	// Swapped the arrays to use the shorter one as the first one.
 	if ( b.length < a.length ) {
-		let tmp = a;
+		const tmp = a;
 
 		a = b;
 		b = tmp;

+ 2 - 2
packages/ckeditor5-utils/src/difftochanges.js

@@ -48,7 +48,7 @@ export default function diffToChanges( diff, output ) {
 
 				lastOperation = {
 					type: 'insert',
-					index: index,
+					index,
 					values: [ output[ index ] ]
 				};
 			}
@@ -62,7 +62,7 @@ export default function diffToChanges( diff, output ) {
 
 				lastOperation = {
 					type: 'delete',
-					index: index,
+					index,
 					howMany: 1
 				};
 			}

+ 1 - 1
packages/ckeditor5-utils/src/dom/createelement.js

@@ -28,7 +28,7 @@ import isIterable from '../isiterable';
 export default function createElement( doc, name, attributes = {}, children = [] ) {
 	const element = doc.createElement( name );
 
-	for ( let key in attributes ) {
+	for ( const key in attributes ) {
 		element.setAttribute( key, attributes[ key ] );
 	}
 

+ 5 - 6
packages/ckeditor5-utils/src/dom/emittermixin.js

@@ -7,8 +7,7 @@
  * @module utils/dom/emittermixin
  */
 
-import EmitterMixin from '../emittermixin';
-import { _getEmitterListenedTo, _setEmitterId } from '../emittermixin';
+import { default as EmitterMixin, _getEmitterListenedTo, _setEmitterId } from '../emittermixin';
 import uid from '../uid';
 import extend from '../lib/lodash/extend';
 import isNative from '../lib/lodash/isNative';
@@ -88,7 +87,7 @@ const DomEmitterMixin = extend( {}, EmitterMixin, {
 
 		// Check if emitter is an instance of DOM Node. If so, replace the argument with corresponding ProxyEmitter.
 		if ( isDomNode( emitter ) ) {
-			let proxy = this._getProxyEmitter( emitter );
+			const proxy = this._getProxyEmitter( emitter );
 
 			// Element has no listeners.
 			if ( !proxy ) {
@@ -188,7 +187,7 @@ extend( ProxyEmitter.prototype, EmitterMixin, {
 	 */
 	on( event, callback, options = {} ) {
 		// Execute parent class method first.
-		EmitterMixin.on.apply( this, arguments );
+		EmitterMixin.on.call( this, event, callback, options );
 
 		// If the DOM Listener for given event already exist it is pointless
 		// to attach another one.
@@ -220,9 +219,9 @@ extend( ProxyEmitter.prototype, EmitterMixin, {
 	 *
 	 * @method module:utils/dom/emittermixin~ProxyEmitter#off
 	 */
-	off( event ) {
+	off( event, callback, context ) {
 		// Execute parent class method first.
-		EmitterMixin.off.apply( this, arguments );
+		EmitterMixin.off.call( this, event, callback, context );
 
 		let events;
 

+ 1 - 1
packages/ckeditor5-utils/src/dom/tounit.js

@@ -23,5 +23,5 @@ export default function toUnit( unit ) {
  	 * @param {*} value A value to be given the unit.
  	 * @returns {String} A value with the trailing unit.
 	 */
-	return ( value ) => value + unit;
+	return value => value + unit;
 }

+ 17 - 17
packages/ckeditor5-utils/src/emittermixin.js

@@ -46,13 +46,13 @@ const EmitterMixin = {
 		const priority = priorities.get( options.priority );
 
 		callback = {
-			callback: callback,
+			callback,
 			context: options.context || this,
-			priority: priority
+			priority
 		};
 
 		// Add the callback to all callbacks list.
-		for ( let callbacks of lists ) {
+		for ( const callbacks of lists ) {
 			// Add the callback to the list in the right priority position.
 			let added = false;
 
@@ -86,12 +86,12 @@ const EmitterMixin = {
 	 * @param {Object} [options.context] The object that represents `this` in the callback. Defaults to the object firing the event.
 	 */
 	once( event, callback, options ) {
-		const onceCallback = function( event ) {
+		const onceCallback = function( event, ...args ) {
 			// Go off() at the first call.
 			event.off();
 
 			// Go with the original callback.
-			callback.apply( this, arguments );
+			callback.call( this, event, ...args );
 		};
 
 		// Make a similar on() call, simply replacing the callback.
@@ -110,7 +110,7 @@ const EmitterMixin = {
 	off( event, callback, context ) {
 		const lists = getCallbacksListsForNamespace( this, event );
 
-		for ( let callbacks of lists ) {
+		for ( const callbacks of lists ) {
 			for ( let i = 0; i < callbacks.length; i++ ) {
 				if ( callbacks[ i ].callback == callback ) {
 					if ( !context || context == callbacks[ i ].context ) {
@@ -137,7 +137,7 @@ const EmitterMixin = {
 	 * @param {Object} [options.context] The object that represents `this` in the callback. Defaults to the object firing the event.
 	 */
 	listenTo( emitter, event, callback, options ) {
-		let emitters, emitterId, emitterInfo, eventCallbacks;
+		let emitterInfo, eventCallbacks;
 
 		// _listeningTo contains a list of emitters that this object is listening to.
 		// This list has the following format:
@@ -157,17 +157,17 @@ const EmitterMixin = {
 			this[ _listeningTo ] = {};
 		}
 
-		emitters = this[ _listeningTo ];
+		const emitters = this[ _listeningTo ];
 
 		if ( !_getEmitterId( emitter ) ) {
 			_setEmitterId( emitter );
 		}
 
-		emitterId = _getEmitterId( emitter );
+		const emitterId = _getEmitterId( emitter );
 
 		if ( !( emitterInfo = emitters[ emitterId ] ) ) {
 			emitterInfo = emitters[ emitterId ] = {
-				emitter: emitter,
+				emitter,
 				callbacks: {}
 			};
 		}
@@ -198,10 +198,10 @@ const EmitterMixin = {
 	 * `event`.
 	 */
 	stopListening( emitter, event, callback ) {
-		let emitters = this[ _listeningTo ];
+		const emitters = this[ _listeningTo ];
 		let emitterId = emitter && _getEmitterId( emitter );
-		let emitterInfo = emitters && emitterId && emitters[ emitterId ];
-		let eventCallbacks = emitterInfo && event && emitterInfo.callbacks[ event ];
+		const emitterInfo = emitters && emitterId && emitters[ emitterId ];
+		const eventCallbacks = emitterInfo && event && emitterInfo.callbacks[ event ];
 
 		// Stop if nothing has been listened.
 		if ( !emitters || ( emitter && !emitterInfo ) || ( event && !eventCallbacks ) ) {
@@ -323,8 +323,8 @@ const EmitterMixin = {
 					this._delegations = new Map();
 				}
 
-				for ( let eventName of events ) {
-					let destinations = this._delegations.get( eventName );
+				for ( const eventName of events ) {
+					const destinations = this._delegations.get( eventName );
 
 					if ( !destinations ) {
 						this._delegations.set( eventName, new Map( [ [ emitter, nameOrFunction ] ] ) );
@@ -490,7 +490,7 @@ function createEventNamespace( source, eventName ) {
 		// event we wanted to register.
 
 		// Copy that event's callbacks to newly registered events.
-		for ( let node of newEventNodes ) {
+		for ( const node of newEventNodes ) {
 			node.callbacks = events[ name ].callbacks.slice();
 		}
 
@@ -513,7 +513,7 @@ function getCallbacksListsForNamespace( source, eventName ) {
 	let callbacksLists = [ eventNode.callbacks ];
 
 	for ( let i = 0; i < eventNode.childEvents.length; i++ ) {
-		let childCallbacksLists = getCallbacksListsForNamespace( source, eventNode.childEvents[ i ] );
+		const childCallbacksLists = getCallbacksListsForNamespace( source, eventNode.childEvents[ i ] );
 
 		callbacksLists = callbacksLists.concat( childCallbacksLists );
 	}

+ 1 - 1
packages/ckeditor5-utils/src/keystrokehandler.js

@@ -91,7 +91,7 @@ export default class KeystrokeHandler {
 			return false;
 		}
 
-		for ( let callback of callbacks ) {
+		for ( const callback of callbacks ) {
 			callback( keyEventData, () => {
 				keyEventData.preventDefault();
 				keyEventData.stopPropagation();

+ 1 - 1
packages/ckeditor5-utils/src/locale.js

@@ -58,7 +58,7 @@ export default class Locale {
 		let translatedString = translate( this.lang, str );
 
 		if ( values ) {
-			translatedString = translatedString.replace( /\%(\d+)/g, ( match, index ) => {
+			translatedString = translatedString.replace( /%(\d+)/g, ( match, index ) => {
 				return ( index < values.length ) ? values[ index ] : match;
 			} );
 		}

+ 3 - 3
packages/ckeditor5-utils/src/mapsequal.js

@@ -17,9 +17,9 @@ export default function mapsEqual( mapA, mapB ) {
 		return false;
 	}
 
-	for ( let attr of mapA.entries() ) {
-		let valA = JSON.stringify( attr[ 1 ] );
-		let valB = JSON.stringify( mapB.get( attr[ 0 ] ) );
+	for ( const attr of mapA.entries() ) {
+		const valA = JSON.stringify( attr[ 1 ] );
+		const valB = JSON.stringify( mapB.get( attr[ 0 ] ) );
 
 		if ( valA !== valB ) {
 			return false;

+ 2 - 2
packages/ckeditor5-utils/src/mix.js

@@ -31,9 +31,9 @@
  * @param {Object} [...mixins] Objects from which to get properties.
  */
 export default function mix( baseClass, ...mixins ) {
-	mixins.forEach( ( mixin ) => {
+	mixins.forEach( mixin => {
 		Object.getOwnPropertyNames( mixin ).concat( Object.getOwnPropertySymbols( mixin ) )
-			.forEach( ( key ) => {
+			.forEach( key => {
 				if ( key in baseClass.prototype ) {
 					return;
 				}

+ 1 - 1
packages/ckeditor5-utils/src/objecttomap.js

@@ -19,7 +19,7 @@
 export default function objectToMap( obj ) {
 	const map = new Map();
 
-	for ( let key in obj ) {
+	for ( const key in obj ) {
 		map.set( key, obj[ key ] );
 	}
 

+ 3 - 4
packages/ckeditor5-utils/src/observablemixin.js

@@ -42,7 +42,7 @@ const ObservableMixin = {
 	set( name, value ) {
 		// If the first parameter is an Object, iterate over its properties.
 		if ( isObject( name ) ) {
-			Object.keys( name ).forEach( ( attr ) => {
+			Object.keys( name ).forEach( attr => {
 				this.set( attr, name[ attr ] );
 			}, this );
 
@@ -372,7 +372,6 @@ function initObservable( observable ) {
 // @private
 // @param {...[Observable|String|Function]} args Arguments of the `.to( args )` binding.
 function bindTo( ...args ) {
-	/* jshint validthis: true */
 	const parsedArgs = parseBindToArgs( ...args );
 	const bindingsKeys = Array.from( this._bindings.keys() );
 	const numberOfBindings = bindingsKeys.length;
@@ -384,7 +383,7 @@ function bindTo( ...args ) {
 		 *
 		 * @error observable-bind-no-callback
 		 */
-		throw new CKEditorError( 'observable-bind-to-no-callback: Binding multiple observables only possible with callback.' ) ;
+		throw new CKEditorError( 'observable-bind-to-no-callback: Binding multiple observables only possible with callback.' );
 	}
 
 	// Eliminate A.bind( 'x', 'y' ).to( B, callback )
@@ -394,7 +393,7 @@ function bindTo( ...args ) {
 		 *
 		 * @error observable-bind-to-extra-callback
 		 */
-		throw new CKEditorError( 'observable-bind-to-extra-callback: Cannot bind multiple attributes and use a callback in one binding.' ) ;
+		throw new CKEditorError( 'observable-bind-to-extra-callback: Cannot bind multiple attributes and use a callback in one binding.' );
 	}
 
 	parsedArgs.to.forEach( to => {

+ 1 - 1
packages/ckeditor5-utils/src/translation-service.js

@@ -45,7 +45,7 @@ export function add( lang, translations ) {
  */
 export function translate( lang, translationKey ) {
 	if ( !hasTranslation( lang, translationKey ) ) {
-		return translationKey.replace( / \[context: [^\]]+\]$/, '' ) ;
+		return translationKey.replace( / \[context: [^\]]+\]$/, '' );
 	}
 
 	return dictionaries[ lang ][ translationKey ];

+ 0 - 22
packages/ckeditor5-utils/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
-  }
-}

+ 1 - 1
packages/ckeditor5-utils/tests/_utils-tests/utils.js

@@ -27,7 +27,7 @@ describe( 'utilsTestUtils.createObserver()', () => {
 		function Emitter() {}
 		Emitter.prototype = EmitterMixin;
 
-		expect( observer  ).to.be.instanceof( Emitter );
+		expect( observer ).to.be.instanceof( Emitter );
 		expect( observer.observe ).is.a( 'function' );
 		expect( observer.stopListening ).is.a( 'function' );
 	} );

+ 1 - 1
packages/ckeditor5-utils/tests/_utils/locale-mock.js

@@ -10,6 +10,6 @@
  */
 export default class Locale {
 	constructor() {
-		this.t = ( str ) => `t( ${ str } )`;
+		this.t = str => `t( ${ str } )`;
 	}
 }

+ 9 - 9
packages/ckeditor5-utils/tests/ckeditorerror.js

@@ -7,28 +7,28 @@ import CKEditorError from '../src/ckeditorerror';
 
 describe( 'CKEditorError', () => {
 	it( 'inherits from Error', () => {
-		let error = new CKEditorError( 'foo' );
+		const error = new CKEditorError( 'foo' );
 
 		expect( error ).to.be.an.instanceOf( Error );
 		expect( error ).to.be.an.instanceOf( CKEditorError );
 	} );
 
 	it( 'sets the name', () => {
-		let error = new CKEditorError( 'foo' );
+		const error = new CKEditorError( 'foo' );
 
 		expect( error ).to.have.property( 'name', 'CKEditorError' );
 	} );
 
 	it( 'sets the message', () => {
-		let error = new CKEditorError( 'foo' );
+		const error = new CKEditorError( 'foo' );
 
 		expect( error ).to.have.property( 'message', 'foo' );
 		expect( error.data ).to.be.undefined;
 	} );
 
 	it( 'sets the message and data', () => {
-		let data = { bar: 1 };
-		let error = new CKEditorError( 'foo', data );
+		const data = { bar: 1 };
+		const error = new CKEditorError( 'foo', data );
 
 		expect( error ).to.have.property( 'message', 'foo {"bar":1}' );
 		expect( error ).to.have.property( 'data', data );
@@ -41,12 +41,12 @@ describe( 'CKEditorError', () => {
 			}
 		}
 
-		let data = {
+		const data = {
 			bar: 'a',
 			bom: new Foo(),
 			bim: 10
 		};
-		let error = new CKEditorError( 'foo', data );
+		const error = new CKEditorError( 'foo', data );
 
 		expect( error ).to.have.property( 'message', 'foo {"bar":"a","bom":{"x":1},"bim":10}' );
 		expect( error ).to.have.property( 'data', data );
@@ -54,8 +54,8 @@ describe( 'CKEditorError', () => {
 
 	describe( 'isCKEditorError', () => {
 		it( 'checks if error is an instance of CKEditorError', () => {
-			let ckeditorError = new CKEditorError( 'foo' );
-			let regularError = new Error( 'foo' );
+			const ckeditorError = new CKEditorError( 'foo' );
+			const regularError = new Error( 'foo' );
 
 			expect( CKEditorError.isCKEditorError( ckeditorError ) ).to.be.true;
 			expect( CKEditorError.isCKEditorError( regularError ) ).to.be.false;

+ 58 - 58
packages/ckeditor5-utils/tests/collection.js

@@ -26,9 +26,9 @@ describe( 'Collection', () => {
 
 	describe( 'constructor()', () => {
 		it( 'allows to change the id property used by the collection', () => {
-			let item1 = { id: 'foo', name: 'xx' };
-			let item2 = { id: 'foo', name: 'yy' };
-			let collection = new Collection( { idProperty: 'name' } );
+			const item1 = { id: 'foo', name: 'xx' };
+			const item2 = { id: 'foo', name: 'yy' };
+			const collection = new Collection( { idProperty: 'name' } );
 
 			collection.add( item1 );
 			collection.add( item2 );
@@ -56,8 +56,8 @@ describe( 'Collection', () => {
 		} );
 
 		it( 'should enable get( index )', () => {
-			let item1 = {};
-			let item2 = {};
+			const item1 = {};
+			const item2 = {};
 
 			collection.add( item1 );
 			expect( collection.get( 0 ) ).to.equal( item1 );
@@ -68,8 +68,8 @@ describe( 'Collection', () => {
 		} );
 
 		it( 'should enable get( id )', () => {
-			let item1 = getItem( 'foo' );
-			let item2 = getItem( 'bar' );
+			const item1 = getItem( 'foo' );
+			const item2 = getItem( 'bar' );
 
 			collection.add( item1 );
 			collection.add( item2 );
@@ -79,9 +79,9 @@ describe( 'Collection', () => {
 		} );
 
 		it( 'should enable get( id ) - custom id property', () => {
-			let collection = new Collection( { idProperty: 'name' } );
-			let item1 = getItem( 'foo', 'name' );
-			let item2 = getItem( 'bar', 'name' );
+			const collection = new Collection( { idProperty: 'name' } );
+			const item1 = getItem( 'foo', 'name' );
+			const item2 = getItem( 'bar', 'name' );
 
 			collection.add( item1 );
 			collection.add( item2 );
@@ -91,7 +91,7 @@ describe( 'Collection', () => {
 		} );
 
 		it( 'should generate an id when not defined', () => {
-			let item = {};
+			const item = {};
 
 			collection.add( item );
 
@@ -100,8 +100,8 @@ describe( 'Collection', () => {
 		} );
 
 		it( 'should generate an id when not defined - custom id property', () => {
-			let collection = new Collection( { idProperty: 'name' } );
-			let item = {};
+			const collection = new Collection( { idProperty: 'name' } );
+			const item = {};
 
 			collection.add( item );
 
@@ -110,7 +110,7 @@ describe( 'Collection', () => {
 		} );
 
 		it( 'should not change an existing id of an item', () => {
-			let item = getItem( 'foo' );
+			const item = getItem( 'foo' );
 
 			collection.add( item );
 
@@ -118,8 +118,8 @@ describe( 'Collection', () => {
 		} );
 
 		it( 'should throw when item with this id already exists', () => {
-			let item1 = getItem( 'foo' );
-			let item2 = getItem( 'foo' );
+			const item1 = getItem( 'foo' );
+			const item2 = getItem( 'foo' );
 
 			collection.add( item1 );
 
@@ -129,7 +129,7 @@ describe( 'Collection', () => {
 		} );
 
 		it( 'should throw when item\'s id is not a string', () => {
-			let item = { id: 1 };
+			const item = { id: 1 };
 
 			expect( () => {
 				collection.add( item );
@@ -195,8 +195,8 @@ describe( 'Collection', () => {
 		} );
 
 		it( 'should fire the "add" event', () => {
-			let spy = sinon.spy();
-			let item = {};
+			const spy = sinon.spy();
+			const item = {};
 
 			collection.on( 'add', spy );
 
@@ -206,10 +206,10 @@ describe( 'Collection', () => {
 		} );
 
 		it( 'should support an optional index argument', () => {
-			let item1 = getItem( 'foo' );
-			let item2 = getItem( 'bar' );
-			let item3 = getItem( 'baz' );
-			let item4 = getItem( 'abc' );
+			const item1 = getItem( 'foo' );
+			const item2 = getItem( 'bar' );
+			const item3 = getItem( 'baz' );
+			const item4 = getItem( 'abc' );
 
 			collection.add( item1 );
 			collection.add( item2, 0 );
@@ -223,9 +223,9 @@ describe( 'Collection', () => {
 		} );
 
 		it( 'should throw when index argument is invalid', () => {
-			let item1 = getItem( 'foo' );
-			let item2 = getItem( 'bar' );
-			let item3 = getItem( 'baz' );
+			const item1 = getItem( 'foo' );
+			const item2 = getItem( 'bar' );
+			const item3 = getItem( 'baz' );
 
 			collection.add( item1 );
 
@@ -244,7 +244,7 @@ describe( 'Collection', () => {
 		} );
 
 		it( 'should fire the "add" event with the index argument', () => {
-			let spy = sinon.spy();
+			const spy = sinon.spy();
 
 			collection.add( {} );
 			collection.add( {} );
@@ -260,7 +260,7 @@ describe( 'Collection', () => {
 
 	describe( 'get()', () => {
 		it( 'should return an item', () => {
-			let item = getItem( 'foo' );
+			const item = getItem( 'foo' );
 			collection.add( item );
 
 			expect( collection.get( 'foo' ) ).to.equal( item );
@@ -323,7 +323,7 @@ describe( 'Collection', () => {
 
 			expect( collection ).to.have.length( 3 );
 
-			let removedItem = collection.remove( 1 );
+			const removedItem = collection.remove( 1 );
 
 			expect( collection ).to.have.length( 2 );
 			expect( collection.get( 'foo' ) ).to.be.null;
@@ -332,11 +332,11 @@ describe( 'Collection', () => {
 		} );
 
 		it( 'should remove the model by index - custom id property', () => {
-			let collection = new Collection( { idProperty: 'name' } );
+			const collection = new Collection( { idProperty: 'name' } );
 
 			collection.add( getItem( 'foo', 'name' ) );
 
-			let removedItem = collection.remove( 0 );
+			const removedItem = collection.remove( 0 );
 
 			expect( collection ).to.have.length( 0 );
 			expect( collection.get( 'foo' ) ).to.be.null;
@@ -350,7 +350,7 @@ describe( 'Collection', () => {
 
 			expect( collection ).to.have.length( 3 );
 
-			let removedItem = collection.remove( 'foo' );
+			const removedItem = collection.remove( 'foo' );
 
 			expect( collection ).to.have.length( 2 );
 			expect( collection.get( 'foo' ) ).to.be.null;
@@ -359,7 +359,7 @@ describe( 'Collection', () => {
 		} );
 
 		it( 'should remove the model by model', () => {
-			let item = getItem( 'foo' );
+			const item = getItem( 'foo' );
 
 			collection.add( getItem( 'bom' ) );
 			collection.add( item );
@@ -367,7 +367,7 @@ describe( 'Collection', () => {
 
 			expect( collection ).to.have.length( 3 );
 
-			let removedItem = collection.remove( item );
+			const removedItem = collection.remove( item );
 
 			expect( collection ).to.have.length( 2 );
 			expect( collection.get( 'foo' ) ).to.be.null;
@@ -376,12 +376,12 @@ describe( 'Collection', () => {
 		} );
 
 		it( 'should remove the model by model - custom id property', () => {
-			let collection = new Collection( null, 'name' );
-			let item = getItem( 'foo', 'name' );
+			const collection = new Collection( null, 'name' );
+			const item = getItem( 'foo', 'name' );
 
 			collection.add( item );
 
-			let removedItem = collection.remove( item );
+			const removedItem = collection.remove( item );
 
 			expect( collection ).to.have.length( 0 );
 			expect( collection.get( 'foo' ) ).to.be.null;
@@ -389,15 +389,15 @@ describe( 'Collection', () => {
 		} );
 
 		it( 'should fire the "remove" event', () => {
-			let item1 = getItem( 'foo' );
-			let item2 = getItem( 'bar' );
-			let item3 = getItem( 'bom' );
+			const item1 = getItem( 'foo' );
+			const item2 = getItem( 'bar' );
+			const item3 = getItem( 'bom' );
 
 			collection.add( item1 );
 			collection.add( item2 );
 			collection.add( item3 );
 
-			let spy = sinon.spy();
+			const spy = sinon.spy();
 
 			collection.on( 'remove', spy );
 
@@ -444,12 +444,12 @@ describe( 'Collection', () => {
 
 	describe( 'map()', () => {
 		it( 'uses native map', () => {
-			let spy = testUtils.sinon.stub( Array.prototype, 'map', () => {
+			const spy = testUtils.sinon.stub( Array.prototype, 'map', () => {
 				return [ 'foo' ];
 			} );
-			let ctx = {};
+			const ctx = {};
 
-			let ret = collection.map( callback, ctx );
+			const ret = collection.map( callback, ctx );
 
 			sinon.assert.calledWithExactly( spy, callback, ctx );
 			expect( ret ).to.deep.equal( [ 'foo' ], 'ret value was forwarded' );
@@ -460,14 +460,14 @@ describe( 'Collection', () => {
 
 	describe( 'find()', () => {
 		it( 'uses native find', () => {
-			let needl = getItem( 'foo' );
+			const needl = getItem( 'foo' );
 
-			let spy = testUtils.sinon.stub( Array.prototype, 'find', () => {
+			const spy = testUtils.sinon.stub( Array.prototype, 'find', () => {
 				return needl;
 			} );
-			let ctx = {};
+			const ctx = {};
 
-			let ret = collection.find( callback, ctx );
+			const ret = collection.find( callback, ctx );
 
 			sinon.assert.calledWithExactly( spy, callback, ctx );
 			expect( ret ).to.equal( needl, 'ret value was forwarded' );
@@ -478,14 +478,14 @@ describe( 'Collection', () => {
 
 	describe( 'filter()', () => {
 		it( 'uses native filter', () => {
-			let needl = getItem( 'foo' );
+			const needl = getItem( 'foo' );
 
-			let spy = testUtils.sinon.stub( Array.prototype, 'filter', () => {
+			const spy = testUtils.sinon.stub( Array.prototype, 'filter', () => {
 				return [ needl ];
 			} );
-			let ctx = {};
+			const ctx = {};
 
-			let ret = collection.filter( callback, ctx );
+			const ret = collection.filter( callback, ctx );
 
 			sinon.assert.calledWithExactly( spy, callback, ctx );
 			expect( ret ).to.deep.equal( [ needl ], 'ret value was forwarded' );
@@ -642,7 +642,7 @@ describe( 'Collection', () => {
 
 			describe( 'callback', () => {
 				it( 'creates a binding (arrow function)', () => {
-					collection.bindTo( items ).using( ( item ) => {
+					collection.bindTo( items ).using( item => {
 						return new FactoryClass( item );
 					} );
 
@@ -1000,16 +1000,16 @@ describe( 'Collection', () => {
 
 	describe( 'iterator', () => {
 		it( 'covers the whole collection', () => {
-			let item1 = getItem( 'foo' );
-			let item2 = getItem( 'bar' );
-			let item3 = getItem( 'bom' );
-			let items = [];
+			const item1 = getItem( 'foo' );
+			const item2 = getItem( 'bar' );
+			const item3 = getItem( 'bom' );
+			const items = [];
 
 			collection.add( item1 );
 			collection.add( item2 );
 			collection.add( item3 );
 
-			for ( let item of collection ) {
+			for ( const item of collection ) {
 				items.push( item.id );
 			}
 

+ 12 - 12
packages/ckeditor5-utils/tests/comparearrays.js

@@ -8,37 +8,37 @@ import compareArrays from '../src/comparearrays';
 describe( 'utils', () => {
 	describe( 'compareArrays', () => {
 		it( 'should return same flag, when arrays are same', () => {
-			let a = [ 'abc', 0, 3 ];
-			let b = [ 'abc', 0, 3 ];
+			const a = [ 'abc', 0, 3 ];
+			const b = [ 'abc', 0, 3 ];
 
-			let result = compareArrays( a, b );
+			const result = compareArrays( a, b );
 
 			expect( result ).to.equal( 'same' );
 		} );
 
 		it( 'should return prefix flag, when all n elements of first array are same as n first elements of the second array', () => {
-			let a = [ 'abc', 0 ];
-			let b = [ 'abc', 0, 3 ];
+			const a = [ 'abc', 0 ];
+			const b = [ 'abc', 0, 3 ];
 
-			let result = compareArrays( a, b );
+			const result = compareArrays( a, b );
 
 			expect( result ).to.equal( 'prefix' );
 		} );
 
 		it( 'should return extension flag, when n first elements of first array are same as all elements of the second array', () => {
-			let a = [ 'abc', 0, 3 ];
-			let b = [ 'abc', 0 ];
+			const a = [ 'abc', 0, 3 ];
+			const b = [ 'abc', 0 ];
 
-			let result = compareArrays( a, b );
+			const result = compareArrays( a, b );
 
 			expect( result ).to.equal( 'extension' );
 		} );
 
 		it( 'should return index on which arrays differ, when arrays are not the same', () => {
-			let a = [ 'abc', 0, 3 ];
-			let b = [ 'abc', 1, 3 ];
+			const a = [ 'abc', 0, 3 ];
+			const b = [ 'abc', 1, 3 ];
 
-			let result = compareArrays( a, b );
+			const result = compareArrays( a, b );
 
 			expect( result ).to.equal( 1 );
 		} );

+ 1 - 1
packages/ckeditor5-utils/tests/config.js

@@ -335,7 +335,7 @@ describe( 'Config', () => {
 		} );
 
 		it( 'should retrieve a object of the configuration', () => {
-			let resize = config.get( 'resize' );
+			const resize = config.get( 'resize' );
 
 			expect( resize ).to.be.an( 'object' );
 			expect( resize.minHeight ).equal( 300 );

+ 1 - 1
packages/ckeditor5-utils/tests/dom/getdatafromelement.js

@@ -23,7 +23,7 @@ describe( 'getDataFromElement', () => {
 		divEl.parentElement.removeChild( divEl );
 	} );
 
-	[ 'textarea', 'template', 'div' ].forEach( ( elementName ) => {
+	[ 'textarea', 'template', 'div' ].forEach( elementName => {
 		it( 'should return the content of a ' + elementName, () => {
 			const data = getDataFromElement( document.getElementById( 'getData-' + elementName ) );
 			expect( data ).to.equal( '<b>foo</b>' );

+ 40 - 40
packages/ckeditor5-utils/tests/dom/position.js

@@ -8,6 +8,46 @@ import { getOptimalPosition } from '../../src/dom/position';
 
 let element, target, limiter;
 
+//	+--------+-----+
+//	|    E   |  T  |
+//	+--------+-----+
+const attachLeft = ( targetRect, elementRect ) => ( {
+	top: targetRect.top,
+	left: targetRect.left - elementRect.width,
+	name: 'left'
+} );
+
+//	+-----+--------+
+//	|  T  |    E   |
+//	+-----+--------+
+const attachRight = targetRect => ( {
+	top: targetRect.top,
+	left: targetRect.left + targetRect.width,
+	name: 'right'
+} );
+
+//	+-----+
+//	|  T  |
+//	+-----+--+
+//	|    E   |
+//	+--------+
+const attachBottom = targetRect => ( {
+	top: targetRect.bottom,
+	left: targetRect.left,
+	name: 'bottom'
+} );
+
+//	+--------+
+//	|    E   |
+//	+--+-----+
+//	   |  T  |
+//	   +-----+
+const attachTop = ( targetRect, elementRect ) => ( {
+	top: targetRect.top - elementRect.height,
+	left: targetRect.left - ( elementRect.width - targetRect.width ),
+	name: 'bottom'
+} );
+
 describe( 'getOptimalPosition()', () => {
 	beforeEach( () => {
 		stubWindow( {
@@ -320,46 +360,6 @@ function assertPosition( options, expected ) {
 	expect( position ).to.deep.equal( expected );
 }
 
-//	+--------+-----+
-//	|    E   |  T  |
-//	+--------+-----+
-const attachLeft = ( targetRect, elementRect ) => ( {
-	top: targetRect.top,
-	left: targetRect.left - elementRect.width,
-	name: 'left'
-} );
-
-//	+-----+--------+
-//	|  T  |    E   |
-//	+-----+--------+
-const attachRight = ( targetRect ) => ( {
-	top: targetRect.top,
-	left: targetRect.left + targetRect.width,
-	name: 'right'
-} );
-
-//	+-----+
-//	|  T  |
-//	+-----+--+
-//	|    E   |
-//	+--------+
-const attachBottom = ( targetRect ) => ( {
-	top: targetRect.bottom,
-	left: targetRect.left,
-	name: 'bottom'
-} );
-
-//	+--------+
-//	|    E   |
-//	+--+-----+
-//	   |  T  |
-//	   +-----+
-const attachTop = ( targetRect, elementRect ) => ( {
-	top: targetRect.top - elementRect.height,
-	left: targetRect.left - ( elementRect.width - targetRect.width ),
-	name: 'bottom'
-} );
-
 // Returns a synthetic element.
 //
 // @private

+ 1 - 1
packages/ckeditor5-utils/tests/dom/setdatainelement.js

@@ -9,7 +9,7 @@ import setDataInElement from '../../src/dom/setdatainelement';
 import getDataFromElement from '../../src/dom/getdatafromelement';
 
 describe( 'setDataInElement', () => {
-	[ 'textarea', 'template', 'div' ].forEach( ( elementName ) => {
+	[ 'textarea', 'template', 'div' ].forEach( elementName => {
 		it( 'should set the content of a ' + elementName, () => {
 			const el = document.createElement( elementName );
 			const expectedData = '<b>foo</b>';

+ 75 - 76
packages/ckeditor5-utils/tests/emittermixin.js

@@ -3,8 +3,7 @@
  * For licensing, see LICENSE.md.
  */
 
-import EmitterMixin from '../src/emittermixin';
-import { _getEmitterListenedTo, _getEmitterId, _setEmitterId } from '../src/emittermixin';
+import { default as EmitterMixin, _getEmitterListenedTo, _getEmitterId, _setEmitterId } from '../src/emittermixin';
 import EventInfo from '../src/eventinfo';
 
 describe( 'EmitterMixin', () => {
@@ -17,9 +16,9 @@ describe( 'EmitterMixin', () => {
 
 	describe( 'fire', () => {
 		it( 'should execute callbacks in the right order without priority', () => {
-			let spy1 = sinon.spy().named( 1 );
-			let spy2 = sinon.spy().named( 2 );
-			let spy3 = sinon.spy().named( 3 );
+			const spy1 = sinon.spy().named( 1 );
+			const spy2 = sinon.spy().named( 2 );
+			const spy3 = sinon.spy().named( 3 );
 
 			emitter.on( 'test', spy1 );
 			emitter.on( 'test', spy2 );
@@ -31,11 +30,11 @@ describe( 'EmitterMixin', () => {
 		} );
 
 		it( 'should execute callbacks in the right order with priority defined', () => {
-			let spy1 = sinon.spy().named( 1 );
-			let spy2 = sinon.spy().named( 2 );
-			let spy3 = sinon.spy().named( 3 );
-			let spy4 = sinon.spy().named( 4 );
-			let spy5 = sinon.spy().named( 5 );
+			const spy1 = sinon.spy().named( 1 );
+			const spy2 = sinon.spy().named( 2 );
+			const spy3 = sinon.spy().named( 3 );
+			const spy4 = sinon.spy().named( 4 );
+			const spy5 = sinon.spy().named( 5 );
 
 			emitter.on( 'test', spy2, { priority: 'high' } );
 			emitter.on( 'test', spy3 ); // Defaults to 'normal'.
@@ -49,8 +48,8 @@ describe( 'EmitterMixin', () => {
 		} );
 
 		it( 'should pass arguments to callbacks', () => {
-			let spy1 = sinon.spy();
-			let spy2 = sinon.spy();
+			const spy1 = sinon.spy();
+			const spy2 = sinon.spy();
 
 			emitter.on( 'test', spy1 );
 			emitter.on( 'test', spy2 );
@@ -62,12 +61,12 @@ describe( 'EmitterMixin', () => {
 		} );
 
 		it( 'should pass proper context to callbacks', () => {
-			let ctx1 = {};
-			let ctx2 = {};
+			const ctx1 = {};
+			const ctx2 = {};
 
-			let spy1 = sinon.spy();
-			let spy2 = sinon.spy();
-			let spy3 = sinon.spy();
+			const spy1 = sinon.spy();
+			const spy2 = sinon.spy();
+			const spy3 = sinon.spy();
 
 			emitter.on( 'test', spy1, { context: ctx1 } );
 			emitter.on( 'test', spy2, { context: ctx2 } );
@@ -81,8 +80,8 @@ describe( 'EmitterMixin', () => {
 		} );
 
 		it( 'should fire the right event', () => {
-			let spy1 = sinon.spy();
-			let spy2 = sinon.spy();
+			const spy1 = sinon.spy();
+			const spy2 = sinon.spy();
 
 			emitter.on( '1', spy1 );
 			emitter.on( '2', spy2 );
@@ -94,7 +93,7 @@ describe( 'EmitterMixin', () => {
 		} );
 
 		it( 'should execute callbacks many times', () => {
-			let spy = sinon.spy();
+			const spy = sinon.spy();
 
 			emitter.on( 'test', spy );
 
@@ -110,7 +109,7 @@ describe( 'EmitterMixin', () => {
 		} );
 
 		it( 'should accept the same callback many times', () => {
-			let spy = sinon.spy();
+			const spy = sinon.spy();
 
 			emitter.on( 'test', spy );
 			emitter.on( 'test', spy );
@@ -122,7 +121,7 @@ describe( 'EmitterMixin', () => {
 		} );
 
 		it( 'should not fire callbacks for an event that were added while firing that event', () => {
-			let spy = sinon.spy();
+			const spy = sinon.spy();
 
 			emitter.on( 'test', () => {
 				emitter.on( 'test', spy );
@@ -134,10 +133,10 @@ describe( 'EmitterMixin', () => {
 		} );
 
 		it( 'should correctly fire callbacks for namespaced events', () => {
-			let spyFoo = sinon.spy();
-			let spyBar = sinon.spy();
-			let spyAbc = sinon.spy();
-			let spyFoo2 = sinon.spy();
+			const spyFoo = sinon.spy();
+			const spyBar = sinon.spy();
+			const spyAbc = sinon.spy();
+			const spyFoo2 = sinon.spy();
 
 			// Mess up with callbacks order to check whether they are called in adding order.
 			emitter.on( 'foo', spyFoo );
@@ -177,9 +176,9 @@ describe( 'EmitterMixin', () => {
 
 	describe( 'on', () => {
 		it( 'should stop()', () => {
-			let spy1 = sinon.spy();
-			let spy2 = sinon.spy();
-			let spy3 = sinon.spy( ( event ) => {
+			const spy1 = sinon.spy();
+			const spy2 = sinon.spy();
+			const spy3 = sinon.spy( event => {
 				event.stop();
 			} );
 
@@ -197,11 +196,11 @@ describe( 'EmitterMixin', () => {
 		} );
 
 		it( 'should take a callback off()', () => {
-			let spy1 = sinon.spy();
-			let spy2 = sinon.spy( ( event ) => {
+			const spy1 = sinon.spy();
+			const spy2 = sinon.spy( event => {
 				event.off();
 			} );
-			let spy3 = sinon.spy();
+			const spy3 = sinon.spy();
 
 			emitter.on( 'test', spy1 );
 			emitter.on( 'test', spy2 );
@@ -216,11 +215,11 @@ describe( 'EmitterMixin', () => {
 		} );
 
 		it( 'should take the callback off() even after stop()', () => {
-			let spy1 = sinon.spy( ( event ) => {
+			const spy1 = sinon.spy( event => {
 				event.stop();
 				event.off();
 			} );
-			let spy2 = sinon.spy();
+			const spy2 = sinon.spy();
 
 			emitter.on( 'test', spy1 );
 			emitter.on( 'test', spy2 );
@@ -235,9 +234,9 @@ describe( 'EmitterMixin', () => {
 
 	describe( 'once', () => {
 		it( 'should be called just once', () => {
-			let spy1 = sinon.spy();
-			let spy2 = sinon.spy();
-			let spy3 = sinon.spy();
+			const spy1 = sinon.spy();
+			const spy2 = sinon.spy();
+			const spy3 = sinon.spy();
 
 			emitter.on( 'test', spy1 );
 			emitter.once( 'test', spy2 );
@@ -252,10 +251,10 @@ describe( 'EmitterMixin', () => {
 		} );
 
 		it( 'should have proper scope', () => {
-			let ctx = {};
+			const ctx = {};
 
-			let spy1 = sinon.spy();
-			let spy2 = sinon.spy();
+			const spy1 = sinon.spy();
+			const spy2 = sinon.spy();
 
 			emitter.once( 'test', spy1, { context: ctx } );
 			emitter.once( 'test', spy2 );
@@ -267,7 +266,7 @@ describe( 'EmitterMixin', () => {
 		} );
 
 		it( 'should have proper arguments', () => {
-			let spy = sinon.spy();
+			const spy = sinon.spy();
 
 			emitter.once( 'test', spy );
 
@@ -279,9 +278,9 @@ describe( 'EmitterMixin', () => {
 
 	describe( 'off', () => {
 		it( 'should get callbacks off()', () => {
-			let spy1 = sinon.spy();
-			let spy2 = sinon.spy();
-			let spy3 = sinon.spy();
+			const spy1 = sinon.spy();
+			const spy2 = sinon.spy();
+			const spy3 = sinon.spy();
 
 			emitter.on( 'test', spy1 );
 			emitter.on( 'test', spy2 );
@@ -304,8 +303,8 @@ describe( 'EmitterMixin', () => {
 		} );
 
 		it( 'should remove all entries for the same callback', () => {
-			let spy1 = sinon.spy().named( 1 );
-			let spy2 = sinon.spy().named( 2 );
+			const spy1 = sinon.spy().named( 1 );
+			const spy2 = sinon.spy().named( 2 );
 
 			emitter.on( 'test', spy1 );
 			emitter.on( 'test', spy2 );
@@ -323,10 +322,10 @@ describe( 'EmitterMixin', () => {
 		} );
 
 		it( 'should remove the callback for given context only', () => {
-			let spy = sinon.spy().named( 1 );
+			const spy = sinon.spy().named( 1 );
 
-			let ctx1 = { context: 1 };
-			let ctx2 = { context: 2 };
+			const ctx1 = { context: 1 };
+			const ctx2 = { context: 2 };
 
 			emitter.on( 'test', spy, { context: ctx1 } );
 			emitter.on( 'test', spy, { context: ctx2 } );
@@ -344,10 +343,10 @@ describe( 'EmitterMixin', () => {
 		} );
 
 		it( 'should properly remove callbacks for namespaced events', () => {
-			let spyFoo = sinon.spy();
-			let spyAbc = sinon.spy();
-			let spyBar = sinon.spy();
-			let spyFoo2 = sinon.spy();
+			const spyFoo = sinon.spy();
+			const spyAbc = sinon.spy();
+			const spyBar = sinon.spy();
+			const spyFoo2 = sinon.spy();
 
 			emitter.on( 'foo', spyFoo );
 			emitter.on( 'foo:bar:abc', spyAbc );
@@ -381,7 +380,7 @@ describe( 'EmitterMixin', () => {
 
 	describe( 'listenTo', () => {
 		it( 'should properly register callbacks', () => {
-			let spy = sinon.spy();
+			const spy = sinon.spy();
 
 			listener.listenTo( emitter, 'test', spy );
 
@@ -391,8 +390,8 @@ describe( 'EmitterMixin', () => {
 		} );
 
 		it( 'should correctly listen to namespaced events', () => {
-			let spyFoo = sinon.spy();
-			let spyBar = sinon.spy();
+			const spyFoo = sinon.spy();
+			const spyBar = sinon.spy();
 
 			listener.listenTo( emitter, 'foo', spyFoo );
 			listener.listenTo( emitter, 'foo:bar', spyBar );
@@ -411,8 +410,8 @@ describe( 'EmitterMixin', () => {
 
 	describe( 'stopListening', () => {
 		it( 'should stop listening to given event callback', () => {
-			let spy1 = sinon.spy();
-			let spy2 = sinon.spy();
+			const spy1 = sinon.spy();
+			const spy2 = sinon.spy();
 
 			listener.listenTo( emitter, 'event1', spy1 );
 			listener.listenTo( emitter, 'event2', spy2 );
@@ -430,9 +429,9 @@ describe( 'EmitterMixin', () => {
 		} );
 
 		it( 'should stop listening to given event', () => {
-			let spy1a = sinon.spy();
-			let spy1b = sinon.spy();
-			let spy2 = sinon.spy();
+			const spy1a = sinon.spy();
+			const spy1b = sinon.spy();
+			const spy2 = sinon.spy();
 
 			listener.listenTo( emitter, 'event1', spy1a );
 			listener.listenTo( emitter, 'event1', spy1b );
@@ -452,8 +451,8 @@ describe( 'EmitterMixin', () => {
 		} );
 
 		it( 'should stop listening to all events from given emitter', () => {
-			let spy1 = sinon.spy();
-			let spy2 = sinon.spy();
+			const spy1 = sinon.spy();
+			const spy2 = sinon.spy();
 
 			listener.listenTo( emitter, 'event1', spy1 );
 			listener.listenTo( emitter, 'event2', spy2 );
@@ -471,11 +470,11 @@ describe( 'EmitterMixin', () => {
 		} );
 
 		it( 'should stop listening to everything', () => {
-			let spy1 = sinon.spy();
-			let spy2 = sinon.spy();
+			const spy1 = sinon.spy();
+			const spy2 = sinon.spy();
 
-			let emitter1 = getEmitterInstance();
-			let emitter2 = getEmitterInstance();
+			const emitter1 = getEmitterInstance();
+			const emitter2 = getEmitterInstance();
 
 			listener.listenTo( emitter1, 'event1', spy1 );
 			listener.listenTo( emitter2, 'event2', spy2 );
@@ -493,10 +492,10 @@ describe( 'EmitterMixin', () => {
 		} );
 
 		it( 'should not stop other emitters when a non-listened emitter is provided', () => {
-			let spy = sinon.spy();
+			const spy = sinon.spy();
 
-			let emitter1 = getEmitterInstance();
-			let emitter2 = getEmitterInstance();
+			const emitter1 = getEmitterInstance();
+			const emitter2 = getEmitterInstance();
 
 			listener.listenTo( emitter1, 'test', spy );
 
@@ -508,8 +507,8 @@ describe( 'EmitterMixin', () => {
 		} );
 
 		it( 'should correctly stop listening to namespaced events', () => {
-			let spyFoo = sinon.spy();
-			let spyBar = sinon.spy();
+			const spyFoo = sinon.spy();
+			const spyBar = sinon.spy();
 
 			listener.listenTo( emitter, 'foo', spyFoo );
 			listener.listenTo( emitter, 'foo:bar', spyBar );
@@ -537,7 +536,7 @@ describe( 'EmitterMixin', () => {
 		} );
 
 		describe( 'to', () => {
-			it( 'forwards an event to another emitter', ( done ) => {
+			it( 'forwards an event to another emitter', done => {
 				const emitterA = getEmitterInstance();
 				const emitterB = getEmitterInstance();
 				const dataA = {};
@@ -644,7 +643,7 @@ describe( 'EmitterMixin', () => {
 				sinon.assert.callCount( spyBaz, 1 );
 			} );
 
-			it( 'supports deep chain event delegation', ( done ) => {
+			it( 'supports deep chain event delegation', done => {
 				const emitterA = getEmitterInstance();
 				const emitterB = getEmitterInstance();
 				const emitterC = getEmitterInstance();
@@ -667,7 +666,7 @@ describe( 'EmitterMixin', () => {
 				emitterC.fire( 'foo', data );
 			} );
 
-			it( 'preserves path in event delegation', ( done ) => {
+			it( 'preserves path in event delegation', done => {
 				const data = {};
 				const emitterA = getEmitterInstance();
 				const emitterB = getEmitterInstance();
@@ -797,7 +796,7 @@ describe( 'EmitterMixin', () => {
 				sinon.assert.callOrder( spyAFooQux, spyABazQux, spyABarQux );
 			} );
 
-			it( 'preserves path in delegation under a different name', ( done ) => {
+			it( 'preserves path in delegation under a different name', done => {
 				const data = {};
 				const emitterA = getEmitterInstance();
 				const emitterB = getEmitterInstance();

+ 2 - 2
packages/ckeditor5-utils/tests/eventinfo.js

@@ -7,7 +7,7 @@ import EventInfo from '../src/eventinfo';
 
 describe( 'EventInfo', () => {
 	it( 'should be created properly', () => {
-		let event = new EventInfo( this, 'test' );
+		const event = new EventInfo( this, 'test' );
 
 		expect( event.source ).to.equal( this );
 		expect( event.name ).to.equal( 'test' );
@@ -17,7 +17,7 @@ describe( 'EventInfo', () => {
 	} );
 
 	it( 'should have stop() and off() marked', () => {
-		let event = new EventInfo( this, 'test' );
+		const event = new EventInfo( this, 'test' );
 
 		event.stop();
 		event.off();

+ 4 - 4
packages/ckeditor5-utils/tests/isIterable.js

@@ -8,13 +8,13 @@ import isIterable from '../src/isiterable';
 describe( 'utils', () => {
 	describe( 'isIterable', () => {
 		it( 'should be true for string', () => {
-			let string = 'foo';
+			const string = 'foo';
 
 			expect( isIterable( string ) ).to.be.true;
 		} );
 
 		it( 'should be true for arrays', () => {
-			let array = [ 1, 2, 3 ];
+			const array = [ 1, 2, 3 ];
 
 			expect( isIterable( array ) ).to.be.true;
 		} );
@@ -30,13 +30,13 @@ describe( 'utils', () => {
 				}
 			}
 
-			let instance = new IterableClass();
+			const instance = new IterableClass();
 
 			expect( isIterable( instance ) ).to.be.true;
 		} );
 
 		it( 'should be false for not iterable objects', () => {
-			let notIterable = { foo: 'bar' };
+			const notIterable = { foo: 'bar' };
 
 			expect( isIterable( notIterable ) ).to.be.false;
 		} );

+ 1 - 1
packages/ckeditor5-utils/tests/keyboard.js

@@ -103,7 +103,7 @@ describe( 'Keyboard', () => {
 	} );
 
 	describe( 'getEnvKeystrokeText', () => {
-		let initialEnvMac = env.mac;
+		const initialEnvMac = env.mac;
 
 		afterEach( () => {
 			env.mac = initialEnvMac;

+ 1 - 1
packages/ckeditor5-utils/tests/keystrokehandler.js

@@ -61,7 +61,7 @@ describe( 'KeystrokeHandler', () => {
 			expect( wasHandled ).to.be.true;
 		} );
 
-		it( 'provides a callback which both preventDefault and stopPropagation', ( done ) => {
+		it( 'provides a callback which both preventDefault and stopPropagation', done => {
 			const keyEvtData = getCtrlA();
 
 			Object.assign( keyEvtData, {

+ 3 - 3
packages/ckeditor5-utils/tests/lodash.js

@@ -10,17 +10,17 @@ describe( 'utils', () => {
 		// Properties of the subsequent objects should override properties of the preceding objects. This is critical for
 		// CKEditor so we keep this test to ensure that Lo-Dash (or whatever) implements it in the way we need it.
 		it( 'should extend by several params in the correct order', () => {
-			let target = {
+			const target = {
 				a: 0,
 				b: 0
 			};
 
-			let ext1 = {
+			const ext1 = {
 				b: 1,
 				c: 1
 			};
 
-			let ext2 = {
+			const ext2 = {
 				c: 2,
 				d: 2
 			};

+ 4 - 4
packages/ckeditor5-utils/tests/log.js

@@ -18,8 +18,8 @@ describe( 'log', () => {
 
 	describe( 'warn()', () => {
 		it( 'logs the message to the console using console.warn()', () => {
-			let spy = sinon.stub( console, 'warn' );
-			let data = { bar: 1 };
+			const spy = sinon.stub( console, 'warn' );
+			const data = { bar: 1 };
 
 			log.warn( 'foo', data );
 
@@ -34,8 +34,8 @@ describe( 'log', () => {
 
 	describe( 'error()', () => {
 		it( 'logs the message to the console using console.error()', () => {
-			let spy = sinon.stub( console, 'error' );
-			let data = { bar: 1 };
+			const spy = sinon.stub( console, 'error' );
+			const data = { bar: 1 };
 
 			log.error( 'foo', data );
 

+ 4 - 4
packages/ckeditor5-utils/tests/manual/position/position.js

@@ -14,7 +14,7 @@ const target = document.querySelector( '.target' );
 target.scrollIntoView();
 
 const positions = {
-	nw: ( targetRect ) => ( {
+	nw: targetRect => ( {
 		top: targetRect.top,
 		left: targetRect.left,
 		name: 'nw'
@@ -36,17 +36,17 @@ const positions = {
 	} )
 };
 
-for ( let box of boxes ) {
+for ( const box of boxes ) {
 	box.scrollTop = box.scrollHeight;
 	box.scrollLeft = box.scrollWidth;
 }
 
 // Wait for the scroll to stabilize.
 setTimeout( () => {
-	for ( let source of sources ) {
+	for ( const source of sources ) {
 		const position = getOptimalPosition( {
 			element: source,
-			target: target,
+			target,
 			positions: [
 				positions[ source.className.split( '-' )[ 1 ] ]
 			],

+ 3 - 3
packages/ckeditor5-utils/tests/manual/tickets/148/1.js

@@ -16,7 +16,7 @@ const positions = {
 		left: targetRect.left,
 		name: 'above'
 	} ),
-	below: ( targetRect ) => ( {
+	below: targetRect => ( {
 		top: targetRect.bottom + 50,
 		left: targetRect.left,
 		name: 'below'
@@ -26,12 +26,12 @@ const positions = {
 function updateSourcePosition() {
 	const position = getOptimalPosition( {
 		element: source,
-		target: target,
+		target,
 		positions: [
 			positions.above,
 			positions.below,
 		],
-		limiter: limiter
+		limiter
 	} );
 
 	source.style.top = position.top + 'px';

+ 1 - 3
packages/ckeditor5-utils/tests/mix.js

@@ -35,7 +35,7 @@ describe( 'utils', () => {
 			class Foo {}
 			mix( Foo, MixinA );
 
-			let foo = new Foo();
+			const foo = new Foo();
 
 			expect( foo ).to.be.instanceof( Foo );
 		} );
@@ -93,8 +93,6 @@ describe( 'utils', () => {
 			const symbolA = Symbol( 'a' );
 			const symbolFoo = Symbol( 'foo' );
 
-			// https://github.com/jscs-dev/node-jscs/issues/2078
-			// jscs:disable disallowSpacesInFunction
 			class Foo {
 				[ symbolFoo ]() {
 					return 'foo';

+ 12 - 9
packages/ckeditor5-utils/tests/observablemixin.js

@@ -89,10 +89,10 @@ describe( 'Observable', () => {
 		} );
 
 		it( 'should fire the "change" event', () => {
-			let spy = sinon.spy();
-			let spyColor = sinon.spy();
-			let spyYear = sinon.spy();
-			let spyWheels = sinon.spy();
+			const spy = sinon.spy();
+			const spyColor = sinon.spy();
+			const spyYear = sinon.spy();
+			const spyWheels = sinon.spy();
 
 			car.on( 'change', spy );
 			car.on( 'change:color', spyColor );
@@ -122,12 +122,15 @@ describe( 'Observable', () => {
 			sinon.assert.calledWithExactly( spy, sinon.match.instanceOf( EventInfo ), 'wheels', 4, sinon.match.typeOf( 'undefined' ) );
 			sinon.assert.calledWithExactly( spyColor, sinon.match.instanceOf( EventInfo ), 'color', 'blue', 'red' );
 			sinon.assert.calledWithExactly( spyYear, sinon.match.instanceOf( EventInfo ), 'year', 2003, 2015 );
-			sinon.assert.calledWithExactly( spyWheels, sinon.match.instanceOf( EventInfo ), 'wheels', 4, sinon.match.typeOf( 'undefined' ) );
+			sinon.assert.calledWithExactly(
+				spyWheels, sinon.match.instanceOf( EventInfo ),
+				'wheels', 4, sinon.match.typeOf( 'undefined' )
+			);
 		} );
 
 		it( 'should not fire the "change" event for the same attribute value', () => {
-			let spy = sinon.spy();
-			let spyColor = sinon.spy();
+			const spy = sinon.spy();
+			const spyColor = sinon.spy();
 
 			car.on( 'change', spy );
 			car.on( 'change:color', spyColor );
@@ -166,7 +169,7 @@ describe( 'Observable', () => {
 		} );
 
 		it( 'should allow setting attributes with undefined value', () => {
-			let spy = sinon.spy();
+			const spy = sinon.spy();
 
 			car.on( 'change', spy );
 			car.set( 'seats', undefined );
@@ -572,7 +575,7 @@ describe( 'Observable', () => {
 				const car1 = new Car( { hue: 'reds' } );
 
 				vehicle.bind( 'color' )
-					.to( car1, 'hue', ( h ) => h.toUpperCase() );
+					.to( car1, 'hue', h => h.toUpperCase() );
 
 				assertBinding( vehicle,
 					{ color: car1.hue.toUpperCase(), year: undefined },

+ 1 - 1
packages/ckeditor5-utils/tests/priorities.js

@@ -7,7 +7,7 @@ import priorities from '../src/priorities';
 
 describe( 'get', () => {
 	it( 'should return correct value for string priority', () => {
-		for ( let name in priorities ) {
+		for ( const name in priorities ) {
 			if ( priorities.hasOwnProperty( name ) && name != 'get' ) {
 				expect( priorities.get( name ) ).to.equal( priorities[ name ] );
 			}

+ 3 - 3
packages/ckeditor5-utils/tests/spy.js

@@ -8,14 +8,14 @@ import spy from '../src/spy';
 describe( 'utils', () => {
 	describe( 'spy', () => {
 		it( 'should not have `called` after creation', () => {
-			let fn = spy();
+			const fn = spy();
 
 			expect( fn.called ).to.not.be.true;
 		} );
 
 		it( 'should register calls', () => {
-			let fn1 = spy();
-			let fn2 = spy();
+			const fn1 = spy();
+			const fn2 = spy();
 
 			fn1();
 

+ 2 - 1
packages/ckeditor5-utils/tests/translation-service.js

@@ -33,7 +33,8 @@ describe( 'translation-service', () => {
 		expect( translation ).to.be.equal( 'Anuluj' );
 	} );
 
-	it( 'should return english string without context if the translations for the concrete language exist, but translation doesn\'t', () => {
+	it( 'should return english string without context if the translations for the concrete language exist, ' +
+		'but translation doesn\'t', () => {
 		add( 'pl', {
 			'OK': 'OK',
 			'Cancel [context: reject]': 'Anuluj'

+ 3 - 3
packages/ckeditor5-utils/tests/uid.js

@@ -8,9 +8,9 @@ import uid from '../src/uid';
 describe( 'utils', () => {
 	describe( 'uid', () => {
 		it( 'should return different ids', () => {
-			let id1 = uid();
-			let id2 = uid();
-			let id3 = uid();
+			const id1 = uid();
+			const id2 = uid();
+			const id3 = uid();
 
 			expect( id1 ).to.be.a( 'string' );
 			expect( id2 ).to.be.a( 'string' ).to.not.equal( id1 ).to.not.equal( id3 );