Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try Babel in gulpfiles. Fix #766 #774

Merged
merged 3 commits into from
Sep 21, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .jscsrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"preset": "airbnb",
"validateIndentation": 2,
"disallowMultipleVarDecl": null,
"requireMultipleVarDecl": true
"requireMultipleVarDecl": true,
"esnext": true
}
6 changes: 4 additions & 2 deletions .jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

"maxerr" : 50, // {int} Maximum error before stopping

// Allow ES6
"esnext" : true,
"multistr" : true,

// Enforcing
"bitwise" : true, // true: Prohibit bitwise operators (&, |, ^, etc.)
"camelcase" : true, // true: Identifiers must be in camelCase
Expand Down Expand Up @@ -40,7 +44,6 @@
"debug" : false, // true: Allow debugger statements e.g. browser breakpoints.
"eqnull" : false, // true: Tolerate use of `== null`
"es5" : false, // true: Allow ES5 syntax (ex: getters and setters)
"esnext" : false, // true: Allow ES.next (ES6) syntax (ex: `const`)
"moz" : false, // true: Allow Mozilla specific syntax (extends and overrides esnext features)
// (ex: `for each`, multiple try/catch, function expression…)
"evil" : false, // true: Tolerate use of `eval` and `new Function()`
Expand All @@ -52,7 +55,6 @@
"laxbreak" : false, // true: Tolerate possibly unsafe line breakings
"laxcomma" : false, // true: Tolerate comma-first style coding
"loopfunc" : false, // true: Tolerate functions being defined in loops
"multistr" : false, // true: Tolerate multi-line strings
"noyield" : false, // true: Tolerate generator functions with no yield statement in them.
"notypeof" : false, // true: Tolerate invalid typeof operator values
"proto" : false, // true: Tolerate using the `__proto__` property
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion gulpfile.js → gulpfile.babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ var gulp = require('gulp'),
chalk = require('chalk'),
outputPath = 'demo-output';

require('./gulpfile-tests')(gulp);
require('./gulpfile-tests.babel')(gulp);

