Parcourir la source

Merge branch 'master' into t/50

Piotrek Koszuliński il y a 8 ans
Parent
commit
8a32587008
25 fichiers modifiés avec 138 ajouts et 254 suppressions
  1. 12 0
      packages/ckeditor5-core/.eslintrc.js
  2. 0 92
      packages/ckeditor5-core/.jscsrc
  3. 0 11
      packages/ckeditor5-core/.jshintrc
  4. 6 5
      packages/ckeditor5-core/gulpfile.js
  5. 3 2
      packages/ckeditor5-core/package.json
  6. 3 3
      packages/ckeditor5-core/src/command/helpers/getschemavalidranges.js
  7. 2 2
      packages/ckeditor5-core/src/command/helpers/isattributeallowedinselection.js
  8. 1 1
      packages/ckeditor5-core/src/command/toggleattributecommand.js
  9. 3 3
      packages/ckeditor5-core/src/editor/editor.js
  10. 1 1
      packages/ckeditor5-core/src/editor/standardeditor.js
  11. 4 4
      packages/ckeditor5-core/src/plugincollection.js
  12. 0 22
      packages/ckeditor5-core/tests/.jshintrc
  13. 6 6
      packages/ckeditor5-core/tests/_utils-tests/classictesteditor.js
  14. 5 5
      packages/ckeditor5-core/tests/_utils-tests/modeltesteditor.js
  15. 5 5
      packages/ckeditor5-core/tests/_utils-tests/virtualtesteditor.js
  16. 1 1
      packages/ckeditor5-core/tests/_utils/classictesteditor.js
  17. 1 1
      packages/ckeditor5-core/tests/_utils/modeltesteditor.js
  18. 1 1
      packages/ckeditor5-core/tests/_utils/virtualtesteditor.js
  19. 4 4
      packages/ckeditor5-core/tests/command/command.js
  20. 2 2
      packages/ckeditor5-core/tests/command/helpers/isattributeallowedinselection.js
  21. 2 2
      packages/ckeditor5-core/tests/editor/editor-base.js
  22. 27 27
      packages/ckeditor5-core/tests/editor/editor.js
  23. 2 7
      packages/ckeditor5-core/tests/editor/standardeditor.js
  24. 3 3
      packages/ckeditor5-core/tests/plugin.js
  25. 44 44
      packages/ckeditor5-core/tests/plugincollection.js

+ 12 - 0
packages/ckeditor5-core/.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 - 92
packages/ckeditor5-core/.jscsrc

@@ -1,92 +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",
-  "safeContextKeyword": [
-    "that"
-  ]
-}

+ 0 - 11
packages/ckeditor5-core/.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-core/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' ] );

+ 3 - 2
packages/ckeditor5-core/package.json

