Browse Source

Added support for jscs and made it a pure grunt task.

fredck 11 years ago
parent
commit
fd34094fd1

+ 0 - 0
packages/ckeditor5-utils/.jscsrc


+ 79 - 2
packages/ckeditor5-utils/gruntfile.js

@@ -1,5 +1,82 @@
 module.exports = function( grunt ) {
 	grunt.initConfig( {
-		pkg: grunt.file.readJSON( 'package.json' )
+		pkg: grunt.file.readJSON( 'package.json' ),
+
+		jscs: {
+			src: '*.js',
+			options: jscsConfig
+		}
 	} );
-};
+
+	grunt.loadNpmTasks( 'grunt-jscs' );
+};
+
+// Configurations for JSCS (JavaScript Code Style checker)
+var jscsConfig = {
+	'excludeFiles': [
+		'node_modules/*'
+	],
+	'requireCurlyBraces': [
+		'if', 'else', 'for', 'while', 'do', 'switch', 'try', 'catch'
+	],
+	'requireSpaceAfterKeywords': [
+		'if', 'else', 'for', 'while', 'do', 'switch', 'return', 'try', 'catch'
+	],
+	'requireSpaceBeforeBlockStatements': true,
+	'requireParenthesesAroundIIFE': true,
+	'requireSpacesInConditionalExpression': {
+		'afterTest': true,
+		'beforeConsequent': true,
+		'afterConsequent': true,
+		'beforeAlternate': true
+	},
+	'requireSpacesInFunctionExpression': {
+		'beforeOpeningCurlyBrace': true
+	},
+	'disallowSpacesInFunctionExpression': {
+		'beforeOpeningRoundBrace': true
+	},
+	'requireBlocksOnNewline': true,
+	'requireSpacesInsideObjectBrackets': 'all',
+	'requireSpacesInsideArrayBrackets': 'all',
+	'disallowSpaceAfterObjectKeys': true,
+	'requireCommaBeforeLineBreak': true,
+	'requireOperatorBeforeLineBreak': [
+		'?', '=', '+', '-', '/', '*', '==', '===', '!=', '!==', '>', '>=', '<', '<=', '|', '||', '&', '&&', '^', '+=', '*=',
+		'-=', '/=', '^='
+	],
+	'requireSpaceBeforeBinaryOperators': [
+		'+', '-', '/', '*', '=', '==', '===', '!=', '!==', '>', '>=', '<', '<=', '|', '||', '&', '&&', '^', '+=', '*=', '-=',
+		'/=', '^='
+	],
+	'requireSpaceAfterBinaryOperators': [
+		'+', '-', '/', '*', '=', '==', '===', '!=', '!==', '>', '>=', '<', '<=', '|', '||', '&', '&&', '^', '+=', '*=', '-=',
+		'/=', '^='
+	],
+	'disallowSpaceAfterPrefixUnaryOperators': [
+		'++', '--', '+', '-', '~', '!'
+	],
+	'disallowSpaceBeforePostfixUnaryOperators': [
+		'++', '--'
+	],
+	'disallowKeywords': [
+		'with'
+	],
+	'validateLineBreaks': 'LF',
+	'validateQuoteMarks': {
+		'mark': '\'',
+		'escape': true
+	},
+	'validateIndentation': '\t',
+	'disallowMixedSpacesAndTabs': true,
+	'disallowTrailingWhitespace': true,
+	'disallowKeywordsOnNewLine': [
+		'else', 'catch'
+	],
+	'maximumLineLength': 120,
+	'safeContextKeyword': [
+		'that'
+	],
+	'requireDotNotation': true,
+	'disallowYodaConditions': true
+};

+ 11 - 13
packages/ckeditor5-utils/package.json

@@ -1,15 +1,13 @@
 {
-	"name": "programmatic-name-of-the-application",
-	"version": "0.1.0",
-	"description": "A short description",
-
-	"devDependencies": {
-		"grunt": "~0.4.5"
-	},
-
-	"author": "CKSource (http://cksource.com/)",
-	"license": "See LICENSE.md",
-
-	"homepage": "http://app.com",
-	"bugs": "http://bugs.app.com"
+  "name": "programmatic-name-of-the-application",
+  "version": "0.1.0",
+  "description": "A short description",
+  "devDependencies": {
+    "grunt": "~0.4.5",
+    "grunt-jscs": "~0.6.2"
+  },
+  "author": "CKSource (http://cksource.com/)",
+  "license": "See LICENSE.md",
+  "homepage": "http://app.com",
+  "bugs": "http://bugs.app.com"
 }