gulp.task('js:app', function() {
return gulp.src([
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
"yargs": "~3.12.0"
},
"devDependencies": {
"babel": "^5.8.23",
"chai": "~3.0.0",
"conventional-changelog": "git://github.com/sc5/conventional-changelog.git#features/sc-styleguide",
"coveralls": "~2.11.2",
Expand Down
34 changes: 9 additions & 25 deletions test/unit/modules/at-rules.test.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,25 @@
var requireModule = require('requirefrom')('lib/modules'),
chai = require('chai'),
expect = chai.expect,
multiline = require('multiline'),
atRules = requireModule('at-rules');

describe('At ruke parsing', function() {
it('should get @font-face definitions', function() {
var str = multiline(function() {
/*
@font-face {
var str = `@font-face {
font-family: myFont;
}

.someSelector {
}
*/
}),
result = multiline(function() {
/*
@font-face {
}`,
result = `@font-face {
font-family: myFont;
}
*/
});
}`;

expect(atRules.stylesFromString(str)).to.eql(result);
});

it('should get @keyframe definitions', function() {
var str = multiline(function() {
/*
@-webkit-keyframes mymove {
var str = `@-webkit-keyframes mymove {

}

Expand All @@ -38,18 +28,12 @@ describe('At ruke parsing', function() {
}

.someSelector {
}
*/
}),
result = multiline(function() {
/*
@-webkit-keyframes mymove {
}`,
result = `@-webkit-keyframes mymove {
}

@keyframes mymove {
}
*/
});
}`;
expect(atRules.stylesFromString(str)).to.eql(result);
});
});
34 changes: 9 additions & 25 deletions test/unit/modules/ignore-block.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,65 +3,49 @@
var requireModule = require('requirefrom')('lib/modules'),
chai = require('chai'),
expect = chai.expect,
multiline = require('multiline'),
ignoreBlock = requireModule('ignore-block');

describe('ignore block removal', function() {
it('should remove definitions between tags and leave other lines intact', function() {
var str = multiline(function() {
/*
First line
var str = `First line
styleguide:ignore:start
Ignore 1
Ignore 2
styleguide:ignore:end
Last line
*/
});
Last line`;

expect(ignoreBlock.removeIgnoredBlocks(str)).to.eql('First line\n\n\n\n\nLast line');
});

it('should remove everything on the same line as tags', function() {
var str = multiline(function() {
/*
First line
var str = `First line
// styleguide:ignore:start something
Ignore 1
Ignore 2
// styleguide:ignore:end something
Last line
*/
});
Last line`;
expect(ignoreBlock.removeIgnoredBlocks(str)).to.eql('First line\n\n\n\n\nLast line');
});

it('should support multiple blocks', function() {
var str = multiline(function() {
/*
First line
var str = `First line
styleguide:ignore:start
Ignore 1
styleguide:ignore:end
Middle line
styleguide:ignore:start
Ignore 1
styleguide:ignore:end
Last line
*/
});
Last line`;
expect(ignoreBlock.removeIgnoredBlocks(str)).to.eql('First line\n\n\n\nMiddle line\n\n\n\nLast line');
});

it('should remove everything after start tag even if it is not closed', function() {
var str = multiline(function() {
/*
First line
var str = `First line
styleguide:ignore:start
Ignore 1
Ignore 2
Ignore 3
*/
});
Ignore 3`;
expect(ignoreBlock.removeIgnoredBlocks(str)).to.eql('First line\n\n\n\n');
});
});
89 changes: 22 additions & 67 deletions test/unit/modules/kss-additional-params.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,14 @@
var requireModule = require('requirefrom')('lib/modules'),
chai = require('chai'),
expect = chai.expect,
multiline = require('multiline'),
kssAdditionalParams = requireModule('kss-additional-params');

describe('Parsing KSS additional params', function() {

it('Should parse from singleline-commented block', function() {
// jscs:disable
var str = multiline(function() {
/*
// sg-param:
// Value
*/
}),
var str = `// sg-param:
// Value`,
// jscs:enable
result = { 'sg-param': ' Value' },
params = kssAdditionalParams.get(str);
Expand Down Expand Up @@ -48,18 +43,14 @@ describe('Parsing KSS additional params', function() {

it('Should parse multiple params', function() {
// jscs:disable
var str = multiline(function() {
/*
// sg-param1:
var str = `// sg-param1:
// Value
//
// sg-param2:
// Value
//
// sg-param3:
// Value
*/
}),
// Value`,
// jscs:enable
result = {
'sg-param1':' Value',
Expand All @@ -73,18 +64,14 @@ describe('Parsing KSS additional params', function() {

it('Should gulp different space combinations', function() {
// jscs:disable
var str = multiline(function() {
/*
// sg-param1 :
var str = `// sg-param1 :
// Value
//
//sg-param2:
// Value
//
// sg-param3:
// Value
*/
}),
// Value`,
// jscs:enable
result = {
'sg-param1':' Value',
Expand All @@ -98,9 +85,7 @@ describe('Parsing KSS additional params', function() {

it('Should ignore extra comments', function() {
// jscs:disable
var str = multiline(function() {
/*
// Something here
var str = `// Something here
//
// sg-param1 :
// Value
Expand All @@ -111,9 +96,7 @@ describe('Parsing KSS additional params', function() {
// sg-empty-param:
//
// sg-param3:
// Value
*/
}),
// Value`,
// jscs:enable
result = {
'sg-param1':' Value',
Expand All @@ -127,14 +110,10 @@ describe('Parsing KSS additional params', function() {

it('Should parse complex variables', function() {
// jscs:disable
var str = multiline(function() {
/*
sg-angular-directive:
var str = ` sg-angular-directive:
name: sgAppTest
template: demo/testDirective.html
file: demo/testDirective.js
*/
}),
file: demo/testDirective.js`,
// jscs:enable
result = {
name: 'sgAppTest',
Expand All @@ -148,15 +127,11 @@ describe('Parsing KSS additional params', function() {

it('Should parse complex variables with 2 nexted values', function() {
// jscs:disable
var str = multiline(function() {
/*
sg-angular-directive:
var str = ` sg-angular-directive:
name: sgAppTest
template: demo/testDirective.html
file: demo/testDirective.js
file: demo/testDirective2.js
*/
}),
file: demo/testDirective2.js`,
// jscs:enable
result = {
name: 'sgAppTest',
Expand All @@ -173,17 +148,13 @@ describe('Parsing KSS additional params', function() {

it('Should parse complex variables with many nexted values', function() {
// jscs:disable
var str = multiline(function() {
/*
sg-angular-directive:
var str = ` sg-angular-directive:
name: sgAppTest
template: demo/testDirective.html
file: demo/testDirective.js
file: demo/testDirective2.js
file: demo/testDirective3.js
file: demo/testDirective4.js
*/
}),
file: demo/testDirective4.js`,
// jscs:enable
result = {
name: 'sgAppTest',
Expand All @@ -201,14 +172,10 @@ describe('Parsing KSS additional params', function() {

it('Should parse complex variables with comma notation', function() {
// jscs:disable
var str = multiline(function() {
/*
sg-angular-directive:
var str = ` sg-angular-directive:
name: sgAppTest
template: demo/testDirective.html
file: demo/testDirective.js, demo/testDirective2.js
*/
}),
file: demo/testDirective.js, demo/testDirective2.js`,
// jscs:enable
result = {
name: 'sgAppTest',
Expand All @@ -224,15 +191,11 @@ describe('Parsing KSS additional params', function() {

it('Should ignore extra spaces when parsing complex variables', function() {
// jscs:disable
var str = multiline(function() {
/*
sg-angular-directive:
var str = ` sg-angular-directive:
name: sgAppTest
template: demo/testDirective.html
file: demo/testDirective.js , demo/testDirective2.js
file: demo/testDirective3.js
*/
}),
file: demo/testDirective3.js`,
// jscs:enable
result = {
name: 'sgAppTest',
Expand All @@ -249,19 +212,11 @@ describe('Parsing KSS additional params', function() {

it('Should parse only listed params as comples', function() {
// jscs:disable
var str = multiline(function() {
/*
sg-another-custom-param:
param1: val1
param2: val2
*/
}),
result = multiline(function() {
/*
var str = ` sg-another-custom-param:
param1: val1
param2: val2
*/
}),
param2: val2`,
result = ` param1: val1
param2: val2`,
value = kssAdditionalParams.getValue('sg-another-custom-param', str);
// jscs:enable
expect(value).eql(result);
Expand Down
Loading