Browse Source

Updated JSCS config and made necessary adjustments in the code. Fixes #2.

Piotrek Koszuliński 11 years ago
parent
commit
0560e1c4aa

+ 32 - 36
packages/ckeditor5-engine/dev/tasks/jscs-config.json

@@ -2,8 +2,9 @@
 	"requireCurlyBraces": [
 		"if", "else", "for", "while", "do", "switch", "try", "catch"
 	],
+	"requireSpaceBeforeKeywords": true,
 	"requireSpaceAfterKeywords": [
-		"if", "else", "for", "while", "do", "switch", "return", "try", "catch"
+		"do", "for", "if", "else", "switch", "case", "try", "catch", "void", "while", "with", "return", "typeof"
 	],
 	"requireSpaceBeforeBlockStatements": true,
 	"requireParenthesesAroundIIFE": true,
@@ -13,53 +14,48 @@
 		"afterConsequent": true,
 		"beforeAlternate": true
 	},
-	"requireSpacesInFunctionExpression": {
+	"requireSpacesInFunction": {
 		"beforeOpeningCurlyBrace": true
 	},
-	"disallowSpacesInFunctionExpression": {
+	"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": [
-		"?", "=", "+", "-", "/", "*", "==", "===", "!=", "!==", ">", ">=", "<", "<=", "|", "||", "&", "&&", "^", "+=",
-		"*=", "-=", "/=", "^="
-	],
-	"requireSpaceBeforeBinaryOperators": [
-		"+", "-", "/", "*", "=", "==", "===", "!=", "!==", ">", ">=", "<", "<=", "|", "||", "&", "&&", "^", "+=", "*=",
-		"-=", "/=", "^="
-	],
-	"requireSpaceAfterBinaryOperators": [
-		"+", "-", "/", "*", "=", "==", "===", "!=", "!==", ">", ">=", "<", "<=", "|", "||", "&", "&&", "^", "+=", "*=",
-		"-=", "/=", "^="
-	],
-	"disallowSpaceAfterPrefixUnaryOperators": [
-		"++", "--", "+", "-", "~", "!"
-	],
-	"disallowSpaceBeforePostfixUnaryOperators": [
-		"++", "--"
-	],
+	"requireOperatorBeforeLineBreak": true,
+	"disallowSpaceAfterPrefixUnaryOperators": true,
+	"disallowSpaceBeforePostfixUnaryOperators": true,
+	"requireSpaceBeforeBinaryOperators": true,
+	"disallowImplicitTypeConversion": [
+		"numeric", "binary", "string"
+	],
+	"requireCamelCaseOrUpperCaseIdentifiers": true,
+	"requireSpaceAfterBinaryOperators": true,
 	"disallowKeywords": [
 		"with"
 	],
-	"validateLineBreaks": "LF",
-	"validateQuoteMarks": {
-		"mark": "'",
-		"escape": true
-	},
-	"validateIndentation": "\t",
+	"disallowMultipleLineStrings": true,
+	"disallowMultipleLineBreaks": true,
 	"disallowMixedSpacesAndTabs": true,
 	"disallowTrailingWhitespace": true,
-	"disallowKeywordsOnNewLine": [
-		"else", "catch"
-	],
-	"maximumLineLength": 120,
-	"safeContextKeyword": [
-		"that"
-	],
+	"maximumLineLength": 140,
+	"requireCapitalizedConstructors": true,
 	"requireDotNotation": true,
-	"disallowYodaConditions": true
-}
+	"disallowYodaConditions": true,
+	"disallowNewlineBeforeBlockStatements": true,
+	"validateLineBreaks": "LF",
+	"validateQuoteMarks": "'",
+	"validateIndentation": "\t",
+	"safeContextKeyword": [ "that" ]
+}

+ 13 - 13
packages/ckeditor5-engine/dev/tasks/utils/tools.js

@@ -18,11 +18,10 @@ module.exports = {
 
 		// Check if the task has been called directly.
 		var 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,
-			// Hacking Grunt hard.
-			isTaskInDefault = isDefaultTask && ( grunt.task._tasks.default.info.indexOf( '"' + task + '"' ) > -1 );
+		var isDefaultTask = ( cliTasks.indexOf( 'default' ) > -1 ) || !cliTasks.length;
+		// Hacking Grunt hard.
+		var isTaskInDefault = isDefaultTask && ( grunt.task._tasks.default.info.indexOf( '"' + task + '"' ) > -1 );
 
 		return isDirectCall || isTaskInDefault;
 	},
@@ -34,15 +33,15 @@ module.exports = {
 	 * @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,
-			taskConfig = {},
-			config = taskConfig[ task ] = {
-				options: options.defaultOptions
-			};
+		var task = options.task;
+		var taskConfig = {};
+		var 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,
-			isAll = true;
+		var all = options.targets.all;
+		var isAll = true;
 
 		delete options.targets.all;
 
@@ -59,8 +58,9 @@ module.exports = {
 
 		// Append .gitignore entries to the ignore list.
 		if ( options.addGitIgnore ) {
-			var ignoreProp = task + '.options.' + options.addGitIgnore,
-				ignores = grunt.config.get( ignoreProp ) || [];
+			var ignoreProp = task + '.options.' + options.addGitIgnore;
+			var ignores = grunt.config.get( ignoreProp ) || [];
+
 			ignores = ignores.concat( this.getGitIgnore( grunt ) );
 			grunt.config.set( ignoreProp, ignores );
 		}