Browse Source

Merge branch 'esnext' into ckeditor5

Piotrek Koszuliński 10 years ago
parent
commit
83551bdf96
5 changed files with 32 additions and 31 deletions
  1. 2 1
      dev/.jshintrc
  2. 4 4
      dev/tasks/jscs.js
  3. 4 4
      dev/tasks/jshint.js
  4. 19 19
      dev/tasks/utils/tools.js
  5. 3 3
      gruntfile.js

+ 2 - 1
dev/.jshintrc

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

+ 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 );
 				} );

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

@@ -1,6 +1,6 @@
 'use strict';
 
-var dirtyFiles,
+let dirtyFiles,
 	ignoreList;
 
 module.exports = {
@@ -11,15 +11,15 @@ module.exports = {
 	 * @param task {String} The task name. May optionally include the target (e.g. 'task:target').
 	 * @returns {Boolean} "true" if the task is in the queue.
 	 */
-	checkTaskInQueue: function( grunt, task ) {
-		var cliTasks = grunt.cli.tasks;
+	checkTaskInQueue( grunt, task ) {
+		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;
 	},
@@ -30,16 +30,16 @@ module.exports = {
 	 * @param grunt {Object} The Grunt object.
 	 * @param options {Object} A list of options for the method. See the jscs and jshint tasks for example.
 	 */
-	setupMultitaskConfig: function( grunt, options ) {
-		var task = options.task;
-		var taskConfig = {};
-		var config = taskConfig[ task ] = {
+	setupMultitaskConfig( grunt, options ) {
+		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;
 
@@ -56,8 +56,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 );
@@ -73,7 +73,7 @@ module.exports = {
 	 * @param grunt {Object} The Grunt object.
 	 * @returns {String[]} The list of ignores.
 	 */
-	getGitIgnore: function( grunt ) {
+	getGitIgnore( grunt ) {
 		if ( !ignoreList ) {
 			ignoreList = grunt.file.read( '.gitignore' );
 
@@ -96,7 +96,7 @@ module.exports = {
 	 *
 	 * @returns {String[]} A list of file paths.
 	 */
-	getGitDirtyFiles: function() {
+	getGitDirtyFiles() {
 		// Cache it, so it is executed only once when running multiple tasks.
 		if ( !dirtyFiles ) {
 			dirtyFiles = this
@@ -122,11 +122,11 @@ module.exports = {
 	 * @param command {String} The command to be executed.
 	 * @returns {String} The command output.
 	 */
-	shExec: function( command ) {
-		var sh = require( 'shelljs' );
+	shExec( command ) {
+		const sh = require( 'shelljs' );
 		sh.config.silent = true;
 
-		var ret = sh.exec( command );
+		const ret = sh.exec( command );
 
 		if ( ret.code ) {
 			throw new Error(

+ 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.
 	];