Merge branch 'add-jscs' into merge-add-jscs
Conflicts: .travis.yml
This commit is contained in:
95
.jscsrc
Normal file
95
.jscsrc
Normal file
@@ -0,0 +1,95 @@
|
|||||||
|
{
|
||||||
|
"requireCurlyBraces": [
|
||||||
|
"if",
|
||||||
|
"else",
|
||||||
|
"for",
|
||||||
|
"while",
|
||||||
|
"do",
|
||||||
|
"try",
|
||||||
|
"catch"
|
||||||
|
],
|
||||||
|
"requireOperatorBeforeLineBreak": true,
|
||||||
|
"requireCamelCaseOrUpperCaseIdentifiers": true,
|
||||||
|
"maximumLineLength": {
|
||||||
|
"value": 80,
|
||||||
|
"allowComments": true,
|
||||||
|
"allowRegex": true
|
||||||
|
},
|
||||||
|
"validateIndentation": 2,
|
||||||
|
"validateQuoteMarks": "'",
|
||||||
|
"disallowMultipleLineStrings": true,
|
||||||
|
"disallowMixedSpacesAndTabs": true,
|
||||||
|
"disallowTrailingWhitespace": true,
|
||||||
|
"disallowSpaceAfterPrefixUnaryOperators": true,
|
||||||
|
"disallowMultipleVarDecl": true,
|
||||||
|
"disallowKeywordsOnNewLine": [
|
||||||
|
"else"
|
||||||
|
],
|
||||||
|
"requireSpaceAfterKeywords": [
|
||||||
|
"if",
|
||||||
|
"else",
|
||||||
|
"for",
|
||||||
|
"while",
|
||||||
|
"do",
|
||||||
|
"switch",
|
||||||
|
"return",
|
||||||
|
"try",
|
||||||
|
"catch"
|
||||||
|
],
|
||||||
|
"requireSpaceBeforeBinaryOperators": [
|
||||||
|
"=",
|
||||||
|
"+=",
|
||||||
|
"-=",
|
||||||
|
"*=",
|
||||||
|
"/=",
|
||||||
|
"%=",
|
||||||
|
"<<=",
|
||||||
|
">>=",
|
||||||
|
">>>=",
|
||||||
|
"&=",
|
||||||
|
"|=",
|
||||||
|
"^=",
|
||||||
|
"+=",
|
||||||
|
"+",
|
||||||
|
"-",
|
||||||
|
"*",
|
||||||
|
"/",
|
||||||
|
"%",
|
||||||
|
"<<",
|
||||||
|
">>",
|
||||||
|
">>>",
|
||||||
|
"&",
|
||||||
|
"|",
|
||||||
|
"^",
|
||||||
|
"&&",
|
||||||
|
"||",
|
||||||
|
"===",
|
||||||
|
"==",
|
||||||
|
">=",
|
||||||
|
"<=",
|
||||||
|
"<",
|
||||||
|
">",
|
||||||
|
"!=",
|
||||||
|
"!=="
|
||||||
|
],
|
||||||
|
"requireSpaceAfterBinaryOperators": true,
|
||||||
|
"requireSpacesInConditionalExpression": true,
|
||||||
|
"requireSpaceBeforeBlockStatements": true,
|
||||||
|
"requireSpacesInForStatement": true,
|
||||||
|
"requireLineFeedAtFileEnd": true,
|
||||||
|
"requireSpacesInFunctionExpression": {
|
||||||
|
"beforeOpeningCurlyBrace": true
|
||||||
|
},
|
||||||
|
"disallowSpacesInAnonymousFunctionExpression": {
|
||||||
|
"beforeOpeningRoundBrace": true
|
||||||
|
},
|
||||||
|
"disallowSpacesInsideObjectBrackets": "all",
|
||||||
|
"disallowSpacesInsideArrayBrackets": "all",
|
||||||
|
"disallowSpacesInsideParentheses": true,
|
||||||
|
"validateJSDoc": {
|
||||||
|
"checkParamNames": true,
|
||||||
|
"requireParamTypes": true
|
||||||
|
},
|
||||||
|
"disallowMultipleLineBreaks": true,
|
||||||
|
"disallowNewlineBeforeBlockStatements": true
|
||||||
|
}
|
||||||
@@ -7,7 +7,7 @@ php:
|
|||||||
- '5.4'
|
- '5.4'
|
||||||
|
|
||||||
before_install:
|
before_install:
|
||||||
- npm install -g bower
|
- npm install -g bower gulp jscs
|
||||||
- npm install
|
- npm install
|
||||||
- pyrus install pear/PHP_CodeSniffer
|
- pyrus install pear/PHP_CodeSniffer
|
||||||
- phpenv rehash
|
- phpenv rehash
|
||||||
@@ -15,4 +15,5 @@ before_install:
|
|||||||
script:
|
script:
|
||||||
- npm run build
|
- npm run build
|
||||||
- npm run jshint
|
- npm run jshint
|
||||||
|
- npm run jscs
|
||||||
- phpcs --standard=ruleset.xml --extensions=php -n -s .
|
- phpcs --standard=ruleset.xml --extensions=php -n -s .
|
||||||
|
|||||||
@@ -16,61 +16,66 @@
|
|||||||
|
|
||||||
(function($) {
|
(function($) {
|
||||||
|
|
||||||
// Use this variable to set up the common and page specific functions. If you
|
// Use this variable to set up the common and page specific functions. If you
|
||||||
// rename this variable, you will also need to rename the namespace below.
|
// rename this variable, you will also need to rename the namespace below.
|
||||||
var Sage = {
|
var Sage = {
|
||||||
// All pages
|
// All pages
|
||||||
common: {
|
'common': {
|
||||||
init: function() {
|
init: function() {
|
||||||
// JavaScript to be fired on all pages
|
// JavaScript to be fired on all pages
|
||||||
|
},
|
||||||
|
finalize: function() {
|
||||||
|
// JavaScript to be fired on all pages, after page specific JS is fired
|
||||||
|
}
|
||||||
},
|
},
|
||||||
finalize: function() {
|
// Home page
|
||||||
// JavaScript to be fired on all pages, after page specific JS is fired
|
'home': {
|
||||||
}
|
init: function() {
|
||||||
},
|
// JavaScript to be fired on the home page
|
||||||
// Home page
|
},
|
||||||
home: {
|
finalize: function() {
|
||||||
init: function() {
|
// JavaScript to be fired on the home page, after the init JS
|
||||||
// JavaScript to be fired on the home page
|
}
|
||||||
},
|
},
|
||||||
finalize: function() {
|
// About us page, note the change from about-us to about_us.
|
||||||
// JavaScript to be fired on the home page, after the init JS
|
'about_us': {
|
||||||
|
init: function() {
|
||||||
|
// JavaScript to be fired on the about us page
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
};
|
||||||
// About us page, note the change from about-us to about_us.
|
|
||||||
about_us: {
|
// The routing fires all common scripts, followed by the page specific scripts.
|
||||||
init: function() {
|
// Add additional events for more control over timing e.g. a finalize event
|
||||||
// JavaScript to be fired on the about us page
|
var UTIL = {
|
||||||
|
fire: function(func, funcname, args) {
|
||||||
|
var fire;
|
||||||
|
var namespace = Sage;
|
||||||
|
funcname = (funcname === undefined) ? 'init' : funcname;
|
||||||
|
fire = func !== '';
|
||||||
|
fire = fire && namespace[func];
|
||||||
|
fire = fire && typeof namespace[func][funcname] === 'function';
|
||||||
|
|
||||||
|
if (fire) {
|
||||||
|
namespace[func][funcname](args);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
loadEvents: function() {
|
||||||
|
// Fire common init JS
|
||||||
|
UTIL.fire('common');
|
||||||
|
|
||||||
|
// Fire page-specific init JS, and then finalize JS
|
||||||
|
$.each(document.body.className.replace(/-/g, '_').split(/\s+/), function(i, classnm) {
|
||||||
|
UTIL.fire(classnm);
|
||||||
|
UTIL.fire(classnm, 'finalize');
|
||||||
|
});
|
||||||
|
|
||||||
|
// Fire common finalize JS
|
||||||
|
UTIL.fire('common', 'finalize');
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
};
|
|
||||||
|
|
||||||
// The routing fires all common scripts, followed by the page specific scripts.
|
// Load Events
|
||||||
// Add additional events for more control over timing e.g. a finalize event
|
$(document).ready(UTIL.loadEvents);
|
||||||
var UTIL = {
|
|
||||||
fire: function(func, funcname, args) {
|
|
||||||
var namespace = Sage;
|
|
||||||
funcname = (funcname === undefined) ? 'init' : funcname;
|
|
||||||
if (func !== '' && namespace[func] && typeof namespace[func][funcname] === 'function') {
|
|
||||||
namespace[func][funcname](args);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
loadEvents: function() {
|
|
||||||
// Fire common init JS
|
|
||||||
UTIL.fire('common');
|
|
||||||
|
|
||||||
// Fire page-specific init JS, and then finalize JS
|
|
||||||
$.each(document.body.className.replace(/-/g, '_').split(/\s+/),function(i,classnm) {
|
|
||||||
UTIL.fire(classnm);
|
|
||||||
UTIL.fire(classnm, 'finalize');
|
|
||||||
});
|
|
||||||
|
|
||||||
// Fire common finalize JS
|
|
||||||
UTIL.fire('common', 'finalize');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Load Events
|
|
||||||
$(document).ready(UTIL.loadEvents);
|
|
||||||
|
|
||||||
})(jQuery); // Fully reference jQuery after this point.
|
})(jQuery); // Fully reference jQuery after this point.
|
||||||
|
|||||||
17
gulpfile.js
17
gulpfile.js
@@ -15,7 +15,7 @@ var project = manifest.getProjectGlobs();
|
|||||||
var cssTasks = function(filename) {
|
var cssTasks = function(filename) {
|
||||||
return lazypipe()
|
return lazypipe()
|
||||||
.pipe($.plumber)
|
.pipe($.plumber)
|
||||||
.pipe(function () {
|
.pipe(function() {
|
||||||
return $.if(mapsEnabled, $.sourcemaps.init());
|
return $.if(mapsEnabled, $.sourcemaps.init());
|
||||||
})
|
})
|
||||||
.pipe(function() {
|
.pipe(function() {
|
||||||
@@ -35,11 +35,12 @@ var cssTasks = function(filename) {
|
|||||||
.pipe($.pleeease, {
|
.pipe($.pleeease, {
|
||||||
autoprefixer: {
|
autoprefixer: {
|
||||||
browsers: [
|
browsers: [
|
||||||
'last 2 versions', 'ie 8', 'ie 9', 'android 2.3', 'android 4', 'opera 12'
|
'last 2 versions', 'ie 8', 'ie 9', 'android 2.3', 'android 4',
|
||||||
|
'opera 12'
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.pipe(function () {
|
.pipe(function() {
|
||||||
return $.if(mapsEnabled, $.sourcemaps.write('.'));
|
return $.if(mapsEnabled, $.sourcemaps.write('.'));
|
||||||
})
|
})
|
||||||
.pipe(gulp.dest, path.dist + 'styles')
|
.pipe(gulp.dest, path.dist + 'styles')
|
||||||
@@ -48,7 +49,7 @@ var cssTasks = function(filename) {
|
|||||||
|
|
||||||
gulp.task('styles', function() {
|
gulp.task('styles', function() {
|
||||||
var merged = merge();
|
var merged = merge();
|
||||||
manifest.forEachDependency('css', function (dep) {
|
manifest.forEachDependency('css', function(dep) {
|
||||||
merged.add(gulp.src(dep.globs)
|
merged.add(gulp.src(dep.globs)
|
||||||
.pipe(cssTasks(dep.name)));
|
.pipe(cssTasks(dep.name)));
|
||||||
});
|
});
|
||||||
@@ -67,14 +68,14 @@ gulp.task('jshint', function() {
|
|||||||
var jsTasks = function(filename) {
|
var jsTasks = function(filename) {
|
||||||
var fn = filename;
|
var fn = filename;
|
||||||
return lazypipe()
|
return lazypipe()
|
||||||
.pipe(function () {
|
.pipe(function() {
|
||||||
return $.if(mapsEnabled, $.sourcemaps.init());
|
return $.if(mapsEnabled, $.sourcemaps.init());
|
||||||
})
|
})
|
||||||
.pipe(function() {
|
.pipe(function() {
|
||||||
return $.if(!!fn, $.concat(fn || 'all.js'));
|
return $.if(!!fn, $.concat(fn || 'all.js'));
|
||||||
})
|
})
|
||||||
.pipe($.uglify)
|
.pipe($.uglify)
|
||||||
.pipe(function () {
|
.pipe(function() {
|
||||||
return $.if(mapsEnabled, $.sourcemaps.write('.'));
|
return $.if(mapsEnabled, $.sourcemaps.write('.'));
|
||||||
})
|
})
|
||||||
.pipe(gulp.dest, path.dist + 'scripts')
|
.pipe(gulp.dest, path.dist + 'scripts')
|
||||||
@@ -83,7 +84,7 @@ var jsTasks = function(filename) {
|
|||||||
|
|
||||||
gulp.task('scripts', ['jshint'], function() {
|
gulp.task('scripts', ['jshint'], function() {
|
||||||
var merged = merge();
|
var merged = merge();
|
||||||
manifest.forEachDependency('js', function (dep) {
|
manifest.forEachDependency('js', function(dep) {
|
||||||
merged.add(gulp.src(dep.globs)
|
merged.add(gulp.src(dep.globs)
|
||||||
.pipe(jsTasks(dep.name)));
|
.pipe(jsTasks(dep.name)));
|
||||||
});
|
});
|
||||||
@@ -106,7 +107,7 @@ gulp.task('images', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('version', function() {
|
gulp.task('version', function() {
|
||||||
return gulp.src([path.dist + '**/*.{js,css}'], { base: path.dist })
|
return gulp.src([path.dist + '**/*.{js,css}'], {base: path.dist})
|
||||||
.pipe(gulp.dest(path.dist))
|
.pipe(gulp.dest(path.dist))
|
||||||
.pipe($.rev())
|
.pipe($.rev())
|
||||||
.pipe(gulp.dest(path.dist))
|
.pipe(gulp.dest(path.dist))
|
||||||
|
|||||||
@@ -18,7 +18,8 @@
|
|||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "bower install && gulp",
|
"build": "bower install && gulp",
|
||||||
"jshint": "gulp jshint"
|
"jshint": "gulp jshint",
|
||||||
|
"jscs": "jscs gulpfile.js assets/scripts/*.js"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">= 0.10.0"
|
"node": ">= 0.10.0"
|
||||||
|
|||||||
Reference in New Issue
Block a user