Skip to content

Commit

Permalink
Update babel to latest version and test new stage0 proposals. Fixes #65
Browse files Browse the repository at this point in the history
  • Loading branch information
STRML committed May 14, 2015
1 parent 04b6be7 commit 22ebb21
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 9 deletions.
2 changes: 1 addition & 1 deletion jsxhint.js
Expand Up @@ -73,7 +73,7 @@ function transformJSX(fileStream, fileName, opts, cb){

function transformSource(source, opts){
if (opts['--babel'] || opts['--babel-experimental']) {
return babel.transform(source, {experimental: opts['--babel-experimental'] || false}).code;
return babel.transform(source, {stage: opts['--babel-experimental'] ? 0 : 2}).code;
} else {
return jstransform.transform(source, {
react: true,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -40,7 +40,7 @@
"through": "~2.3.6"
},
"devDependencies": {
"babel": "^4.0.1",
"babel": "^5.4.0",
"precommit-hook": "~1.0.7",
"tap": "~0.4.13"
},
Expand Down
9 changes: 9 additions & 0 deletions test/fixtures/test_es7classproperties.jsx
@@ -0,0 +1,9 @@
'use strict';

class MyClass {
myProp = 42;

constructor() {
console.log(this.myProp); // 42
}
}
31 changes: 24 additions & 7 deletions test/test.js
Expand Up @@ -34,7 +34,7 @@ function runJSHint(args, cb) {
}

test('Convert JSX to JS', function(t){
t.plan(28);
t.plan(34);
jsxhint.transformJSX('./fixtures/test_article_without_pragma.js', { '--jsx-only' : true }, function(err, data){
t.ifError(err);
t.equal(data.match(/React.DOM/), null, 'JS was converted but should not be.');
Expand Down Expand Up @@ -88,23 +88,40 @@ test('Convert JSX to JS', function(t){
runJSXHint(['--babel', 'fixtures/test_es6module.jsx'], function(err, jsxhintOut) {
t.ifError(err);
t.equal(jsxhintOut, '',
'JSXHint should succeed using acorn parser.');
'JSXHint should succeed using babel parser.');
});

runJSXHint('fixtures/test_es7exponentiation.jsx', function(err, jsxhintOut) {
runJSXHint(['--babel-experimental', 'fixtures/test_es6module.jsx'], function(err, jsxhintOut) {
t.ifError(err);
t.equal(jsxhintOut, '',
'JSXHint should succeed using babel parser with experimental support.');
});

runJSXHint('fixtures/test_es7classproperties.jsx', function(err, jsxhintOut) {
t.ifError(err);
t.ok(jsxhintOut.length > 0, 'JSXHint should fail using esprima parser.');
});

runJSXHint(['--babel', 'fixtures/test_es7exponentiation.jsx'], function(err, jsxhintOut) {
runJSXHint(['--babel', 'fixtures/test_es7classproperties.jsx'], function(err, jsxhintOut) {
t.ifError(err);
t.ok(jsxhintOut.length > 0, 'JSXHint should fail using babel parser without experimental.');
});

runJSXHint(['--babel-experimental', 'fixtures/test_es7classproperties.jsx'], function(err, jsxhintOut) {
t.ifError(err);
t.equal(jsxhintOut, '',
'JSXHint should succeed using babel parser with experimental support for ES7.');
});

runJSXHint('fixtures/test_es7exponentiation.jsx', function(err, jsxhintOut) {
t.ifError(err);
t.ok(jsxhintOut.length > 0, 'JSXHint should fail using acorn parser.');
t.ok(jsxhintOut.length > 0, 'JSXHint should fail using esprima parser.');
});

runJSXHint(['--babel-experimental', 'fixtures/test_es7exponentiation.jsx'], function(err, jsxhintOut) {
runJSXHint(['--babel', 'fixtures/test_es7exponentiation.jsx'], function(err, jsxhintOut) {
t.ifError(err);
t.equal(jsxhintOut, '',
'JSXHint should succeed using acorn parser with experimental support for ES7.');
'JSXHint should succeed using babel parser without experimental support for ES7.');
});
});

Expand Down

0 comments on commit 22ebb21

Please sign in to comment.