Skip to content

Commit

Permalink
Introduce JSCS and fix all the formatting.
Browse files Browse the repository at this point in the history
  • Loading branch information
eriwen committed Jan 30, 2016
1 parent 967fc9c commit c15b737
Show file tree
Hide file tree
Showing 7 changed files with 135 additions and 106 deletions.
8 changes: 6 additions & 2 deletions .editorconfig
Expand Up @@ -10,13 +10,17 @@ charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.js]
[*.{js,json}]
indent_style = space
indent_size = 4

[*.json]
[.{jshintrc,jscsrc}]
indent_style = space
indent_size = 4

[*.{yml,yaml}]
indent_style = space
indent_size = 2

[*.md]
trim_trailing_whitespace = false
28 changes: 28 additions & 0 deletions .jscsrc
@@ -0,0 +1,28 @@
{
"preset": "google",
"fileExtensions": [
".js"
],
"requireSemicolons": true,
"requireParenthesesAroundIIFE": true,
"maximumLineLength": 120,
"validateLineBreaks": "LF",
"validateIndentation": 4,
"disallowTrailingComma": true,
"disallowSpacesInsideObjectBrackets": null,
"disallowImplicitTypeConversion": [
"string"
],
"jsDoc": {
"checkAnnotations": "closurecompiler",
"checkParamNames": true,
"requireParamTypes": true,
"checkRedundantParams": true,
"checkReturnTypes": true,
"checkRedundantReturns": true,
"requireReturnTypes": true,
"checkTypes": "capitalizedNativeCase",
"checkRedundantAccess": true,
"requireNewlineAfterDescription": true
}
}
26 changes: 14 additions & 12 deletions gulpfile.js
Expand Up @@ -20,54 +20,56 @@ var dependencies = [
];
var source = 'stacktrace-gps.js';

gulp.task('lint', function () {
gulp.task('lint', function() {
return gulp.src(source)
.pipe(jshint())
.pipe(jshint.reporter('default'))
.pipe(jshint.reporter('fail'));
});

gulp.task('webpack-source-consumer', function () {
gulp.task('webpack-source-consumer', function() {
return webpack({
entry: './node_modules/source-map/lib/source-map-consumer.js',
output: {
library: 'SourceMap',
path: path.join(__dirname, 'build'),
name: 'bundle.js'
}
}, function (err) {
if (err) throw new Error('webpack', err);
}, function(err) {
if (err) {
throw new Error('webpack', err);
}
});
});

gulp.task('test', ['webpack-source-consumer'], function (done) {
gulp.task('test', ['webpack-source-consumer'], function(done) {
new karma.Server({
configFile: __dirname + '/karma.conf.js',
singleRun: true
}, done).start();
});

gulp.task('test-pr', ['dist'], function (done) {
gulp.task('test-pr', ['dist'], function(done) {
new karma.Server({
configFile: __dirname + '/karma.conf.js',
browsers: ['Firefox', 'Chrome_Travis'],
browsers: ['Firefox', 'ChromeTravis'],
singleRun: true
}, done).start();
});

gulp.task('test-ci', ['dist'], function (done) {
gulp.task('test-ci', ['dist'], function(done) {
new karma.Server({
configFile: __dirname + '/karma.conf.ci.js',
singleRun: true
}, done).start();
});

gulp.task('copy', function () {
gulp.task('copy', function() {
return gulp.src(source)
.pipe(gulp.dest('dist'));
});

gulp.task('dist', ['copy', 'webpack-source-consumer'], function () {
gulp.task('dist', ['copy', 'webpack-source-consumer'], function() {
// Build with ES6Promise and other polyfills
gulp.src(polyfills.concat(dependencies.concat(source)))
.pipe(sourcemaps.init())
Expand All @@ -88,11 +90,11 @@ gulp.task('clean', del.bind(null, ['build', 'coverage', 'dist']));

gulp.task('pr', ['lint', 'test-pr']);

gulp.task('ci', ['lint', 'test-ci'], function () {
gulp.task('ci', ['lint', 'test-ci'], function() {
gulp.src('./coverage/**/lcov.info')
.pipe(coveralls());
});

gulp.task('default', ['clean'], function (cb) {
gulp.task('default', ['clean'], function(cb) {
runSequence('lint', ['copy', 'dist'], 'test', cb);
});
16 changes: 1 addition & 15 deletions karma.conf.ci.js
@@ -1,4 +1,4 @@
module.exports = function (config) {
module.exports = function(config) {
'use strict';
if (!process.env.SAUCE_USERNAME || !process.env.SAUCE_ACCESS_KEY) {
console.log('Make sure the SAUCE_USERNAME and SAUCE_ACCESS_KEY environment variables are set.');
Expand Down Expand Up @@ -90,20 +90,6 @@ module.exports = function (config) {
browserName: 'internet explorer',
platform: 'Windows 8',
version: '10'
},
slIE9: {
base: 'SauceLabs',
browserName: 'internet explorer',
platform: 'Windows 8',
version: '10',
'x-ua-compatible': 'IE=EmulateIE9'
},
slIE8: {
base: 'SauceLabs',
browserName: 'internet explorer',
platform: 'Windows 8',
version: '10',
'x-ua-compatible': 'IE=EmulateIE8'
}
//slIE9: {
// base: 'SauceLabs',
Expand Down
4 changes: 2 additions & 2 deletions karma.conf.js
@@ -1,4 +1,4 @@
module.exports = function (config) {
module.exports = function(config) {
config.set({
basePath: '',
frameworks: ['jasmine-ajax', 'jasmine'],
Expand All @@ -15,7 +15,7 @@ module.exports = function (config) {
logLevel: config.LOG_INFO,
autoWatch: true,
customLaunchers: {
Chrome_Travis: {
ChromeTravis: {
base: 'Chrome',
flags: ['--no-sandbox']
}
Expand Down

0 comments on commit c15b737

Please sign in to comment.