@@ -8,9 +8,10 @@
     "@ckeditor/ckeditor5-utils": "^0.9.1"
   },
   "devDependencies": {
-    "@ckeditor/ckeditor5-dev-lint": "^2.0.2",
+    "@ckeditor/ckeditor5-dev-lint": "^3.0.0",
     "@ckeditor/ckeditor5-ui": "^0.9.0",
-    "gulp": "^3.9.0",
+    "eslint-config-ckeditor5": "^1.0.0",
+    "gulp": "^3.9.1",
     "guppy-pre-commit": "^0.4.0"
   },
   "engines": {

+ 3 - 3
packages/ckeditor5-core/src/command/helpers/getschemavalidranges.js

@@ -23,19 +23,19 @@ import Position from '@ckeditor/ckeditor5-engine/src/model/position';
 export default function getSchemaValidRanges( attribute, ranges, schema ) {
 	const validRanges = [];
 
-	for ( let range of ranges ) {
+	for ( const range of ranges ) {
 		const walker = new TreeWalker( { boundaries: range, mergeCharacters: true } );
 		let step = walker.next();
 
 		let last = range.start;
 		let from = range.start;
-		let to = range.end;
+		const to = range.end;
 
 		while ( !step.done ) {
 			const name = step.value.item.name || '$text';
 			const itemPosition = Position.createBefore( step.value.item );
 
-			if ( !schema.check( { name: name, inside: itemPosition, attributes: attribute } ) ) {
+			if ( !schema.check( { name, inside: itemPosition, attributes: attribute } ) ) {
 				if ( !from.isEqual( last ) ) {
 					validRanges.push( new Range( from, last ) );
 				}

+ 2 - 2
packages/ckeditor5-core/src/command/helpers/isattributeallowedinselection.js

@@ -28,7 +28,7 @@ export default function isAttributeAllowedInSelection( attribute, selection, sch
 		const ranges = selection.getRanges();
 
 		// For all ranges, check nodes in them until you find a node that is allowed to have `attributeKey` attribute.
-		for ( let range of ranges ) {
+		for ( const range of ranges ) {
 			const walker = new TreeWalker( { boundaries: range, mergeCharacters: true } );
 			let last = walker.position;
 			let step = walker.next();
@@ -38,7 +38,7 @@ export default function isAttributeAllowedInSelection( attribute, selection, sch
 				// If returned item does not have name property, it is a model.TextFragment.
 				const name = step.value.item.name || '$text';
 
-				if ( schema.check( { name: name, inside: last, attributes: attribute } ) ) {
+				if ( schema.check( { name, inside: last, attributes: attribute } ) ) {
 					// If we found a node that is allowed to have the attribute, return true.
 					return true;
 				}

+ 1 - 1
packages/ckeditor5-core/src/command/toggleattributecommand.js

@@ -109,7 +109,7 @@ export default class ToggleAttributeCommand extends Command {
 				// Keep it as one undo step.
 				const batch = options.batch || document.batch();
 
-				for ( let range of ranges ) {
+				for ( const range of ranges ) {
 					if ( value ) {
 						batch.setAttribute( range, this.attributeKey, value );
 					} else {

+ 3 - 3
packages/ckeditor5-core/src/editor/editor.js

@@ -113,7 +113,7 @@ export default class Editor {
 		const config = this.config;
 
 		return loadPlugins()
-			.then( ( loadedPlugins ) => {
+			.then( loadedPlugins => {
 				return initPlugins( loadedPlugins, 'init' )
 					.then( () => initPlugins( loadedPlugins, 'afterInit' ) );
 			} )
@@ -157,7 +157,7 @@ export default class Editor {
 	 * @param {*} [commandParam] If set, command will be executed with this parameter.
 	 */
 	execute( commandName, commandParam ) {
-		let command = this.commands.get( commandName );
+		const command = this.commands.get( commandName );
 
 		if ( !command ) {
 			/**
@@ -179,7 +179,7 @@ export default class Editor {
 	 * @returns {module:core/editor/editor~Editor} return.editor The editor instance.
 	 */
 	static create( config ) {
-		return new Promise( ( resolve ) => {
+		return new Promise( resolve => {
 			const editor = new this( config );
 
 			resolve(

+ 1 - 1
packages/ckeditor5-core/src/editor/standardeditor.js

@@ -111,7 +111,7 @@ export default class StandardEditor extends Editor {
 	 * @returns {module:core/editor/standardeditor~StandardEditor} return.editor The editor instance.
 	 */
 	static create( element, config ) {
-		return new Promise( ( resolve ) => {
+		return new Promise( resolve => {
 			const editor = new this( element, config );
 
 			resolve(

+ 4 - 4
packages/ckeditor5-core/src/plugincollection.js

@@ -58,7 +58,7 @@ export default class PluginCollection {
 	/**
 	 * Collection iterator. Returns `[ PluginConstructor, pluginInstance ]` pairs.
 	 */
-	*[ Symbol.iterator ]() {
+	* [ Symbol.iterator ]() {
 		for ( const entry of this._plugins ) {
 			if ( typeof entry[ 0 ] == 'function' ) {
 				yield entry;
@@ -133,7 +133,7 @@ export default class PluginCollection {
 			}
 
 			return instantiatePlugin( PluginConstructor )
-				.catch( ( err ) => {
+				.catch( err => {
 					/**
 					 * It was not possible to load the plugin.
 					 *
@@ -147,13 +147,13 @@ export default class PluginCollection {
 		}
 
 		function instantiatePlugin( PluginConstructor ) {
-			return new Promise( ( resolve ) => {
+			return new Promise( resolve => {
 				loading.add( PluginConstructor );
 
 				assertIsPlugin( PluginConstructor );
 
 				if ( PluginConstructor.requires ) {
-					PluginConstructor.requires.forEach( ( RequiredPluginConstructorOrName ) => {
+					PluginConstructor.requires.forEach( RequiredPluginConstructorOrName => {
 						const RequiredPluginConstructor = getPluginConstructor( RequiredPluginConstructorOrName );
 
 						if ( removePlugins.includes( RequiredPluginConstructor ) ) {

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

+ 6 - 6
packages/ckeditor5-core/tests/_utils-tests/classictesteditor.js

@@ -108,13 +108,13 @@ describe( 'ClassicTestEditor', () => {
 			}
 
 			return ClassicTestEditor.create( editorElement, {
-					plugins: [ EventWatcher ]
-				} )
-				.then( editor => {
-					expect( fired ).to.deep.equal( [ 'pluginsReady', 'uiReady', 'dataReady', 'ready' ] );
+				plugins: [ EventWatcher ]
+			} )
+			.then( editor => {
+				expect( fired ).to.deep.equal( [ 'pluginsReady', 'uiReady', 'dataReady', 'ready' ] );
 
-					return editor.destroy();
-				} );
+				return editor.destroy();
+			} );
 		} );
 
 		it( 'inserts editor UI next to editor element', () => {

+ 5 - 5
packages/ckeditor5-core/tests/_utils-tests/modeltesteditor.js

@@ -59,11 +59,11 @@ describe( 'ModelTestEditor', () => {
 			}
 
 			return ModelTestEditor.create( {
-					plugins: [ EventWatcher ]
-				} )
-				.then( () => {
-					expect( fired ).to.deep.equal( [ 'pluginsReady', 'dataReady', 'ready' ] );
-				} );
+				plugins: [ EventWatcher ]
+			} )
+			.then( () => {
+				expect( fired ).to.deep.equal( [ 'pluginsReady', 'dataReady', 'ready' ] );
+			} );
 		} );
 	} );
 

+ 5 - 5
packages/ckeditor5-core/tests/_utils-tests/virtualtesteditor.js

@@ -58,11 +58,11 @@ describe( 'VirtualTestEditor', () => {
 			}
 
 			return VirtualTestEditor.create( {
-					plugins: [ EventWatcher ]
-				} )
-				.then( () => {
-					expect( fired ).to.deep.equal( [ 'pluginsReady', 'dataReady', 'ready' ] );
-				} );
+				plugins: [ EventWatcher ]
+			} )
+			.then( () => {
+				expect( fired ).to.deep.equal( [ 'pluginsReady', 'dataReady', 'ready' ] );
+			} );
 		} );
 	} );
 } );

+ 1 - 1
packages/ckeditor5-core/tests/_utils/classictesteditor.js

@@ -51,7 +51,7 @@ export default class ClassicTestEditor extends StandardEditor {
 	 * @inheritDoc
 	 */
 	static create( element, config ) {
-		return new Promise( ( resolve ) => {
+		return new Promise( resolve => {
 			const editor = new this( element, config );
 
 			resolve(

+ 1 - 1
packages/ckeditor5-core/tests/_utils/modeltesteditor.js

@@ -47,7 +47,7 @@ export default class ModelTestEditor extends Editor {
 	 * @returns {core.editor.VirtualTestEditor} return.editor The editor instance.
 	 */
 	static create( config ) {
-		return new Promise( ( resolve ) => {
+		return new Promise( resolve => {
 			const editor = new this( config );
 
 			resolve(

+ 1 - 1
packages/ckeditor5-core/tests/_utils/virtualtesteditor.js

@@ -33,7 +33,7 @@ export default class VirtualTestEditor extends StandardEditor {
 	 * @returns {core.editor.VirtualTestEditor} return.editor The editor instance.
 	 */
 	static create( config ) {
-		return new Promise( ( resolve ) => {
+		return new Promise( resolve => {
 			const editor = new this( config );
 
 			resolve(

+ 4 - 4
packages/ckeditor5-core/tests/command/command.js

@@ -52,7 +52,7 @@ describe( 'Command', () => {
 
 			expect( command._checkEnabled.called ).to.be.false;
 
-			let newCommand = new CommandWithSchema( editor, true );
+			const newCommand = new CommandWithSchema( editor, true );
 			sinon.spy( newCommand, '_checkEnabled' );
 
 			newCommand.refreshState();
@@ -73,7 +73,7 @@ describe( 'Command', () => {
 
 	describe( 'refreshState', () => {
 		it( 'should fire refreshState event', () => {
-			let spy = sinon.spy();
+			const spy = sinon.spy();
 
 			command.on( 'refreshState', spy );
 			command.refreshState();
@@ -90,7 +90,7 @@ describe( 'Command', () => {
 		} );
 
 		it( 'should set isEnabled to false if _checkEnabled returns false', () => {
-			let disabledCommand = new CommandWithSchema( editor, false );
+			const disabledCommand = new CommandWithSchema( editor, false );
 
 			disabledCommand.refreshState();
 
@@ -106,7 +106,7 @@ describe( 'Command', () => {
 		} );
 
 		it( 'should not make command disabled if there is a high-priority listener forcing command to be enabled', () => {
-			command.on( 'refreshState', ( evt ) => {
+			command.on( 'refreshState', evt => {
 				evt.stop();
 
 				return true;

+ 2 - 2
packages/ckeditor5-core/tests/command/helpers/isattributeallowedinselection.js

@@ -9,11 +9,11 @@ import { setData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
 
 describe( 'isAttributeAllowedInSelection', () => {
 	const attribute = 'bold';
-	let document, root;
+	let document;
 
 	beforeEach( () => {
 		document = new Document();
-		root = document.createRoot();
+		document.createRoot();
 
 		document.schema.registerItem( 'p', '$block' );
 		document.schema.registerItem( 'h1', '$block' );

+ 2 - 2
packages/ckeditor5-core/tests/editor/editor-base.js

@@ -27,7 +27,7 @@ describe( 'Editor', () => {
 	describe( 'destroy', () => {
 		it( 'should fire "destroy"', () => {
 			const editor = new Editor();
-			let spy = sinon.spy();
+			const spy = sinon.spy();
 
 			editor.on( 'destroy', spy );
 
@@ -54,7 +54,7 @@ describe( 'Editor', () => {
 		it( 'should execute specified command', () => {
 			const editor = new Editor();
 
-			let command = new Command( editor );
+			const command = new Command( editor );
 			sinon.spy( command, '_execute' );
 
 			editor.commands.set( 'commandName', command );

+ 27 - 27
packages/ckeditor5-core/tests/editor/editor.js

@@ -119,7 +119,7 @@ describe( 'Editor', () => {
 
 	describe( 'create', () => {
 		it( 'should return a promise that resolves properly', () => {
-			let promise = Editor.create();
+			const promise = Editor.create();
 
 			expect( promise ).to.be.an.instanceof( Promise );
 
@@ -128,8 +128,8 @@ describe( 'Editor', () => {
 
 		it( 'loads plugins', () => {
 			return Editor.create( {
-					plugins: [ PluginA ]
-				} )
+				plugins: [ PluginA ]
+			} )
 				.then( editor => {
 					expect( getPlugins( editor ).length ).to.equal( 1 );
 
@@ -152,9 +152,7 @@ describe( 'Editor', () => {
 				}
 			}
 
-			return Editor.create( {
-					plugins: [ EventWatcher ]
-				} )
+			return Editor.create( { plugins: [ EventWatcher ] } )
 				.then( () => {
 					expect( fired ).to.deep.equal( [ 'pluginsReady', 'dataReady', 'ready' ] );
 				} );
@@ -220,7 +218,7 @@ describe( 'Editor', () => {
 					super( editor );
 
 					this.init = sinon.spy( () => {
-						return new Promise( ( resolve ) => {
+						return new Promise( resolve => {
 							setTimeout( () => {
 								asyncSpy();
 								resolve();
@@ -234,15 +232,16 @@ describe( 'Editor', () => {
 				plugins: [ PluginA, PluginSync ]
 			} );
 
-			return editor.initPlugins().then( () => {
-				sinon.assert.callOrder(
-					editor.plugins.get( PluginA ).init,
-					editor.plugins.get( PluginAsync ).init,
-					// This one is called with delay by the async init.
-					asyncSpy,
-					editor.plugins.get( PluginSync ).init
-				);
-			} );
+			return editor.initPlugins()
+				.then( () => {
+					sinon.assert.callOrder(
+						editor.plugins.get( PluginA ).init,
+						editor.plugins.get( PluginAsync ).init,
+						// This one is called with delay by the async init.
+						asyncSpy,
+						editor.plugins.get( PluginSync ).init
+					);
+				} );
 		} );
 
 		it( 'should initialize plugins in the right order, waiting for asynchronous afterInit()', () => {
@@ -265,7 +264,7 @@ describe( 'Editor', () => {
 					super( editor );
 
 					this.afterInit = sinon.spy( () => {
-						return new Promise( ( resolve ) => {
+						return new Promise( resolve => {
 							setTimeout( () => {
 								asyncSpy();
 								resolve();
@@ -279,16 +278,17 @@ describe( 'Editor', () => {
 				plugins: [ PluginA, PluginSync ]
 			} );
 
-			return editor.initPlugins().then( () => {
-				sinon.assert.callOrder(
-					editor.plugins.get( PluginA ).afterInit,
-					editor.plugins.get( PluginAsync ).afterInit,
-
-					// This one is called with delay by the async init.
-					asyncSpy,
-					editor.plugins.get( PluginSync ).afterInit
-				);
-			} );
+			return editor.initPlugins()
+				.then( () => {
+					sinon.assert.callOrder(
+						editor.plugins.get( PluginA ).afterInit,
+						editor.plugins.get( PluginAsync ).afterInit,
+
+						// This one is called with delay by the async init.
+						asyncSpy,
+						editor.plugins.get( PluginSync ).afterInit
+					);
+				} );
 		} );
 
 		it( 'should load plugins built in the Editor even if the passed config is empty', () => {

+ 2 - 7
packages/ckeditor5-core/tests/editor/standardeditor.js

@@ -93,10 +93,7 @@ describe( 'StandardEditor', () => {
 		it( 'initializes editor with plugins and config', () => {
 			class PluginFoo extends Plugin {}
 
-			return StandardEditor.create( editorElement, {
-					foo: 1,
-					plugins: [ PluginFoo ]
-				} )
+			return StandardEditor.create( editorElement, { foo: 1, plugins: [ PluginFoo ] } )
 				.then( editor => {
 					expect( editor ).to.be.instanceof( StandardEditor );
 
@@ -122,9 +119,7 @@ describe( 'StandardEditor', () => {
 				}
 			}
 
-			return StandardEditor.create( editorElement, {
-					plugins: [ EventWatcher ]
-				} )
+			return StandardEditor.create( editorElement, { plugins: [ EventWatcher ] } )
 				.then( () => {
 					expect( fired ).to.deep.equal( [ 'pluginsReady', 'dataReady', 'ready' ] );
 				} );

+ 3 - 3
packages/ckeditor5-core/tests/plugin.js

@@ -14,7 +14,7 @@ before( () => {
 
 describe( 'constructor()', () => {
 	it( 'should set the `editor` property', () => {
-		let plugin = new Plugin( editor );
+		const plugin = new Plugin( editor );
 
 		expect( plugin ).to.have.property( 'editor' ).to.equal( editor );
 	} );
@@ -22,7 +22,7 @@ describe( 'constructor()', () => {
 
 describe( 'init', () => {
 	it( 'should exist and do nothing', () => {
-		let plugin = new Plugin( editor );
+		const plugin = new Plugin( editor );
 
 		expect( plugin.init ).to.be.a( 'function' );
 
@@ -32,7 +32,7 @@ describe( 'init', () => {
 
 describe( 'destroy', () => {
 	it( 'should exist and do nothing', () => {
-		let plugin = new Plugin( editor );
+		const plugin = new Plugin( editor );
 
 		expect( plugin.destroy ).to.be.a( 'function' );
 

+ 44 - 44
packages/ckeditor5-core/tests/plugincollection.js

@@ -69,7 +69,7 @@ describe( 'PluginCollection', () => {
 
 	describe( 'load()', () => {
 		it( 'should not fail when trying to load 0 plugins (empty array)', () => {
-			let plugins = new PluginCollection( editor, availablePlugins );
+			const plugins = new PluginCollection( editor, availablePlugins );
 
 			return plugins.load( [] )
 				.then( () => {
@@ -78,7 +78,7 @@ describe( 'PluginCollection', () => {
 		} );
 
 		it( 'should add collection items for loaded plugins', () => {
-			let plugins = new PluginCollection( editor, availablePlugins );
+			const plugins = new PluginCollection( editor, availablePlugins );
 
 			return plugins.load( [ PluginA, PluginB ] )
 				.then( () => {
@@ -90,7 +90,7 @@ describe( 'PluginCollection', () => {
 		} );
 
 		it( 'should add collection items for loaded plugins using plugin names', () => {
-			let plugins = new PluginCollection( editor, availablePlugins );
+			const plugins = new PluginCollection( editor, availablePlugins );
 
 			return plugins.load( [ 'A', 'B' ] )
 				.then( () => {
@@ -102,11 +102,11 @@ describe( 'PluginCollection', () => {
 		} );
 
 		it( 'should load dependency plugins', () => {
-			let plugins = new PluginCollection( editor, availablePlugins );
-			let spy = sinon.spy( plugins, '_add' );
+			const plugins = new PluginCollection( editor, availablePlugins );
+			const spy = sinon.spy( plugins, '_add' );
 
 			return plugins.load( [ PluginA, PluginC ] )
-				.then( ( loadedPlugins ) => {
+				.then( loadedPlugins => {
 					expect( getPlugins( plugins ).length ).to.equal( 3 );
 
 					expect( getPluginNames( getPluginsFromSpy( spy ) ) )
@@ -117,11 +117,11 @@ describe( 'PluginCollection', () => {
 		} );
 
 		it( 'should load dependency plugins defined by plugin names', () => {
-			let plugins = new PluginCollection( editor, availablePlugins );
-			let spy = sinon.spy( plugins, '_add' );
+			const plugins = new PluginCollection( editor, availablePlugins );
+			const spy = sinon.spy( plugins, '_add' );
 
 			return plugins.load( [ 'J' ] )
-				.then( ( loadedPlugins ) => {
+				.then( loadedPlugins => {
 					expect( getPlugins( plugins ).length ).to.equal( 3 );
 
 					expect( getPluginNames( getPluginsFromSpy( spy ) ) )
@@ -132,11 +132,11 @@ describe( 'PluginCollection', () => {
 		} );
 
 		it( 'should be ok when dependencies are loaded first', () => {
-			let plugins = new PluginCollection( editor, availablePlugins );
-			let spy = sinon.spy( plugins, '_add' );
+			const plugins = new PluginCollection( editor, availablePlugins );
+			const spy = sinon.spy( plugins, '_add' );
 
 			return plugins.load( [ PluginA, PluginB, PluginC ] )
-				.then( ( loadedPlugins ) => {
+				.then( loadedPlugins => {
 					expect( getPlugins( plugins ).length ).to.equal( 3 );
 
 					expect( getPluginNames( getPluginsFromSpy( spy ) ) )
@@ -147,11 +147,11 @@ describe( 'PluginCollection', () => {
 		} );
 
 		it( 'should load deep dependency plugins', () => {
-			let plugins = new PluginCollection( editor, availablePlugins );
-			let spy = sinon.spy( plugins, '_add' );
+			const plugins = new PluginCollection( editor, availablePlugins );
+			const spy = sinon.spy( plugins, '_add' );
 
 			return plugins.load( [ PluginD ] )
-				.then( ( loadedPlugins ) => {
+				.then( loadedPlugins => {
 					expect( getPlugins( plugins ).length ).to.equal( 4 );
 
 					// The order must have dependencies first.
@@ -163,11 +163,11 @@ describe( 'PluginCollection', () => {
 		} );
 
 		it( 'should handle cross dependency plugins', () => {
-			let plugins = new PluginCollection( editor, availablePlugins );
-			let spy = sinon.spy( plugins, '_add' );
+			const plugins = new PluginCollection( editor, availablePlugins );
+			const spy = sinon.spy( plugins, '_add' );
 
 			return plugins.load( [ PluginA, PluginE ] )
-				.then( ( loadedPlugins ) => {
+				.then( loadedPlugins => {
 					expect( getPlugins( plugins ).length ).to.equal( 3 );
 
 					// The order must have dependencies first.
@@ -179,7 +179,7 @@ describe( 'PluginCollection', () => {
 		} );
 
 		it( 'should load grand child classes', () => {
-			let plugins = new PluginCollection( editor, availablePlugins );
+			const plugins = new PluginCollection( editor, availablePlugins );
 
 			return plugins.load( [ PluginG ] )
 				.then( () => {
@@ -188,7 +188,7 @@ describe( 'PluginCollection', () => {
 		} );
 
 		it( 'should set the `editor` property on loaded plugins', () => {
-			let plugins = new PluginCollection( editor, availablePlugins );
+			const plugins = new PluginCollection( editor, availablePlugins );
 
 			return plugins.load( [ PluginA, PluginB ] )
 				.then( () => {
@@ -198,16 +198,16 @@ describe( 'PluginCollection', () => {
 		} );
 
 		it( 'should reject on broken plugins (forward the error thrown in a plugin)', () => {
-			let logSpy = testUtils.sinon.stub( log, 'error' );
+			const logSpy = testUtils.sinon.stub( log, 'error' );
 
-			let plugins = new PluginCollection( editor, availablePlugins );
+			const plugins = new PluginCollection( editor, availablePlugins );
 
 			return plugins.load( [ PluginA, PluginX, PluginB ] )
 				// Throw here, so if by any chance plugins.load() was resolved correctly catch() will be stil executed.
 				.then( () => {
 					throw new Error( 'Test error: this promise should not be resolved successfully' );
 				} )
-				.catch( ( err ) => {
+				.catch( err => {
 					expect( err ).to.be.an.instanceof( TestError );
 					expect( err ).to.have.property( 'message', 'Some error inside a plugin' );
 
@@ -221,16 +221,16 @@ describe( 'PluginCollection', () => {
 
 			availablePlugins.push( Y );
 
-			let logSpy = testUtils.sinon.stub( log, 'error' );
+			const logSpy = testUtils.sinon.stub( log, 'error' );
 
-			let plugins = new PluginCollection( editor, availablePlugins );
+			const plugins = new PluginCollection( editor, availablePlugins );
 
 			return plugins.load( [ Y ] )
 				// Throw here, so if by any chance plugins.load() was resolved correctly catch() will be stil executed.
 				.then( () => {
 					throw new Error( 'Test error: this promise should not be resolved successfully' );
 				} )
-				.catch( ( err ) => {
+				.catch( err => {
 					expect( err ).to.be.an.instanceof( CKEditorError );
 					expect( err.message ).to.match( /^plugincollection-instance/ );
 
@@ -240,16 +240,16 @@ describe( 'PluginCollection', () => {
 		} );
 
 		it( 'should reject when loading non-existent plugin', () => {
-			let logSpy = testUtils.sinon.stub( log, 'error' );
+			const logSpy = testUtils.sinon.stub( log, 'error' );
 
-			let plugins = new PluginCollection( editor, availablePlugins );
+			const plugins = new PluginCollection( editor, availablePlugins );
 
 			return plugins.load( [ 'NonExistentPlugin' ] )
 				// Throw here, so if by any chance plugins.load() was resolved correctly catch() will be stil executed.
 				.then( () => {
 					throw new Error( 'Test error: this promise should not be resolved successfully' );
 				} )
-				.catch( ( err ) => {
+				.catch( err => {
 					expect( err ).to.be.an.instanceof( CKEditorError );
 					expect( err.message ).to.match( /^plugincollection-plugin-not-found/ );
 
@@ -259,7 +259,7 @@ describe( 'PluginCollection', () => {
 		} );
 
 		it( 'should load chosen plugins (plugins and removePlugins are constructors)', () => {
-			let plugins = new PluginCollection( editor, availablePlugins );
+			const plugins = new PluginCollection( editor, availablePlugins );
 
 			return plugins.load( [ PluginA, PluginB, PluginC ], [ PluginA ] )
 				.then( () => {
@@ -271,7 +271,7 @@ describe( 'PluginCollection', () => {
 		} );
 
 		it( 'should load chosen plugins (plugins are constructors, removePlugins are names)', () => {
-			let plugins = new PluginCollection( editor, availablePlugins );
+			const plugins = new PluginCollection( editor, availablePlugins );
 
 			return plugins.load( [ PluginA, PluginB, PluginC ], [ 'A' ] )
 				.then( () => {
@@ -283,7 +283,7 @@ describe( 'PluginCollection', () => {
 		} );
 
 		it( 'should load chosen plugins (plugins and removePlugins are names)', () => {
-			let plugins = new PluginCollection( editor, availablePlugins );
+			const plugins = new PluginCollection( editor, availablePlugins );
 
 			return plugins.load( [ 'A', 'B', 'C' ], [ 'A' ] )
 				.then( () => {
@@ -295,7 +295,7 @@ describe( 'PluginCollection', () => {
 		} );
 
 		it( 'should load chosen plugins (plugins are names, removePlugins are constructors)', () => {
-			let plugins = new PluginCollection( editor, availablePlugins );
+			const plugins = new PluginCollection( editor, availablePlugins );
 
 			return plugins.load( [ 'A', 'B', 'C' ], [ PluginA ] )
 				.then( () => {
@@ -309,7 +309,7 @@ describe( 'PluginCollection', () => {
 		it( 'should load chosen plugins (plugins are names, removePlugins contains an anonymous plugin)', () => {
 			class AnonymousPlugin extends Plugin {}
 
-			let plugins = new PluginCollection( editor, [ AnonymousPlugin ].concat( availablePlugins ) );
+			const plugins = new PluginCollection( editor, [ AnonymousPlugin ].concat( availablePlugins ) );
 
 			return plugins.load( [ AnonymousPlugin, 'A', 'B' ], [ AnonymousPlugin ] )
 				.then( () => {
@@ -321,15 +321,15 @@ describe( 'PluginCollection', () => {
 		} );
 
 		it( 'should reject when loaded plugin requires not allowed plugins', () => {
-			let logSpy = testUtils.sinon.stub( log, 'error' );
-			let plugins = new PluginCollection( editor, availablePlugins );
+			const logSpy = testUtils.sinon.stub( log, 'error' );
+			const plugins = new PluginCollection( editor, availablePlugins );
 
 			return plugins.load( [ PluginA, PluginB, PluginC, PluginD ], [ PluginA, PluginB ] )
 				// Throw here, so if by any chance plugins.load() was resolved correctly catch() will be stil executed.
 				.then( () => {
 					throw new Error( 'Test error: this promise should not be resolved successfully' );
 				} )
-				.catch( ( err ) => {
+				.catch( err => {
 					expect( err ).to.be.an.instanceof( CKEditorError );
 					expect( err.message ).to.match( /^plugincollection-required/ );
 
@@ -344,7 +344,7 @@ describe( 'PluginCollection', () => {
 
 			availablePlugins.push( SomePlugin );
 
-			let plugins = new PluginCollection( editor, availablePlugins );
+			const plugins = new PluginCollection( editor, availablePlugins );
 
 			return plugins.load( [ SomePlugin ] )
 				.then( () => {
@@ -358,7 +358,7 @@ describe( 'PluginCollection', () => {
 
 			availablePlugins.push( SomePlugin );
 
-			let plugins = new PluginCollection( editor, availablePlugins );
+			const plugins = new PluginCollection( editor, availablePlugins );
 
 			return plugins.load( [ SomePlugin ] )
 				.then( () => {
@@ -370,7 +370,7 @@ describe( 'PluginCollection', () => {
 
 	describe( 'iterator', () => {
 		it( 'exists', () => {
-			let plugins = new PluginCollection( editor, availablePlugins );
+			const plugins = new PluginCollection( editor, availablePlugins );
 
 			expect( plugins ).to.have.property( Symbol.iterator );
 		} );
@@ -383,7 +383,7 @@ describe( 'PluginCollection', () => {
 			availablePlugins.push( SomePlugin1 );
 			availablePlugins.push( SomePlugin2 );
 
-			let plugins = new PluginCollection( editor, availablePlugins );
+			const plugins = new PluginCollection( editor, availablePlugins );
 
 			return plugins.load( [ SomePlugin1, SomePlugin2 ] )
 				.then( () => {
@@ -416,12 +416,12 @@ function getPlugins( pluginCollection ) {
 
 function getPluginsFromSpy( addSpy ) {
 	return addSpy.args
-		.map( ( arg ) => arg[ 0 ] )
+		.map( arg => arg[ 0 ] )
 		// Entries may be kept twice in the plugins map - once as a pluginName => plugin, once as pluginClass => plugin.
 		// Return only pluginClass => plugin entries as these will always represent all plugins.
-		.filter( ( plugin ) => typeof plugin == 'function' );
+		.filter( plugin => typeof plugin == 'function' );
 }
 
 function getPluginNames( plugins ) {
-	return plugins.map( ( plugin ) => plugin.pluginName );
+	return plugins.map( plugin => plugin.pluginName );
 }