Преглед на файлове

Merge branch 'master' into t/36

Szymon Kupś преди 10 години
родител
ревизия
4827816d0d

+ 6 - 1
.jshintrc

@@ -9,6 +9,11 @@
 	"undef": true,
 	"unused": true,
 	"strict": true,
+	"varstmt": true,
 
-	"globalstrict": true
+	"globalstrict": true,
+
+	"globals": {
+		"CKEDITOR": false
+	}
 }

+ 2 - 2
bender.js

@@ -3,9 +3,9 @@
 'use strict';
 
 // Set it to true to test with the build version.
-var isBuild = false;
+const isBuild = false;
 
-var config = {
+const config = {
 	plugins: [
 		'benderjs-chai',
 		'benderjs-coverage',

+ 8 - 8
ckeditor.js

@@ -10,7 +10,7 @@
 // This file is shared by the dev and release versions of CKEditor. It bootstraps the API.
 
 ( function( root ) {
-	var CKEDITOR = root.CKEDITOR = {
+	const CKEDITOR = root.CKEDITOR = {
 		/**
 		 * Computes the value of the `basePath` property.
 		 *
@@ -63,7 +63,7 @@
 		 * @method
 		 * @member CKEDITOR
 		 */
-		define: function( name, deps ) {
+		define( name, deps ) {
 			// If this is a named module with dependencies, save this in the dependency list.
 			if ( Array.isArray( deps ) && name && !this._dependencies[ name ] ) {
 				this._dependencies[ name ] = deps;
@@ -102,7 +102,7 @@
 	} );
 
 	// Define a new "ckeditor" module, which overrides the core one with the above and the dev stuff.
-	define( 'ckeditor', [ 'ckeditor-core', 'ckeditor-dev', 'utils' ], function( core, dev, utils ) {
+	define( 'ckeditor', [ 'ckeditor-core', 'ckeditor-dev', 'utils' ], ( core, dev, utils ) => {
 		root.CKEDITOR = utils.extend( {}, core, root.CKEDITOR, ( dev || /* istanbul ignore next */ {} ) );
 
 		return root.CKEDITOR;
@@ -113,13 +113,13 @@
 			return window.CKEDITOR_BASEPATH;
 		}
 
-		var scripts = document.getElementsByTagName( 'script' );
-		var basePathSrcPattern = /(^|.*[\\\/])ckeditor\.js(?:\?.*|;.*)?$/i;
-		var path;
+		const scripts = document.getElementsByTagName( 'script' );
+		const basePathSrcPattern = /(^|.*[\\\/])ckeditor\.js(?:\?.*|;.*)?$/i;
+		let path;
 
 		// Find the first script that src matches ckeditor.js.
-		[].some.call( scripts, function( script ) {
-			var match = script.src.match( basePathSrcPattern );
+		[].some.call( scripts, ( script ) => {
+			const match = script.src.match( basePathSrcPattern );
 
 			if ( match ) {
 				path = match[ 1 ];

+ 2 - 1
dev/.jshintrc

@@ -8,5 +8,6 @@
 	"nonbsp": true,
 	"undef": true,
 	"unused": true,
-	"strict": true
+	"strict": true,
+	"varstmt": true
 }

+ 7 - 10
dev/bender/plugins/ckeditor5/lib/index.js

@@ -5,8 +5,8 @@
 
 'use strict';
 
-var path = require( 'path' );
-var files = [
+const path = require( 'path' );
+const files = [
 	path.join( __dirname, '../static/extensions.js' ),
 	path.join( __dirname, '../static/tools.js' )
 ];
@@ -14,14 +14,11 @@ var files = [
 module.exports = {
 	name: 'bender-ckeditor5',
 
-	attach: function() {
-		var that = this;
-		var bender = that;
+	attach() {
+		this.plugins.addFiles( files );
 
-		bender.plugins.addFiles( files );
-
-		bender.on( 'test:created', function( test ) {
-			var name = test.displayName;
+		this.on( 'test:created', ( test ) => {
+			let name = test.displayName;
 
 			name = name.replace( /node_modules\/ckeditor5-core/, 'core: ' );
 			name = name.replace( /node_modules\/ckeditor5-plugin-([^\/]+)/, 'plugin!$1: ' );
@@ -34,7 +31,7 @@ module.exports = {
 		this.pagebuilders.add( 'ckeditor5', build, this.pagebuilders.getPriority( 'includes' ) - 1 );
 
 		function build( data ) {
-			files.forEach( function( file ) {
+			files.forEach( ( file ) => {
 				data.addJS( path.join( '/plugins/', file ).split( path.sep ).join( '/' ) );
 			} );
 

+ 7 - 8
dev/bender/plugins/ckeditor5/static/extensions.js

@@ -8,9 +8,9 @@
 
 'use strict';
 
-( function() {
+( () => {
 	// Make Bender wait to start running tests.
-	var done = bender.defer();
+	const done = bender.defer();
 
 	// Wait for the "ckeditor" module to be ready to start testing.
 	CKEDITOR.require( [ 'ckeditor' ], done );
@@ -25,18 +25,17 @@
 		 * @params {...String} module The name of the module to load.
 		 * @returns {Object} The object that will hold the loaded modules.
 		 */
-		require: function() {
-			var modules = {};
+		require() {
+			const modules = {};
+			const done = bender.defer();
 
-			var done = bender.defer();
-
-			var names = [].slice.call( arguments );
+			const names = [].slice.call( arguments );
 
 			// To avoid race conditions with required modules, require `ckeditor` first and then others. This guarantees
 			// that `ckeditor` will be loaded before any other module.
 			CKEDITOR.require( [ 'ckeditor' ], function() {
 				CKEDITOR.require( names, function() {
-					for ( var i = 0; i < names.length; i++ ) {
+					for ( let i = 0; i < names.length; i++ ) {
 						modules[ names[ i ] ] = arguments[ i ] ;
 					}
 

+ 4 - 4
dev/bender/plugins/ckeditor5/static/tools.js

@@ -8,7 +8,7 @@
 
 'use strict';
 
-( function() {
+( () => {
 	/**
 	 * Test tools for CKEditor.
 	 *
@@ -35,16 +35,16 @@
 		 *		bender.tools.createSinonSandbox();
 		 *
 		 *		// Then inside tests you can use bender.sinon:
-		 *		it( 'does something', function() {
+		 *		it( 'does something', () => {
 		 *			bender.sinon.spy( obj, 'method' );
 		 *		} );
 		 */
 		createSinonSandbox() {
-			before( function() {
+			before( () => {
 				bender.sinon = sinon.sandbox.create();
 			} );
 
-			afterEach( function() {
+			afterEach( () => {
 				bender.sinon.restore();
 			} );
 		}

+ 4 - 5
dev/tasks/build.js

@@ -3,16 +3,15 @@
  * For licensing, see LICENSE.md.
  */
 
-/* jshint node: true */
-
 'use strict';
 
-var Builder = require( './build/builder' );
+const Builder = require( './build/builder' );
 
 module.exports = function( grunt ) {
 	grunt.registerTask( 'build', 'Build a release out of the current development code.', function() {
-		var done = this.async();
-		var builder = new Builder();
+		const done = this.async();
+		const builder = new Builder();
+
 		builder.build( done );
 	} );
 };

+ 158 - 158
dev/tasks/build/builder.js

@@ -5,56 +5,54 @@
 
 'use strict';
 
-module.exports = Builder;
-
 /**
  * A CKEditor 5 release builder.
  *
  * @class Builder
  */
-function Builder( target ) {
-	/**
-	 * The target directory where to create the build.
-	 *
-	 * **Warning**: if existing, this directory will be deleted before processing.
-	 *
-	 * @property {String}
-	 */
-	this.target = target || 'build';
+class Builder {
+	constructor( target ) {
+		/**
+		 * The target directory where to create the build.
+		 *
+		 * **Warning**: if existing, this directory will be deleted before processing.
+		 *
+		 * @property {String}
+		 */
+		this.target = target || 'build';
 
-	/**
-	 * The temporary directory to use for build processing.
-	 *
-	 * **Warning**: if existing, this directory will be deleted before processing.
-	 *
-	 * @property {String}
-	 */
-	this.tmp = 'build-tmp';
+		/**
+		 * The temporary directory to use for build processing.
+		 *
+		 * **Warning**: if existing, this directory will be deleted before processing.
+		 *
+		 * @property {String}
+		 */
+		this.tmp = 'build-tmp';
 
-	/**
-	 * The list of tasks to be executed by the `build()` method. Each entry is an Array containing the name of the
-	 * method inside `tasks` to execute and the message to show to the end user when executing it.
-	 *
-	 * @property {Array}
-	 */
-	this.taskList = [
-		[ 'cleanUp', 'Cleaning the "' + this.target + '" directory...' ],
-		[ 'copyToTmp', 'Copying source files for manipulation...' ],
-		[ 'removeAmdNamespace', 'AMD cleanup...' ],
-		[ 'optimize', 'Creating the optimized code...' ],
-		[ 'cleanUpTmp', 'Removing the "' + this.tmp + '" directory...' ]
-	];
-}
+		/**
+		 * The list of tasks to be executed by the `build()` method. Each entry is an Array containing the name of the
+		 * method inside `tasks` to execute and the message to show to the end user when executing it.
+		 *
+		 * @property {Array}
+		 */
+		this.taskList = [
+			[ 'cleanUp', 'Cleaning the "' + this.target + '" directory...' ],
+			[ 'copyToTmp', 'Copying source files for manipulation...' ],
+			[ 'removeAmdNamespace', 'AMD cleanup...' ],
+			[ 'optimize', 'Creating the optimized code...' ],
+			[ 'cleanUpTmp', 'Removing the "' + this.tmp + '" directory...' ]
+		];
+	}
 
-Builder.prototype = {
 	/**
 	 * Builds a CKEditor release based on the current development code.
 	 *
 	 * @param {Function} [callback] Function to be called when build finishes. It receives `false` on error.
 	 */
-	build: function( callback ) {
-		var that = this;
-		var stepCounter = 0;
+	build( callback ) {
+		const that = this;
+		let stepCounter = 0;
 
 		// Before starting, run the initial checkups.
 		if ( !this.checkUp() ) {
@@ -69,22 +67,22 @@ Builder.prototype = {
 		runNext();
 
 		function runNext() {
-			var next = that.taskList.shift();
+			const next = that.taskList.shift();
 
 			if ( next ) {
 				stepCounter++;
 				console.log( stepCounter + '. ' + next[ 1 ] );
-				that.tasks[ next[ 0 ] ].call( that, runNext );
+				Builder.tasks[ next[ 0 ] ].call( that, runNext );
 			} else {
 				if ( callback ) {
 					callback();
 				}
 			}
 		}
-	},
+	}
 
-	checkUp: function() {
-		var fs = require( 'fs' );
+	checkUp() {
+		const fs = require( 'fs' );
 
 		// Stop if the tmp folder already exists.
 		if ( fs.existsSync( this.tmp ) ) {
@@ -94,143 +92,145 @@ Builder.prototype = {
 		}
 
 		return true;
-	},
+	}
+}
 
+/**
+ * Holds individual methods for each task executed by the builder.
+ *
+ * All methods here MUST be called in the builder context by using
+ * `builder.tasks.someMethod.call( builder, callback )`.
+ */
+Builder.tasks = {
 	/**
-	 * Holds individual methods for each task executed by the builder.
+	 * Deletes the `target` and `tmp` directories.
 	 *
-	 * All methods here MUST be called in the builder context by using
-	 * `builder.tasks.someMethod.call( builder, callback )`.
+	 * @param {Function} callback Function to be called when the task is done.
+	 * @returns {Object} The callback returned value.
 	 */
-	tasks: {
-		/**
-		 * Deletes the `target` and `tmp` directories.
-		 *
-		 * @param {Function} callback Function to be called when the task is done.
-		 * @returns {Object} The callback returned value.
-		 */
-		cleanUp: function( callback ) {
-			var del = require( 'del' );
-			del.sync( this.target );
-			del.sync( this.tmp );
-
-			return callback();
-		},
+	cleanUp( callback ) {
+		const del = require( 'del' );
+		del.sync( this.target );
+		del.sync( this.tmp );
 
-		/**
-		 * Copy the local source code of CKEditor and its dependencies to the `tmp` directory for processing.
-		 *
-		 * @param {Function} callback Function to be called when the task is done.
-		 * @returns {Object} The callback returned value.
-		 */
-		copyToTmp: function( callback ) {
-			var ncp = require( 'ncp' ).ncp;
-			var path = require( 'path' );
-			var fs = require( 'fs' );
-			var tmp = this.tmp;
-
-			var deps = require( '../../../package.json' ).dependencies;
+		return callback();
+	},
 
-			var toCopy = Object.keys( deps ).filter( function( name ) {
-				return name.indexOf( 'ckeditor5-' ) === 0;
-			} );
+	/**
+	 * Copy the local source code of CKEditor and its dependencies to the `tmp` directory for processing.
+	 *
+	 * @param {Function} callback Function to be called when the task is done.
+	 * @returns {Object} The callback returned value.
+	 */
+	copyToTmp( callback ) {
+		const ncp = require( 'ncp' ).ncp;
+		const path = require( 'path' );
+		const fs = require( 'fs' );
+		const tmp = this.tmp;
 
-			fs.mkdirSync( tmp );
+		const deps = require( '../../../package.json' ).dependencies;
 
-			function copy() {
-				var module = toCopy.shift();
+		const toCopy = Object.keys( deps ).filter( function( name ) {
+			return name.indexOf( 'ckeditor5-' ) === 0;
+		} );
 
-				if ( !module ) {
-					return callback();
-				}
+		fs.mkdirSync( tmp );
 
-				var dest = path.join( tmp + '/', module );
+		function copy() {
+			const module = toCopy.shift();
 
-				if ( !fs.existsSync( dest ) ) {
-					fs.mkdirSync( dest );
-				}
+			if ( !module ) {
+				return callback();
+			}
 
-				// Copy the "src" directory only.
-				ncp( path.join( 'node_modules', module, 'src' ), path.join( dest, 'src' ), {
-					dereference: true
-				}, function( err ) {
-					if ( err ) {
-						throw err;
-					}
+			const dest = path.join( tmp + '/', module );
 
-					copy();
-				} );
+			if ( !fs.existsSync( dest ) ) {
+				fs.mkdirSync( dest );
 			}
 
-			copy();
-		},
+			// Copy the "src" directory only.
+			ncp( path.join( 'node_modules', module, 'src' ), path.join( dest, 'src' ), {
+				dereference: true
+			}, function( err ) {
+				if ( err ) {
+					throw err;
+				}
 
-		/**
-		 * Removes the `CKEDITOR` namespace from AMD calls in the `tmp` copy of the source code.
-		 *
-		 * @param {Function} callback Function to be called when the task is done.
-		 * @returns {Object} The callback returned value.
-		 */
-		removeAmdNamespace: function( callback ) {
-			var replace = require( 'replace' );
-
-			replace( {
-				regex: /^\s*CKEDITOR\.(define|require)/mg,
-				replacement: '$1',
-				paths: [ this.tmp ],
-				recursive: true,
-				silent: true
+				copy();
 			} );
+		}
 
-			callback();
-		},
+		copy();
+	},
 
-		/**
-		 * Creates the optimized release version of `ckeditor.js` in the `target` directory out of the `tmp` copy of the
-		 * source code.
-		 *
-		 * @param {Function} callback Function to be called when the task is done.
-		 * @returns {Object} The callback returned value.
-		 */
-		optimize: function( callback ) {
-			var requirejs = require( 'requirejs' );
-
-			var config = {
-				out: this.target + '/ckeditor.js',
-
-				baseUrl: this.tmp + '/ckeditor5-core/src/',
-				paths: {
-					'ckeditor': '../../../ckeditor',
-					'ckeditor-dev': '../../../src/ckeditor-dev',
-					'ckeditor-core': 'ckeditor'
-				},
-
-				include: [ 'ckeditor' ],
-				stubModules: [ 'ckeditor-dev' ],
-
-				//			optimize: 'none',
-				optimize: 'uglify2',
-				preserveLicenseComments: false,
-				wrap: {
-					startFile: [ 'src/build/start.frag', require.resolve( 'almond' ) ],
-					endFile: 'src/build/end.frag'
-				}
-			};
+	/**
+	 * Removes the `CKEDITOR` namespace from AMD calls in the `tmp` copy of the source code.
+	 *
+	 * @param {Function} callback Function to be called when the task is done.
+	 * @returns {Object} The callback returned value.
+	 */
+	removeAmdNamespace( callback ) {
+		const replace = require( 'replace' );
+
+		replace( {
+			regex: /^\s*CKEDITOR\.(define|require)/mg,
+			replacement: '$1',
+			paths: [ this.tmp ],
+			recursive: true,
+			silent: true
+		} );
+
+		callback();
+	},
 
-			requirejs.optimize( config, callback );
-		},
+	/**
+	 * Creates the optimized release version of `ckeditor.js` in the `target` directory out of the `tmp` copy of the
+	 * source code.
+	 *
+	 * @param {Function} callback Function to be called when the task is done.
+	 * @returns {Object} The callback returned value.
+	 */
+	optimize( callback ) {
+		const requirejs = require( 'requirejs' );
+
+		const config = {
+			out: this.target + '/ckeditor.js',
+
+			baseUrl: this.tmp + '/ckeditor5-core/src/',
+			paths: {
+				'ckeditor': '../../../ckeditor',
+				'ckeditor-dev': '../../../src/ckeditor-dev',
+				'ckeditor-core': 'ckeditor'
+			},
+
+			include: [ 'ckeditor' ],
+			stubModules: [ 'ckeditor-dev' ],
+
+			//			optimize: 'none',
+			optimize: 'uglify2',
+			preserveLicenseComments: false,
+			wrap: {
+				startFile: [ 'src/build/start.frag', require.resolve( 'almond' ) ],
+				endFile: 'src/build/end.frag'
+			}
+		};
 
-		/**
-		 * Deletes `tmp` directory.
-		 *
-		 * @param {Function} callback Function to be called when the task is done.
-		 * @returns {Object} The callback returned value.
-		 */
-		cleanUpTmp: function( callback ) {
-			var del = require( 'del' );
-			del.sync( this.tmp );
+		requirejs.optimize( config, callback );
+	},
 
-			return callback();
-		}
+	/**
+	 * Deletes `tmp` directory.
+	 *
+	 * @param {Function} callback Function to be called when the task is done.
+	 * @returns {Object} The callback returned value.
+	 */
+	cleanUpTmp( callback ) {
+		const del = require( 'del' );
+		del.sync( this.tmp );
+
+		return callback();
 	}
 };
+
+module.exports = Builder;

+ 4 - 4
dev/tasks/jscs.js

@@ -1,8 +1,8 @@
 'use strict';
 
-var tools = require( './utils/tools' );
+const tools = require( './utils/tools' );
 
-module.exports = function( grunt ) {
+module.exports = ( grunt ) => {
 	tools.setupMultitaskConfig( grunt, {
 		task: 'jscs',
 		defaultOptions: {
@@ -10,11 +10,11 @@ module.exports = function( grunt ) {
 			},
 		addGitIgnore: 'excludeFiles',
 		targets: {
-			all: function() {
+			all() {
 				return [ '**/*.js' ];
 			},
 
-			git: function() {
+			git() {
 				return tools.getGitDirtyFiles().filter( function( file ) {
 					return ( /\.js$/ ).test( file );
 				} );

+ 4 - 4
dev/tasks/jshint.js

@@ -1,8 +1,8 @@
 'use strict';
 
-var tools = require( './utils/tools' );
+const tools = require( './utils/tools' );
 
-module.exports = function( grunt ) {
+module.exports = ( grunt ) => {
 	tools.setupMultitaskConfig( grunt, {
 		task: 'jshint',
 		defaultOptions: {
@@ -10,11 +10,11 @@ module.exports = function( grunt ) {
 			},
 		addGitIgnore: 'ignores',
 		targets: {
-			all: function() {
+			all() {
 				return [ '**/*.js' ];
 			},
 
-			git: function() {
+			git() {
 				return tools.getGitDirtyFiles().filter( function( file ) {
 					return ( /\.js$/ ).test( file );
 				} );

+ 12 - 12
dev/tasks/utils/tools.js

@@ -14,14 +14,14 @@ module.exports = {
 	 * @returns {Boolean} "true" if the task is in the queue.
 	 */
 	checkTaskInQueue( grunt, task ) {
-		var cliTasks = grunt.cli.tasks;
+		const cliTasks = grunt.cli.tasks;
 
 		// Check if the task has been called directly.
-		var isDirectCall = ( cliTasks.indexOf( task ) > -1 );
+		const isDirectCall = ( cliTasks.indexOf( task ) > -1 );
 		// Check if this is a "default" call and that the task is inside "default".
-		var isDefaultTask = ( cliTasks.indexOf( 'default' ) > -1 ) || !cliTasks.length;
+		const isDefaultTask = ( cliTasks.indexOf( 'default' ) > -1 ) || !cliTasks.length;
 		// Hacking Grunt hard.
-		var isTaskInDefault = isDefaultTask && ( grunt.task._tasks.default.info.indexOf( '"' + task + '"' ) > -1 );
+		const isTaskInDefault = isDefaultTask && ( grunt.task._tasks.default.info.indexOf( '"' + task + '"' ) > -1 );
 
 		return isDirectCall || isTaskInDefault;
 	},
@@ -33,15 +33,15 @@ module.exports = {
 	 * @param options {Object} A list of options for the method. See the jscs and jshint tasks for example.
 	 */
 	setupMultitaskConfig( grunt, options ) {
-		var task = options.task;
-		var taskConfig = {};
-		var config = taskConfig[ task ] = {
+		const task = options.task;
+		const taskConfig = {};
+		const config = taskConfig[ task ] = {
 			options: options.defaultOptions
 		};
 
 		// "all" is the default target to be used if others are not to be run.
-		var all = options.targets.all;
-		var isAll = true;
+		const all = options.targets.all;
+		let isAll = true;
 
 		delete options.targets.all;
 
@@ -58,8 +58,8 @@ module.exports = {
 
 		// Append .gitignore entries to the ignore list.
 		if ( options.addGitIgnore ) {
-			var ignoreProp = task + '.options.' + options.addGitIgnore;
-			var ignores = grunt.config.get( ignoreProp ) || [];
+			let ignoreProp = task + '.options.' + options.addGitIgnore;
+			let ignores = grunt.config.get( ignoreProp ) || [];
 
 			ignores = ignores.concat( this.getGitIgnore( grunt ) );
 			grunt.config.set( ignoreProp, ignores );
@@ -200,7 +200,7 @@ module.exports = {
 	 * @returns {Boolean}
 	 */
 	isDirectory( path ) {
-		var fs = require( 'fs' );
+		const fs = require( 'fs' );
 
 		try {
 			return fs.statSync( path ).isDirectory();

+ 3 - 3
gruntfile.js

@@ -1,13 +1,13 @@
-/* jshint node: true */
+/* jshint node: true, esnext: true, varstmt: true */
 
 'use strict';
 
-module.exports = function( grunt ) {
+module.exports = ( grunt ) => {
 	// First register the "default" task, so it can be analyzed by other tasks.
 	grunt.registerTask( 'default', [ 'jshint:git', 'jscs:git' ] );
 
 	// Files that will be ignored by the "jscs" and "jshint" tasks.
-	var ignoreFiles = [
+	const ignoreFiles = [
 		// Automatically loaded from .gitignore. Add more if necessary.
 		'lib/**'
 	];

+ 2 - 2
src/ckeditor-dev.js

@@ -7,7 +7,7 @@
 
 'use strict';
 
-define( 'ckeditor-dev', function() {
+define( 'ckeditor-dev', () => {
 	return {
 		/**
 		 * A flag specifying whether CKEditor is running in development mode (original source code).
@@ -21,7 +21,7 @@ define( 'ckeditor-dev', function() {
 		isDev: true,
 
 		// Documented in ckeditor5-core/ckeditor.
-		getPluginPath: function( name ) {
+		getPluginPath( name ) {
 			return this.basePath + 'node_modules/ckeditor-plugin-' + name + '/src/';
 		}
 	};

+ 2 - 2
src/plugin.js

@@ -14,12 +14,12 @@
 // core Plugin class with the necessary RequireJS plugin methods. This should have no harm on the use of the Plugin
 // class.
 
-define( 'plugin', [ 'plugin-core' ], function( CorePlugin ) {
+define( 'plugin', [ 'plugin-core' ], ( CorePlugin ) => {
 	// Called when a "plugin!" module is to be loaded.
 	// http://requirejs.org/docs/plugins.html#apiload
 	CorePlugin.load = function( name, require, onload ) {
 		// We may have a path to plugin modules (e.g. test/somemodule). Here we break the path on slashes.
-		var path = name.split( '/' );
+		let path = name.split( '/' );
 
 		// Inject the /src/ part right after the plugin name (e.g test/src).
 		path.splice( 1, 0, 'src' );

+ 1 - 0
tests/.jshintrc

@@ -10,6 +10,7 @@
 	"unused": true,
 	"strict": true,
 	"expr": true,
+	"varstmt": true,
 
 	"globalstrict": true,
 

+ 6 - 6
tests/amd/amd.js

@@ -5,22 +5,22 @@
 
 'use strict';
 
-CKEDITOR.define( 'testModule', [ 'ckeditor' ], function( ckeditor ) {
+CKEDITOR.define( 'testModule', [ 'ckeditor' ], ( ckeditor ) => {
 	return {
 		test: ( ckeditor && ( typeof ckeditor == 'object' ) )
 	};
 } );
 
-describe( 'CKEDITOR.require()', function() {
-	it( 'should work with a defined module', function( done ) {
-		CKEDITOR.require( [ 'testModule' ], function( testModule ) {
+describe( 'CKEDITOR.require()', () => {
+	it( 'should work with a defined module', ( done ) => {
+		CKEDITOR.require( [ 'testModule' ], ( testModule ) => {
 			expect( testModule ).to.have.property( 'test' ).to.be.true();
 			done();
 		} );
 	} );
 
-	it( 'should work with a core module', function( done ) {
-		CKEDITOR.require( [ 'utils' ], function( utils ) {
+	it( 'should work with a core module', ( done ) => {
+		CKEDITOR.require( [ 'utils' ], ( utils ) => {
 			expect( utils ).to.be.an( 'object' );
 			done();
 		} );

+ 7 - 7
tests/bender/createsinonsandbox.js

@@ -5,28 +5,28 @@
 
 'use strict';
 
-var obj = {
+const obj = {
 	method() {}
 };
-var spy;
-var origMethod = obj.method;
+const origMethod = obj.method;
+let spy;
 
 bender.tools.createSinonSandbox();
 
-describe( 'bender.tools.createSinonSandbox()', function() {
-	it( 'creates a sandbox', function() {
+describe( 'bender.tools.createSinonSandbox()', () => {
+	it( 'creates a sandbox', () => {
 		expect( bender.sinon ).to.be.an( 'object' );
 		expect( bender.sinon ).to.have.property( 'spy' );
 	} );
 
 	// This test is needed for the following one.
-	it( 'really works', function() {
+	it( 'really works', () => {
 		spy = bender.sinon.spy( obj, 'method' );
 
 		expect( obj ).to.have.property( 'method', spy );
 	} );
 
-	it( 'restores spies after each test', function() {
+	it( 'restores spies after each test', () => {
 		obj.method();
 
 		sinon.assert.notCalled( spy );

+ 13 - 13
tests/ckeditor/basepath.js

@@ -5,9 +5,9 @@
 
 'use strict';
 
-var modules = bender.amd.require( 'ckeditor' );
+const modules = bender.amd.require( 'ckeditor' );
 
-beforeEach( function() {
+beforeEach( () => {
 	// Ensure that no CKEDITOR_BASEPATH global is available.
 	delete window.CKEDITOR_BASEPATH;
 
@@ -15,7 +15,7 @@ beforeEach( function() {
 	removeScripts();
 } );
 
-describe( 'basePath', function() {
+describe( 'basePath', () => {
 	testGetBasePathFromTag( 'http://bar.com/ckeditor/ckeditor.js', 'http://bar.com/ckeditor/' );
 	testGetBasePathFromTag( '/ckeditor/ckeditor.js', /\/ckeditor\/$/ );
 	testGetBasePathFromTag( '/ckeditor/ckeditor.js?foo=1#bar', /\/ckeditor\/$/ );
@@ -23,16 +23,16 @@ describe( 'basePath', function() {
 	testGetBasePathFromTag( '/ckeditor/CKEDITOR.JS', /\/ckeditor\/$/ );
 	testGetBasePathFromTag( '../ckeditor/foo/ckeditor.JS', /\/ckeditor\/foo\/$/ );
 
-	it( 'should work with the CKEDITOR_BASEPATH global', function() {
-		var CKEDITOR = modules.ckeditor;
+	it( 'should work with the CKEDITOR_BASEPATH global', () => {
+		const CKEDITOR = modules.ckeditor;
 
 		window.CKEDITOR_BASEPATH = 'http://foo.com/ckeditor/';
 		expect( CKEDITOR._getBasePath() ).to.equal( 'http://foo.com/ckeditor/' );
 	} );
 
 	function testGetBasePathFromTag( url, expectedBasePath ) {
-		it( 'should work with script tags - ' + url, function() {
-			var CKEDITOR = modules.ckeditor;
+		it( 'should work with script tags - ' + url, () => {
+			const CKEDITOR = modules.ckeditor;
 
 			addScript( url );
 
@@ -45,17 +45,17 @@ describe( 'basePath', function() {
 	}
 } );
 
-describe( 'This browser', function() {
+describe( 'This browser', () => {
 	testUrlIsFull( '/absolute/url/ckeditor.js' );
 	testUrlIsFull( '../relative/url/ckeditor.js' );
 
 	// Browsers should convert absolute and relative URLs to full URLs.
 	// If this test fails in any browser, _getBasePath() must be reviewed to deal with such case (v4 does it).
 	function testUrlIsFull( url ) {
-		it( 'should not keep script URLs absolute or relative - ' + url, function() {
+		it( 'should not keep script URLs absolute or relative - ' + url, () => {
 			removeScripts();
 
-			var script = addScript( url );
+			const script = addScript( url );
 
 			// Test if the src now contains '://'.
 			expect( script.src ).to.match( /:\/\// );
@@ -64,7 +64,7 @@ describe( 'This browser', function() {
 } );
 
 function addScript( url ) {
-	var script = document.createElement( 'script' );
+	const script = document.createElement( 'script' );
 
 	script.src = url;
 	document.head.appendChild( script );
@@ -73,8 +73,8 @@ function addScript( url ) {
 }
 
 function removeScripts() {
-	var scripts = [].slice.call( document.getElementsByTagName( 'script' ) );
-	var script;
+	const scripts = [].slice.call( document.getElementsByTagName( 'script' ) );
+	let script;
 
 	while ( ( script = scripts.shift() ) ) {
 		script.parentNode.removeChild( script );

+ 15 - 15
tests/ckeditor/ckeditor.js

@@ -5,14 +5,14 @@
 
 'use strict';
 
-var modules = bender.amd.require( 'ckeditor', 'ckeditor-core' );
+const modules = bender.amd.require( 'ckeditor', 'ckeditor-core' );
 
-describe( 'getPluginPath()', function() {
-	it( 'should return a proper path', function() {
-		var CKEDITOR = modules.ckeditor;
+describe( 'getPluginPath()', () => {
+	it( 'should return a proper path', () => {
+		const CKEDITOR = modules.ckeditor;
 
-		var basePath = CKEDITOR.basePath;
-		var path = CKEDITOR.getPluginPath( 'test' );
+		const basePath = CKEDITOR.basePath;
+		const path = CKEDITOR.getPluginPath( 'test' );
 
 		if ( CKEDITOR.isDev ) {
 			expect( path ).to.equal( basePath + 'node_modules/ckeditor-plugin-test/src/' );
@@ -21,18 +21,18 @@ describe( 'getPluginPath()', function() {
 		}
 	} );
 
-	it( '(the production version) should work even when in dev', function() {
-		var CKEDITOR = modules.ckeditor;
-		var core = modules[ 'ckeditor-core' ];
+	it( '(the production version) should work even when in dev', () => {
+		const CKEDITOR = modules.ckeditor;
+		const core = modules[ 'ckeditor-core' ];
 
 		// To be able to run this test on both dev and production code, we need to override getPluginPath with the
 		// core version of it and restore it after testing.
-		var originalGetPluginPath = CKEDITOR.getPluginPath;
+		const originalGetPluginPath = CKEDITOR.getPluginPath;
 		CKEDITOR.getPluginPath = core.getPluginPath;
 
 		// This test is good for both the development and production codes.
-		var basePath = CKEDITOR.basePath;
-		var path = CKEDITOR.getPluginPath( 'test' );
+		const basePath = CKEDITOR.basePath;
+		const path = CKEDITOR.getPluginPath( 'test' );
 
 		// Revert the override before assertions or it will not do it in case of errors.
 		CKEDITOR.getPluginPath = originalGetPluginPath;
@@ -41,9 +41,9 @@ describe( 'getPluginPath()', function() {
 	} );
 } );
 
-describe( 'isDebug', function() {
-	it( 'is a boolean', function() {
-		var CKEDITOR = modules.ckeditor;
+describe( 'isDebug', () => {
+	it( 'is a boolean', () => {
+		const CKEDITOR = modules.ckeditor;
 
 		expect( CKEDITOR.isDebug ).to.be.a( 'boolean' );
 	} );

+ 11 - 11
tests/plugin/plugin.js

@@ -5,27 +5,27 @@
 
 'use strict';
 
-describe( 'CKEDITOR.require()', function() {
-	it( 'should load a CKEditor plugin', function( done ) {
-		CKEDITOR.require( [ 'plugin!devtest' ], function( DevTest ) {
+describe( 'CKEDITOR.require()', () => {
+	it( 'should load a CKEditor plugin', ( done ) => {
+		CKEDITOR.require( [ 'plugin!devtest' ], ( DevTest ) => {
 			expect( DevTest ).to.have.property( 'isDevTest' );
-			done() ;
+			done();
 		} );
 	} );
 
-	it( 'should load dependencies on CKEditor plugins', function( done ) {
-		CKEDITOR.require( [ 'plugin!devtest/someclass' ], function( SomeClass ) {
+	it( 'should load dependencies on CKEditor plugins', ( done ) => {
+		CKEDITOR.require( [ 'plugin!devtest/someclass' ], ( SomeClass ) => {
 			expect( SomeClass ).to.have.property( 'isSomeClass' );
-			done() ;
+			done();
 		} );
 	} );
 
-	it( 'should load a dependency into a CKEditor plugin', function( done ) {
-		CKEDITOR.require( [ 'plugin!devtest', 'plugin!devtest/someclass' ], function( DevTest, SomeClass ) {
-			var test = new DevTest();
+	it( 'should load a dependency into a CKEditor plugin', ( done ) => {
+		CKEDITOR.require( [ 'plugin!devtest', 'plugin!devtest/someclass' ], ( DevTest, SomeClass ) => {
+			const test = new DevTest();
 
 			expect( test ).to.have.property( 'someProperty' ).to.be.an.instanceof( SomeClass );
-			done() ;
+			done();
 		} );
 	} );
 } );