Skip to content
This repository has been archived by the owner on Feb 9, 2023. It is now read-only.

Commit

Permalink
do not check syntax of transpiled files
Browse files Browse the repository at this point in the history
  • Loading branch information
shvaikalesh committed Sep 12, 2016
1 parent 6662d28 commit 143f727
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
10 changes: 5 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ class JavaScriptCompiler {
this.validate = 'validate' in js ? js.validate : true;
}

compile(params) {
if (this.validate) {
compile(file) {
if (this.validate && !file.map) {
try {
const errors = esprima.parse(params.data, {tolerant: true}).errors.map(error => error.message);
if (errors.length) return Promise.reject(errors);
const errors = esprima.parse(file.data, {tolerant: true});
if (errors.length) throw errors.map(error => error.message);
} catch (error) {
return Promise.reject(error);
}
}

return Promise.resolve(params);
return Promise.resolve(file);
}
}

Expand Down
6 changes: 6 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,11 @@ describe(Plugin.name, () => {
plugin = new Plugin({plugins: {javascript: {validate: false}}});
return plugin.compile({data: 'var a =;'});
});

it('should not validate syntax of transpiled files', () => {
const file = {data: 'var a =;', map: {}};
return plugin.compile(file).then(result => {
expect(result).to.equal(file);
});
});
});

0 comments on commit 143f727

Please sign in to comment.